Bug#927911: systemd: Does not expand %h identifier in ExecStart

Michael Biebl biebl at debian.org
Tue Apr 30 09:39:13 BST 2019


Am 26.04.19 um 03:56 schrieb Norbert Preining:
> Hi
> 
>> The man pages say that %h and %u are resolved to the root user if you
>> are using the system instance (PID 1).
>> That is consistent with the behaviour you are getting.
>> If I missed a part which mentions the contrary, could you quote the
>> relevant bits from the documentation, so it can be fixed?
> 
> 	Unit files can be parameterized by a single argument called the
> 	"instance name". The unit is then constructed based on a "template file"
> 	which serves as the definition of multiple services or other units.
> 	A template unit must have a single "@" at the end of the name (right
> 	before the type suffix). The name of the full unit is formed by inserting
> 	the instance name between "@" and the unit type suffix. In the unit file
> 	itself, the instance parameter may be referred to 
> 	using "%i" and other specifiers, see below.
> 	   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> There is no real indication what means "below", but the somehow for me
> logical reference is the section
> 	Specifiers
> 
> 	Many settings resolve specifiers which may be used to write generic
> 	unit files referring to runtime or unit parameters that are replaced
> 	when the unit files are loaded. Specifiers must be known and resolvable
> 	for the setting to be valid. The following specifiers are understood:
> 
> 	Table 4. Specifiers available in unit files
> 	...
> 
> In my reading that says:
> 	You can use %i and other specifiers **as laid out in the secion
> 	"Specifiers" in the Unit file** ....
> 
> I searched all occurrences of % in the man page, and that is all that is
> said.

See [1]

>> That said, I do acknowledge that the systemd.unit(5) man page could be
>> clearer what effect it has on %h and %u when setting `User=` when
> 
> I am not sure how this relates to my question.

Section "SPECIFIERS" [1] in systemd.unit(5) says this about %h

>        │"%h"      │ User home directory                     │ This is the home directory of the user   │
>        │          │                                         │ running the service manager instance. In │
>        │          │                                         │ case of the system manager this resolves │
>        │          │                                         │ to "/root".           


So, the documentation says that %h is expanded to the home directory of
root user in your case (as you run the service as system service).
The incorrect bit is, that the documentation says it is expanded to
"/root" whereas really it is "/" for system services.

In your case, you use "User=" and I think (please correct me if I'm
wrong) you expected "%h" to be expanded to the home directory of that
user specified via "User="

That's why I filed an upstream bug report
- to fix the documentation to say "/" instead of "/root"
- to be more explicit that setting "User=" has no effect on %h


[1]
https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Specifiers
-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/attachments/20190430/8101207c/attachment.sig>


More information about the Pkg-systemd-maintainers mailing list