From 447b7fc84b8a47884d758fa5145b1bbfb043d466 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Tue, 4 Oct 2005 11:35:18 +0000 Subject: 2005-10-02 Dmitry V. Levin Steve Langasek 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 . (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. --- modules/pam_ftp/pam_ftp.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'modules/pam_ftp') diff --git a/modules/pam_ftp/pam_ftp.c b/modules/pam_ftp/pam_ftp.c index 37056767..4f4231c2 100644 --- a/modules/pam_ftp/pam_ftp.c +++ b/modules/pam_ftp/pam_ftp.c @@ -43,7 +43,7 @@ #define PAM_NO_ANON 04 static int -_pam_parse(pam_handle_t *pamh, int argc, const char **argv, char **users) +_pam_parse(pam_handle_t *pamh, int argc, const char **argv, const char **users) { int ctrl=0; @@ -55,12 +55,7 @@ _pam_parse(pam_handle_t *pamh, int argc, const char **argv, char **users) if (!strcmp(*argv,"debug")) ctrl |= PAM_DEBUG_ARG; else if (!strncmp(*argv,"users=",6)) { - *users = x_strdup(6+*argv); - if (*users == NULL) { - ctrl |= PAM_NO_ANON; - pam_syslog(pamh, LOG_CRIT, - "failed to duplicate user list - anon off"); - } + *users = 6 + *argv; } else if (!strcmp(*argv,"ignore")) { ctrl |= PAM_IGNORE_EMAIL; } else { @@ -76,23 +71,26 @@ _pam_parse(pam_handle_t *pamh, int argc, const char **argv, char **users) * return 1 if listed 0 if not. */ -static int lookup(const char *name, char *list, const char **_user) +static int lookup(const char *name, const char *list, const char **_user) { int anon = 0; *_user = name; /* this is the default */ - if (list) { + if (list && *list) { const char *l; - char *x; + char *list_copy, *x; - x = list; - while ((l = strtok(x, ","))) { + list_copy = x_strdup(list); + x = list_copy; + while (list_copy && (l = strtok(x, ","))) { x = NULL; if (!strcmp(name, l)) { *_user = list; anon = 1; } } + _pam_overwrite(list_copy); + _pam_drop(list_copy); } else { #define MAX_L 2 static const char *l[MAX_L] = { "ftp", "anonymous" }; @@ -118,7 +116,7 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags UNUSED, { int retval, anon=0, ctrl; const char *user; - char *users=NULL; + const char *users = NULL; /* * this module checks if the user name is ftp or annonymous. If -- cgit v1.2.3