[systemd-devel] By what mechanism are locale-related environment variables (LC_*) set in services?

Andrei Borzenkov arvidjaar at gmail.com
Thu May 25 15:31:17 UTC 2023


On 25.05.2023 17:12, Farblos wrote:
> Running on systemd 252 (252.6-1) on Debian testing.
> 
> It seems that systemd services, also transient ones, get the full set of locale environment variables (LANG, LANGUAGE, LC_*) as defined in /etc/default/locale.
> 
> I only have found environment variable $LANG mentioned in systemd.exec(5) as "Set or Propagated by the Service Manager".
> 
> And I have found the following mentioned in locale.conf(5):
> 
>    Depending on the operating system, other configuration files might be
>    checked for locale configuration as well, however only as fallback.
> 
> I guess from that:
> 
> 1) On Debian, systemd consults /etc/default/locale for locale settings as fallback.
> 

I do not know. May be Debian has downstream patch to do it. In principle 
it is also possible to push variable into systemd, so it could be done 
outside of systemd itself.

... hmm, briefly testing systemd-localed does check for 
/etc/default/locale on Ubuntu.

> 2) systemd does not only propagate $LANG, but also all other locale-related environment variables to the processes it invokes.
> 

Yes. systemd system instance will import locale variables on startup 
(from locale.conf or kernel command line), it imports all variables that 
are set.

> Is that correct?
> 
> Is there any other systemd documentation on that which I might have missed?
> 
> If not, should I open whatever doc bugs on GitHub to get the man page(s) extended?
> 

I would sat yes.




More information about the systemd-devel mailing list