]> git.ipfire.org Git - thirdparty/systemd.git/commit
pid1: when creating service directories, don't chown existing files (#8181)
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 22 Feb 2018 10:30:59 +0000 (11:30 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 22 Feb 2018 10:30:59 +0000 (11:30 +0100)
commit30c81ce2cef97b05e143c7adf4cd1b1c5fb59932
tree530ce8c16c6f98602f38324fbb5b4bc988ca295a
parenta4896a1f14a9c89f59a19e1bec5e6229b5cf1528
pid1: when creating service directories, don't chown existing files (#8181)

This partially reverts 3536f49e8fa281539798a7bc5004d73302f39673 and
3536f49e8fa281539798a7bc5004d73302f39673.

When the user is dynamic, and we are setting up state, cache, or logs dirs,
behaviour is unchanged, we always do a recursive chown. This is necessary
because the user number might change between invocations.

But when setting up a directory for non-dynamic user, or a runtime directory
for a dynamic user, do any ownership or mode changes only when the directory
is initially created. Nothing says that the files under those directories have
to be all recursively owned by our user. This restores behaviour before
3536f49e8fa281539798a7bc5004d73302f39673, so modifications to the state of
the runtime directory persist between ExecStartPre's and ExecStart's, and even
longer in case the directory is persistent.

I think it _would_ be a nice property if setting a user would automatically
propagate to ownership of any Runtime/Logs/Cache directories. But this is
incompatible with another nice property, namely preserving changes to those
directories made by an admin, and with allowing change of ownership of files
in those directories by the service (e.g. to allow other users to access them).
Of the two, I think the second property is more important. Also, it's backwards
compatible.

https://bugzilla.redhat.com/show_bug.cgi?id=1508495

There is no need to chmod a directory we just created, so move that step
up into a branch. After that, 'effective' is only used once, so get rid of
it too.
src/core/execute.c