hush: initial stab at brace expansion support
[oweals/busybox.git] / miscutils / crond.c
index 767aa120a912f3d0e41356a96758bc283582d3f0..8e4f0bfd6f9e41267d0f245084c131c28acbd0e7 100644 (file)
@@ -29,7 +29,7 @@
 #define SENDMAIL        "sendmail"
 #endif
 #ifndef SENDMAIL_ARGS
-#define SENDMAIL_ARGS   "-ti", "oem"
+#define SENDMAIL_ARGS   "-ti", NULL
 #endif
 #ifndef CRONUPDATE
 #define CRONUPDATE      "cron.update"
@@ -55,7 +55,7 @@ typedef struct CronLine {
 #if ENABLE_FEATURE_CROND_CALL_SENDMAIL
        int cl_MailPos;         /* 'empty file' size                    */
        smallint cl_MailFlag;   /* running pid is for mail              */
-       char *cl_MailTo;        /* whom to mail results                 */
+       char *cl_MailTo;        /* whom to mail results                 */
 #endif
        /* ordered by size, not in natural order. makes code smaller: */
        char cl_Dow[7];         /* 0-6, beginning sunday                */
@@ -142,7 +142,7 @@ static void crondlog(const char *ctl, ...)
                /* Syslog mode: all to syslog (logmode = LOGMODE_SYSLOG), */
                if (!DebugOpt && LogFile) {
                        /* Otherwise (log to file): we reopen log file at every write: */
-                       int logfd = open3_or_warn(LogFile, O_WRONLY | O_CREAT | O_APPEND, 0600);
+                       int logfd = open3_or_warn(LogFile, O_WRONLY | O_CREAT | O_APPEND, 0666);
                        if (logfd >= 0)
                                xmove_fd(logfd, STDERR_FILENO);
                }
@@ -162,11 +162,11 @@ int crond_main(int argc UNUSED_PARAM, char **argv)
        INIT_G();
 
        /* "-b after -f is ignored", and so on for every pair a-b */
-       opt_complementary = "f-b:b-f:S-L:L-S" USE_FEATURE_CROND_D(":d-l")
+       opt_complementary = "f-b:b-f:S-L:L-S" IF_FEATURE_CROND_D(":d-l")
                        ":l+:d+"; /* -l and -d have numeric param */
-       opt = getopt32(argv, "l:L:fbSc:" USE_FEATURE_CROND_D("d:"),
+       opt = getopt32(argv, "l:L:fbSc:" IF_FEATURE_CROND_D("d:"),
                        &LogLevel, &LogFile, &CDir
-                       USE_FEATURE_CROND_D(,&LogLevel));
+                       IF_FEATURE_CROND_D(,&LogLevel));
        /* both -d N and -l N set the same variable: LogLevel */
 
        if (!(opt & OPT_f)) {
@@ -320,11 +320,13 @@ static void ParseField(char *user, char *ary, int modvalue, int off,
                        skip = 1;
                        ++ptr;
                } else if (isdigit(*ptr)) {
+                       char *endp;
                        if (n1 < 0) {
-                               n1 = strtol(ptr, &ptr, 10) + off;
+                               n1 = strtol(ptr, &endp, 10) + off;
                        } else {
-                               n2 = strtol(ptr, &ptr, 10) + off;
+                               n2 = strtol(ptr, &endp, 10) + off;
                        }
+                       ptr = endp; /* gcc likes temp var for &endp */
                        skip = 1;
                } else if (names) {
                        int i;
@@ -361,7 +363,9 @@ static void ParseField(char *user, char *ary, int modvalue, int off,
                        n2 = n1;
                }
                if (*ptr == '/') {
-                       skip = strtol(ptr + 1, &ptr, 10);
+                       char *endp;
+                       skip = strtol(ptr + 1, &endp, 10);
+                       ptr = endp; /* gcc likes temp var for &endp */
                }
 
                /*
@@ -830,7 +834,7 @@ static void RunJob(const char *user, CronLine *line)
                                line->cl_Shell);
                        line->cl_MailPos = lseek(mailFd, 0, SEEK_CUR);
                } else {
-                       crondlog(ERR20 "cannot create mail file %s for user %s, "
+                       crondlog(ERR20 "can't create mail file %s for user %s, "
                                        "discarding output", mailFile, user);
                }
        }