diff options
author | Tobias Stoeckmann <tobias@stoeckmann.org> | 2024-01-18 20:25:20 +0100 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2024-01-18 19:25:20 +0000 |
commit | 9e4e3e42554fc6344a0b20b42aafb48011e9b2c9 (patch) | |
tree | b6c1bece35acff34eeb6dd7bc64a1a9fdfca7f6b | |
parent | 28894b319488e8302899ee569b6e0911905f374e (diff) | |
download | pam-9e4e3e42554fc6344a0b20b42aafb48011e9b2c9.tar.gz pam-9e4e3e42554fc6344a0b20b42aafb48011e9b2c9.tar.bz2 pam-9e4e3e42554fc6344a0b20b42aafb48011e9b2c9.zip |
pam_env: remove escaped newlines from econf lines
The libeconf routines do not remove escaped newlines the way we want to
process them later on. Manually remove them from values.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Resolves: https://github.com/linux-pam/linux-pam/issues/738
Fixes: 6135c45347b6 ("pam_env: Use vendor specific pam_env.conf and environment as fallback")
-rw-r--r-- | modules/pam_env/pam_env.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/pam_env/pam_env.c b/modules/pam_env/pam_env.c index 8b40b6a5..6bece0f8 100644 --- a/modules/pam_env/pam_env.c +++ b/modules/pam_env/pam_env.c @@ -160,6 +160,28 @@ isDirectory(const char *path) { return S_ISDIR(statbuf.st_mode); } +/* + * Remove escaped newline from string. + * + * All occurrences of "\\n" will be removed from string. + */ +static void +econf_unescnl(char *val) +{ + char *dest, *p; + + dest = p = val; + + while (*p != '\0') { + if (p[0] == '\\' && p[1] == '\n') { + p += 2; + } else { + *dest++ = *p++; + } + } + *dest = '\0'; +} + static int econf_read_file(const pam_handle_t *pamh, const char *filename, const char *delim, const char *name, const char *suffix, const char *subpath, @@ -270,6 +292,7 @@ econf_read_file(const pam_handle_t *pamh, const char *filename, const char *deli keys[i], econf_errString(error)); } else { + econf_unescnl(val); if (asprintf(&(*lines)[i],"%s%c%s", keys[i], delim[0], val) < 0) { pam_syslog(pamh, LOG_ERR, "Cannot allocate memory."); econf_free(keys); |