[systemd-devel] Accpetance of Environment Variables in Attributes

Kevin P. Fleming kevin at km6g.us
Thu Jun 25 11:31:21 UTC 2020


Normally you'd set instance-specific variables using an override file
for the unit. You could easily put just 'User' and 'LimitMEMLOCK' in
the override file and leave the rest of the service settings in the
main unit file, with no need for an environment variable file at all.

On Thu, Jun 25, 2020 at 7:24 AM Ede Wolf <listac at nebelschwaden.de> wrote:
>
> So I have an environmentfile containing two variable definitions:
>
> RUNASUSER=nobody
> MEM=4294967296
>
> And my service section reads:
>
> [Service]
> EnvironmentFile=/path/myfile
> User=$RUNASUSER
> LimitMEMLOCK=$MEM
>
> This service failes to startup, as I cannot seem to being able to  use a
> variable for the User attribute, but I may very well for LimitMEMLOCK.
>
> Error:
>
> Failed to determine user credentials: No such process
>
>
> And if specifying instead:
>
> [Service]
> EnvironmentFile=/path/myfile
> User=nobody
> LimitMEMLOCK=$MEM
>
> Everything does work. And I am wondering, why? And moreover, is there
> any source of documentation, that lists or even explains, what
> attributes may have a variable as an argument and what do not?
>
> As for instances/template units it would be really helpful to being able
> to set the running user in the configuration/environment file. Or at
> least have a knowledge of those settings, that do not allow this, for
> what reason ever. Especially when talking about directory settings.
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel


More information about the systemd-devel mailing list