From: Tomas Mraz Date: Mon, 7 Mar 2011 14:01:26 +0000 (+0100) Subject: Set mailfrom to the user account, better PAM logging. X-Git-Tag: cronie1.4.7~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a5365f125222a23330faaa0cf9aa493b48399a4;p=cronie Set mailfrom to the user account, better PAM logging. --- diff --git a/src/do_command.c b/src/do_command.c index e664d4c..e1f5401 100644 --- a/src/do_command.c +++ b/src/do_command.c @@ -382,14 +382,10 @@ static int child_process(entry * e, user * u, char **jobenv) { } /* 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 diff --git a/src/security.c b/src/security.c index 5816205..f6940a5 100644 --- a/src/security.c +++ b/src/security.c @@ -65,7 +65,7 @@ static const struct pam_conv conv = { 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); \