Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157541490
D32630.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D32630.id.diff
View Options
diff --git a/usr.sbin/cron/cron/cron.c b/usr.sbin/cron/cron/cron.c
--- a/usr.sbin/cron/cron/cron.c
+++ b/usr.sbin/cron/cron/cron.c
@@ -56,7 +56,7 @@
#endif
fprintf(stderr, "usage: cron [-j jitter] [-J rootjitter] "
- "[-m mailto] [-n] [-s] [-o] [-x debugflag[,...]]\n");
+ "[-m mailto] [-n] [-s] [-o] [-H] [-x debugflag[,...]]\n");
#if DEBUGGING
fprintf(stderr, "\ndebugflags: ");
@@ -499,7 +499,7 @@
int argch;
char *endp;
- while ((argch = getopt(argc, argv, "j:J:m:nosx:")) != -1) {
+ while ((argch = getopt(argc, argv, "j:J:m:nosHx:")) != -1) {
switch (argch) {
case 'j':
Jitter = strtoul(optarg, &endp, 10);
@@ -525,6 +525,9 @@
case 's':
dst_enabled = 1;
break;
+ case 'H':
+ HtmlPreformat = 1;
+ break;
case 'x':
if (!set_debug_flags(optarg))
usage();
diff --git a/usr.sbin/cron/cron/do_command.c b/usr.sbin/cron/cron/do_command.c
--- a/usr.sbin/cron/cron/do_command.c
+++ b/usr.sbin/cron/cron/do_command.c
@@ -77,6 +77,23 @@
}
+static char*
+escape_html(int ch, char *tempbuf)
+{
+ switch (ch) {
+ case '<':
+ return "<";
+ case '>':
+ return ">";
+ case '&':
+ return "&";
+ default:
+ tempbuf[0] = ch;
+ return tempbuf;
+ }
+}
+
+
static void
child_process(entry *e, user *u)
{
@@ -557,8 +574,11 @@
for (env = e->envp; *env; env++)
fprintf(mail, "X-Cron-Env: <%s>\n",
*env);
+ if (HtmlPreformat)
+ fprintf(mail, "Content-Type: text/html\n");
fprintf(mail, "\n");
-
+ if (HtmlPreformat)
+ fprintf(mail, "<html><pre style=\"white-space: pre;\">\n");
/* this was the first char from the pipe
*/
putc(ch, mail);
@@ -571,9 +591,18 @@
while (EOF != (ch = getc(in))) {
bytes++;
- if (mail)
- putc(ch, mail);
+ if (mail) {
+ if (HtmlPreformat) {
+ char tempbuf[2] = {0, 0};
+ char *escapedstring = escape_html(ch, &tempbuf[0]);
+ fputs(escapedstring, mail);
+ } else {
+ putc(ch, mail);
+ }
+ }
}
+ if (mailto && HtmlPreformat)
+ fprintf(mail, "</pre></html>\n");
}
/*if data from grandchild*/
diff --git a/usr.sbin/cron/cron/globals.h b/usr.sbin/cron/cron/globals.h
--- a/usr.sbin/cron/cron/globals.h
+++ b/usr.sbin/cron/cron/globals.h
@@ -63,6 +63,7 @@
XTRN unsigned Jitter;
XTRN unsigned RootJitter;
XTRN time_t TargetTime INIT(0);
+XTRN int HtmlPreformat INIT(0);
XTRN struct pidfh *pfh;
#if DEBUGGING
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, May 23, 3:08 PM (9 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33448550
Default Alt Text
D32630.id.diff (2 KB)
Attached To
Mode
D32630: HTML pre-formatted cron's emails
Attached
Detach File
Event Timeline
Log In to Comment