diff options
author | Sam Hartman <hartmans@debian.org> | 2023-09-11 14:09:57 -0600 |
---|---|---|
committer | Sam Hartman <hartmans@debian.org> | 2023-09-11 14:09:57 -0600 |
commit | e9aa2ef52a423a3a33299bf7e8715eb5bd76ea67 (patch) | |
tree | 8b1bd3f4fc01ef0261a13d75cf48be9002480aaf /modules/pam_time/pam_time.c | |
parent | 99d0d1c5c4f07332daa86e73981267a761bc966e (diff) | |
parent | bf07335a19d6192adaf4b1a817d2101ee0bad134 (diff) | |
download | pam-e9aa2ef52a423a3a33299bf7e8715eb5bd76ea67.tar.gz pam-e9aa2ef52a423a3a33299bf7e8715eb5bd76ea67.tar.bz2 pam-e9aa2ef52a423a3a33299bf7e8715eb5bd76ea67.zip |
New upstream version 1.5.3
Diffstat (limited to 'modules/pam_time/pam_time.c')
-rw-r--r-- | modules/pam_time/pam_time.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/modules/pam_time/pam_time.c b/modules/pam_time/pam_time.c index 089ae22d..6b7adefc 100644 --- a/modules/pam_time/pam_time.c +++ b/modules/pam_time/pam_time.c @@ -33,6 +33,11 @@ #include <libaudit.h> #endif +#define PAM_TIME_CONF (SCONFIGDIR "/time.conf") +#ifdef VENDOR_SCONFIGDIR +#define VENDOR_PAM_TIME_CONF (VENDOR_SCONFIGDIR "/time.conf") +#endif + #define PAM_TIME_BUFLEN 1000 #define FIELD_SEPARATOR ';' /* this is new as of .02 */ @@ -53,7 +58,7 @@ _pam_parse (const pam_handle_t *pamh, int argc, const char **argv, const char ** { int ctrl = 0; - *conffile = PAM_TIME_CONF; + *conffile = NULL; /* step through arguments */ for (; argc-- > 0; ++argv) { const char *str; @@ -77,6 +82,20 @@ _pam_parse (const pam_handle_t *pamh, int argc, const char **argv, const char ** } } + if (*conffile == NULL) { + *conffile = PAM_TIME_CONF; +#ifdef VENDOR_PAM_TIME_CONF + /* + * Check whether PAM_TIME_CONF file is available. + * If it does not exist, fall back to VENDOR_PAM_TIME_CONF file. + */ + struct stat buffer; + if (stat(*conffile, &buffer) != 0 && errno == ENOENT) { + *conffile = VENDOR_PAM_TIME_CONF; + } +#endif + } + return ctrl; } @@ -88,7 +107,7 @@ shift_buf(char *mem, int from) char *start = mem; while ((*mem = mem[from]) != '\0') ++mem; - memset(mem, '\0', PAM_TIME_BUFLEN - (mem - start)); + pam_overwrite_n(mem, PAM_TIME_BUFLEN - (mem - start)); return mem; } @@ -149,7 +168,7 @@ read_field(const pam_handle_t *pamh, int fd, char **buf, int *from, int *state, if (i < 0) { pam_syslog(pamh, LOG_ERR, "error reading %s: %m", file); close(fd); - memset(*buf, 0, PAM_TIME_BUFLEN); + pam_overwrite_n(*buf, PAM_TIME_BUFLEN); _pam_drop(*buf); *state = STATE_EOF; return -1; @@ -168,7 +187,7 @@ read_field(const pam_handle_t *pamh, int fd, char **buf, int *from, int *state, return -1; } - memset(to, '\0', PAM_TIME_BUFLEN - (to - *buf)); + pam_overwrite_n(to, PAM_TIME_BUFLEN - (to - *buf)); to = *buf; onspace = 1; /* delete any leading spaces */ |