[systemd-devel] [PATCH] printf specifiers %u and %h: $USER and $HOME.

Kok, Auke-jan H auke-jan.h.kok at intel.com
Mon Jul 16 09:40:31 PDT 2012


On Mon, Jul 16, 2012 at 10:47 AM, Lennart Poettering
<lennart at poettering.net> wrote:
> On Fri, 13.07.12 22:28, Auke Kok (auke-jan.h.kok at intel.com) wrote:
>
>> These printf specifiers allow us to refer to $HOME and $USER
>> in unit files. These are particularly helpful in instanced
>> units that have "User=" set, and in systemd --user domains.
>>
>> The specifiers will return the pw_name and pw_dir fields
>> if the unit file has a User= field.
>>
>> If the unit file does not have a User= field, the value
>> substituted is either $USER or $HOME from the environment,
>> or, if unset, the values from pw_name or pw_dir.
>>
>> This patch is somewhat after Ran Benita's original patch,
>> which didn't get merged. I've split up the 2 specifiers
>> and extended them to do what is logically expected from
>> these specifiers.
>>
>> Note that expansion is done at `start` time, not after
>> the units are parsed. Using `systemctl show` will just
>> show the specifiers.
>
> Applied, but modified it to use the new getusername_malloc() and
> get_home_dir() that I added, too. Also made a couple of minor other
> changes and added %s for the user shell as discussed. Please test!

thanks for doing that. This one had me head-scratching for quite a bit
trying to figure out the right expectation as well as finding the
right ways to resolve the username with get_user_creds.

I'll make some time tonight to go over it.

Auke


More information about the systemd-devel mailing list