}
#endif
- *jobenv = build_env(e->envp);
-
#ifdef WITH_SELINUX
/* we must get the crontab context BEFORE changing user, else
* we'll not be permitted to read the cron spool directory :-)
*/
security_context_t ucontext = 0;
- if (cron_get_job_range(u, &ucontext, *jobenv) < OK) {
+ if (cron_get_job_range(u, &ucontext, e->envp) < OK) {
log_it(e->pwd->pw_name, getpid(), "ERROR",
"failed to get SELinux context", 0);
return -1;
return -1;
}
+ *jobenv = build_env(e->envp);
+
time_t job_run_time = time(0L);
if ((minutely_time > 0) && ((job_run_time / 60) != (minutely_time / 60))) {
*/
static char **build_env(char **cronenv) {
#ifdef WITH_PAM
- char **jobenv;
- char **pamenv = pam_getenvlist(pamh);
+ char **jobenv = pam_getenvlist(pamh);
char *cronvar;
int count = 0;
- jobenv = env_copy(pamenv);
+
+ if (jobenv == NULL) {
+ jobenv = env_init();
+ if (jobenv == NULL) {
+ log_it("CRON", getpid(),
+ "ERROR", "Initialization of cron environment variables failed", 0);
+ return NULL;
+ }
+ }
/* Now add the cron environment variables. Since env_set()
* overwrites existing variables, this will let cron's