Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (7 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
Location:
branches/3.2/mindi-busybox/runit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/runit/chpst.c

    r2725 r3232  
    2929/* Dependencies on runit_lib.c removed */
    3030
     31//usage:#define chpst_trivial_usage
     32//usage:       "[-vP012] [-u USER[:GRP]] [-U USER[:GRP]] [-e DIR]\n"
     33//usage:       "    [-/ DIR] [-n NICE] [-m BYTES] [-d BYTES] [-o N]\n"
     34//usage:       "    [-p N] [-f BYTES] [-c BYTES] PROG ARGS"
     35//usage:#define chpst_full_usage "\n\n"
     36//usage:       "Change the process state, run PROG\n"
     37//usage:     "\n    -u USER[:GRP]   Set uid and gid"
     38//usage:     "\n    -U USER[:GRP]   Set $UID and $GID in environment"
     39//usage:     "\n    -e DIR      Set environment variables as specified by files"
     40//usage:     "\n            in DIR: file=1st_line_of_file"
     41//usage:     "\n    -/ DIR      Chroot to DIR"
     42//usage:     "\n    -n NICE     Add NICE to nice value"
     43//usage:     "\n    -m BYTES    Same as -d BYTES -s BYTES -l BYTES"
     44//usage:     "\n    -d BYTES    Limit data segment"
     45//usage:     "\n    -o N        Limit number of open files per process"
     46//usage:     "\n    -p N        Limit number of processes per uid"
     47//usage:     "\n    -f BYTES    Limit output file sizes"
     48//usage:     "\n    -c BYTES    Limit core file size"
     49//usage:     "\n    -v      Verbose"
     50//usage:     "\n    -P      Create new process group"
     51//usage:     "\n    -0      Close stdin"
     52//usage:     "\n    -1      Close stdout"
     53//usage:     "\n    -2      Close stderr"
     54//usage:
     55//usage:#define envdir_trivial_usage
     56//usage:       "DIR PROG ARGS"
     57//usage:#define envdir_full_usage "\n\n"
     58//usage:       "Set various environment variables as specified by files\n"
     59//usage:       "in the directory DIR, run PROG"
     60//usage:
     61//usage:#define envuidgid_trivial_usage
     62//usage:       "USER PROG ARGS"
     63//usage:#define envuidgid_full_usage "\n\n"
     64//usage:       "Set $UID to USER's uid and $GID to USER's gid, run PROG"
     65//usage:
     66//usage:#define setuidgid_trivial_usage
     67//usage:       "USER PROG ARGS"
     68//usage:#define setuidgid_full_usage "\n\n"
     69//usage:       "Set uid and gid to USER's uid and gid, drop supplementary group ids,\n"
     70//usage:       "run PROG"
     71//usage:
     72//usage:#define softlimit_trivial_usage
     73//usage:       "[-a BYTES] [-m BYTES] [-d BYTES] [-s BYTES] [-l BYTES]\n"
     74//usage:       "    [-f BYTES] [-c BYTES] [-r BYTES] [-o N] [-p N] [-t N]\n"
     75//usage:       "    PROG ARGS"
     76//usage:#define softlimit_full_usage "\n\n"
     77//usage:       "Set soft resource limits, then run PROG\n"
     78//usage:     "\n    -a BYTES    Limit total size of all segments"
     79//usage:     "\n    -m BYTES    Same as -d BYTES -s BYTES -l BYTES -a BYTES"
     80//usage:     "\n    -d BYTES    Limit data segment"
     81//usage:     "\n    -s BYTES    Limit stack segment"
     82//usage:     "\n    -l BYTES    Limit locked memory size"
     83//usage:     "\n    -o N        Limit number of open files per process"
     84//usage:     "\n    -p N        Limit number of processes per uid"
     85//usage:     "\nOptions controlling file sizes:"
     86//usage:     "\n    -f BYTES    Limit output file sizes"
     87//usage:     "\n    -c BYTES    Limit core file size"
     88//usage:     "\nEfficiency opts:"
     89//usage:     "\n    -r BYTES    Limit resident set size"
     90//usage:     "\n    -t N        Limit CPU time, process receives"
     91//usage:     "\n            a SIGXCPU after N seconds"
     92
    3193#include "libbb.h"
     94#include <sys/resource.h> /* getrlimit */
    3295
    3396/*
     
    344407        edir(env_dir);
    345408
    346     // FIXME: chrooted jail must have /etc/passwd if we move this after chroot!
    347     // OTOH chroot fails for non-roots!
    348     // SOLUTION: cache uid/gid before chroot, apply uid/gid after
     409    if (opt & (OPT_u|OPT_U))
     410        xget_uidgid(&ugid, set_user);
     411
     412    // chrooted jail must have /etc/passwd if we move this after chroot.
     413    // OTOH chroot fails for non-roots.
     414    // Solution: cache uid/gid before chroot, apply uid/gid after.
    349415    if (opt & OPT_U) {
    350         xget_uidgid(&ugid, env_user);
    351416        xsetenv("GID", utoa(ugid.gid));
    352417        xsetenv("UID", utoa(ugid.uid));
    353418    }
    354419
    355     if (opt & OPT_u) {
    356         xget_uidgid(&ugid, set_user);
    357     }
    358 
    359420    if (opt & OPT_root) {
    360         xchdir(root);
    361         xchroot(".");
     421        xchroot(root);
    362422    }
    363423
  • branches/3.2/mindi-busybox/runit/runsv.c

    r2725 r3232  
    2828/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */
    2929/* TODO: depends on runit_lib.c - review and reduce/eliminate */
     30
     31//usage:#define runsv_trivial_usage
     32//usage:       "DIR"
     33//usage:#define runsv_full_usage "\n\n"
     34//usage:       "Start and monitor a service and optionally an appendant log service"
    3035
    3136#include <sys/poll.h>
     
    140145}
    141146
    142 /* libbb candidate */
    143 static char *bb_stpcpy(char *p, const char *to_add)
    144 {
    145     while ((*p = *to_add) != '\0') {
    146         p++;
    147         to_add++;
    148     }
    149     return p;
    150 }
    151 
    152147static int open_trunc_or_warn(const char *name)
    153148{
     
    178173        close(fd);
    179174        if (rename_or_warn("supervise/pid.new",
    180             s->islog ? "log/supervise/pid" : "log/supervise/pid"+4))
     175                s->islog ? "log/supervise/pid" : "log/supervise/pid"+4))
    181176            return;
    182177        pidchanged = 0;
     
    193188        switch (s->state) {
    194189        case S_DOWN:
    195             p = bb_stpcpy(p, "down");
     190            p = stpcpy(p, "down");
    196191            break;
    197192        case S_RUN:
    198             p = bb_stpcpy(p, "run");
     193            p = stpcpy(p, "run");
    199194            break;
    200195        case S_FINISH:
    201             p = bb_stpcpy(p, "finish");
     196            p = stpcpy(p, "finish");
    202197            break;
    203198        }
    204199        if (s->ctrl & C_PAUSE)
    205             p = bb_stpcpy(p, ", paused");
     200            p = stpcpy(p, ", paused");
    206201        if (s->ctrl & C_TERM)
    207             p = bb_stpcpy(p, ", got TERM");
     202            p = stpcpy(p, ", got TERM");
    208203        if (s->state != S_DOWN)
    209204            switch (s->sd_want) {
    210205            case W_DOWN:
    211                 p = bb_stpcpy(p, ", want down");
     206                p = stpcpy(p, ", want down");
    212207                break;
    213208            case W_EXIT:
    214                 p = bb_stpcpy(p, ", want exit");
     209                p = stpcpy(p, ", want exit");
    215210                break;
    216211            }
  • branches/3.2/mindi-busybox/runit/runsvdir.c

    r2725 r3232  
    2929/* TODO: depends on runit_lib.c - review and reduce/eliminate */
    3030
     31//usage:#define runsvdir_trivial_usage
     32//usage:       "[-P] [-s SCRIPT] DIR"
     33//usage:#define runsvdir_full_usage "\n\n"
     34//usage:       "Start a runsv process for each subdirectory. If it exits, restart it.\n"
     35//usage:     "\n    -P      Put each runsv in a new session"
     36//usage:     "\n    -s SCRIPT   Run SCRIPT <signo> after signal is processed"
     37
    3138#include <sys/poll.h>
    3239#include <sys/file.h>
     
    6976#define pfd         (G.pfd         )
    7077#define stamplog    (G.stamplog    )
    71 #define INIT_G() do { \
    72 } while (0)
     78#define INIT_G() do { } while (0)
    7379
    7480static void fatal2_cannot(const char *m1, const char *m2)
  • branches/3.2/mindi-busybox/runit/sv.c

    r2725 r3232  
    154154/* TODO: depends on runit_lib.c - review and reduce/eliminate */
    155155
     156//usage:#define sv_trivial_usage
     157//usage:       "[-v] [-w SEC] CMD SERVICE_DIR..."
     158//usage:#define sv_full_usage "\n\n"
     159//usage:       "Control services monitored by runsv supervisor.\n"
     160//usage:       "Commands (only first character is enough):\n"
     161//usage:       "\n"
     162//usage:       "status: query service status\n"
     163//usage:       "up: if service isn't running, start it. If service stops, restart it\n"
     164//usage:       "once: like 'up', but if service stops, don't restart it\n"
     165//usage:       "down: send TERM and CONT signals. If ./run exits, start ./finish\n"
     166//usage:       "    if it exists. After it stops, don't restart service\n"
     167//usage:       "exit: send TERM and CONT signals to service and log service. If they exit,\n"
     168//usage:       "    runsv exits too\n"
     169//usage:       "pause, cont, hup, alarm, interrupt, quit, 1, 2, term, kill: send\n"
     170//usage:       "STOP, CONT, HUP, ALRM, INT, QUIT, USR1, USR2, TERM, KILL signal to service"
     171
    156172#include <sys/poll.h>
    157173#include <sys/file.h>
     
    422438int sv_main(int argc UNUSED_PARAM, char **argv)
    423439{
    424     unsigned opt;
    425440    char *x;
    426441    char *action;
     
    443458
    444459    opt_complementary = "w+:vv"; /* -w N, -v is a counter */
    445     opt = getopt32(argv, "w:v", &waitsec, &verbose);
     460    getopt32(argv, "w:v", &waitsec, &verbose);
    446461    argv += optind;
    447462    action = *argv++;
  • branches/3.2/mindi-busybox/runit/svlogd.c

    r2725 r3232  
    126126*/
    127127
     128//usage:#define svlogd_trivial_usage
     129//usage:       "[-ttv] [-r C] [-R CHARS] [-l MATCHLEN] [-b BUFLEN] DIR..."
     130//usage:#define svlogd_full_usage "\n\n"
     131//usage:       "Continuously read log data from stdin and write to rotated log files in DIRs"
     132//usage:   "\n"
     133//usage:   "\n""DIR/config file modifies behavior:"
     134//usage:   "\n""sSIZE - when to rotate logs"
     135//usage:   "\n""nNUM - number of files to retain"
     136/*usage:   "\n""NNUM - min number files to retain" - confusing */
     137/*usage:   "\n""tSEC - rotate file if it get SEC seconds old" - confusing */
     138//usage:   "\n""!PROG - process rotated log with PROG"
     139/*usage:   "\n""uIPADDR - send log over UDP" - unsupported */
     140/*usage:   "\n""UIPADDR - send log over UDP and DONT log" - unsupported */
     141/*usage:   "\n""pPFX - prefix each line with PFX" - unsupported */
     142//usage:   "\n""+,-PATTERN - (de)select line for logging"
     143//usage:   "\n""E,ePATTERN - (de)select line for stderr"
     144
    128145#include <sys/poll.h>
    129146#include <sys/file.h>
     
    171188
    172189    void* (*memRchr)(const void *, int, size_t);
     190    char *shell;
    173191
    174192    smallint exitasap;
     
    366384    sv_ch = ld->fnsave[26];
    367385
     386    if (!G.shell)
     387        G.shell = xstrdup(get_shell_name());
     388
    368389    while ((pid = vfork()) == -1)
    369390        pause2cannot("vfork for processor", ld->name);
     
    400421        xmove_fd(fd, 5);
    401422
    402 // getenv("SHELL")?
    403         execl(DEFAULT_SHELL, DEFAULT_SHELL_SHORT_NAME, "-c", ld->processor, (char*) NULL);
     423        execl(G.shell, G.shell, "-c", ld->processor, (char*) NULL);
    404424        bb_perror_msg_and_die(FATAL"can't %s processor %s", "run", ld->name);
    405425    }
     
    582602            while (fchdir(ld->fddir) == -1)
    583603                pause2cannot("change directory, want remove old logfile",
    584                              ld->name);
     604                            ld->name);
    585605            oldest[0] = 'A';
    586606            oldest[1] = oldest[27] = '\0';
    587607            while (!(d = opendir(".")))
    588608                pause2cannot("open directory, want remove old logfile",
    589                              ld->name);
     609                            ld->name);
    590610            errno = 0;
    591611            while ((f = readdir(d)))
Note: See TracChangeset for help on using the changeset viewer.