diff options
author | Ron Yorston <rmy@pobox.com> | 2013-03-19 11:18:39 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2013-03-19 11:18:39 +0000 |
commit | 63d2c5fead323df5f4250ed544d0bc03527c8936 (patch) | |
tree | 660979b139a4bc4b143c08843cb7efbc69bdcb4d /debianutils | |
parent | 27fc2d535588728ac3ca69337271471fb6fe3ee9 (diff) | |
parent | a42f530e034b673726a91ea5d8202254e677f066 (diff) | |
download | busybox-w32-63d2c5fead323df5f4250ed544d0bc03527c8936.tar.gz busybox-w32-63d2c5fead323df5f4250ed544d0bc03527c8936.tar.bz2 busybox-w32-63d2c5fead323df5f4250ed544d0bc03527c8936.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'debianutils')
-rw-r--r-- | debianutils/run_parts.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c index 005b30420..2c2b032be 100644 --- a/debianutils/run_parts.c +++ b/debianutils/run_parts.c | |||
@@ -21,24 +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 | */ | 24 | */ |
31 | 25 | ||
32 | //usage:#define run_parts_trivial_usage | 26 | //usage:#define run_parts_trivial_usage |
33 | //usage: "[-t"IF_FEATURE_RUN_PARTS_FANCY("l")"] [-a ARG]... [-u MASK] 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" | ||
34 | //usage:#define run_parts_full_usage "\n\n" | 30 | //usage:#define run_parts_full_usage "\n\n" |
35 | //usage: "Run a bunch of scripts in DIRECTORY\n" | 31 | //usage: "Run a bunch of scripts in DIRECTORY\n" |
36 | //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" | ||
37 | //usage: IF_FEATURE_RUN_PARTS_FANCY( | 38 | //usage: IF_FEATURE_RUN_PARTS_FANCY( |
38 | //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: ) | ||
39 | //usage: ) | 41 | //usage: ) |
40 | //usage: "\n -a ARG Pass ARG as argument to programs" | ||
41 | //usage: "\n -u MASK Set umask to MASK before running programs" | ||
42 | //usage: | 42 | //usage: |
43 | //usage:#define run_parts_example_usage | 43 | //usage:#define run_parts_example_usage |
44 | //usage: "$ run-parts -a start /etc/init.d\n" | 44 | //usage: "$ run-parts -a start /etc/init.d\n" |
@@ -70,19 +70,15 @@ struct globals { | |||
70 | enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(G)) / sizeof(cmd[0]) - 1 }; | 70 | enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(G)) / sizeof(cmd[0]) - 1 }; |
71 | 71 | ||
72 | enum { | 72 | enum { |
73 | OPT_r = (1 << 0), | 73 | OPT_a = (1 << 0), |
74 | OPT_a = (1 << 1), | 74 | OPT_u = (1 << 1), |
75 | OPT_u = (1 << 2), | 75 | OPT_r = (1 << 2) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS, |
76 | OPT_t = (1 << 3), | 76 | OPT_t = (1 << 3) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS, |
77 | OPT_l = (1 << 4) * ENABLE_FEATURE_RUN_PARTS_FANCY, | 77 | OPT_e = (1 << 4) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS, |
78 | OPT_l = (1 << 5) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS | ||
79 | * ENABLE_FEATURE_RUN_PARTS_FANCY, | ||
78 | }; | 80 | }; |
79 | 81 | ||
80 | #if ENABLE_FEATURE_RUN_PARTS_FANCY | ||
81 | #define list_mode (option_mask32 & OPT_l) | ||
82 | #else | ||
83 | #define list_mode 0 | ||
84 | #endif | ||
85 | |||
86 | /* Is this a valid filename (upper/lower alpha, digits, | 82 | /* Is this a valid filename (upper/lower alpha, digits, |
87 | * underscores, and hyphens only?) | 83 | * underscores, and hyphens only?) |
88 | */ | 84 | */ |
@@ -110,7 +106,7 @@ static int FAST_FUNC act(const char *file, struct stat *statbuf, void *args UNUS | |||
110 | if (depth == 2 | 106 | if (depth == 2 |
111 | && ( !(statbuf->st_mode & (S_IFREG | S_IFLNK)) | 107 | && ( !(statbuf->st_mode & (S_IFREG | S_IFLNK)) |
112 | || invalid_name(file) | 108 | || invalid_name(file) |
113 | || (!list_mode && access(file, X_OK) != 0)) | 109 | || (!(option_mask32 & OPT_l) && access(file, X_OK) != 0)) |
114 | ) { | 110 | ) { |
115 | return SKIP; | 111 | return SKIP; |
116 | } | 112 | } |
@@ -126,11 +122,12 @@ static int FAST_FUNC act(const char *file, struct stat *statbuf, void *args UNUS | |||
126 | static const char runparts_longopts[] ALIGN1 = | 122 | static const char runparts_longopts[] ALIGN1 = |
127 | "arg\0" Required_argument "a" | 123 | "arg\0" Required_argument "a" |
128 | "umask\0" Required_argument "u" | 124 | "umask\0" Required_argument "u" |
129 | "test\0" No_argument "t" | ||
130 | #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" | 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" | ||
134 | #endif | 131 | #endif |
135 | ; | 132 | ; |
136 | #endif | 133 | #endif |
@@ -150,7 +147,7 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv) | |||
150 | #endif | 147 | #endif |
151 | /* We require exactly one argument: the directory name */ | 148 | /* We require exactly one argument: the directory name */ |
152 | opt_complementary = "=1:a::"; | 149 | opt_complementary = "=1:a::"; |
153 | getopt32(argv, "ra:u:t"IF_FEATURE_RUN_PARTS_FANCY("l"), &arg_list, &umask_p); | 150 | getopt32(argv, "a:u:", &arg_list, &umask_p); |
154 | 151 | ||
155 | umask(xstrtou_range(umask_p, 8, 0, 07777)); | 152 | umask(xstrtou_range(umask_p, 8, 0, 07777)); |
156 | 153 | ||
@@ -193,6 +190,9 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv) | |||
193 | bb_perror_msg("can't execute '%s'", name); | 190 | bb_perror_msg("can't execute '%s'", name); |
194 | else /* ret > 0 */ | 191 | else /* ret > 0 */ |
195 | bb_error_msg("%s exited with code %d", name, ret & 0xff); | 192 | bb_error_msg("%s exited with code %d", name, ret & 0xff); |
193 | |||
194 | if (option_mask32 & OPT_e) | ||
195 | xfunc_die(); | ||
196 | } | 196 | } |
197 | 197 | ||
198 | return n; | 198 | return n; |