diff options
author | Tomas Mraz <tm@t8m.info> | 2005-04-19 07:37:50 +0000 |
---|---|---|
committer | Tomas Mraz <tm@t8m.info> | 2005-04-19 07:37:50 +0000 |
commit | 5fd4e6dd66443119070b41c226809d263a6d0d23 (patch) | |
tree | 0e790f908bf83d695ecf684f214743bcdd720dff /modules/pam_motd/pam_motd.c | |
parent | 9c459446c2424d46622e95e4d54280fee0ef9607 (diff) | |
download | pam-5fd4e6dd66443119070b41c226809d263a6d0d23.tar.gz pam-5fd4e6dd66443119070b41c226809d263a6d0d23.tar.bz2 pam-5fd4e6dd66443119070b41c226809d263a6d0d23.zip |
Relevant BUGIDs:
Purpose of commit: bugfix
Commit summary:
---------------
Various cleanups and minor bugfixes by Steve Grubb.
Diffstat (limited to 'modules/pam_motd/pam_motd.c')
-rw-r--r-- | modules/pam_motd/pam_motd.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/modules/pam_motd/pam_motd.c b/modules/pam_motd/pam_motd.c index b1d9c9d9..3ff7a30e 100644 --- a/modules/pam_motd/pam_motd.c +++ b/modules/pam_motd/pam_motd.c @@ -44,6 +44,8 @@ int pam_sm_close_session(pam_handle_t *pamh, int flags, int argc, return PAM_IGNORE; } +static char default_motd[] = DEFAULT_MOTD; + PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv) @@ -51,7 +53,7 @@ int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, int retval = PAM_IGNORE; int fd; char *mtmp=NULL; - const char *motd_path=NULL; + char *motd_path=NULL; struct pam_conv *conversation; struct pam_message message; struct pam_message *pmessage = &message; @@ -67,7 +69,7 @@ int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, motd_path = (char *) strdup(5+*argv); if (motd_path != NULL) { - D(("set motd path: %s (and a memory leak)", motd_path)); + D(("set motd path: %s", motd_path)); } else { D(("failed to duplicate motd path - ignored")); } @@ -75,11 +77,13 @@ int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, } if (motd_path == NULL) - motd_path = DEFAULT_MOTD; + motd_path = default_motd; message.msg_style = PAM_TEXT_INFO; if ((fd = open(motd_path, O_RDONLY, 0)) >= 0) { + if (motd_path != default_motd) + free(motd_path); /* fill in message buffer with contents of motd */ if ((fstat(fd, &st) < 0) || !st.st_size) { close(fd); @@ -108,6 +112,9 @@ int pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, } } free(mtmp); + } else { + if (motd_path != default_motd) + free(motd_path); } return retval; |