]> git.ipfire.org Git - thirdparty/systemd.git/commit
basic/env-util: (mostly) follow POSIX for what variable names are allowed
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 28 Sep 2020 14:30:53 +0000 (16:30 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 12 Oct 2020 16:24:28 +0000 (18:24 +0200)
commitb45c068dd8fac7661a15e99e7cf699ff06010b13
tree8b0e1fe2b8a3d2aa877d86aeaf7985d9f852a388
parent0b3456428be9e11d7067e499ede8456717d225af
basic/env-util: (mostly) follow POSIX for what variable names are allowed

There was some confusion about what POSIX says about variable names:

   names shall not contain the character '='. For values to be portable
   across systems conforming to POSIX.1-2008, the value shall be composed
   of characters from the portable character set (except NUL and as
   indicated below).

i.e. it allows almost all ASCII in variable names (without NUL and DEL and
'='). OTOH, it says that *utilities* use a smaller set of characters:

   Environment variable names used by the utilities in the Shell and
   Utilities volume of POSIX.1-2008 consist solely of uppercase letters,
   digits, and the <underscore> ( '_' ) from the characters defined in
   Portable Character Set and do not begin with a digit.

When enforcing variable names in environment blocks, we need to use this
first definition, so that we can propagate all valid variables.
I think having non-printable characters in variable names is too much, so
I took out the whitespace stuff from the first definition.

OTOH, when we use *shell syntax*, for example doing variable expansion,
it seems enough to support expansion of variables that the shell would allow.

Fixes #14878,
https://bugzilla.redhat.com/show_bug.cgi?id=1754395,
https://bugzilla.redhat.com/show_bug.cgi?id=1879216.
src/basic/env-util.c
src/test/test-env-util.c
src/test/test-load-fragment.c