Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 106795 | Differences between
and this patch

Collapse All | Expand All

(-)dcron/job.c (-1 / +33 lines)
Lines 11-21 Link Here
11
Prototype void RunJob(CronFile *file, CronLine *line);
11
Prototype void RunJob(CronFile *file, CronLine *line);
12
Prototype void EndJob(CronFile *file, CronLine *line);
12
Prototype void EndJob(CronFile *file, CronLine *line);
13
13
14
void 
15
maildate(char *date, int len) 
16
{
17
	char days[7][4] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
18
	char months[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", 
19
					"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
20
	time_t now = time(NULL);
21
	/*
22
	 * Use GMT for simplicity
23
	 */
24
	struct tm nowbr = *gmtime(&now);
25
	/*
26
	 * RFC2822 compliant date format
27
	 */
28
	snprintf(date, len, "%s, %d %s %d %02d:%02d:%02d +0000", 
29
		days[nowbr.tm_wday], 
30
		nowbr.tm_mday, 
31
		months[nowbr.tm_mon], 
32
		nowbr.tm_year+1900,
33
		nowbr.tm_hour,
34
		nowbr.tm_min,
35
		nowbr.tm_sec
36
	);
37
}
38
14
void
39
void
15
RunJob(CronFile *file, CronLine *line)
40
RunJob(CronFile *file, CronLine *line)
16
{
41
{
17
    char mailFile[128];
42
    char mailFile[128];
18
    int mailFd;
43
    int mailFd;
44
    char date[128];
19
45
20
    line->cl_Pid = 0;
46
    line->cl_Pid = 0;
21
    line->cl_MailFlag = 0;
47
    line->cl_MailFlag = 0;
Lines 30-37 Link Here
30
56
31
    if (mailFd >= 0) {
57
    if (mailFd >= 0) {
32
	line->cl_MailFlag = 1;
58
	line->cl_MailFlag = 1;
33
	fdprintf(mailFd, "To: %s\nSubject: cron: %s\n\n", 
59
	/*
60
	 * RFC2822 compliant mail header
61
	 */
62
	maildate(date, sizeof(date));
63
	fdprintf(mailFd, "To: %s@localhost\nFrom: %s@localhost\nDate: %s\nSubject: cron: %s\n\n", 
64
	    file->cf_UserName,
34
	    file->cf_UserName,
65
	    file->cf_UserName,
66
	    date,
35
	    line->cl_Shell
67
	    line->cl_Shell
36
	);
68
	);
37
	line->cl_MailPos = lseek(mailFd, 0, 1);
69
	line->cl_MailPos = lseek(mailFd, 0, 1);

Return to bug 106795