Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/runit


Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 deleted
7 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/runit/Config.src

    r2725 r3621  
    88INSERT
    99
    10 config RUNSV
    11     bool "runsv"
    12     default y
    13     help
    14       runsv starts and monitors a service and optionally an appendant log
    15       service.
    16 
    17 config RUNSVDIR
    18     bool "runsvdir"
    19     default y
    20     help
    21       runsvdir starts a runsv process for each subdirectory, or symlink to
    22       a directory, in the services directory dir, up to a limit of 1000
    23       subdirectories, and restarts a runsv process if it terminates.
    24 
    25 config FEATURE_RUNSVDIR_LOG
    26     bool "Enable scrolling argument log"
    27     depends on RUNSVDIR
    28     default n
    29     help
    30       Enable feature where second parameter of runsvdir holds last error
    31       message (viewable via top/ps). Otherwise (feature is off
    32       or no parameter), error messages go to stderr only.
    33 
    34 config SV
    35     bool "sv"
    36     default y
    37     help
    38       sv reports the current status and controls the state of services
    39       monitored by the runsv supervisor.
    40 
    41 config SV_DEFAULT_SERVICE_DIR
    42     string "Default directory for services"
    43     default "/var/service"
    44     depends on SV
    45     help
    46       Default directory for services.
    47       Defaults to "/var/service"
    48 
    49 config SVLOGD
    50     bool "svlogd"
    51     default y
    52     help
    53       svlogd continuously reads log data from its standard input, optionally
    54       filters log messages, and writes the data to one or more automatically
    55       rotated logs.
    56 
    57 config CHPST
    58     bool "chpst"
    59     default y
    60     help
    61       chpst changes the process state according to the given options, and
    62       execs specified program.
    63 
    64 config SETUIDGID
    65     bool "setuidgid"
    66     default y
    67     help
    68       Sets soft resource limits as specified by options
    69 
    70 config ENVUIDGID
    71     bool "envuidgid"
    72     default y
    73     help
    74       Sets $UID to account's uid and $GID to account's gid
    75 
    76 config ENVDIR
    77     bool "envdir"
    78     default y
    79     help
    80       Sets various environment variables as specified by files
    81       in the given directory
    82 
    83 config SOFTLIMIT
    84     bool "softlimit"
    85     default y
    86     help
    87       Sets soft resource limits as specified by options
    88 
    8910endmenu
  • branches/3.3/mindi-busybox/runit/Kbuild.src

    r2725 r3621  
    88
    99INSERT
    10 
    11 lib-$(CONFIG_RUNSV) += runsv.o
    12 lib-$(CONFIG_RUNSVDIR) += runsvdir.o
    13 lib-$(CONFIG_SV) += sv.o
    14 lib-$(CONFIG_SVLOGD) += svlogd.o
    15 lib-$(CONFIG_CHPST) += chpst.o
    16 
    17 lib-$(CONFIG_ENVDIR) += chpst.o
    18 lib-$(CONFIG_ENVUIDGID) += chpst.o
    19 lib-$(CONFIG_SETUIDGID) += chpst.o
    20 lib-$(CONFIG_SOFTLIMIT) += chpst.o
  • branches/3.3/mindi-busybox/runit/chpst.c

    r3232 r3621  
    2727
    2828/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */
    29 /* Dependencies on runit_lib.c removed */
     29
     30//config:config CHPST
     31//config:   bool "chpst"
     32//config:   default y
     33//config:   help
     34//config:     chpst changes the process state according to the given options, and
     35//config:     execs specified program.
     36//config:
     37//config:config SETUIDGID
     38//config:   bool "setuidgid"
     39//config:   default y
     40//config:   help
     41//config:     Sets soft resource limits as specified by options
     42//config:
     43//config:config ENVUIDGID
     44//config:   bool "envuidgid"
     45//config:   default y
     46//config:   help
     47//config:     Sets $UID to account's uid and $GID to account's gid
     48//config:
     49//config:config ENVDIR
     50//config:   bool "envdir"
     51//config:   default y
     52//config:   help
     53//config:     Sets various environment variables as specified by files
     54//config:     in the given directory
     55//config:
     56//config:config SOFTLIMIT
     57//config:   bool "softlimit"
     58//config:   default y
     59//config:   help
     60//config:     Sets soft resource limits as specified by options
     61
     62//applet:IF_CHPST(APPLET(chpst, BB_DIR_USR_BIN, BB_SUID_DROP))
     63//applet:IF_ENVDIR(APPLET_ODDNAME(envdir, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envdir))
     64//applet:IF_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envuidgid))
     65//applet:IF_SETUIDGID(APPLET_ODDNAME(setuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, setuidgid))
     66//applet:IF_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, softlimit))
     67
     68//kbuild:lib-$(CONFIG_CHPST) += chpst.o
     69//kbuild:lib-$(CONFIG_ENVDIR) += chpst.o
     70//kbuild:lib-$(CONFIG_ENVUIDGID) += chpst.o
     71//kbuild:lib-$(CONFIG_SETUIDGID) += chpst.o
     72//kbuild:lib-$(CONFIG_SOFTLIMIT) += chpst.o
    3073
    3174//usage:#define chpst_trivial_usage
     
    213256    }
    214257    closedir(dir);
    215     if (fchdir(wdir) == -1)
    216         bb_perror_msg_and_die("fchdir");
     258    xfchdir(wdir);
    217259    close(wdir);
    218260}
     
    237279    struct bb_uidgid_t ugid;
    238280    char *set_user = set_user; /* for compiler */
    239     char *env_user = env_user;
    240281    char *env_dir = env_dir;
    241282    char *root;
     
    265306            &limita, &limitc, &limitd, &limitf, &limitl,
    266307            &limitm, &limito, &limitp, &limitr, &limits, &limitt,
    267             &set_user, &env_user, &env_dir
     308            &set_user, &set_user, &env_dir
    268309            IF_CHPST(, &root, &nicestr));
    269310        argv += optind;
     
    293334    // envuidgid?
    294335    if (ENABLE_ENVUIDGID && applet_name[0] == 'e' && applet_name[3] == 'u') {
    295         env_user = *argv++;
     336        set_user = *argv++;
    296337        opt |= OPT_U;
    297338    }
  • branches/3.3/mindi-busybox/runit/runsv.c

    r3232 r3621  
    2727
    2828/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */
    29 /* TODO: depends on runit_lib.c - review and reduce/eliminate */
     29
     30//config:config RUNSV
     31//config:   bool "runsv"
     32//config:   default y
     33//config:   help
     34//config:     runsv starts and monitors a service and optionally an appendant log
     35//config:     service.
     36
     37//applet:IF_RUNSV(APPLET(runsv, BB_DIR_USR_BIN, BB_SUID_DROP))
     38
     39//kbuild:lib-$(CONFIG_RUNSV) += runsv.o
    3040
    3141//usage:#define runsv_trivial_usage
     
    3444//usage:       "Start and monitor a service and optionally an appendant log service"
    3545
    36 #include <sys/poll.h>
    3746#include <sys/file.h>
    3847#include "libbb.h"
     48#include "common_bufsiz.h"
    3949#include "runit_lib.h"
    4050
     
    5161static void gettimeofday_ns(struct timespec *ts)
    5262{
    53     if (sizeof(struct timeval) == sizeof(struct timespec)
    54      && sizeof(((struct timeval*)ts)->tv_usec) == sizeof(ts->tv_nsec)
    55     ) {
    56         /* Cheat */
    57         gettimeofday((void*)ts, NULL);
    58         ts->tv_nsec *= 1000;
    59     } else {
    60         extern void BUG_need_to_implement_gettimeofday_ns(void);
    61         BUG_need_to_implement_gettimeofday_ns();
    62     }
     63    BUILD_BUG_ON(sizeof(struct timeval) != sizeof(struct timespec));
     64    BUILD_BUG_ON(sizeof(((struct timeval*)ts)->tv_usec) != sizeof(ts->tv_nsec));
     65    /* Cheat */
     66    gettimeofday((void*)ts, NULL);
     67    ts->tv_nsec *= 1000;
    6368}
    6469#endif
     
    102107    struct svdir svd[2];
    103108} FIX_ALIASING;
    104 #define G (*(struct globals*)&bb_common_bufsiz1)
     109#define G (*(struct globals*)bb_common_bufsiz1)
    105110#define haslog       (G.haslog      )
    106111#define sigterm      (G.sigterm     )
     
    111116#define svd          (G.svd         )
    112117#define INIT_G() do { \
     118    setup_common_bufsiz(); \
    113119    pidchanged = 1; \
    114120} while (0)
     
    116122static void fatal2_cannot(const char *m1, const char *m2)
    117123{
    118     bb_perror_msg_and_die("%s: fatal: cannot %s%s", dir, m1, m2);
     124    bb_perror_msg_and_die("%s: fatal: can't %s%s", dir, m1, m2);
    119125    /* was exiting 111 */
    120126}
     
    126132static void fatal2x_cannot(const char *m1, const char *m2)
    127133{
    128     bb_error_msg_and_die("%s: fatal: cannot %s%s", dir, m1, m2);
     134    bb_error_msg_and_die("%s: fatal: can't %s%s", dir, m1, m2);
    129135    /* was exiting 111 */
    130136}
  • branches/3.3/mindi-busybox/runit/runsvdir.c

    r3232 r3621  
    2727
    2828/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */
    29 /* TODO: depends on runit_lib.c - review and reduce/eliminate */
     29
     30//config:config RUNSVDIR
     31//config:   bool "runsvdir"
     32//config:   default y
     33//config:   help
     34//config:     runsvdir starts a runsv process for each subdirectory, or symlink to
     35//config:     a directory, in the services directory dir, up to a limit of 1000
     36//config:     subdirectories, and restarts a runsv process if it terminates.
     37//config:
     38//config:config FEATURE_RUNSVDIR_LOG
     39//config:   bool "Enable scrolling argument log"
     40//config:   depends on RUNSVDIR
     41//config:   default n
     42//config:   help
     43//config:     Enable feature where second parameter of runsvdir holds last error
     44//config:     message (viewable via top/ps). Otherwise (feature is off
     45//config:     or no parameter), error messages go to stderr only.
     46
     47//applet:IF_RUNSVDIR(APPLET(runsvdir, BB_DIR_USR_BIN, BB_SUID_DROP))
     48
     49//kbuild:lib-$(CONFIG_RUNSVDIR) += runsvdir.o
    3050
    3151//usage:#define runsvdir_trivial_usage
     
    3656//usage:     "\n    -s SCRIPT   Run SCRIPT <signo> after signal is processed"
    3757
    38 #include <sys/poll.h>
    3958#include <sys/file.h>
    4059#include "libbb.h"
     60#include "common_bufsiz.h"
    4161#include "runit_lib.h"
    4262
     
    6181#if ENABLE_FEATURE_RUNSVDIR_LOG
    6282    char *rplog;
    63     int rploglen;
    6483    struct fd_pair logpipe;
    6584    struct pollfd pfd[1];
     
    6786#endif
    6887} FIX_ALIASING;
    69 #define G (*(struct globals*)&bb_common_bufsiz1)
     88#define G (*(struct globals*)bb_common_bufsiz1)
    7089#define sv          (G.sv          )
    7190#define svdir       (G.svdir       )
    7291#define svnum       (G.svnum       )
    7392#define rplog       (G.rplog       )
    74 #define rploglen    (G.rploglen    )
    7593#define logpipe     (G.logpipe     )
    7694#define pfd         (G.pfd         )
    7795#define stamplog    (G.stamplog    )
    78 #define INIT_G() do { } while (0)
     96#define INIT_G() do { setup_common_bufsiz(); } while (0)
    7997
    8098static void fatal2_cannot(const char *m1, const char *m2)
     
    221239    dev_t last_dev = last_dev; /* for gcc */
    222240    ino_t last_ino = last_ino; /* for gcc */
    223     time_t last_mtime = 0;
    224     int wstat;
     241    time_t last_mtime;
    225242    int curdir;
    226     pid_t pid;
    227     unsigned deadline;
    228     unsigned now;
    229243    unsigned stampcheck;
    230244    int i;
    231     int need_rescan = 1;
     245    int need_rescan;
     246    bool i_am_init;
    232247    char *opt_s_argv[3];
    233248
     
    240255    argv += optind;
    241256
     257    i_am_init = (getpid() == 1);
    242258    bb_signals(0
    243259        | (1 << SIGTERM)
    244260        | (1 << SIGHUP)
    245261        /* For busybox's init, SIGTERM == reboot,
    246          * SIGUSR1 == halt
    247          * SIGUSR2 == poweroff
    248          * so we need to intercept SIGUSRn too.
     262         * SIGUSR1 == halt,
     263         * SIGUSR2 == poweroff,
     264         * Ctlr-ALt-Del sends SIGINT to init,
     265         * so we need to intercept SIGUSRn and SIGINT too.
    249266         * Note that we do not implement actual reboot
    250267         * (killall(TERM) + umount, etc), we just pause
    251268         * respawing and avoid exiting (-> making kernel oops).
    252          * The user is responsible for the rest. */
    253         | (getpid() == 1 ? ((1 << SIGUSR1) | (1 << SIGUSR2)) : 0)
     269         * The user is responsible for the rest.
     270         */
     271        | (i_am_init ? ((1 << SIGUSR1) | (1 << SIGUSR2) | (1 << SIGINT)) : 0)
    254272        , record_signo);
    255273    svdir = *argv++;
     
    259277    if (*argv) {
    260278        rplog = *argv;
    261         rploglen = strlen(rplog);
    262         if (rploglen < 7) {
     279        if (strlen(rplog) < 7) {
    263280            warnx("log must have at least seven characters");
    264281        } else if (piped_pair(logpipe)) {
     
    289306
    290307    stampcheck = monotonic_sec();
     308    need_rescan = 1;
     309    last_mtime = 0;
    291310
    292311    for (;;) {
     312        unsigned now;
     313        unsigned sig;
     314
    293315        /* collect children */
    294316        for (;;) {
    295             pid = wait_any_nohang(&wstat);
     317            pid_t pid = wait_any_nohang(NULL);
    296318            if (pid <= 0)
    297319                break;
     
    347369        pfd[0].revents = 0;
    348370#endif
    349         deadline = (need_rescan ? 1 : 5);
    350         sig_block(SIGCHLD);
    351 #if ENABLE_FEATURE_RUNSVDIR_LOG
    352         if (rplog)
    353             poll(pfd, 1, deadline*1000);
    354         else
    355 #endif
    356             sleep(deadline);
    357         sig_unblock(SIGCHLD);
     371        {
     372            unsigned deadline = (need_rescan ? 1 : 5);
     373#if ENABLE_FEATURE_RUNSVDIR_LOG
     374            if (rplog)
     375                poll(pfd, 1, deadline*1000);
     376            else
     377#endif
     378                sleep(deadline);
     379        }
    358380
    359381#if ENABLE_FEATURE_RUNSVDIR_LOG
     
    363385                if (ch < ' ')
    364386                    ch = ' ';
    365                 for (i = 6; i < rploglen; i++)
     387                for (i = 6; rplog[i] != '\0'; i++)
    366388                    rplog[i-1] = rplog[i];
    367                 rplog[rploglen-1] = ch;
    368             }
    369         }
    370 #endif
    371         if (!bb_got_signal)
     389                rplog[i-1] = ch;
     390            }
     391        }
     392#endif
     393        sig = bb_got_signal;
     394        if (!sig)
    372395            continue;
     396        bb_got_signal = 0;
    373397
    374398        /* -s SCRIPT: useful if we are init.
     
    376400         * it halts/powers off/reboots the system. */
    377401        if (opt_s_argv[0]) {
     402            pid_t pid;
     403
    378404            /* Single parameter: signal# */
    379             opt_s_argv[1] = utoa(bb_got_signal);
     405            opt_s_argv[1] = utoa(sig);
    380406            pid = spawn(opt_s_argv);
    381407            if (pid > 0) {
     
    387413        }
    388414
    389         if (bb_got_signal == SIGHUP) {
     415        if (sig == SIGHUP) {
    390416            for (i = 0; i < svnum; i++)
    391417                if (sv[i].pid)
     
    394420        /* SIGHUP or SIGTERM (or SIGUSRn if we are init) */
    395421        /* Exit unless we are init */
    396         if (getpid() != 1)
    397             return (SIGHUP == bb_got_signal) ? 111 : EXIT_SUCCESS;
     422        if (!i_am_init)
     423            return (SIGHUP == sig) ? 111 : EXIT_SUCCESS;
    398424
    399425        /* init continues to monitor services forever */
    400         bb_got_signal = 0;
    401426    } /* for (;;) */
    402427}
  • branches/3.3/mindi-busybox/runit/sv.c

    r3232 r3621  
    152152
    153153/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */
    154 /* TODO: depends on runit_lib.c - review and reduce/eliminate */
     154
     155//config:config SV
     156//config:   bool "sv"
     157//config:   default y
     158//config:   help
     159//config:     sv reports the current status and controls the state of services
     160//config:     monitored by the runsv supervisor.
     161//config:
     162//config:config SV_DEFAULT_SERVICE_DIR
     163//config:   string "Default directory for services"
     164//config:   default "/var/service"
     165//config:   depends on SV
     166//config:   help
     167//config:     Default directory for services.
     168//config:     Defaults to "/var/service"
     169
     170//applet:IF_SV(APPLET(sv, BB_DIR_USR_BIN, BB_SUID_DROP))
     171
     172//kbuild:lib-$(CONFIG_SV) += sv.o
    155173
    156174//usage:#define sv_trivial_usage
     
    170188//usage:       "STOP, CONT, HUP, ALRM, INT, QUIT, USR1, USR2, TERM, KILL signal to service"
    171189
    172 #include <sys/poll.h>
    173190#include <sys/file.h>
    174191#include "libbb.h"
     192#include "common_bufsiz.h"
    175193#include "runit_lib.h"
    176194
     
    183201    svstatus_t svstatus;
    184202} FIX_ALIASING;
    185 #define G (*(struct globals*)&bb_common_bufsiz1)
     203#define G (*(struct globals*)bb_common_bufsiz1)
    186204#define acts         (G.acts        )
    187205#define service      (G.service     )
     
    190208#define tnow         (G.tnow        )
    191209#define svstatus     (G.svstatus    )
    192 #define INIT_G() do { } while (0)
     210#define INIT_G() do { setup_common_bufsiz(); } while (0)
    193211
    194212
  • branches/3.3/mindi-busybox/runit/svlogd.c

    r3232 r3621  
    2727
    2828/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */
    29 /* TODO: depends on runit_lib.c - review and reduce/eliminate */
    3029
    3130/*
     
    126125*/
    127126
     127//config:config SVLOGD
     128//config:   bool "svlogd"
     129//config:   default y
     130//config:   help
     131//config:     svlogd continuously reads log data from its standard input, optionally
     132//config:     filters log messages, and writes the data to one or more automatically
     133//config:     rotated logs.
     134
     135//applet:IF_SVLOGD(APPLET(svlogd, BB_DIR_USR_SBIN, BB_SUID_DROP))
     136
     137//kbuild:lib-$(CONFIG_SVLOGD) += svlogd.o
     138
    128139//usage:#define svlogd_trivial_usage
    129140//usage:       "[-ttv] [-r C] [-R CHARS] [-l MATCHLEN] [-b BUFLEN] DIR..."
     
    143154//usage:   "\n""E,ePATTERN - (de)select line for stderr"
    144155
    145 #include <sys/poll.h>
    146156#include <sys/file.h>
    147157#include "libbb.h"
     158#include "common_bufsiz.h"
    148159#include "runit_lib.h"
    149160
     
    224235#define fl_flag_0      (G.fl_flag_0     )
    225236#define dirn           (G.dirn          )
     237#define line bb_common_bufsiz1
    226238#define INIT_G() do { \
     239    setup_common_bufsiz(); \
    227240    SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
    228241    linemax = 1000; \
     
    231244    replace = ""; \
    232245} while (0)
    233 
    234 #define line bb_common_bufsiz1
    235246
    236247
     
    746757                break;
    747758            case 's': {
    748                 static const struct suffix_mult km_suffixes[] = {
    749                     { "k", 1024 },
    750                     { "m", 1024*1024 },
    751                     { "", 0 }
    752                 };
    753759                ld->sizemax = xatou_sfx(&s[1], km_suffixes);
    754760                break;
     
    10411047    if (opt & 2) if (!repl) repl = '_'; // -R
    10421048    if (opt & 4) { // -l
    1043         linemax = xatou_range(l, 0, BUFSIZ-26);
     1049        linemax = xatou_range(l, 0, COMMON_BUFSIZE-26);
    10441050        if (linemax == 0)
    1045             linemax = BUFSIZ-26;
     1051            linemax = COMMON_BUFSIZE-26;
    10461052        if (linemax < 256)
    10471053            linemax = 256;
Note: See TracChangeset for help on using the changeset viewer.