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 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/debianutils/run_parts.c

    r3232 r3621  
    2222 * report mode. As the original run-parts support only long options, I've
    2323 * broken compatibility because the BusyBox policy doesn't allow them.
    24  * The supported options are:
    25  * -t           test. Print the name of the files to be executed, without
    26  *              execute them.
    27  * -a ARG       argument. Pass ARG as an argument the program executed. It can
    28  *              be repeated to pass multiple arguments.
    29  * -u MASK      umask. Set the umask of the program executed to MASK.
    3024 */
     25//config:config RUN_PARTS
     26//config:   bool "run-parts"
     27//config:   default y
     28//config:   help
     29//config:     run-parts is a utility designed to run all the scripts in a directory.
     30//config:
     31//config:     It is useful to set up a directory like cron.daily, where you need to
     32//config:     execute all the scripts in that directory.
     33//config:
     34//config:     In this implementation of run-parts some features (such as report
     35//config:     mode) are not implemented.
     36//config:
     37//config:     Unless you know that run-parts is used in some of your scripts
     38//config:     you can safely say N here.
     39//config:
     40//config:config FEATURE_RUN_PARTS_LONG_OPTIONS
     41//config:   bool "Enable long options"
     42//config:   default y
     43//config:   depends on RUN_PARTS && LONG_OPTS
     44//config:   help
     45//config:     Support long options for the run-parts applet.
     46//config:
     47//config:config FEATURE_RUN_PARTS_FANCY
     48//config:   bool "Support additional arguments"
     49//config:   default y
     50//config:   depends on RUN_PARTS
     51//config:   help
     52//config:     Support additional options:
     53//config:     -l --list print the names of the all matching files (not
     54//config:               limited to executables), but don't actually run them.
     55
     56//applet:IF_RUN_PARTS(APPLET_ODDNAME(run-parts, run_parts, BB_DIR_BIN, BB_SUID_DROP, run_parts))
     57
     58//kbuild:lib-$(CONFIG_RUN_PARTS) += run_parts.o
    3159
    3260//usage:#define run_parts_trivial_usage
    33 //usage:       "[-t"IF_FEATURE_RUN_PARTS_FANCY("l")"] [-a ARG]... [-u MASK] DIRECTORY"
     61//usage:       "[-a ARG]... [-u UMASK] "
     62//usage:       IF_FEATURE_RUN_PARTS_LONG_OPTIONS("[--reverse] [--test] [--exit-on-error] "IF_FEATURE_RUN_PARTS_FANCY("[--list] "))
     63//usage:       "DIRECTORY"
    3464//usage:#define run_parts_full_usage "\n\n"
    3565//usage:       "Run a bunch of scripts in DIRECTORY\n"
    36 //usage:     "\n    -t  Dry run"
     66//usage:     "\n    -a ARG      Pass ARG as argument to scripts"
     67//usage:     "\n    -u UMASK    Set UMASK before running scripts"
     68//usage:    IF_FEATURE_RUN_PARTS_LONG_OPTIONS(
     69//usage:     "\n    --reverse   Reverse execution order"
     70//usage:     "\n    --test      Dry run"
     71//usage:     "\n    --exit-on-error Exit if a script exits with non-zero"
    3772//usage:    IF_FEATURE_RUN_PARTS_FANCY(
    38 //usage:     "\n    -l  Print names of matching files even if they are not executable"
     73//usage:     "\n    --list      Print names of matching files even if they are not executable"
    3974//usage:    )
    40 //usage:     "\n    -a ARG  Pass ARG as argument to programs"
    41 //usage:     "\n    -u MASK Set umask to MASK before running programs"
     75//usage:    )
    4276//usage:
    4377//usage:#define run_parts_example_usage
     
    5690
    5791#include "libbb.h"
     92#include "common_bufsiz.h"
    5893
    5994struct globals {
    6095    char **names;
    6196    int    cur;
    62     char  *cmd[1];
     97    char  *cmd[2 /* using 1 provokes compiler warning */];
    6398} FIX_ALIASING;
    64 #define G (*(struct globals*)&bb_common_bufsiz1)
     99#define G (*(struct globals*)bb_common_bufsiz1)
    65100#define names (G.names)
    66101#define cur   (G.cur  )
    67102#define cmd   (G.cmd  )
    68 #define INIT_G() do { } while (0)
     103#define INIT_G() do { setup_common_bufsiz(); } while (0)
    69104
    70105enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(G)) / sizeof(cmd[0]) - 1 };
    71106
    72107enum {
    73     OPT_r = (1 << 0),
    74     OPT_a = (1 << 1),
    75     OPT_u = (1 << 2),
    76     OPT_t = (1 << 3),
    77     OPT_l = (1 << 4) * ENABLE_FEATURE_RUN_PARTS_FANCY,
     108    OPT_a = (1 << 0),
     109    OPT_u = (1 << 1),
     110    OPT_r = (1 << 2) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS,
     111    OPT_t = (1 << 3) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS,
     112    OPT_e = (1 << 4) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS,
     113    OPT_l = (1 << 5) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS
     114            * ENABLE_FEATURE_RUN_PARTS_FANCY,
    78115};
    79 
    80 #if ENABLE_FEATURE_RUN_PARTS_FANCY
    81 #define list_mode (option_mask32 & OPT_l)
    82 #else
    83 #define list_mode 0
    84 #endif
    85116
    86117/* Is this a valid filename (upper/lower alpha, digits,
     
    111142     && (  !(statbuf->st_mode & (S_IFREG | S_IFLNK))
    112143        || invalid_name(file)
    113         || (!list_mode && access(file, X_OK) != 0))
     144        || (!(option_mask32 & OPT_l) && access(file, X_OK) != 0))
    114145    ) {
    115146        return SKIP;
     
    127158    "arg\0"     Required_argument "a"
    128159    "umask\0"   Required_argument "u"
    129     "test\0"    No_argument       "t"
     160//TODO: "verbose\0" No_argument       "v"
     161    "reverse\0" No_argument       "\xf0"
     162    "test\0"    No_argument       "\xf1"
     163    "exit-on-error\0" No_argument "\xf2"
    130164#if ENABLE_FEATURE_RUN_PARTS_FANCY
    131     "list\0"    No_argument       "l"
    132     "reverse\0" No_argument       "r"
    133 //TODO: "verbose\0" No_argument       "v"
     165    "list\0"    No_argument       "\xf3"
    134166#endif
    135167    ;
     
    151183    /* We require exactly one argument: the directory name */
    152184    opt_complementary = "=1:a::";
    153     getopt32(argv, "ra:u:t"IF_FEATURE_RUN_PARTS_FANCY("l"), &arg_list, &umask_p);
     185    getopt32(argv, "a:u:", &arg_list, &umask_p);
    154186
    155187    umask(xstrtou_range(umask_p, 8, 0, 07777));
     
    193225            bb_perror_msg("can't execute '%s'", name);
    194226        else /* ret > 0 */
    195             bb_error_msg("%s exited with code %d", name, ret & 0xff);
     227            bb_error_msg("%s: exit status %u", name, ret & 0xff);
     228
     229        if (option_mask32 & OPT_e)
     230            xfunc_die();
    196231    }
    197232
Note: See TracChangeset for help on using the changeset viewer.