Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/debianutils
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 7 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/debianutils/Config.src
r2725 r3621 8 8 INSERT 9 9 10 config MKTEMP11 bool "mktemp"12 default y13 help14 mktemp is used to create unique temporary files15 16 config PIPE_PROGRESS17 bool "pipe_progress"18 default y19 help20 Display a dot to indicate pipe activity.21 22 config RUN_PARTS23 bool "run-parts"24 default y25 help26 run-parts is a utility designed to run all the scripts in a directory.27 28 It is useful to set up a directory like cron.daily, where you need to29 execute all the scripts in that directory.30 31 In this implementation of run-parts some features (such as report32 mode) are not implemented.33 34 Unless you know that run-parts is used in some of your scripts35 you can safely say N here.36 37 config FEATURE_RUN_PARTS_LONG_OPTIONS38 bool "Enable long options"39 default y40 depends on RUN_PARTS && LONG_OPTS41 help42 Support long options for the run-parts applet.43 44 config FEATURE_RUN_PARTS_FANCY45 bool "Support additional arguments"46 default y47 depends on RUN_PARTS48 help49 Support additional options:50 -l --list print the names of the all matching files (not51 limited to executables), but don't actually run them.52 53 config START_STOP_DAEMON54 bool "start-stop-daemon"55 default y56 help57 start-stop-daemon is used to control the creation and58 termination of system-level processes, usually the ones59 started during the startup of the system.60 61 config FEATURE_START_STOP_DAEMON_FANCY62 bool "Support additional arguments"63 default y64 depends on START_STOP_DAEMON65 help66 Support additional arguments.67 -o|--oknodo ignored since we exit with 0 anyway68 -v|--verbose69 -N|--nicelevel N70 71 config FEATURE_START_STOP_DAEMON_LONG_OPTIONS72 bool "Enable long options"73 default y74 depends on START_STOP_DAEMON && LONG_OPTS75 help76 Support long options for the start-stop-daemon applet.77 78 config WHICH79 bool "which"80 default y81 help82 which is used to find programs in your PATH and83 print out their pathnames.84 85 10 endmenu -
branches/3.3/mindi-busybox/debianutils/Kbuild.src
r2725 r3621 8 8 9 9 INSERT 10 lib-$(CONFIG_MKTEMP) += mktemp.o11 lib-$(CONFIG_PIPE_PROGRESS) += pipe_progress.o12 lib-$(CONFIG_RUN_PARTS) += run_parts.o13 lib-$(CONFIG_START_STOP_DAEMON) += start_stop_daemon.o14 lib-$(CONFIG_WHICH) += which.o -
branches/3.3/mindi-busybox/debianutils/mktemp.c
r3232 r3621 31 31 * -p; else /tmp [deprecated] 32 32 */ 33 //config:config MKTEMP 34 //config: bool "mktemp" 35 //config: default y 36 //config: help 37 //config: mktemp is used to create unique temporary files 38 39 //applet:IF_MKTEMP(APPLET(mktemp, BB_DIR_BIN, BB_SUID_DROP)) 40 41 //kbuild:lib-$(CONFIG_MKTEMP) += mktemp.o 33 42 34 43 //usage:#define mktemp_trivial_usage -
branches/3.3/mindi-busybox/debianutils/pipe_progress.c
r3232 r3621 7 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 8 */ 9 //config:config PIPE_PROGRESS 10 //config: bool "pipe_progress" 11 //config: default y 12 //config: help 13 //config: Display a dot to indicate pipe activity. 14 15 //applet:IF_PIPE_PROGRESS(APPLET(pipe_progress, BB_DIR_BIN, BB_SUID_DROP)) 16 17 //kbuild:lib-$(CONFIG_PIPE_PROGRESS) += pipe_progress.o 9 18 10 19 //usage:#define pipe_progress_trivial_usage NOUSAGE_STR -
branches/3.3/mindi-busybox/debianutils/run_parts.c
r3232 r3621 22 22 * report mode. As the original run-parts support only long options, I've 23 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, without26 * execute them.27 * -a ARG argument. Pass ARG as an argument the program executed. It can28 * be repeated to pass multiple arguments.29 * -u MASK umask. Set the umask of the program executed to MASK.30 24 */ 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 31 59 32 60 //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" 34 64 //usage:#define run_parts_full_usage "\n\n" 35 65 //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" 37 72 //usage: IF_FEATURE_RUN_PARTS_FANCY( 38 //usage: "\n - lPrint 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" 39 74 //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: ) 42 76 //usage: 43 77 //usage:#define run_parts_example_usage … … 56 90 57 91 #include "libbb.h" 92 #include "common_bufsiz.h" 58 93 59 94 struct globals { 60 95 char **names; 61 96 int cur; 62 char *cmd[ 1];97 char *cmd[2 /* using 1 provokes compiler warning */]; 63 98 } FIX_ALIASING; 64 #define G (*(struct globals*) &bb_common_bufsiz1)99 #define G (*(struct globals*)bb_common_bufsiz1) 65 100 #define names (G.names) 66 101 #define cur (G.cur ) 67 102 #define cmd (G.cmd ) 68 #define INIT_G() do { } while (0)103 #define INIT_G() do { setup_common_bufsiz(); } while (0) 69 104 70 105 enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(G)) / sizeof(cmd[0]) - 1 }; 71 106 72 107 enum { 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, 78 115 }; 79 80 #if ENABLE_FEATURE_RUN_PARTS_FANCY81 #define list_mode (option_mask32 & OPT_l)82 #else83 #define list_mode 084 #endif85 116 86 117 /* Is this a valid filename (upper/lower alpha, digits, … … 111 142 && ( !(statbuf->st_mode & (S_IFREG | S_IFLNK)) 112 143 || invalid_name(file) 113 || (! list_mode&& access(file, X_OK) != 0))144 || (!(option_mask32 & OPT_l) && access(file, X_OK) != 0)) 114 145 ) { 115 146 return SKIP; … … 127 158 "arg\0" Required_argument "a" 128 159 "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" 130 164 #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" 134 166 #endif 135 167 ; … … 151 183 /* We require exactly one argument: the directory name */ 152 184 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); 154 186 155 187 umask(xstrtou_range(umask_p, 8, 0, 07777)); … … 193 225 bb_perror_msg("can't execute '%s'", name); 194 226 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(); 196 231 } 197 232 -
branches/3.3/mindi-busybox/debianutils/start_stop_daemon.c
r3232 r3621 57 57 -v,--verbose Verbose 58 58 */ 59 //config:config START_STOP_DAEMON 60 //config: bool "start-stop-daemon" 61 //config: default y 62 //config: help 63 //config: start-stop-daemon is used to control the creation and 64 //config: termination of system-level processes, usually the ones 65 //config: started during the startup of the system. 66 //config: 67 //config:config FEATURE_START_STOP_DAEMON_FANCY 68 //config: bool "Support additional arguments" 69 //config: default y 70 //config: depends on START_STOP_DAEMON 71 //config: help 72 //config: Support additional arguments. 73 //config: -o|--oknodo ignored since we exit with 0 anyway 74 //config: -v|--verbose 75 //config: -N|--nicelevel N 76 //config: 77 //config:config FEATURE_START_STOP_DAEMON_LONG_OPTIONS 78 //config: bool "Enable long options" 79 //config: default y 80 //config: depends on START_STOP_DAEMON && LONG_OPTS 81 //config: help 82 //config: Support long options for the start-stop-daemon applet. 83 84 //applet:IF_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, BB_DIR_SBIN, BB_SUID_DROP, start_stop_daemon)) 85 86 //kbuild:lib-$(CONFIG_START_STOP_DAEMON) += start_stop_daemon.o 59 87 60 88 //usage:#define start_stop_daemon_trivial_usage … … 126 154 #define WANT_PIDFILE 1 127 155 #include "libbb.h" 156 #include "common_bufsiz.h" 128 157 129 158 struct pid_list { … … 164 193 smallint signal_nr; 165 194 } FIX_ALIASING; 166 #define G (*(struct globals*) &bb_common_bufsiz1)195 #define G (*(struct globals*)bb_common_bufsiz1) 167 196 #define userspec (G.userspec ) 168 197 #define cmdname (G.cmdname ) … … 172 201 #define signal_nr (G.signal_nr ) 173 202 #define INIT_G() do { \ 203 setup_common_bufsiz(); \ 174 204 user_id = -1; \ 175 205 signal_nr = 15; \ … … 512 542 } 513 543 if (opt & OPT_c) { 514 struct bb_uidgid_t ugid = { -1, -1 };544 struct bb_uidgid_t ugid; 515 545 parse_chown_usergroup_or_die(&ugid, chuid); 516 if (ugid.uid != (uid_t) -1 ) {546 if (ugid.uid != (uid_t) -1L) { 517 547 struct passwd *pw = xgetpwuid(ugid.uid); 518 if (ugid.gid != (gid_t) -1 )548 if (ugid.gid != (gid_t) -1L) 519 549 pw->pw_gid = ugid.gid; 520 550 /* initgroups, setgid, setuid: */ 521 551 change_identity(pw); 522 } else if (ugid.gid != (gid_t) -1 ) {552 } else if (ugid.gid != (gid_t) -1L) { 523 553 xsetgid(ugid.gid); 524 554 setgroups(1, &ugid.gid); -
branches/3.3/mindi-busybox/debianutils/which.c
r3232 r3621 1 1 /* vi: set sw=4 ts=4: */ 2 2 /* 3 * Which implementation for busybox4 *5 3 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 6 4 * Copyright (C) 2006 Gabriel Somlo <somlo at cmu.edu> 7 5 * 8 6 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 *10 * Based on which from debianutils11 7 */ 8 //config:config WHICH 9 //config: bool "which" 10 //config: default y 11 //config: help 12 //config: which is used to find programs in your PATH and 13 //config: print out their pathnames. 14 15 //applet:IF_WHICH(APPLET(which, BB_DIR_USR_BIN, BB_SUID_DROP)) 16 17 //kbuild:lib-$(CONFIG_WHICH) += which.o 12 18 13 19 //usage:#define which_trivial_usage … … 25 31 int which_main(int argc UNUSED_PARAM, char **argv) 26 32 { 27 IF_DESKTOP(int opt;) 28 int status = EXIT_SUCCESS; 29 char *path; 30 char *p; 33 const char *env_path; 34 int status = 0; 35 36 env_path = getenv("PATH"); 37 if (!env_path) 38 env_path = bb_default_root_path; 31 39 32 40 opt_complementary = "-1"; /* at least one argument */ 33 IF_DESKTOP(opt =)getopt32(argv, "a");41 getopt32(argv, "a"); 34 42 argv += optind; 35 43 36 /* This matches what is seen on e.g. ubuntu. 37 * "which" there is a shell script. */ 38 path = getenv("PATH"); 39 if (!path) { 40 path = (char*)bb_PATH_root_path; 41 putenv(path); 42 path += 5; /* skip "PATH=" */ 43 } 44 do { 45 int missing = 1; 44 46 45 do { 46 #if ENABLE_DESKTOP 47 /* Much bloat just to support -a */ 47 /* If file contains a slash don't use PATH */ 48 48 if (strchr(*argv, '/')) { 49 if (execable_file(*argv)) { 49 if (file_is_executable(*argv)) { 50 missing = 0; 50 51 puts(*argv); 51 continue;52 52 } 53 status = EXIT_FAILURE;54 53 } else { 55 char *path2 = xstrdup(path); 56 char *tmp = path2; 54 char *path; 55 char *tmp; 56 char *p; 57 57 58 p = find_execable(*argv, &tmp); 59 if (!p) 60 status = EXIT_FAILURE; 61 else { 62 print: 58 path = tmp = xstrdup(env_path); 59 while ((p = find_executable(*argv, &tmp)) != NULL) { 60 missing = 0; 63 61 puts(p); 64 62 free(p); 65 if (opt) { 66 /* -a: show matches in all PATH components */ 67 if (tmp) { 68 p = find_execable(*argv, &tmp); 69 if (p) 70 goto print; 71 } 72 } 63 if (!option_mask32) /* -a not set */ 64 break; 73 65 } 74 free(path 2);66 free(path); 75 67 } 76 #else 77 /* Just ignoring -a */ 78 if (strchr(*argv, '/')) { 79 if (execable_file(*argv)) { 80 puts(*argv); 81 continue; 82 } 83 } else { 84 char *path2 = xstrdup(path); 85 char *tmp = path2; 86 p = find_execable(*argv, &tmp); 87 free(path2); 88 if (p) { 89 puts(p); 90 free(p); 91 continue; 92 } 93 } 94 status = EXIT_FAILURE; 95 #endif 96 } while (*(++argv) != NULL); 68 status |= missing; 69 } while (*++argv); 97 70 98 fflush_stdout_and_exit(status);71 return status; 99 72 }
Note:
See TracChangeset
for help on using the changeset viewer.