#95 Keep LC_*, LANG, set default LC_CTYPE
Merged 6 years ago by rcritten. Opened 6 years ago by cheimes.
cheimes/certmonger lc_ctype  into  master

file modified
+9
@@ -74,6 +74,13 @@ 

  	    (strncmp(p, CERTMONGER_PVT_ADDRESS_ENV, equal) == 0)) {

  		return equal;

  	}

+ 	if ((strlen("LANG") == equal) && (strncmp(p, "LANG", equal) == 0)) {

+ 		return equal;

+ 	}

+ 	if ((equal > 4) &&

+ 	    (strncmp(p, "LC_", 3) == 0)) {

+ 		return equal;

+ 	}

  	if ((equal > 6) &&

  	    ((strncmp(p + equal - 6, "_PROXY", 6) == 0) ||

  	     (strncmp(p + equal - 6, "_proxy", 6) == 0))) {
@@ -158,6 +165,8 @@ 

  				setenv("PATH", _PATH_STDPATH, 1);

  				setenv("SHELL", _PATH_BSHELL, 1);

  				setenv("TERM", "dumb", 1);

+ 				/* sane default, can be overruled by childenv */

+ 				setenv("LC_CTYPE", "C.UTF-8", 1);

  				if (configdir != NULL) {

  					setenv(CM_STORE_CONFIG_DIRECTORY_ENV,

  					       configdir, 1);

Python 3.6 and earlier Python 3 require a correctly configured locale to
support non-ASCII values for file names and other parameters. Certmonger
now passes down LANG and LC_* env vars. It also sets LC_CTYPE=C.UTF-8 as
default in case no LC_CTYPE is set.

Fixes: https://pagure.io/certmonger/issue/94
Signed-off-by: Christian Heimes cheimes@redhat.com

Is it intentional that setting LC_CTYPE in the environment will be overridden by this?

LC_CTYPE is forced to C.UTF-8 after the environment is checked (and it is potentially set to something else).

The the opposite around:

  • first certmonger preserves some vars in childenv. My patch adds LANG and LC_*.
  • then all env vars are cleared
  • after that my patch sets LC_CTYPE=C.UTF-8 as sane default
  • finally all preserved childenv values are restored. This overrides LC_CTYPE in case it was set in the certmonger process. Otherwise LC_CTYPE=C.UTF-8 is kept.

I added a comment to setenv("LC_CTYPE", "C.UTF-8", 1);

rebased onto 0288d36

6 years ago

Metadata Update from @rcritten:
- Request assigned

6 years ago

Pull-Request has been merged by rcritten

6 years ago
Metadata