summaryrefslogtreecommitdiff
path: root/modules/pam_mail
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2005-10-04 11:35:18 +0000
committerDmitry V. Levin <ldv@altlinux.org>2005-10-04 11:35:18 +0000
commit447b7fc84b8a47884d758fa5145b1bbfb043d466 (patch)
tree7a23ae0ae278b223ee4b442afd4621b3cccf5c49 /modules/pam_mail
parent21ee1936c230da8c2304cc366c79c4f3ab20b0d9 (diff)
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_mail')
-rw-r--r--modules/pam_mail/pam_mail.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/modules/pam_mail/pam_mail.c b/modules/pam_mail/pam_mail.c
index caa58eae..c67a36c4 100644
--- a/modules/pam_mail/pam_mail.c
+++ b/modules/pam_mail/pam_mail.c
@@ -62,7 +62,7 @@
static int
_pam_parse (const pam_handle_t *pamh, int flags, int argc,
- const char **argv, char **maildir, size_t *hashcount)
+ const char **argv, const char **maildir, size_t *hashcount)
{
int ctrl=0;
@@ -84,13 +84,13 @@ _pam_parse (const pam_handle_t *pamh, int flags, int argc,
else if (!strcmp(*argv,"standard"))
ctrl |= PAM_STANDARD_MAIL | PAM_EMPTY_TOO;
else if (!strncmp(*argv,"dir=",4)) {
- *maildir = x_strdup(4+*argv);
- if (*maildir != NULL) {
+ *maildir = 4 + *argv;
+ if (**maildir != '\0') {
D(("new mail directory: %s", *maildir));
ctrl |= PAM_NEW_MAIL_DIR;
} else {
- pam_syslog (pamh, LOG_CRIT,
- "failed to duplicate mail directory - ignored");
+ pam_syslog(pamh, LOG_ERR,
+ "dir= specification missing argument - ignored");
}
} else if (!strncmp(*argv,"hash=",5)) {
char *ep = NULL;
@@ -112,7 +112,7 @@ _pam_parse (const pam_handle_t *pamh, int flags, int argc,
}
if ((*hashcount != 0) && !(ctrl & PAM_NEW_MAIL_DIR)) {
- *maildir = x_strdup(DEFAULT_MAIL_DIRECTORY);
+ *maildir = DEFAULT_MAIL_DIRECTORY;
ctrl |= PAM_NEW_MAIL_DIR;
}
@@ -121,7 +121,7 @@ _pam_parse (const pam_handle_t *pamh, int flags, int argc,
static int
get_folder(pam_handle_t *pamh, int ctrl,
- char **path_mail, char **folder_p, size_t hashcount)
+ const char *path_mail, char **folder_p, size_t hashcount)
{
int retval;
const char *user, *path;
@@ -136,7 +136,7 @@ get_folder(pam_handle_t *pamh, int ctrl,
}
if (ctrl & PAM_NEW_MAIL_DIR) {
- path = *path_mail;
+ path = path_mail;
if (*path == '~') { /* support for $HOME delivery */
pwd = pam_modutil_getpwnam(pamh, user);
if (pwd == NULL) {
@@ -149,7 +149,7 @@ get_folder(pam_handle_t *pamh, int ctrl,
*/
if (!*++path || (*path == '/' && !*++path)) {
pam_syslog(pamh, LOG_ERR,
- "badly formed mail path [%s]", *path_mail);
+ "badly formed mail path [%s]", path_mail);
retval = PAM_SERVICE_ERR;
goto get_folder_cleanup;
}
@@ -197,8 +197,6 @@ get_folder(pam_handle_t *pamh, int ctrl,
/* tidy up */
get_folder_cleanup:
- _pam_overwrite(*path_mail);
- _pam_drop(*path_mail);
user = NULL;
path = NULL;
@@ -361,8 +359,8 @@ static int _do_mail(pam_handle_t *pamh, int flags, int argc,
{
int retval, ctrl;
size_t hashcount;
- char *path_mail = NULL, *folder = NULL;
- const char *type;
+ char *folder = NULL;
+ const char *path_mail = NULL, *type;
/*
* this module (un)sets the MAIL environment variable, and checks if
@@ -378,7 +376,7 @@ static int _do_mail(pam_handle_t *pamh, int flags, int argc,
/* which folder? */
- retval = get_folder(pamh, ctrl, &path_mail, &folder, hashcount);
+ retval = get_folder(pamh, ctrl, path_mail, &folder, hashcount);
if (retval != PAM_SUCCESS) {
D(("failed to find folder"));
return retval;