Ignore:
Timestamp:
Nov 6, 2007, 11:01:53 AM (16 years ago)
Author:
Bruno Cornec
Message:
  • Better output for mindi-busybox revision
  • Remove dummy file created on NFS - report from Arnaud Tiger <arnaud.tiger_at_hp.com>
  • strace useful for debug
  • fix new versions for pb (2.0.0 for mindi and 1.7.2 for mindi-busybox)
  • fix build process for mindi-busybox + options used in that version (dd for label-partitions-as-necessary)
  • fix typo in label-partitions-as-necessary which doesn't seem to work
  • Update to busybox 1.7.2
  • perl is now required at restore time to support uuid swap partitions (and will be used for many other thigs

in the future for sure)

  • next mindi version will be 2.0.0 due to all the changes made in it (udev may break working distros)
  • small optimization in mindi on keyboard handling (one single find instead of multiple)
  • better interaction for USB device when launching mindi manually
  • attempt to automatically guess block disk size for ramdisk
  • fix typos in bkphw
  • Fix the remaining problem with UUID support for swap partitions
  • Updates mondoarchive man page for USB support
  • Adds preliminary Hardware support to mindi (Proliant SSSTK)
  • Tries to add udev support also for rhel4
  • Fix UUID support which was still broken.
  • Be conservative in test for the start-nfs script
  • Update config file for mindi-busybox for 1.7.2 migration
  • Try to run around a busybox bug (1.2.2 pb on inexistant links)
  • Add build content for mindi-busybox in pb
  • Remove distributions content for mindi-busybox
  • Fix a warning on inexistant raidtab
  • Solve problem on tmpfs in restore init (Problem of inexistant symlink and busybox)
  • Create MONDO_CACHE and use it everywhere + creation at start
  • Really never try to eject a USB device
  • Fix a issue with &> usage (replaced with 1> and 2>)
  • Adds magic file to depllist in order to have file working + ldd which helps for debugging issues
  • tty modes correct to avoid sh error messages
  • Use ext3 normally and not ext2 instead
  • USB device should be corrected after reading (take 1st part)
  • Adds a mount_USB_here function derived from mount_CDROM_here
  • usb detection place before /dev detection in device name at restore time
  • Fix when restoring from USB: media is asked in interactive mode
  • Adds USB support for mondorestore
  • mount_cdrom => mount_media
  • elilo.efi is now searched throughout /boot/efi and not in a fixed place as there is no standard
  • untar-and-softlink => untar (+ interface change)
  • suppress useless softlinks creation/removal in boot process
  • avoids udevd messages on groups
  • Increase # of disks to 99 as in mindi at restore time (should be a conf file parameter)
  • skip existing big file creation
  • seems to work correctly for USB mindi boot
  • Adds group and tty link to udev conf
  • Always load usb-torage (even 2.6) to initiate USB bus discovery
  • Better printing of messages
  • Attempt to fix a bug in supporting OpenSusE 10.3 kernel for initramfs (mindi may now use multiple regex for kernel initrd detection)
  • Links were not correctly done as non relative for modules in mindi
  • exclusion of modules denied now works
  • Also create modules in their ordinary place, so that classical modprobe works + copy modules.dep
  • Fix bugs for DENY_MODS handling
  • Add device /dev/console for udev
  • ide-generic should now really be excluded
  • Fix a bug in major number for tty
  • If udev then adds modprobe/insmod to rootfs
  • tty0 is also cretaed with udev
  • ide-generic put rather in DENY_MODS
  • udevd remove from deplist s handled in mindi directly
  • better default for mindi when using --usb
  • Handles dynamically linked busybox (in case we want to use it soon ;-)
  • Adds fixed devices to create for udev
  • ide-generic should not be part of the initrd when using libata v2
  • support a dynamically linked udev (case on Ubuntu 7.10 and Mandriva 2008.0 so should be quite generic) This will give incitation to move to dyn. linked binaries in the initrd which will help for other tasks (ia6 4)
  • Improvement in udev support (do not use cl options not available in busybox)
  • Udev in mindi
    • auto creation of the right links at boot time with udev-links.conf(from Mandriva 2008.0)
    • rework startup of udev as current makes kernel crash (from Mandriva 2008.0)
    • add support for 64 bits udev
  • Try to render MyInsmod silent at boot time
  • Adds udev support (mandatory for newest distributions to avoid remapping of devices in a different way as on the original system)
  • We also need vaft format support for USB boot
  • Adds libusual support (Ubuntu 7.10 needs it for USB)
  • Improve Ubuntu/Debian keyboard detection and support
  • pbinit adapted to new pb (0.8.10). Filtering of docs done in it
  • Suppress some mondo warnings and errors on USB again
  • Tries to fix lack of files in deb mindi package
  • Verify should now work for USB devices
  • More log/mesages improvement for USB support
  • - Supress g_erase_tmpdir_and_scratchdir
  • Improve some log messages for USB support
  • Try to improve install in mindi to avoid issues with isolinux.cfg not installed vene if in the pkg :-(
  • Improve mindi-busybox build
  • In conformity with pb 0.8.9
  • Add support for Ubuntu 7.10 in build process
  • Add USB Key button to Menu UI (CD streamer removed)
  • Attempt to fix error messages on tmp/scratch files at the end by removing those dir at the latest possible.
  • Fix a bug linked to the size of the -E param which could be used (Arnaud Tiger/René Ribaud).
  • Integrate ~/.pbrc content into mondorescue.pb (required project-builder >= 0.8.7)
  • Put mondorescue in conformity with new pb filtering rules
  • Add USB support at restore time (no test done yet). New start-usb script PB varibale added where useful
  • Unmounting USB device before removal of temporary scratchdir
  • Stil refining USB copy back to mondo (one command was not executed)
  • No need to have the image subdor in the csratchdir when USB.
  • umount the USB partition before attempting to use it
  • Remove useless copy from mindi to mondo at end of USB handling

(risky merge, we are raising the limits of 2 diverging branches. The status of stable is not completely sure as such. Will need lots of tests, but it's not yet done :-()
(merge -r1692:1769 $SVN_M/branches/2.2.5)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mindi-busybox/miscutils/crond.c

    r821 r1770  
    66 *
    77 * Copyright 1994 Matthew Dillon (dillon@apollo.west.oic.com)
     8 * (version 2.3.2)
    89 * Vladimir Oleynik <dzo@simtreas.ru> (C) 2002
    910 *
     
    1112 */
    1213
    13 #define VERSION "2.3.2"
    14 
    15 #include "busybox.h"
    16 #include <stdio.h>
    17 #include <stdlib.h>
    18 #include <stdarg.h>
    19 #include <string.h>
    20 #include <errno.h>
    21 #include <time.h>
    22 #include <dirent.h>
    23 #include <fcntl.h>
    24 #include <unistd.h>
    25 #include <syslog.h>
    26 #include <signal.h>
    27 #include <getopt.h>
    28 #include <sys/ioctl.h>
    29 #include <sys/wait.h>
    30 #include <sys/stat.h>
    31 #include <sys/resource.h>
    32 
    33 #define arysize(ary)    (sizeof(ary)/sizeof((ary)[0]))
     14#include <sys/syslog.h>
     15#include "libbb.h"
    3416
    3517#ifndef CRONTABS
     
    4022#endif
    4123#ifndef SENDMAIL
    42 #define SENDMAIL        "/usr/sbin/sendmail"
     24#define SENDMAIL        "sendmail"
    4325#endif
    4426#ifndef SENDMAIL_ARGS
     
    8163
    8264#if ENABLE_DEBUG_CROND_OPTION
    83 static short DebugOpt;
    84 #endif
    85 
    86 static short LogLevel = 8;
     65static unsigned DebugOpt;
     66#endif
     67
     68static unsigned LogLevel = 8;
    8769static const char *LogFile;
    8870static const char *CDir = CRONTABS;
     
    130112            vsyslog(type, fmt, va);
    131113        } else {
     114#if !ENABLE_DEBUG_CROND_OPTION
    132115            int logfd = open(LogFile, O_WRONLY | O_CREAT | O_APPEND, 0600);
     116#else
     117            int logfd = open3_or_warn(LogFile, O_WRONLY | O_CREAT | O_APPEND, 0600);
     118#endif
    133119            if (logfd >= 0) {
    134120                vdprintf(logfd, fmt, va);
    135121                close(logfd);
    136 #if ENABLE_DEBUG_CROND_OPTION
    137             } else {
    138                 bb_perror_msg("Can't open log file");
    139 #endif
    140122            }
    141123        }
     
    147129}
    148130
     131int crond_main(int ac, char **av);
    149132int crond_main(int ac, char **av)
    150133{
    151     unsigned long opt;
     134    unsigned opt;
    152135    char *lopt, *Lopt, *copt;
    153 
    154 #if ENABLE_DEBUG_CROND_OPTION
    155     char *dopt;
    156 
    157     bb_opt_complementally = "f-b:b-f:S-L:L-S:d-l";
    158 #else
    159     bb_opt_complementally = "f-b:b-f:S-L:L-S";
    160 #endif
    161 
     136    USE_DEBUG_CROND_OPTION(char *dopt;)
     137
     138    opt_complementary = "f-b:b-f:S-L:L-S" USE_DEBUG_CROND_OPTION(":d-l");
    162139    opterr = 0;         /* disable getopt 'errors' message. */
    163     opt = bb_getopt_ulflags(ac, av, "l:L:fbSc:"
    164 #if ENABLE_DEBUG_CROND_OPTION
    165                             "d:"
    166 #endif
    167                             , &lopt, &Lopt, &copt
    168 #if ENABLE_DEBUG_CROND_OPTION
    169                             , &dopt
    170 #endif
    171         );
    172     if (opt & 1) {
    173         LogLevel = atoi(lopt);
    174     }
    175     if (opt & 2) {
    176         if (*Lopt != 0) {
     140    opt = getopt32(av, "l:L:fbSc:" USE_DEBUG_CROND_OPTION("d:"),
     141            &lopt, &Lopt, &copt USE_DEBUG_CROND_OPTION(, &dopt));
     142    if (opt & 1) /* -l */
     143        LogLevel = xatou(lopt);
     144    if (opt & 2) /* -L */
     145        if (*Lopt)
    177146            LogFile = Lopt;
    178         }
    179     }
    180     if (opt & 32) {
    181         if (*copt != 0) {
     147    if (opt & 32) /* -c */
     148        if (*copt)
    182149            CDir = copt;
    183         }
    184     }
    185 #if ENABLE_DEBUG_CROND_OPTION
    186     if (opt & 64) {
    187         DebugOpt = atoi(dopt);
     150#if ENABLE_DEBUG_CROND_OPTION
     151    if (opt & 64) { /* -d */
     152        DebugOpt = xatou(dopt);
    188153        LogLevel = 0;
    189154    }
    190155#endif
    191156
    192     /*
    193      * change directory
    194      */
    195 
    196     bb_xchdir(CDir);
    197     signal(SIGHUP, SIG_IGN);    /* hmm.. but, if kill -HUP original
    198                                  * version - his died. ;(
    199                                  */
    200     /*
    201      * close stdin and stdout, stderr.
     157    /* close stdin and stdout, stderr.
    202158     * close unused descriptors -  don't need.
    203159     * optional detach from controlling terminal
    204160     */
    205 
    206     if (!(opt & 4)) {
    207 #ifdef BB_NOMMU
    208         /* reexec for vfork() do continue parent */
    209         vfork_daemon_rexec(1, 0, ac, av, "-f");
    210 #else
    211         bb_xdaemon(1, 0);
    212 #endif
    213     }
    214 
    215     (void) startlogger();   /* need if syslog mode selected */
     161    if (!(opt & 4))
     162        bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, av);
     163
     164    xchdir(CDir);
     165    signal(SIGHUP, SIG_IGN); /* ? original crond dies on HUP... */
     166
     167    startlogger();  /* need if syslog mode selected */
    216168
    217169    /*
     
    219171     *             of 1 second.
    220172     */
    221 
    222     crondlog("\011%s " VERSION " dillon, started, log level %d\n",
    223              bb_applet_name, LogLevel);
     173    crondlog("\011%s " BB_VER " started, log level %d\n",
     174             applet_name, LogLevel);
    224175
    225176    SynchronizeDir();
     
    232183        short sleep_time = 60;
    233184
     185        write_pidfile("/var/run/crond.pid");
    234186        for (;;) {
    235187            sleep((sleep_time + 1) - (short) (time(NULL) % sleep_time));
     
    280232        }
    281233    }
    282     bb_fflush_stdout_and_exit(EXIT_SUCCESS); /* not reached */
     234    return 0; /* not reached */
    283235}
    284236
     
    294246    if (pas == 0) {
    295247        crondlog("\011failed to get uid for %s", user);
    296         return (-1);
     248        return -1;
    297249    }
    298250    setenv("USER", pas->pw_name, 1);
     
    306258    if (err_msg) {
    307259        crondlog("\011%s for user %s", err_msg, user);
    308         return (-1);
     260        return -1;
    309261    }
    310262    if (chdir(pas->pw_dir) < 0) {
     
    312264        if (chdir(TMPDIR) < 0) {
    313265            crondlog("\011chdir failed: %s: %m", TMPDIR);
    314             return (-1);
    315         }
    316     }
    317     return (pas->pw_uid);
     266            return -1;
     267        }
     268    }
     269    return pas->pw_uid;
    318270}
    319271
     
    321273{
    322274    if (LogFile == 0) {
    323         openlog(bb_applet_name, LOG_CONS | LOG_PID, LOG_CRON);
     275        openlog(applet_name, LOG_CONS | LOG_PID, LOG_CRON);
    324276    }
    325277#if ENABLE_DEBUG_CROND_OPTION
     
    327279        int logfd;
    328280
    329         if ((logfd = open(LogFile, O_WRONLY | O_CREAT | O_APPEND, 0600)) >= 0) {
     281        logfd = open3_or_warn(LogFile, O_WRONLY | O_CREAT | O_APPEND, 0600);
     282        if (logfd >= 0) {
    330283            close(logfd);
    331         } else {
    332             bb_perror_msg("Failed to open log file '%s' reason", LogFile);
    333         }
    334     }
    335 #endif
    336 }
    337 
    338 
    339 static const char *const DowAry[] = {
    340     "sun",
    341     "mon",
    342     "tue",
    343     "wed",
    344     "thu",
    345     "fri",
    346     "sat",
    347 
    348     "Sun",
    349     "Mon",
    350     "Tue",
    351     "Wed",
    352     "Thu",
    353     "Fri",
    354     "Sat",
    355     NULL
    356 };
    357 
    358 static const char *const MonAry[] = {
    359     "jan",
    360     "feb",
    361     "mar",
    362     "apr",
    363     "may",
    364     "jun",
    365     "jul",
    366     "aug",
    367     "sep",
    368     "oct",
    369     "nov",
    370     "dec",
    371 
    372     "Jan",
    373     "Feb",
    374     "Mar",
    375     "Apr",
    376     "May",
    377     "Jun",
    378     "Jul",
    379     "Aug",
    380     "Sep",
    381     "Oct",
    382     "Nov",
    383     "Dec",
    384     NULL
    385 };
     284        }
     285    }
     286#endif
     287}
     288
     289
     290static const char DowAry[] ALIGN1 =
     291    "sun""mon""tue""wed""thu""fri""sat"
     292    /* "Sun""Mon""Tue""Wed""Thu""Fri""Sat" */
     293;
     294
     295static const char MonAry[] ALIGN1 =
     296    "jan""feb""mar""apr""may""jun""jul""aug""sep""oct""nov""dec"
     297    /* "Jan""Feb""Mar""Apr""May""Jun""Jul""Aug""Sep""Oct""Nov""Dec" */
     298;
    386299
    387300static char *ParseField(char *user, char *ary, int modvalue, int off,
    388                         const char *const *names, char *ptr)
     301                const char *names, char *ptr)
     302/* 'names' is a pointer to a set of 3-char abbreviations */
    389303{
    390304    char *base = ptr;
     
    393307
    394308    if (base == NULL) {
    395         return (NULL);
     309        return NULL;
    396310    }
    397311
     
    416330            int i;
    417331
    418             for (i = 0; names[i]; ++i) {
    419                 if (strncmp(ptr, names[i], strlen(names[i])) == 0) {
     332            for (i = 0; names[i]; i += 3) {
     333                /* was using strncmp before... */
     334                if (strncasecmp(ptr, &names[i], 3) == 0) {
     335                    ptr += 3;
     336                    if (n1 < 0) {
     337                        n1 = i / 3;
     338                    } else {
     339                        n2 = i / 3;
     340                    }
     341                    skip = 1;
    420342                    break;
    421343                }
    422             }
    423             if (names[i]) {
    424                 ptr += strlen(names[i]);
    425                 if (n1 < 0) {
    426                     n1 = i;
    427                 } else {
    428                     n2 = i;
    429                 }
    430                 skip = 1;
    431344            }
    432345        }
     
    436349        if (skip == 0) {
    437350            crondlog("\111failed user %s parsing %s\n", user, base);
    438             return (NULL);
     351            return NULL;
    439352        }
    440353        if (*ptr == '-' && n2 < 0) {
     
    476389            if (failsafe == 0) {
    477390                crondlog("\111failed user %s parsing %s\n", user, base);
    478                 return (NULL);
     391                return NULL;
    479392            }
    480393        }
     
    489402    if (*ptr != ' ' && *ptr != '\t' && *ptr != '\n') {
    490403        crondlog("\111failed user %s parsing %s\n", user, base);
    491         return (NULL);
     404        return NULL;
    492405    }
    493406
     
    506419#endif
    507420
    508     return (ptr);
     421    return ptr;
    509422}
    510423
     
    515428    int daysUsed = 0;
    516429
    517     for (i = 0; i < (int)(arysize(line->cl_Dow)); ++i) {
     430    for (i = 0; i < (int)(ARRAY_SIZE(line->cl_Dow)); ++i) {
    518431        if (line->cl_Dow[i] == 0) {
    519432            weekUsed = 1;
     
    521434        }
    522435    }
    523     for (i = 0; i < (int)(arysize(line->cl_Days)); ++i) {
     436    for (i = 0; i < (int)(ARRAY_SIZE(line->cl_Days)); ++i) {
    524437        if (line->cl_Days[i] == 0) {
    525438            daysUsed = 1;
     
    558471
    559472            if (fstat(fileno(fi), &sbuf) == 0 && sbuf.st_uid == DaemonUid) {
    560                 CronFile *file = calloc(1, sizeof(CronFile));
     473                CronFile *file = xzalloc(sizeof(CronFile));
    561474                CronLine **pline;
    562475
     
    602515                    FixDayDow(&line);
    603516
    604                     *pline = calloc(1, sizeof(CronLine));
     517                    *pline = xzalloc(sizeof(CronLine));
    605518                    **pline = line;
    606519
     
    670583    remove(CRONUPDATE);
    671584    if (chdir(CDir) < 0) {
    672         crondlog("\311unable to find %s\n", CDir);
     585        crondlog("\311cannot find %s\n", CDir);
    673586    }
    674587    {
     
    689602            closedir(dir);
    690603        } else {
    691             crondlog("\311Unable to open current dir!\n");
     604            crondlog("\311cannot open current dir!\n");
    692605        }
    693606    }
     
    793706        }
    794707    }
    795     return (nJobs);
     708    return nJobs;
    796709}
    797710
     
    859772        nStillRunning += file->cf_Running;
    860773    }
    861     return (nStillRunning);
     774    return nStillRunning;
    862775}
    863776
     
    892805        }
    893806        execl(prog, prog, cmd, arg, NULL);
    894         crondlog("\024unable to exec, user %s cmd %s %s %s\n", user, prog, cmd, arg);
     807        crondlog("\024cannot exec, user %s cmd %s %s %s\n", user, prog, cmd, arg);
    895808        if (mailf) {
    896809            fdprintf(1, "Exec failed: %s -c %s\n", prog, arg);
     
    899812    } else if (pid < 0) {
    900813        /* FORK FAILED */
    901         crondlog("\024couldn't fork, user %s\n", user);
     814        crondlog("\024cannot fork, user %s\n", user);
    902815        line->cl_Pid = 0;
    903816        if (mailf) {
     
    940853        fdprintf(mailFd, "To: %s\nSubject: cron: %s\n\n", user,
    941854            line->cl_Shell);
    942         line->cl_MailPos = lseek(mailFd, 0, 1);
     855        line->cl_MailPos = lseek(mailFd, 0, SEEK_CUR);
    943856    } else {
    944         crondlog("\024unable to create mail file user %s file %s, output to /dev/null\n", user, mailFile);
     857        crondlog("\024cannot create mail file user %s file %s, output to /dev/null\n", user, mailFile);
    945858    }
    946859
     
    989902    }
    990903
    991     if (fstat(mailFd, &sbuf) < 0 || sbuf.st_uid != DaemonUid || sbuf.st_nlink != 0 ||
    992         sbuf.st_size == line->cl_MailPos || !S_ISREG(sbuf.st_mode)) {
     904    if (fstat(mailFd, &sbuf) < 0 || sbuf.st_uid != DaemonUid
     905     || sbuf.st_nlink != 0 || sbuf.st_size == line->cl_MailPos
     906     || !S_ISREG(sbuf.st_mode)
     907    ) {
    993908        close(mailFd);
    994909        return;
     
    1019934
    1020935        execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", line->cl_Shell, NULL);
    1021         crondlog("\024unable to exec, user %s cmd %s -c %s\n", user,
     936        crondlog("\024cannot exec, user %s cmd %s -c %s\n", user,
    1022937                 DEFAULT_SHELL, line->cl_Shell);
    1023938        exit(0);
    1024939    } else if (pid < 0) {
    1025940        /* FORK FAILED */
    1026         crondlog("\024couldn't fork, user %s\n", user);
     941        crondlog("\024cannot, user %s\n", user);
    1027942        pid = 0;
    1028943    }
Note: See TracChangeset for help on using the changeset viewer.