You are not logged in.
I am using pam_env to set many system-wide environment variables (regardless of the shell being used) like LS_COLORS for ls, etc; and, everything is working as expected except when I want to set a variable containing a backslash; eg:
colorWHATEVER DEFAULT="\e[1;37m"Upon login:
echo $colorWHATEVER;
e[1;37mThe backslash is missing; so, without reading further I did:
colorWHATEVER DEFAULT="\\e[1;37m"Upon login:
echo $colorWHATEVER;
e[1;37mSame result: no backslash -not even without the double quotes.
The silly examples in /etc/security/pam_env.conf show that you can escape with the backslash and provides two examples: \$ for $ and \@ for @
Now, reading the man page for pam_env.conf:
(Possibly non-existent) environment variables may be used in values using the ${string} syntax and (possibly non-existent) PAM_ITEMs may be used in values using the @{string} syntax. Both the $ and @ characters can be backslash escaped to be used as literal values values can be delimited with "", escaped " not supported.
Which seems (convoluted) english to state that the only characters you can escape are $ and @ ... am I right ?
Last edited by dawnofman (2019-08-09 18:02:56)
Offline
This probably has nothing to do w/ pam_env - try
colorWHATEVER="\\\e[1;37m"or
colorWHATEVER='\\e[1;37m'However I assume what you're trying to do won't work this way.
colorWHATEVER='\e[1;37m'will be the correct export even if "echo $colorWHATEVER" doesn't reflect what you think it reflects.
Offline
colorWHATEVER="\\\e[1;37m"
same result: no backslah, no color:
echo "${colorWHATEVER}";
e[1;37m
printf "${colorWHATEVER}xxxxxx\n";
e[1;37mxxxxxxcolorWHATEVER='\\e[1;37m'
same result: no backslah, no color:
echo "${colorWHATEVER}";
'e[1;37m'
printf "${colorWHATEVER}xxxxxx\n";
'e[1;37m'xxxxxxcolorWHATEVER='\e[1;37m'
same result: no backslah, no color:
echo "${colorWHATEVER}";
'e[1;37m'
printf "${colorWHATEVER}xxxxxx\n";
'e[1;37m'xxxxxxOffline
I'd understand if the escaping variable doesn't work, but the other two should seriously print "\e[1;37m" - did you check whether the changes you made were applied at all to your test environment (eg. w/ a different color or exporting another, more trivial variable like "foo DEFAULT=bar")?
Offline
I'd understand if the escaping variable doesn't work, but the other two should seriously print "\e[1;37m" - did you check whether the changes you made were applied at all to your test environment (eg. w/ a different color or exporting another, more trivial variable like "foo DEFAULT=bar")?
whatever='abc'
printf "${whatever}\n";
'abc'pam_env.conf doesn't treat single quotes like anything special, it seems it only looks for double quotes, and whether there are @ and/or $ escaped characters, everything else is disregarded.
Try it in your /etc/security/pam_env.conf with something inocuos, you don't have to modify the PAM stack, pam_env is loaded by default.
Offline