aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2013-02-28 10:22:49 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-02-28 10:22:49 +0100
commit1e43a381b20f74ff3ff911daa28c9c9c799bcd82 (patch)
treed8f687758083eaf116bcaea83df4058695f2fefb
parent0496e824a5b97edc9991f62c7c74f9b24b16edc7 (diff)
downloadbusybox-w32-1e43a381b20f74ff3ff911daa28c9c9c799bcd82.tar.gz
busybox-w32-1e43a381b20f74ff3ff911daa28c9c9c799bcd82.tar.bz2
busybox-w32-1e43a381b20f74ff3ff911daa28c9c9c799bcd82.zip
run-parts: stop providing incompatible short options
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--debianutils/run_parts.c57
1 files changed, 25 insertions, 32 deletions
diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c
index 6be83edf9..916aa90e0 100644
--- a/debianutils/run_parts.c
+++ b/debianutils/run_parts.c
@@ -21,26 +21,24 @@
21 * taken from debian-utils. I've only removed the long options and the 21 * taken from debian-utils. I've only removed the long options and the
22 * report mode. As the original run-parts support only long options, I've 22 * report mode. As the original run-parts support only long options, I've
23 * broken compatibility because the BusyBox policy doesn't allow them. 23 * 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.
30 * -e exit as soon as a script returns with a non-zero exit code
31 */ 24 */
32 25
33//usage:#define run_parts_trivial_usage 26//usage:#define run_parts_trivial_usage
34//usage: "[-t"IF_FEATURE_RUN_PARTS_FANCY("l")"] [-a ARG]... [-u MASK] [-e] DIRECTORY" 27//usage: "[-a ARG]... [-u UMASK] "
28//usage: IF_FEATURE_RUN_PARTS_LONG_OPTIONS("[--reverse] [--test] [-−exit−on−error] "IF_FEATURE_RUN_PARTS_FANCY("[--list] "))
29//usage: "DIRECTORY"
35//usage:#define run_parts_full_usage "\n\n" 30//usage:#define run_parts_full_usage "\n\n"
36//usage: "Run a bunch of scripts in DIRECTORY\n" 31//usage: "Run a bunch of scripts in DIRECTORY\n"
37//usage: "\n -t Dry run" 32//usage: "\n -a ARG Pass ARG as argument to scripts"
33//usage: "\n -u UMASK Set UMASK before running scripts"
34//usage: IF_FEATURE_RUN_PARTS_LONG_OPTIONS(
35//usage: "\n -−reverse Reverse execution order"
36//usage: "\n --test Dry run"
37//usage: "\n -−exit−on−error Exit if a script exits with non-zero"
38//usage: IF_FEATURE_RUN_PARTS_FANCY( 38//usage: IF_FEATURE_RUN_PARTS_FANCY(
39//usage: "\n -l Print names of matching files even if they are not executable" 39//usage: "\n --list Print names of matching files even if they are not executable"
40//usage: )
40//usage: ) 41//usage: )
41//usage: "\n -a ARG Pass ARG as argument to programs"
42//usage: "\n -u MASK Set umask to MASK before running programs"
43//usage: "\n -e Exit as soon as a script returns with a non-zero exit code"
44//usage: 42//usage:
45//usage:#define run_parts_example_usage 43//usage:#define run_parts_example_usage
46//usage: "$ run-parts -a start /etc/init.d\n" 44//usage: "$ run-parts -a start /etc/init.d\n"
@@ -72,20 +70,15 @@ struct globals {
72enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(G)) / sizeof(cmd[0]) - 1 }; 70enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(G)) / sizeof(cmd[0]) - 1 };
73 71
74enum { 72enum {
75 OPT_r = (1 << 0), 73 OPT_a = (1 << 0),
76 OPT_a = (1 << 1), 74 OPT_u = (1 << 1),
77 OPT_u = (1 << 2), 75 OPT_r = (1 << 2) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS,
78 OPT_t = (1 << 3), 76 OPT_t = (1 << 3) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS,
79 OPT_e = (1 << 4), 77 OPT_e = (1 << 4) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS,
80 OPT_l = (1 << 5) * ENABLE_FEATURE_RUN_PARTS_FANCY, 78 OPT_l = (1 << 5) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS
79 * ENABLE_FEATURE_RUN_PARTS_FANCY,
81}; 80};
82 81
83#if ENABLE_FEATURE_RUN_PARTS_FANCY
84#define list_mode (option_mask32 & OPT_l)
85#else
86#define list_mode 0
87#endif
88
89/* Is this a valid filename (upper/lower alpha, digits, 82/* Is this a valid filename (upper/lower alpha, digits,
90 * underscores, and hyphens only?) 83 * underscores, and hyphens only?)
91 */ 84 */
@@ -113,7 +106,7 @@ static int FAST_FUNC act(const char *file, struct stat *statbuf, void *args UNUS
113 if (depth == 2 106 if (depth == 2
114 && ( !(statbuf->st_mode & (S_IFREG | S_IFLNK)) 107 && ( !(statbuf->st_mode & (S_IFREG | S_IFLNK))
115 || invalid_name(file) 108 || invalid_name(file)
116 || (!list_mode && access(file, X_OK) != 0)) 109 || (!(option_mask32 & OPT_l) && access(file, X_OK) != 0))
117 ) { 110 ) {
118 return SKIP; 111 return SKIP;
119 } 112 }
@@ -129,12 +122,12 @@ static int FAST_FUNC act(const char *file, struct stat *statbuf, void *args UNUS
129static const char runparts_longopts[] ALIGN1 = 122static const char runparts_longopts[] ALIGN1 =
130 "arg\0" Required_argument "a" 123 "arg\0" Required_argument "a"
131 "umask\0" Required_argument "u" 124 "umask\0" Required_argument "u"
132 "test\0" No_argument "t"
133 "exit-on-error\0" No_argument "e"
134#if ENABLE_FEATURE_RUN_PARTS_FANCY
135 "list\0" No_argument "l"
136 "reverse\0" No_argument "r"
137//TODO: "verbose\0" No_argument "v" 125//TODO: "verbose\0" No_argument "v"
126 "reverse\0" No_argument "\xf0"
127 "test\0" No_argument "\xf1"
128 "exit-on-error\0" No_argument "\xf2"
129#if ENABLE_FEATURE_RUN_PARTS_FANCY
130 "list\0" No_argument "\xf3"
138#endif 131#endif
139 ; 132 ;
140#endif 133#endif
@@ -154,7 +147,7 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv)
154#endif 147#endif
155 /* We require exactly one argument: the directory name */ 148 /* We require exactly one argument: the directory name */
156 opt_complementary = "=1:a::"; 149 opt_complementary = "=1:a::";
157 getopt32(argv, "ra:u:te"IF_FEATURE_RUN_PARTS_FANCY("l"), &arg_list, &umask_p); 150 getopt32(argv, "a:u:", &arg_list, &umask_p);
158 151
159 umask(xstrtou_range(umask_p, 8, 0, 07777)); 152 umask(xstrtou_range(umask_p, 8, 0, 07777));
160 153