summaryrefslogtreecommitdiff
path: root/Linux-PAM/modules/pam_mail/pam_mail.c
diff options
context:
space:
mode:
Diffstat (limited to 'Linux-PAM/modules/pam_mail/pam_mail.c')
-rw-r--r--Linux-PAM/modules/pam_mail/pam_mail.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/Linux-PAM/modules/pam_mail/pam_mail.c b/Linux-PAM/modules/pam_mail/pam_mail.c
index d63e79b1..7987cb28 100644
--- a/Linux-PAM/modules/pam_mail/pam_mail.c
+++ b/Linux-PAM/modules/pam_mail/pam_mail.c
@@ -1,7 +1,7 @@
/* pam_mail module */
/*
- * $Id: pam_mail.c,v 1.1.1.1 2001/04/29 04:17:24 hartmans Exp $
+ * $Id: pam_mail.c,v 1.6 2004/11/16 14:27:41 toady Exp $
*
* Written by Andrew Morgan <morgan@linux.kernel.org> 1996/3/11
* $HOME additions by David Kinchlea <kinch@kinch.ark.com> 1997/1/7
@@ -32,7 +32,7 @@
#define MAIL_ENV_FORMAT MAIL_ENV_NAME "=%s"
#define YOUR_MAIL_VERBOSE_FORMAT "You have %s mail in %s."
#define YOUR_MAIL_STANDARD_FORMAT "You have %smail."
-#define NO_MAIL_STANDARD_FORMAT "No mail."
+#define NO_MAIL_STANDARD_FORMAT "No mail."
/*
* here, we make a definition for the externally accessible function
@@ -46,6 +46,7 @@
#include <security/pam_modules.h>
#include <security/_pam_macros.h>
+#include <security/_pam_modutil.h>
/* some syslogging */
@@ -142,8 +143,8 @@ static int converse(pam_handle_t *pamh, int ctrl, int nargs
D(("begin to converse"));
- retval = pam_get_item( pamh, PAM_CONV, (const void **) &conv ) ;
- if ( retval == PAM_SUCCESS ) {
+ retval = pam_get_item( pamh, PAM_CONV, (const void **) &conv ) ;
+ if ( retval == PAM_SUCCESS && conv ) {
retval = conv->conv(nargs, ( const struct pam_message ** ) message
, response, conv->appdata_ptr);
@@ -158,6 +159,8 @@ static int converse(pam_handle_t *pamh, int ctrl, int nargs
} else {
_log_err(LOG_ERR, "couldn't obtain coversation function [%s]"
, pam_strerror(pamh, retval));
+ if (retval == PAM_SUCCESS)
+ retval = PAM_BAD_ITEM; /* conv was NULL */
}
D(("ready to return from module conversation"));
@@ -182,7 +185,7 @@ static int get_folder(pam_handle_t *pamh, int ctrl,
if (ctrl & PAM_NEW_MAIL_DIR) {
path = *path_mail;
if (*path == '~') { /* support for $HOME delivery */
- pwd = getpwnam(user);
+ pwd = _pammodutil_getpwnam(pamh, user);
if (pwd == NULL) {
_log_err(LOG_ERR, "user [%s] unknown", user);
_pam_overwrite(*path_mail);
@@ -234,7 +237,9 @@ static int get_folder(pam_handle_t *pamh, int ctrl,
_pam_overwrite(hash);
_pam_drop(hash);
} else {
- sprintf(folder, "error");
+ _pam_drop(folder);
+ _log_err(LOG_CRIT, "out of memory for mail folder");
+ return PAM_BUF_ERR;
}
}
D(("folder =[%s]", folder));
@@ -386,7 +391,7 @@ PAM_EXTERN
int pam_sm_close_session(pam_handle_t *pamh,int flags,int argc
,const char **argv)
{
- return _do_mail(pamh,flags,argc,argv,0);;
+ return _do_mail(pamh,flags,argc,argv,0);
}
/* Checking mail as part of the session management */
@@ -467,9 +472,9 @@ static int _do_mail(pam_handle_t *pamh, int flags, int argc,
type = NULL;
}
}
-
- /* Delete environment variable? */
- if (!est)
+
+ /* Delete environment variable? */
+ if ( ! est && ! (ctrl & PAM_NO_ENV) )
(void) pam_putenv(pamh, MAIL_ENV_NAME);
_pam_overwrite(folder); /* clean up */