Bug 1755287

Summary: localectl set-locale should issue an error message when trying to set a nonexistent locale
Product: Red Hat Enterprise Linux 8 Reporter: Bernd Finger <bfinger>
Component: systemdAssignee: David Tardon <dtardon>
Status: CLOSED ERRATA QA Contact: Frantisek Sumsal <fsumsal>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 8.0CC: ashankar, codonell, dj, dtardon, fweimer, jamacku, mnewsome, msekleta, pfrankli, systemd-maint-list
Target Milestone: rc   
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: systemd-239-43.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-18 14:53:17 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 Bernd Finger 2019-09-25 08:25:08 UTC
Description of problem:
Running "localectl set-locale aaa" on RHEL 8 succeeds and does not issue an error or warning message.

Version-Release number of selected component (if applicable):
RHEL 8.0 GA

How reproducible:
always

Steps to Reproduce:
1. Execute:
# localectl set-locale aaa
2. Run:
# echo $?

Actual results:
a) There is no warning or error message.
b) The return code is 0:
0

Expected results:
The behavior should be identical to RHEL 7.6:
a) There should be an error message like:
Failed to issue method call: Invalid Locale data.
b) The return code should be 1:
1

Additional info:

Comment 1 Florian Weimer 2019-09-25 08:35:46 UTC
localectl comes from systemd:

$ rpm -qf /usr/bin/localectl 
systemd-239-13.el8_0.5.x86_64

I think systemd should be able to check the availability of a locale using the setlocale function, so I don't think we need any glibc changes to enable this feature.

Comment 3 Jan Synacek 2019-10-31 11:53:41 UTC
(In reply to Bernd Finger from comment #0)
> Expected results:
> The behavior should be identical to RHEL 7.6:
> a) There should be an error message like:
> Failed to issue method call: Invalid Locale data.

Well, the RHEL-7.6 version does not check the input either. It just fails if you don't provide the variable that you want to set too.

# localectl set-locale foobar
Failed to issue method call: Invalid Locale data.

# localectl set-locale LANG=foobar
# echo $?
0

The upstream version (673d873a42fd6e7821e310cfb81bc37d092c4a22) doesn't sanity-check the input as well.

Comment 4 Jan Synacek 2019-11-06 13:20:09 UTC
https://github.com/systemd/systemd/pull/13964

Comment 8 Lukáš Nykrýn 2020-11-24 18:01:25 UTC
fix merged to github master branch -> https://github.com/systemd-rhel/rhel-8/pull/132

Comment 14 errata-xmlrpc 2021-05-18 14:53:17 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: systemd security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:1611