[2567553] | 1 | Submitted By: Joe Ciccone <jciccone@gmail.com> |
---|
| 2 | Date: 2008-11-08 |
---|
| 3 | Origin: Busybox FTP |
---|
| 4 | Initial Package Version: 1.12.1 |
---|
| 5 | Upstream Status: From Upstream |
---|
| 6 | Descriprion: Apply fixes from upstream |
---|
| 7 | busybox-1.12.1-basename.patch |
---|
| 8 | busybox-1.12.1-grep.patch |
---|
| 9 | busybox-1.12.1-lineedit.patch |
---|
| 10 | busybox-1.12.1-login.patch |
---|
| 11 | busybox-1.12.1-modprobe.patch |
---|
| 12 | busybox-1.12.1-standalone.patch |
---|
| 13 | busybox-1.12.1-vi.patch |
---|
| 14 | |
---|
| 15 | diff -Naur busybox-1.12.1.orig/coreutils/basename.c busybox-1.12.1/coreutils/basename.c |
---|
| 16 | --- busybox-1.12.1.orig/coreutils/basename.c 2008-09-28 14:04:18.000000000 -0400 |
---|
| 17 | +++ busybox-1.12.1/coreutils/basename.c 2008-11-08 09:49:16.000000000 -0500 |
---|
| 18 | @@ -48,5 +48,5 @@ |
---|
| 19 | |
---|
| 20 | /* puts(s) will do, but we can do without stdio this way: */ |
---|
| 21 | s[m++] = '\n'; |
---|
| 22 | - return full_write(STDOUT_FILENO, s, m) == (ssize_t)m; |
---|
| 23 | + return full_write(STDOUT_FILENO, s, m) != (ssize_t)m; |
---|
| 24 | } |
---|
| 25 | diff -Naur busybox-1.12.1.orig/coreutils/env.c busybox-1.12.1/coreutils/env.c |
---|
| 26 | --- busybox-1.12.1.orig/coreutils/env.c 2008-09-28 14:04:18.000000000 -0400 |
---|
| 27 | +++ busybox-1.12.1/coreutils/env.c 2008-11-08 09:49:16.000000000 -0500 |
---|
| 28 | @@ -29,6 +29,8 @@ |
---|
| 29 | * - use xfunc_error_retval |
---|
| 30 | */ |
---|
| 31 | |
---|
| 32 | +/* This is a NOEXEC applet. Be very careful! */ |
---|
| 33 | + |
---|
| 34 | #include "libbb.h" |
---|
| 35 | |
---|
| 36 | #if ENABLE_FEATURE_ENV_LONG_OPTIONS |
---|
| 37 | @@ -119,5 +121,3 @@ |
---|
| 38 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
| 39 | * SUCH DAMAGE. |
---|
| 40 | */ |
---|
| 41 | - |
---|
| 42 | - |
---|
| 43 | diff -Naur busybox-1.12.1.orig/editors/vi.c busybox-1.12.1/editors/vi.c |
---|
| 44 | --- busybox-1.12.1.orig/editors/vi.c 2008-09-28 14:04:29.000000000 -0400 |
---|
| 45 | +++ busybox-1.12.1/editors/vi.c 2008-11-08 09:49:16.000000000 -0500 |
---|
| 46 | @@ -291,6 +291,8 @@ |
---|
| 47 | #define INIT_G() do { \ |
---|
| 48 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
---|
| 49 | last_file_modified = -1; \ |
---|
| 50 | + /* "" but has space for 2 chars */ \ |
---|
| 51 | + USE_FEATURE_VI_SEARCH(last_search_pattern = xzalloc(2);) \ |
---|
| 52 | } while (0) |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | @@ -2974,7 +2976,7 @@ |
---|
| 56 | const char *msg = msg; // for compiler |
---|
| 57 | char c1, *p, *q, *save_dot; |
---|
| 58 | char buf[12]; |
---|
| 59 | - int dir = dir; // for compiler |
---|
| 60 | + int dir; |
---|
| 61 | int cnt, i, j; |
---|
| 62 | |
---|
| 63 | // c1 = c; // quiet the compiler |
---|
| 64 | @@ -3316,7 +3318,7 @@ |
---|
| 65 | q = get_input_line(buf); // get input line- use "status line" |
---|
| 66 | if (q[0] && !q[1]) { |
---|
| 67 | if (last_search_pattern[0]) |
---|
| 68 | - last_search_pattern[0] = c; |
---|
| 69 | + last_search_pattern[0] = c; |
---|
| 70 | goto dc3; // if no pat re-use old pat |
---|
| 71 | } |
---|
| 72 | if (q[0]) { // strlen(q) > 1: new pat- save it and find |
---|
| 73 | @@ -3346,14 +3348,8 @@ |
---|
| 74 | do_cmd(c); |
---|
| 75 | } // repeat cnt |
---|
| 76 | dc3: |
---|
| 77 | - if (last_search_pattern == 0) { |
---|
| 78 | - msg = "No previous regular expression"; |
---|
| 79 | - goto dc2; |
---|
| 80 | - } |
---|
| 81 | - if (last_search_pattern[0] == '/') { |
---|
| 82 | - dir = FORWARD; // assume FORWARD search |
---|
| 83 | - p = dot + 1; |
---|
| 84 | - } |
---|
| 85 | + dir = FORWARD; // assume FORWARD search |
---|
| 86 | + p = dot + 1; |
---|
| 87 | if (last_search_pattern[0] == '?') { |
---|
| 88 | dir = BACK; |
---|
| 89 | p = dot - 1; |
---|
| 90 | diff -Naur busybox-1.12.1.orig/findutils/grep.c busybox-1.12.1/findutils/grep.c |
---|
| 91 | --- busybox-1.12.1.orig/findutils/grep.c 2008-09-28 14:04:28.000000000 -0400 |
---|
| 92 | +++ busybox-1.12.1/findutils/grep.c 2008-11-08 09:49:16.000000000 -0500 |
---|
| 93 | @@ -363,12 +363,22 @@ |
---|
| 94 | * (unless -v: -Fov doesnt print anything at all) */ |
---|
| 95 | if (found) |
---|
| 96 | print_line(gl->pattern, strlen(gl->pattern), linenum, ':'); |
---|
| 97 | - } else { |
---|
| 98 | + } else while (1) { |
---|
| 99 | + char old = line[gl->matched_range.rm_eo]; |
---|
| 100 | line[gl->matched_range.rm_eo] = '\0'; |
---|
| 101 | print_line(line + gl->matched_range.rm_so, |
---|
| 102 | gl->matched_range.rm_eo - gl->matched_range.rm_so, |
---|
| 103 | linenum, ':'); |
---|
| 104 | - } |
---|
| 105 | + line[gl->matched_range.rm_eo] = old; |
---|
| 106 | +#if !ENABLE_EXTRA_COMPAT |
---|
| 107 | + break; |
---|
| 108 | +#else |
---|
| 109 | + if (re_search(&gl->compiled_regex, line, line_len, |
---|
| 110 | + gl->matched_range.rm_eo, line_len - gl->matched_range.rm_eo, |
---|
| 111 | + &gl->matched_range) < 0) |
---|
| 112 | + break; |
---|
| 113 | +#endif |
---|
| 114 | + } |
---|
| 115 | } else { |
---|
| 116 | print_line(line, line_len, linenum, ':'); |
---|
| 117 | } |
---|
| 118 | diff -Naur busybox-1.12.1.orig/include/applets.h busybox-1.12.1/include/applets.h |
---|
| 119 | --- busybox-1.12.1.orig/include/applets.h 2008-09-28 14:04:26.000000000 -0400 |
---|
| 120 | +++ busybox-1.12.1/include/applets.h 2008-11-08 09:49:16.000000000 -0500 |
---|
| 121 | @@ -136,7 +136,7 @@ |
---|
| 122 | USE_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_NEVER)) |
---|
| 123 | USE_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER, egrep)) |
---|
| 124 | USE_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
---|
| 125 | -USE_ENV(APPLET(env, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
---|
| 126 | +USE_ENV(APPLET_NOEXEC(env, env, _BB_DIR_USR_BIN, _BB_SUID_NEVER, env)) |
---|
| 127 | USE_ENVDIR(APPLET_ODDNAME(envdir, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envdir)) |
---|
| 128 | USE_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envuidgid)) |
---|
| 129 | USE_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, _BB_DIR_USR_BIN, _BB_SUID_NEVER, ether_wake)) |
---|
| 130 | @@ -171,7 +171,7 @@ |
---|
| 131 | USE_GUNZIP(APPLET(gunzip, _BB_DIR_BIN, _BB_SUID_NEVER)) |
---|
| 132 | USE_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_NEVER)) |
---|
| 133 | USE_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
---|
| 134 | -USE_HD(APPLET_ODDNAME(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hd)) |
---|
| 135 | +USE_HD(APPLET_NOEXEC(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hd)) |
---|
| 136 | USE_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
---|
| 137 | USE_HEAD(APPLET(head, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
---|
| 138 | USE_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hexdump)) |
---|
| 139 | diff -Naur busybox-1.12.1.orig/libbb/getopt32.c busybox-1.12.1/libbb/getopt32.c |
---|
| 140 | --- busybox-1.12.1.orig/libbb/getopt32.c 2008-09-28 14:04:20.000000000 -0400 |
---|
| 141 | +++ busybox-1.12.1/libbb/getopt32.c 2008-11-08 09:49:16.000000000 -0500 |
---|
| 142 | @@ -515,28 +515,6 @@ |
---|
| 143 | } |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | - /* In case getopt32 was already called: |
---|
| 147 | - * reset the libc getopt() function, which keeps internal state. |
---|
| 148 | - * |
---|
| 149 | - * BSD-derived getopt() functions require that optind be set to 1 in |
---|
| 150 | - * order to reset getopt() state. This used to be generally accepted |
---|
| 151 | - * way of resetting getopt(). However, glibc's getopt() |
---|
| 152 | - * has additional getopt() state beyond optind, and requires that |
---|
| 153 | - * optind be set to zero to reset its state. So the unfortunate state of |
---|
| 154 | - * affairs is that BSD-derived versions of getopt() misbehave if |
---|
| 155 | - * optind is set to 0 in order to reset getopt(), and glibc's getopt() |
---|
| 156 | - * will core dump if optind is set 1 in order to reset getopt(). |
---|
| 157 | - * |
---|
| 158 | - * More modern versions of BSD require that optreset be set to 1 in |
---|
| 159 | - * order to reset getopt(). Sigh. Standards, anyone? |
---|
| 160 | - */ |
---|
| 161 | -#ifdef __GLIBC__ |
---|
| 162 | - optind = 0; |
---|
| 163 | -#else /* BSD style */ |
---|
| 164 | - optind = 1; |
---|
| 165 | - /* optreset = 1; */ |
---|
| 166 | -#endif |
---|
| 167 | - /* optarg = NULL; opterr = 0; optopt = 0; - do we need this?? */ |
---|
| 168 | pargv = NULL; |
---|
| 169 | |
---|
| 170 | /* Note: just "getopt() <= 0" will not work well for |
---|
| 171 | diff -Naur busybox-1.12.1.orig/libbb/lineedit.c busybox-1.12.1/libbb/lineedit.c |
---|
| 172 | --- busybox-1.12.1.orig/libbb/lineedit.c 2008-09-28 14:04:20.000000000 -0400 |
---|
| 173 | +++ busybox-1.12.1/libbb/lineedit.c 2008-11-08 09:49:16.000000000 -0500 |
---|
| 174 | @@ -1415,7 +1415,8 @@ |
---|
| 175 | if ((state->flags & SAVE_HISTORY) && state->hist_file) |
---|
| 176 | load_history(state->hist_file); |
---|
| 177 | #endif |
---|
| 178 | - state->cur_history = state->cnt_history; |
---|
| 179 | + if (state->flags & DO_HISTORY) |
---|
| 180 | + state->cur_history = state->cnt_history; |
---|
| 181 | |
---|
| 182 | /* prepare before init handlers */ |
---|
| 183 | cmdedit_y = 0; /* quasireal y, not true if line > xt*yt */ |
---|
| 184 | diff -Naur busybox-1.12.1.orig/libbb/setup_environment.c busybox-1.12.1/libbb/setup_environment.c |
---|
| 185 | --- busybox-1.12.1.orig/libbb/setup_environment.c 2008-09-28 14:04:20.000000000 -0400 |
---|
| 186 | +++ busybox-1.12.1/libbb/setup_environment.c 2008-11-08 09:49:16.000000000 -0500 |
---|
| 187 | @@ -32,16 +32,16 @@ |
---|
| 188 | |
---|
| 189 | void FAST_FUNC setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw) |
---|
| 190 | { |
---|
| 191 | + /* Change the current working directory to be the home directory |
---|
| 192 | + * of the user */ |
---|
| 193 | + if (chdir(pw->pw_dir)) { |
---|
| 194 | + xchdir("/"); |
---|
| 195 | + bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir); |
---|
| 196 | + } |
---|
| 197 | + |
---|
| 198 | if (clear_env) { |
---|
| 199 | const char *term; |
---|
| 200 | |
---|
| 201 | - /* Change the current working directory to be the home directory |
---|
| 202 | - * of the user */ |
---|
| 203 | - if (chdir(pw->pw_dir)) { |
---|
| 204 | - xchdir("/"); |
---|
| 205 | - bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir); |
---|
| 206 | - } |
---|
| 207 | - |
---|
| 208 | /* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH. |
---|
| 209 | Unset all other environment variables. */ |
---|
| 210 | term = getenv("TERM"); |
---|
| 211 | diff -Naur busybox-1.12.1.orig/libbb/vfork_daemon_rexec.c busybox-1.12.1/libbb/vfork_daemon_rexec.c |
---|
| 212 | --- busybox-1.12.1.orig/libbb/vfork_daemon_rexec.c 2008-09-28 14:04:20.000000000 -0400 |
---|
| 213 | +++ busybox-1.12.1/libbb/vfork_daemon_rexec.c 2008-11-08 09:49:16.000000000 -0500 |
---|
| 214 | @@ -125,6 +125,7 @@ |
---|
| 215 | int rc, argc; |
---|
| 216 | |
---|
| 217 | applet_name = APPLET_NAME(applet_no); |
---|
| 218 | + |
---|
| 219 | xfunc_error_retval = EXIT_FAILURE; |
---|
| 220 | |
---|
| 221 | /* Special flag for xfunc_die(). If xfunc will "die" |
---|
| 222 | @@ -132,7 +133,30 @@ |
---|
| 223 | * die_sleep and longjmp here instead. */ |
---|
| 224 | die_sleep = -1; |
---|
| 225 | |
---|
| 226 | - /* option_mask32 = 0; - not needed */ |
---|
| 227 | + /* In case getopt() or getopt32() was already called: |
---|
| 228 | + * reset the libc getopt() function, which keeps internal state. |
---|
| 229 | + * |
---|
| 230 | + * BSD-derived getopt() functions require that optind be set to 1 in |
---|
| 231 | + * order to reset getopt() state. This used to be generally accepted |
---|
| 232 | + * way of resetting getopt(). However, glibc's getopt() |
---|
| 233 | + * has additional getopt() state beyond optind, and requires that |
---|
| 234 | + * optind be set to zero to reset its state. So the unfortunate state of |
---|
| 235 | + * affairs is that BSD-derived versions of getopt() misbehave if |
---|
| 236 | + * optind is set to 0 in order to reset getopt(), and glibc's getopt() |
---|
| 237 | + * will core dump if optind is set 1 in order to reset getopt(). |
---|
| 238 | + * |
---|
| 239 | + * More modern versions of BSD require that optreset be set to 1 in |
---|
| 240 | + * order to reset getopt(). Sigh. Standards, anyone? |
---|
| 241 | + */ |
---|
| 242 | +#ifdef __GLIBC__ |
---|
| 243 | + optind = 0; |
---|
| 244 | +#else /* BSD style */ |
---|
| 245 | + optind = 1; |
---|
| 246 | + /* optreset = 1; */ |
---|
| 247 | +#endif |
---|
| 248 | + /* optarg = NULL; opterr = 1; optopt = 63; - do we need this too? */ |
---|
| 249 | + /* (values above are what they initialized to in glibc and uclibc) */ |
---|
| 250 | + /* option_mask32 = 0; - not needed, no applet depends on it being 0 */ |
---|
| 251 | |
---|
| 252 | argc = 1; |
---|
| 253 | while (argv[argc]) |
---|
| 254 | @@ -161,8 +185,16 @@ |
---|
| 255 | rc = 0; |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | - /* Restoring globals */ |
---|
| 259 | + /* Restoring some globals */ |
---|
| 260 | restore_nofork_data(old); |
---|
| 261 | + |
---|
| 262 | + /* Other globals can be simply reset to defaults */ |
---|
| 263 | +#ifdef __GLIBC__ |
---|
| 264 | + optind = 0; |
---|
| 265 | +#else /* BSD style */ |
---|
| 266 | + optind = 1; |
---|
| 267 | +#endif |
---|
| 268 | + |
---|
| 269 | return rc & 0xff; /* don't confuse people with "exitcodes" >255 */ |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | diff -Naur busybox-1.12.1.orig/modutils/modprobe.c busybox-1.12.1/modutils/modprobe.c |
---|
| 273 | --- busybox-1.12.1.orig/modutils/modprobe.c 2008-09-28 14:04:15.000000000 -0400 |
---|
| 274 | +++ busybox-1.12.1/modutils/modprobe.c 2008-11-08 09:49:16.000000000 -0500 |
---|
| 275 | @@ -263,9 +263,9 @@ |
---|
| 276 | return TRUE; |
---|
| 277 | } |
---|
| 278 | |
---|
| 279 | -static int include_conf_recursive(struct include_conf_t *conf, const char *filename) |
---|
| 280 | +static int include_conf_recursive(struct include_conf_t *conf, const char *filename, int flags) |
---|
| 281 | { |
---|
| 282 | - return recursive_action(filename, ACTION_RECURSE, |
---|
| 283 | + return recursive_action(filename, ACTION_RECURSE | flags, |
---|
| 284 | include_conf_file_act, |
---|
| 285 | include_conf_dir_act, |
---|
| 286 | conf, 1); |
---|
| 287 | @@ -362,7 +362,7 @@ |
---|
| 288 | char *includefile; |
---|
| 289 | |
---|
| 290 | includefile = skip_whitespace(line_buffer + 8); |
---|
| 291 | - include_conf_recursive(conf, includefile); |
---|
| 292 | + include_conf_recursive(conf, includefile, 0); |
---|
| 293 | } else if (ENABLE_FEATURE_MODPROBE_BLACKLIST && |
---|
| 294 | (is_conf_command(line_buffer, "blacklist"))) { |
---|
| 295 | char *mod; |
---|
| 296 | @@ -559,7 +559,7 @@ |
---|
| 297 | if (ENABLE_FEATURE_2_6_MODULES) { |
---|
| 298 | if (include_conf_file(&conf, "/etc/modprobe.conf")) |
---|
| 299 | r = TRUE; |
---|
| 300 | - if (include_conf_recursive(&conf, "/etc/modprobe.d")) |
---|
| 301 | + if (include_conf_recursive(&conf, "/etc/modprobe.d", ACTION_QUIET)) |
---|
| 302 | r = TRUE; |
---|
| 303 | } |
---|
| 304 | if (ENABLE_FEATURE_2_4_MODULES && !r) |
---|
| 305 | diff -Naur busybox-1.12.1.orig/shell/ash.c busybox-1.12.1/shell/ash.c |
---|
| 306 | --- busybox-1.12.1.orig/shell/ash.c 2008-09-28 14:04:18.000000000 -0400 |
---|
| 307 | +++ busybox-1.12.1/shell/ash.c 2008-11-08 09:49:16.000000000 -0500 |
---|
| 308 | @@ -6964,8 +6964,11 @@ |
---|
| 309 | |
---|
| 310 | #if ENABLE_FEATURE_SH_STANDALONE |
---|
| 311 | if (applet_no >= 0) { |
---|
| 312 | - if (APPLET_IS_NOEXEC(applet_no)) |
---|
| 313 | + if (APPLET_IS_NOEXEC(applet_no)) { |
---|
| 314 | + while (*envp) |
---|
| 315 | + putenv(*envp++); |
---|
| 316 | run_applet_no_and_exit(applet_no, argv); |
---|
| 317 | + } |
---|
| 318 | /* re-exec ourselves with the new arguments */ |
---|
| 319 | execve(bb_busybox_exec_path, argv, envp); |
---|
| 320 | /* If they called chroot or otherwise made the binary no longer |
---|
| 321 | @@ -12014,7 +12017,7 @@ |
---|
| 322 | char *name; |
---|
| 323 | const char *p; |
---|
| 324 | char **aptr; |
---|
| 325 | - int flag = argv[0][0] == 'r'? VREADONLY : VEXPORT; |
---|
| 326 | + int flag = argv[0][0] == 'r' ? VREADONLY : VEXPORT; |
---|
| 327 | |
---|
| 328 | if (nextopt("p") != 'p') { |
---|
| 329 | aptr = argptr; |
---|
| 330 | diff -Naur busybox-1.12.1.orig/util-linux/getopt.c busybox-1.12.1/util-linux/getopt.c |
---|
| 331 | --- busybox-1.12.1.orig/util-linux/getopt.c 2008-09-28 14:04:30.000000000 -0400 |
---|
| 332 | +++ busybox-1.12.1/util-linux/getopt.c 2008-11-08 09:49:16.000000000 -0500 |
---|
| 333 | @@ -142,7 +142,8 @@ |
---|
| 334 | * Other settings are found in global variables. |
---|
| 335 | */ |
---|
| 336 | #if !ENABLE_GETOPT_LONG |
---|
| 337 | -#define generate_output(argv,argc,optstr,longopts) generate_output(argv,argc,optstr) |
---|
| 338 | +#define generate_output(argv,argc,optstr,longopts) \ |
---|
| 339 | + generate_output(argv,argc,optstr) |
---|
| 340 | #endif |
---|
| 341 | static int generate_output(char **argv, int argc, const char *optstr, const struct option *longopts) |
---|
| 342 | { |
---|
| 343 | @@ -156,14 +157,6 @@ |
---|
| 344 | if (quiet_errors) /* No error reporting from getopt(3) */ |
---|
| 345 | opterr = 0; |
---|
| 346 | |
---|
| 347 | - /* Reset getopt(3) (see libbb/getopt32.c for long rant) */ |
---|
| 348 | -#ifdef __GLIBC__ |
---|
| 349 | - optind = 0; |
---|
| 350 | -#else /* BSD style */ |
---|
| 351 | - optind = 1; |
---|
| 352 | - /* optreset = 1; */ |
---|
| 353 | -#endif |
---|
| 354 | - |
---|
| 355 | while (1) { |
---|
| 356 | opt = |
---|
| 357 | #if ENABLE_GETOPT_LONG |
---|