}
/* get sender address. this is MAILFROM if set (and safe),
- * root otherwise.
- * mailfrom is not freed because it lives only in this short
- * child process. Freeing could lead to segfaul, when mailfrom
- * is acquired from env_get function.
+ * the user account name otherwise.
*/
if (!mailfrom || !*mailfrom || !safe_p(usernm, mailfrom)) {
- mailfrom = calloc(5, sizeof (char));
- strcpy(mailfrom, "root");
+ mailfrom = e->pwd->pw_name;
}
/* if we are supposed to be mailing, MAILTO will
static int cron_open_pam_session(struct passwd *pw);
# define PAM_FAIL_CHECK if (retcode != PAM_SUCCESS) { \
- fprintf(stderr,"\n%s\n",pam_strerror(pamh, retcode)); \
+ log_it(pw->pw_name, getpid(), "PAM ERROR", pam_strerror(pamh, retcode), 0); \
if (pamh != NULL) { \
if (pam_session_opened != 0) \
pam_close_session(pamh, PAM_SILENT); \