Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F103076738
D32630.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.diff
View Options
diff --git a/usr.sbin/cron/cron/cron.h b/usr.sbin/cron/cron/cron.h
--- a/usr.sbin/cron/cron/cron.h
+++ b/usr.sbin/cron/cron/cron.h
@@ -292,6 +292,7 @@
unsigned Jitter,
RootJitter;
time_t TargetTime;
+int HtmlPreformat = 0;
# if DEBUGGING
int DebugFlags;
@@ -310,6 +311,7 @@
extern unsigned Jitter,
RootJitter;
extern time_t TargetTime;
+extern int HtmlPreformat;
extern struct pidfh *pfh;
# if DEBUGGING
extern int DebugFlags;
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
@@ -61,7 +61,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: ");
@@ -525,7 +525,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);
@@ -551,6 +551,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
@@ -84,6 +84,20 @@
Debug(DPROC, ("[%d] main process returning to work\n", getpid()))
}
+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(e, u)
@@ -524,7 +538,12 @@
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
*/
@@ -538,8 +557,19 @@
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*/
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 21, 3:26 PM (6 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14763377
Default Alt Text
D32630.diff (2 KB)
Attached To
Mode
D32630: HTML pre-formatted cron's emails
Attached
Detach File
Event Timeline
Log In to Comment