tmpfiles: with "e" don't attempt to set permissions when file doesn't exist (#6682)
authorMichal Sekletar <msekletar@users.noreply.github.com>
Thu, 31 Aug 2017 10:45:25 +0000 (12:45 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 31 Aug 2017 10:45:25 +0000 (12:45 +0200)
commit780e2ee187e373565f9ded2859f8c6c7760b814a
treea5077a696f5b94f96b5d8f80386c1d3fbb84d135
parent617da14cfd3ed898fcd1616dc7129a2756cfb347
tmpfiles: with "e" don't attempt to set permissions when file doesn't exist (#6682)

tmpfiles.d option "e" when run through systemd-tmpfiles --create should
apply configured permissions (uid,gid) only to already existing
files. When file doesn't exist we bail out with error. Instead we should
silently ignore non-existing files.

$ useradd test
$ cat /etc/tmpfiles.d/foobar.conf
e /tmp/test - test test 1d
$ ls -l /tmp/test
ls: cannot access '/tmp/test': No such file or directory

Before:
$ systemd-tmpfiles --create /etc/tmpfiles.d/foobar.conf
Adjusting owner and mode for /tmp/test failed: No such file or directory
$ echo $?
1

After:
$ systemd-tmpfiles --create /etc/tmpfiles.d/foobar.conf
$ echo $?
0
src/tmpfiles/tmpfiles.c