1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
diff --git a/miscutils/crond.c b/miscutils/crond.c
index 4a3103c..7ba8bab 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -827,7 +827,7 @@ ForkJob(const char *user, CronLine *line, int mailFd,
static void RunJob(const char *user, CronLine *line)
{
- char mailFile[128];
+ char mailFile[128], *mail_filename = NULL;
int mailFd = -1;
line->cl_Pid = 0;
@@ -836,6 +836,7 @@ static void RunJob(const char *user, CronLine *line)
if (line->cl_MailTo) {
/* open mail file - owner root so nobody can screw with it. */
snprintf(mailFile, sizeof(mailFile), "%s/cron.%s.%d", TMPDIR, user, getpid());
+ mail_filename = mailFile;
mailFd = open(mailFile, O_CREAT | O_TRUNC | O_WRONLY | O_EXCL | O_APPEND, 0600);
if (mailFd >= 0) {
@@ -849,7 +850,7 @@ static void RunJob(const char *user, CronLine *line)
}
}
- ForkJob(user, line, mailFd, DEFAULT_SHELL, "-c", line->cl_Shell, mailFile);
+ ForkJob(user, line, mailFd, DEFAULT_SHELL, "-c", line->cl_Shell, mail_filename);
}
/*
|