diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2005-10-04 11:35:18 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2005-10-04 11:35:18 +0000 |
commit | 447b7fc84b8a47884d758fa5145b1bbfb043d466 (patch) | |
tree | 7a23ae0ae278b223ee4b442afd4621b3cccf5c49 /modules/pam_motd/pam_motd.c | |
parent | 21ee1936c230da8c2304cc366c79c4f3ab20b0d9 (diff) | |
download | pam-447b7fc84b8a47884d758fa5145b1bbfb043d466.tar.gz pam-447b7fc84b8a47884d758fa5145b1bbfb043d466.tar.bz2 pam-447b7fc84b8a47884d758fa5145b1bbfb043d466.zip |
2005-10-02 Dmitry V. Levin <ldv@altlinux.org>
Steve Langasek <vorlon@debian.org>
Cleanup gratuitous use of strdup().
Fix "missing argument" checks.
* modules/pam_env/pam_env.c (_pam_parse): Add const qualifier
to conffile and envfile arguments. Do not use x_strdup() for
conffile and envfile initialization. Fix "missing argument"
checks.
(_parse_config_file): Take conffile argument of type "const char *"
instead of "char **". Do not free conffile.
(_parse_env_file): Take env_file argument of type "const char *"
instead of "char **". Do not free env_file.
(pam_sm_setcred): Add const qualifier to conf_file and env_file.
Pass conf_file and env_file to _parse_config_file() and
_parse_env_file() by value.
(pam_sm_open_session): Likewise.
* modules/pam_ftp/pam_ftp.c (_pam_parse): Add const qualifier to
users argument. Do not use x_strdup() for users initialization.
(lookup): Add const qualifier to list argument.
(pam_sm_authenticate): Add const qualifier to users argument.
* modules/pam_mail/pam_mail.c (_pam_parse): Add const qualifier
to maildir argument. Do not use x_strdup() for maildir
initialization. Fix "missing argument" check.
(get_folder): Take path_mail argument of type "const char *"
instead of "char **". Do not free path_mail.
(_do_mail): Add const qualifier to path_mail argument.
Pass path_mail to get_folder() by value.
* modules/pam_motd/pam_motd.c: Include <syslog.h>.
(pam_sm_open_session): Add const qualifier to motd_path.
Do not use x_strdup() for motd_path initialization. Do not
free motd_path. Fix "missing argument" check. Add "unknown
option" warning.
* modules/pam_userdb/pam_userdb.c (_pam_parse): Add const
qualifier to database and cryptmode arguments. Fix "missing
argument" checks.
(pam_sm_authenticate): Add const qualifier to database and cryptmode.
(pam_sm_acct_mgmt): Likewise.
Diffstat (limited to 'modules/pam_motd/pam_motd.c')
-rw-r--r-- | modules/pam_motd/pam_motd.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/modules/pam_motd/pam_motd.c b/modules/pam_motd/pam_motd.c index fff76e07..ff9b1690 100644 --- a/modules/pam_motd/pam_motd.c +++ b/modules/pam_motd/pam_motd.c @@ -20,6 +20,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <pwd.h> +#include <syslog.h> #include <security/_pam_macros.h> #include <security/pam_ext.h> @@ -53,7 +54,7 @@ int pam_sm_open_session(pam_handle_t *pamh, int flags, { int retval = PAM_IGNORE; int fd; - char *motd_path = NULL; + const char *motd_path = NULL; char *mtmp = NULL; if (flags & PAM_SILENT) { @@ -63,13 +64,17 @@ int pam_sm_open_session(pam_handle_t *pamh, int flags, for (; argc-- > 0; ++argv) { if (!strncmp(*argv,"motd=",5)) { - motd_path = (char *) strdup(5+*argv); - if (motd_path != NULL) { + motd_path = 5 + *argv; + if (*motd_path != '\0') { D(("set motd path: %s", motd_path)); - } else { - D(("failed to duplicate motd path - ignored")); - } + } else { + motd_path = NULL; + pam_syslog(pamh, LOG_ERR, + "motd= specification missing argument - ignored"); + } } + else + pam_syslog(pamh, LOG_ERR, "unknown option: %s", *argv); } if (motd_path == NULL) @@ -102,9 +107,6 @@ int pam_sm_open_session(pam_handle_t *pamh, int flags, if (fd >= 0) close(fd); - if (motd_path != default_motd) - free(motd_path); - return retval; } |