Bug 1357861

Summary: localectl ineffective for regular users
Product: [Fedora] Fedora Reporter: Aleksandar Kostadinov <akostadi>
Component: systemdAssignee: systemd-maint
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 24CC: johannbg, lnykryn, msekleta, muadda, ssahani, s, systemd-maint, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-19 16:34:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Aleksandar Kostadinov 2016-07-19 12:28:08 UTC
Description of problem:
It appears that doing localectl set-locale as root works globally. Doing as user changes locale settings but the locale after login is still what root has initially set.

I would expect that changes by root would affect whole system and changes by user would affect only the particular user. That means after user sets locale, new shells will use that locale for the particular user. See current behavior:

# localectl set-locale LANG=C.utf8
// now system locale changed to C.utf8
// lets do as a user
$ localectl set-locale LANG=bg_BG.utf8
// then in a new shell
$ locale
LANG=C.utf8
LC_CTYPE="C.utf8"
LC_NUMERIC="C.utf8"
LC_TIME="C.utf8"
LC_COLLATE="C.utf8"
LC_MONETARY="C.utf8"
LC_MESSAGES="C.utf8"
LC_PAPER="C.utf8"
LC_NAME="C.utf8"
LC_ADDRESS="C.utf8"
LC_TELEPHONE="C.utf8"
LC_MEASUREMENT="C.utf8"
LC_IDENTIFICATION="C.utf8"
LC_ALL=
$ localectl
   System Locale: LANG=bg_BG.utf8
       VC Keymap: us
      X11 Layout: us,bg
     X11 Variant: ,phonetic
     X11 Options: grp:alt_shift_toggle

Even worse as root:
# localectl status
   System Locale: LANG=bg_BG.utf8
       VC Keymap: us
      X11 Layout: us,bg
     X11 Variant: ,phonetic
     X11 Options: grp:alt_shift_toggle


Version-Release number of selected component (if applicable):
systemd-229-8.fc24.x86_64

I'm not even sure if there's any security implication here.

Comment 1 Zbigniew Jędrzejewski-Szmek 2016-07-19 16:34:23 UTC
localectl communicates with systemd-localed which modifies /etc/locale.conf, i.e. the global configuration. It does not dynamically modify the environment of a user, because there's no way to do that. You have to log in again to see the changes. Whether the root or a normal user invokes localectl makes no difference for the result of the command (assuming that the user has sufficient privileges to invoke set-locale). To summarize, localectl set-locale sets the state for all users, but does not influence existing sessions. That's the design and your examples seems to show everything working as designed.

Comment 2 Zbigniew Jędrzejewski-Szmek 2016-07-19 16:59:41 UTC
I also filed https://github.com/systemd/systemd/pull/3754 to maybe clarify things a bit in the man page.