When setting User= option, the process is still started in / directory. This makes the configuration of daemons started under a non-root user (e,g, cruisecontrol) much harder, since relative paths cannot be used. Although there a possibility to use WorkingDirectory= option to specify the home directory of the user (or to specify full absolute path in the config), it is not very convenient way - the home dir must be changed in several places, or the configuration may start to be difficult to read. There are basically two possibilities of handling it: 1. use home directory by default (instead of / currently used), if User= is set 2. support, e.g. WorkingDirectory=~ special alias, which will be resolved by systemd and replaced by the home directory of the user set Thank you for considering this DT.
This is now supported with WorkingDirectory=%h
The resolution (WorkingDirectory=%h) is no longer supported. Would it be possible to set the working directory to the user's home directory by default (in the absence of WorkingDirectory=) after forking?
(In reply to comment #2) > The resolution (WorkingDirectory=%h) is no longer supported. Can you link to when (commit or mailing list message) this changed?
(In reply to comment #3) > Can you link to when (commit or mailing list message) this changed? http://cgit.freedesktop.org/systemd/systemd/commit/?id=2cfbd749af308bdbe56edcfed7f3eea0fc2b93d2 from NEWS: CHANGES WITH 209: * %h, %s, %U specifier support is not available anymore when used in unit files for PID 1. This is because NSS calls are not safe from PID 1. They stay available for --user instances of systemd, and as special case for the root user.
One possible fix would be to change src/core/unit.c:unit_patch_contexts, replacing if (u->manager->running_as == SYSTEMD_USER && !ec->working_directory) { with something along the lines of if (/* uid of process-to-run != 0 */ && !ec->working_directory) { and also modify src/shared/util.c:get_home_dir, where we add the uid as a parameter. Would this be acceptable? If so, I will try to come up with a patch.
This is now available again with the WorkingDirectory=~ syntax.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.