[systemd-devel] [PATCH] tmpfiles: only execute chmod()/chown() when needed

Colin Walters walters at verbum.org
Fri Jul 11 14:26:13 PDT 2014



On Fri, Jul 11, 2014, at 06:05 AM, Michael Olbrich wrote:
> This avoids errors like this, when the paths are already there with the
> correct permissions and owner:
> 
> chmod(/var/spool) failed: Read-only file system

I'd say we should avoid running systemd-tmpfiles if the filesystem is
read only.  In your case is / read-write even?  What do you think about
e.g.:

diff --git a/units/systemd-tmpfiles-setup.service.in
b/units/systemd-tmpfiles-setup.service.in
index 72ab083..c5b6416 100644
--- a/units/systemd-tmpfiles-setup.service.in
+++ b/units/systemd-tmpfiles-setup.service.in
@@ -13,6 +13,7 @@ Conflicts=shutdown.target
 After=systemd-readahead-collect.service
 systemd-readahead-replay.service local-fs.target
 systemd-sysusers.service
 Before=sysinit.target shutdown.target
 RefuseManualStop=yes
+ConditionPathIsReadWrite=/
 
 [Service]
 Type=oneshot

See also
https://git.gnome.org/browse/ostree/commit/?id=ff6883ca0655ac8844cd783caf6a7d8815515ba3

> +        if (stat(path, &st) >= 0) {

I don't think we want to follow symlinks here, right?


More information about the systemd-devel mailing list