diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-09-26 17:41:00 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-09-26 17:41:00 +0000 |
commit | acf1aba1e59ea3e2c76106b8dd6aad15191ada33 (patch) | |
tree | bc6843cbc8ca3d0d2257a9e2349c03358b70b85a | |
parent | 40c74e75a0139de991873f099aa350509955cf06 (diff) | |
download | busybox-w32-acf1aba1e59ea3e2c76106b8dd6aad15191ada33.tar.gz busybox-w32-acf1aba1e59ea3e2c76106b8dd6aad15191ada33.tar.bz2 busybox-w32-acf1aba1e59ea3e2c76106b8dd6aad15191ada33.zip |
several fixes from openWRT project
git-svn-id: svn://busybox.net/trunk/busybox@16229 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | editors/awk.c | 31 | ||||
-rw-r--r-- | include/usage.h | 1 | ||||
-rw-r--r-- | loginutils/passwd.c | 2 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 14 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.h | 1 | ||||
-rw-r--r-- | networking/udhcp/options.c | 3 | ||||
-rw-r--r-- | networking/udhcp/options.h | 2 | ||||
-rw-r--r-- | shell/ash.c | 39 |
8 files changed, 88 insertions, 5 deletions
diff --git a/editors/awk.c b/editors/awk.c index c934fe0df..bebc78092 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -249,7 +249,8 @@ enum { | |||
249 | /* builtins */ | 249 | /* builtins */ |
250 | enum { | 250 | enum { |
251 | B_a2=0, B_ix, B_ma, B_sp, B_ss, B_ti, B_lo, B_up, | 251 | B_a2=0, B_ix, B_ma, B_sp, B_ss, B_ti, B_lo, B_up, |
252 | B_ge, B_gs, B_su | 252 | B_ge, B_gs, B_su, |
253 | B_an, B_co, B_ls, B_or, B_rs, B_xo, | ||
253 | }; | 254 | }; |
254 | 255 | ||
255 | /* tokens and their corresponding info values */ | 256 | /* tokens and their corresponding info values */ |
@@ -289,6 +290,8 @@ static char * const tokenlist = | |||
289 | "\5while" NTC | 290 | "\5while" NTC |
290 | "\4else" NTC | 291 | "\4else" NTC |
291 | 292 | ||
293 | "\3and" "\5compl" "\6lshift" "\2or" | ||
294 | "\6rshift" "\3xor" | ||
292 | "\5close" "\6system" "\6fflush" "\5atan2" /* BUILTIN */ | 295 | "\5close" "\6system" "\6fflush" "\5atan2" /* BUILTIN */ |
293 | "\3cos" "\3exp" "\3int" "\3log" | 296 | "\3cos" "\3exp" "\3int" "\3log" |
294 | "\4rand" "\3sin" "\4sqrt" "\5srand" | 297 | "\4rand" "\3sin" "\4sqrt" "\5srand" |
@@ -342,6 +345,8 @@ static const uint32_t tokeninfo[] = { | |||
342 | ST_WHILE, | 345 | ST_WHILE, |
343 | 0, | 346 | 0, |
344 | 347 | ||
348 | OC_B|B_an|P(0x83), OC_B|B_co|P(0x41), OC_B|B_ls|P(0x83), OC_B|B_or|P(0x83), | ||
349 | OC_B|B_rs|P(0x83), OC_B|B_xo|P(0x83), | ||
345 | OC_FBLTIN|Sx|F_cl, OC_FBLTIN|Sx|F_sy, OC_FBLTIN|Sx|F_ff, OC_B|B_a2|P(0x83), | 350 | OC_FBLTIN|Sx|F_cl, OC_FBLTIN|Sx|F_sy, OC_FBLTIN|Sx|F_ff, OC_B|B_a2|P(0x83), |
346 | OC_FBLTIN|Nx|F_co, OC_FBLTIN|Nx|F_ex, OC_FBLTIN|Nx|F_in, OC_FBLTIN|Nx|F_lg, | 351 | OC_FBLTIN|Nx|F_co, OC_FBLTIN|Nx|F_ex, OC_FBLTIN|Nx|F_in, OC_FBLTIN|Nx|F_lg, |
347 | OC_FBLTIN|F_rn, OC_FBLTIN|Nx|F_si, OC_FBLTIN|Nx|F_sq, OC_FBLTIN|Nx|F_sr, | 352 | OC_FBLTIN|F_rn, OC_FBLTIN|Nx|F_si, OC_FBLTIN|Nx|F_sq, OC_FBLTIN|Nx|F_sr, |
@@ -1923,6 +1928,30 @@ static var *exec_builtin(node *op, var *res) | |||
1923 | s[n] = '\0'; | 1928 | s[n] = '\0'; |
1924 | setvar_p(res, s); | 1929 | setvar_p(res, s); |
1925 | break; | 1930 | break; |
1931 | |||
1932 | case B_an: | ||
1933 | setvar_i(res, (long)getvar_i(av[0]) & (long)getvar_i(av[1])); | ||
1934 | break; | ||
1935 | |||
1936 | case B_co: | ||
1937 | setvar_i(res, ~(long)getvar_i(av[0])); | ||
1938 | break; | ||
1939 | |||
1940 | case B_ls: | ||
1941 | setvar_i(res, (long)getvar_i(av[0]) << (long)getvar_i(av[1])); | ||
1942 | break; | ||
1943 | |||
1944 | case B_or: | ||
1945 | setvar_i(res, (long)getvar_i(av[0]) | (long)getvar_i(av[1])); | ||
1946 | break; | ||
1947 | |||
1948 | case B_rs: | ||
1949 | setvar_i(res, (long)((unsigned long)getvar_i(av[0]) >> (unsigned long)getvar_i(av[1]))); | ||
1950 | break; | ||
1951 | |||
1952 | case B_xo: | ||
1953 | setvar_i(res, (long)getvar_i(av[0]) ^ (long)getvar_i(av[1])); | ||
1954 | break; | ||
1926 | 1955 | ||
1927 | case B_lo: | 1956 | case B_lo: |
1928 | to_xxx = tolower; | 1957 | to_xxx = tolower; |
diff --git a/include/usage.h b/include/usage.h index 6ef7f1ecf..da176d156 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -3211,6 +3211,7 @@ USE_FEATURE_START_STOP_DAEMON_FANCY( \ | |||
3211 | "\t-n,\t--now\tExit with failure if lease cannot be immediately negotiated\n" \ | 3211 | "\t-n,\t--now\tExit with failure if lease cannot be immediately negotiated\n" \ |
3212 | "\t-p,\t--pidfile=file\tStore process ID of daemon in file\n" \ | 3212 | "\t-p,\t--pidfile=file\tStore process ID of daemon in file\n" \ |
3213 | "\t-q,\t--quit\tQuit after obtaining lease\n" \ | 3213 | "\t-q,\t--quit\tQuit after obtaining lease\n" \ |
3214 | "\t-R,\t--release\tRelease IP on quit\n" \ | ||
3214 | "\t-r,\t--request=IP\tIP address to request (default: none)\n" \ | 3215 | "\t-r,\t--request=IP\tIP address to request (default: none)\n" \ |
3215 | "\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \ | 3216 | "\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \ |
3216 | "\t-t,\t--retries=NUM\tSend up to NUM request packets\n"\ | 3217 | "\t-t,\t--retries=NUM\tSend up to NUM request packets\n"\ |
diff --git a/loginutils/passwd.c b/loginutils/passwd.c index f48f15f89..211a49ea3 100644 --- a/loginutils/passwd.c +++ b/loginutils/passwd.c | |||
@@ -318,7 +318,7 @@ static int new_password(const struct passwd *pw, int amroot, int algo) | |||
318 | } else { | 318 | } else { |
319 | orig[0] = '\0'; | 319 | orig[0] = '\0'; |
320 | } | 320 | } |
321 | cp = bb_askpass(0, "Enter the new password (minimum of 5, maximum of 8 characters).\n" | 321 | cp = bb_askpass(0, "Enter the new password (minimum of 5 characters).\n" |
322 | "Please use a combination of upper and lower case letters and numbers.\n" | 322 | "Please use a combination of upper and lower case letters and numbers.\n" |
323 | "Enter new password: "); | 323 | "Enter new password: "); |
324 | if (!cp ) { | 324 | if (!cp ) { |
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index ff4d5018c..499183f18 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -53,6 +53,7 @@ struct client_config_t client_config = { | |||
53 | .abort_if_no_lease = 0, | 53 | .abort_if_no_lease = 0, |
54 | .foreground = 0, | 54 | .foreground = 0, |
55 | .quit_after_lease = 0, | 55 | .quit_after_lease = 0, |
56 | .release_on_quit = 0, | ||
56 | .background_if_no_lease = 0, | 57 | .background_if_no_lease = 0, |
57 | .interface = "eth0", | 58 | .interface = "eth0", |
58 | .pidfile = NULL, | 59 | .pidfile = NULL, |
@@ -169,6 +170,7 @@ int udhcpc_main(int argc, char *argv[]) | |||
169 | {"now", no_argument, 0, 'n'}, | 170 | {"now", no_argument, 0, 'n'}, |
170 | {"pidfile", required_argument, 0, 'p'}, | 171 | {"pidfile", required_argument, 0, 'p'}, |
171 | {"quit", no_argument, 0, 'q'}, | 172 | {"quit", no_argument, 0, 'q'}, |
173 | {"release", no_argument, 0, 'R'}, | ||
172 | {"request", required_argument, 0, 'r'}, | 174 | {"request", required_argument, 0, 'r'}, |
173 | {"script", required_argument, 0, 's'}, | 175 | {"script", required_argument, 0, 's'}, |
174 | {"timeout", required_argument, 0, 'T'}, | 176 | {"timeout", required_argument, 0, 'T'}, |
@@ -180,7 +182,7 @@ int udhcpc_main(int argc, char *argv[]) | |||
180 | /* get options */ | 182 | /* get options */ |
181 | while (1) { | 183 | while (1) { |
182 | int option_index = 0; | 184 | int option_index = 0; |
183 | c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qr:s:T:t:v", arg_options, &option_index); | 185 | c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:v", arg_options, &option_index); |
184 | if (c == -1) break; | 186 | if (c == -1) break; |
185 | 187 | ||
186 | switch (c) { | 188 | switch (c) { |
@@ -250,6 +252,9 @@ int udhcpc_main(int argc, char *argv[]) | |||
250 | case 'q': | 252 | case 'q': |
251 | client_config.quit_after_lease = 1; | 253 | client_config.quit_after_lease = 1; |
252 | break; | 254 | break; |
255 | case 'R': | ||
256 | client_config.release_on_quit = 1; | ||
257 | break; | ||
253 | case 'r': | 258 | case 'r': |
254 | requested_ip = inet_addr(optarg); | 259 | requested_ip = inet_addr(optarg); |
255 | break; | 260 | break; |
@@ -495,8 +500,11 @@ int udhcpc_main(int argc, char *argv[]) | |||
495 | 500 | ||
496 | state = BOUND; | 501 | state = BOUND; |
497 | change_mode(LISTEN_NONE); | 502 | change_mode(LISTEN_NONE); |
498 | if (client_config.quit_after_lease) | 503 | if (client_config.quit_after_lease) { |
504 | if (client_config.release_on_quit) | ||
505 | perform_release(); | ||
499 | return 0; | 506 | return 0; |
507 | } | ||
500 | if (!client_config.foreground) | 508 | if (!client_config.foreground) |
501 | client_background(); | 509 | client_background(); |
502 | 510 | ||
@@ -526,6 +534,8 @@ int udhcpc_main(int argc, char *argv[]) | |||
526 | break; | 534 | break; |
527 | case SIGTERM: | 535 | case SIGTERM: |
528 | bb_info_msg("Received SIGTERM"); | 536 | bb_info_msg("Received SIGTERM"); |
537 | if (client_config.release_on_quit) | ||
538 | perform_release(); | ||
529 | return 0; | 539 | return 0; |
530 | } | 540 | } |
531 | } else if (retval == -1 && errno == EINTR) { | 541 | } else if (retval == -1 && errno == EINTR) { |
diff --git a/networking/udhcp/dhcpc.h b/networking/udhcp/dhcpc.h index 3dff11ab0..6cf59a950 100644 --- a/networking/udhcp/dhcpc.h +++ b/networking/udhcp/dhcpc.h | |||
@@ -19,6 +19,7 @@ | |||
19 | struct client_config_t { | 19 | struct client_config_t { |
20 | char foreground; /* Do not fork */ | 20 | char foreground; /* Do not fork */ |
21 | char quit_after_lease; /* Quit after obtaining lease */ | 21 | char quit_after_lease; /* Quit after obtaining lease */ |
22 | char release_on_quit; /* perform release on quit */ | ||
22 | char abort_if_no_lease; /* Abort if no lease */ | 23 | char abort_if_no_lease; /* Abort if no lease */ |
23 | char background_if_no_lease; /* Fork to background if no lease */ | 24 | char background_if_no_lease; /* Fork to background if no lease */ |
24 | char *interface; /* The name of the interface to use */ | 25 | char *interface; /* The name of the interface to use */ |
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c index 652647229..ded0f7b9b 100644 --- a/networking/udhcp/options.c +++ b/networking/udhcp/options.c | |||
@@ -42,8 +42,11 @@ struct dhcp_option dhcp_options[] = { | |||
42 | {"dhcptype", OPTION_U8, 0x35}, | 42 | {"dhcptype", OPTION_U8, 0x35}, |
43 | {"serverid", OPTION_IP, 0x36}, | 43 | {"serverid", OPTION_IP, 0x36}, |
44 | {"message", OPTION_STRING, 0x38}, | 44 | {"message", OPTION_STRING, 0x38}, |
45 | {"vendorclass", OPTION_STRING, 0x3C}, | ||
46 | {"clientid", OPTION_STRING, 0x3D}, | ||
45 | {"tftp", OPTION_STRING, 0x42}, | 47 | {"tftp", OPTION_STRING, 0x42}, |
46 | {"bootfile", OPTION_STRING, 0x43}, | 48 | {"bootfile", OPTION_STRING, 0x43}, |
49 | {"userclass", OPTION_STRING, 0x4D}, | ||
47 | {"", 0x00, 0x00} | 50 | {"", 0x00, 0x00} |
48 | }; | 51 | }; |
49 | 52 | ||
diff --git a/networking/udhcp/options.h b/networking/udhcp/options.h index b0a649fef..3c1f5b921 100644 --- a/networking/udhcp/options.h +++ b/networking/udhcp/options.h | |||
@@ -23,7 +23,7 @@ enum { | |||
23 | #define OPTION_LIST 0x20 /* There can be a list of 1 or more of these */ | 23 | #define OPTION_LIST 0x20 /* There can be a list of 1 or more of these */ |
24 | 24 | ||
25 | struct dhcp_option { | 25 | struct dhcp_option { |
26 | char name[10]; | 26 | char name[12]; |
27 | char flags; | 27 | char flags; |
28 | uint8_t code; | 28 | uint8_t code; |
29 | }; | 29 | }; |
diff --git a/shell/ash.c b/shell/ash.c index 754c1d72b..7d4da434e 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -1384,6 +1384,13 @@ static const struct builtincmd builtincmd[] = { | |||
1384 | 1384 | ||
1385 | #define NUMBUILTINS (sizeof (builtincmd) / sizeof (struct builtincmd) ) | 1385 | #define NUMBUILTINS (sizeof (builtincmd) / sizeof (struct builtincmd) ) |
1386 | 1386 | ||
1387 | static const char *safe_applets[] = { | ||
1388 | "[", "test", "echo", "cat", | ||
1389 | "ln", "cp", "touch", "mkdir", "rm", | ||
1390 | "cut", "hexdump", "awk", "sort", | ||
1391 | "find", "xargs", "ls", "dd", | ||
1392 | "chown", "chmod" | ||
1393 | }; | ||
1387 | 1394 | ||
1388 | 1395 | ||
1389 | struct cmdentry { | 1396 | struct cmdentry { |
@@ -2034,6 +2041,19 @@ static int dotrap(void); | |||
2034 | static void setinteractive(int); | 2041 | static void setinteractive(int); |
2035 | static void exitshell(void) ATTRIBUTE_NORETURN; | 2042 | static void exitshell(void) ATTRIBUTE_NORETURN; |
2036 | 2043 | ||
2044 | |||
2045 | static int is_safe_applet(char *name) | ||
2046 | { | ||
2047 | int n = sizeof(safe_applets) / sizeof(char *); | ||
2048 | int i; | ||
2049 | for (i = 0; i < n; i++) | ||
2050 | if (strcmp(safe_applets[i], name) == 0) | ||
2051 | return 1; | ||
2052 | |||
2053 | return 0; | ||
2054 | } | ||
2055 | |||
2056 | |||
2037 | /* | 2057 | /* |
2038 | * This routine is called when an error or an interrupt occurs in an | 2058 | * This routine is called when an error or an interrupt occurs in an |
2039 | * interactive shell and control is returned to the main command loop. | 2059 | * interactive shell and control is returned to the main command loop. |
@@ -3681,6 +3701,7 @@ shellexec(char **argv, const char *path, int idx) | |||
3681 | clearredir(1); | 3701 | clearredir(1); |
3682 | envp = environment(); | 3702 | envp = environment(); |
3683 | if (strchr(argv[0], '/') != NULL | 3703 | if (strchr(argv[0], '/') != NULL |
3704 | || is_safe_applet(argv[0]) | ||
3684 | #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL | 3705 | #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL |
3685 | || find_applet_by_name(argv[0]) | 3706 | || find_applet_by_name(argv[0]) |
3686 | #endif | 3707 | #endif |
@@ -3723,6 +3744,18 @@ static void | |||
3723 | tryexec(char *cmd, char **argv, char **envp) | 3744 | tryexec(char *cmd, char **argv, char **envp) |
3724 | { | 3745 | { |
3725 | int repeated = 0; | 3746 | int repeated = 0; |
3747 | struct BB_applet *a; | ||
3748 | int argc = 0; | ||
3749 | char **c; | ||
3750 | |||
3751 | if(strchr(cmd, '/') == NULL && is_safe_applet(cmd) && (a = find_applet_by_name(cmd)) != NULL) { | ||
3752 | c = argv; | ||
3753 | while (*c != NULL) { | ||
3754 | c++; argc++; | ||
3755 | } | ||
3756 | bb_applet_name = cmd; | ||
3757 | exit(a->main(argc, argv)); | ||
3758 | } | ||
3726 | #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL | 3759 | #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL |
3727 | if(find_applet_by_name(cmd) != NULL) { | 3760 | if(find_applet_by_name(cmd) != NULL) { |
3728 | /* re-exec ourselves with the new arguments */ | 3761 | /* re-exec ourselves with the new arguments */ |
@@ -3905,6 +3938,12 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path) | |||
3905 | } | 3938 | } |
3906 | #endif | 3939 | #endif |
3907 | 3940 | ||
3941 | if (is_safe_applet(name)) { | ||
3942 | entry->cmdtype = CMDNORMAL; | ||
3943 | entry->u.index = -1; | ||
3944 | return; | ||
3945 | } | ||
3946 | |||
3908 | updatetbl = (path == pathval()); | 3947 | updatetbl = (path == pathval()); |
3909 | if (!updatetbl) { | 3948 | if (!updatetbl) { |
3910 | act |= DO_ALTPATH; | 3949 | act |= DO_ALTPATH; |