aboutsummaryrefslogtreecommitdiff
path: root/modules/pam_env
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@stoeckmann.org>2024-01-11 20:25:22 +0100
committerDmitry V. Levin <ldv@strace.io>2024-01-12 17:01:04 +0000
commit47661a8eda337f23baf12d3bf6a479fc738be73f (patch)
tree947ef3af093b4ff806a47423451689eb3d4f58eb /modules/pam_env
parentd9494352c571d332cf92bdadcd898894f0af12df (diff)
downloadpam-47661a8eda337f23baf12d3bf6a479fc738be73f.tar.gz
pam-47661a8eda337f23baf12d3bf6a479fc738be73f.tar.bz2
pam-47661a8eda337f23baf12d3bf6a479fc738be73f.zip
pam_env: allow escaping of escape character
Otherwise it is not possible to add \ into an environment variable. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Diffstat (limited to 'modules/pam_env')
-rw-r--r--modules/pam_env/pam_env.c2
-rw-r--r--modules/pam_env/tst-pam_env-retval.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/modules/pam_env/pam_env.c b/modules/pam_env/pam_env.c
index 5819ed07..778c5345 100644
--- a/modules/pam_env/pam_env.c
+++ b/modules/pam_env/pam_env.c
@@ -607,7 +607,7 @@ _expand_arg(pam_handle_t *pamh, char **value)
while (*orig) { /* while there is some input to deal with */
if ('\\' == *orig) {
++orig;
- if ('$' != *orig && '@' != *orig) {
+ if ('$' != *orig && '@' != *orig && '\\' != *orig) {
D(("Unrecognized escaped character: <%c> - ignoring", *orig));
pam_syslog(pamh, LOG_ERR,
"Unrecognized escaped character: <%c> - ignoring",
diff --git a/modules/pam_env/tst-pam_env-retval.c b/modules/pam_env/tst-pam_env-retval.c
index be9eff50..68f65455 100644
--- a/modules/pam_env/tst-pam_env-retval.c
+++ b/modules/pam_env/tst-pam_env-retval.c
@@ -73,7 +73,7 @@ setup(void)
"PAGER\tDEFAULT=more\n"
"# ignore escaped newlines in comments \\\n"
"NAME\tDEFAULT=@{PAM_\\ \t\n"
- "USER}\n"));
+ "USER}\\\\name\n"));
ASSERT_EQ(0, fclose(fp));
ASSERT_NE(NULL, fp = fopen(my_env, "w"));
@@ -234,7 +234,7 @@ main(void)
cwd, my_conf, "/dev/null"));
ASSERT_EQ(0, fclose(fp));
- const char *env1[] = { "EDITOR=vim", "PAGER=more", "NAME=user", NULL };
+ const char *env1[] = { "EDITOR=vim", "PAGER=more", "NAME=user\\name", NULL };
check_env(env1);
/*