aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2005-08-13 00:26:01 +0000
committerRob Landley <rob@landley.net>2005-08-13 00:26:01 +0000
commitfc455b2101edbf97331384831de2989ce9cdb731 (patch)
tree521f09b4ca5cb42280e51c7618930ea4f0e68dfb
parent365a345e92c25c60c977aa1596e31a1e6b9cea80 (diff)
downloadbusybox-w32-fc455b2101edbf97331384831de2989ce9cdb731.tar.gz
busybox-w32-fc455b2101edbf97331384831de2989ce9cdb731.tar.bz2
busybox-w32-fc455b2101edbf97331384831de2989ce9cdb731.zip
1.0 backports of:
10861, 10875, 10881, 10888 ash fix 10865 suid thing? (look at this) 10886 telnet bugfix 10866 ftp fix for RFC 959 compliance. 10867 Remove spurious newline from cp -i prompt. 10874 ksyslogd fix 10876 msh fix 10877 httpd fix 10880, 10889, 11005 dhcp fixes
-rw-r--r--busybox/include/applets.h2
-rw-r--r--busybox/include/usage.h5
-rw-r--r--busybox/libbb/copy_file.c2
-rw-r--r--busybox/networking/ftpgetput.c4
-rw-r--r--busybox/networking/httpd.c4
-rw-r--r--busybox/networking/telnet.c14
-rw-r--r--busybox/networking/udhcp/dhcpc.c19
-rw-r--r--busybox/shell/ash.c35
-rw-r--r--busybox/shell/cmdedit.c4
-rw-r--r--busybox/shell/msh.c2
-rw-r--r--busybox/sysklogd/syslogd.c2
11 files changed, 60 insertions, 33 deletions
diff --git a/busybox/include/applets.h b/busybox/include/applets.h
index 21f82f57d..d89500e77 100644
--- a/busybox/include/applets.h
+++ b/busybox/include/applets.h
@@ -672,7 +672,7 @@
672#endif 672#endif
673 673
674#if !defined(PROTOTYPES) && !defined(MAKE_USAGE) 674#if !defined(PROTOTYPES) && !defined(MAKE_USAGE)
675 { 0,NULL,0 } 675 { 0,NULL,0,0 }
676}; 676};
677 677
678#endif 678#endif
diff --git a/busybox/include/usage.h b/busybox/include/usage.h
index ad4410196..b58c57275 100644
--- a/busybox/include/usage.h
+++ b/busybox/include/usage.h
@@ -2610,9 +2610,10 @@
2610 "/dev/tty2\n" 2610 "/dev/tty2\n"
2611 2611
2612#define udhcpc_trivial_usage \ 2612#define udhcpc_trivial_usage \
2613 "[-fbnqv] [-c CLIENTID] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]" 2613 "[-Cfbnqv] [-c CLIENTID] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]"
2614#define udhcpc_full_usage \ 2614#define udhcpc_full_usage \
2615 "\t-c,\t--clientid=CLIENTID\tClient identifier\n" \ 2615 "\t-c,\t--clientid=CLIENTID\tSet client identifier\n" \
2616 "\t-C,\t--clientid-none\tSuppress default client identifier\n" \
2616 "\t-H,\t--hostname=HOSTNAME\tClient hostname\n" \ 2617 "\t-H,\t--hostname=HOSTNAME\tClient hostname\n" \
2617 "\t-h,\t \tAlias for -H\n" \ 2618 "\t-h,\t \tAlias for -H\n" \
2618 "\t-f,\t--foreground\tDo not fork after getting lease\n" \ 2619 "\t-f,\t--foreground\tDo not fork after getting lease\n" \
diff --git a/busybox/libbb/copy_file.c b/busybox/libbb/copy_file.c
index 4b349b7fc..f5fecaf73 100644
--- a/busybox/libbb/copy_file.c
+++ b/busybox/libbb/copy_file.c
@@ -146,7 +146,7 @@ int copy_file(const char *source, const char *dest, int flags)
146 146
147 if (dest_exists) { 147 if (dest_exists) {
148 if (flags & FILEUTILS_INTERACTIVE) { 148 if (flags & FILEUTILS_INTERACTIVE) {
149 bb_error_msg("overwrite `%s'? ", dest); 149 fprintf(stderr, "%s: overwrite `%s'? ", bb_applet_name, dest);
150 if (!bb_ask_confirmation()) { 150 if (!bb_ask_confirmation()) {
151 close (src_fd); 151 close (src_fd);
152 return 0; 152 return 0;
diff --git a/busybox/networking/ftpgetput.c b/busybox/networking/ftpgetput.c
index f6bd82bc8..02c21d9e1 100644
--- a/busybox/networking/ftpgetput.c
+++ b/busybox/networking/ftpgetput.c
@@ -65,9 +65,9 @@ static int ftpcmd(const char *s1, const char *s2, FILE *stream, char *buf)
65 65
66 if (s1) { 66 if (s1) {
67 if (s2) { 67 if (s2) {
68 fprintf(stream, "%s%s\n", s1, s2); 68 fprintf(stream, "%s%s\r\n", s1, s2);
69 } else { 69 } else {
70 fprintf(stream, "%s\n", s1); 70 fprintf(stream, "%s\r\n", s1);
71 } 71 }
72 } 72 }
73 do { 73 do {
diff --git a/busybox/networking/httpd.c b/busybox/networking/httpd.c
index 94fcfc8c1..e3f4027dc 100644
--- a/busybox/networking/httpd.c
+++ b/busybox/networking/httpd.c
@@ -1259,6 +1259,8 @@ static int sendCgi(const char *url,
1259 post_readed_idx += count; 1259 post_readed_idx += count;
1260 if(post_readed_size == 0) 1260 if(post_readed_size == 0)
1261 post_readed_idx = 0; 1261 post_readed_idx = 0;
1262 } else {
1263 post_readed_size = post_readed_idx = bodyLen = 0; /* broken pipe to CGI */
1262 } 1264 }
1263 } else if(bodyLen > 0 && post_readed_size == 0 && FD_ISSET(a_c_r, &readSet)) { 1265 } else if(bodyLen > 0 && post_readed_size == 0 && FD_ISSET(a_c_r, &readSet)) {
1264 count = bodyLen > sizeof(wbuf) ? sizeof(wbuf) : bodyLen; 1266 count = bodyLen > sizeof(wbuf) ? sizeof(wbuf) : bodyLen;
@@ -1266,7 +1268,7 @@ static int sendCgi(const char *url,
1266 if(count > 0) { 1268 if(count > 0) {
1267 post_readed_size += count; 1269 post_readed_size += count;
1268 bodyLen -= count; 1270 bodyLen -= count;
1269 } else { 1271 } else {
1270 bodyLen = 0; /* closed */ 1272 bodyLen = 0; /* closed */
1271 } 1273 }
1272 } 1274 }
diff --git a/busybox/networking/telnet.c b/busybox/networking/telnet.c
index 6ad7712ab..24160057b 100644
--- a/busybox/networking/telnet.c
+++ b/busybox/networking/telnet.c
@@ -96,6 +96,7 @@ static struct Globalvars {
96 byte charmode; 96 byte charmode;
97 byte telflags; 97 byte telflags;
98 byte gotsig; 98 byte gotsig;
99 byte do_termios;
99 /* buffer to handle telnet negotiations */ 100 /* buffer to handle telnet negotiations */
100 char iacbuf[IACBUFSIZE]; 101 char iacbuf[IACBUFSIZE];
101 short iaclen; /* could even use byte */ 102 short iaclen; /* could even use byte */
@@ -616,12 +617,12 @@ static void fgotsig(int sig)
616 617
617static void rawmode(void) 618static void rawmode(void)
618{ 619{
619 tcsetattr(0, TCSADRAIN, &G.termios_raw); 620 if (G.do_termios) tcsetattr(0, TCSADRAIN, &G.termios_raw);
620} 621}
621 622
622static void cookmode(void) 623static void cookmode(void)
623{ 624{
624 tcsetattr(0, TCSADRAIN, &G.termios_def); 625 if (G.do_termios) tcsetattr(0, TCSADRAIN, &G.termios_def);
625} 626}
626 627
627extern int telnet_main(int argc, char** argv) 628extern int telnet_main(int argc, char** argv)
@@ -649,11 +650,12 @@ extern int telnet_main(int argc, char** argv)
649 650
650 memset(&G, 0, sizeof G); 651 memset(&G, 0, sizeof G);
651 652
652 if (tcgetattr(0, &G.termios_def) < 0) 653 if (tcgetattr(0, &G.termios_def) >= 0) {
653 exit(1); 654 G.do_termios = 1;
654 655
655 G.termios_raw = G.termios_def; 656 G.termios_raw = G.termios_def;
656 cfmakeraw(&G.termios_raw); 657 cfmakeraw(&G.termios_raw);
658 }
657 659
658 if (argc < 2) 660 if (argc < 2)
659 bb_show_usage(); 661 bb_show_usage();
diff --git a/busybox/networking/udhcp/dhcpc.c b/busybox/networking/udhcp/dhcpc.c
index 91af9153b..e89affe1f 100644
--- a/busybox/networking/udhcp/dhcpc.c
+++ b/busybox/networking/udhcp/dhcpc.c
@@ -76,7 +76,8 @@ static void __attribute__ ((noreturn)) show_usage(void)
76{ 76{
77 printf( 77 printf(
78"Usage: udhcpc [OPTIONS]\n\n" 78"Usage: udhcpc [OPTIONS]\n\n"
79" -c, --clientid=CLIENTID Client identifier\n" 79" -c, --clientid=CLIENTID Set client identifier\n"
80" -C, --clientid-none Suppress default client identifier\n"
80" -H, --hostname=HOSTNAME Client hostname\n" 81" -H, --hostname=HOSTNAME Client hostname\n"
81" -h Alias for -H\n" 82" -h Alias for -H\n"
82" -f, --foreground Do not fork after getting lease\n" 83" -f, --foreground Do not fork after getting lease\n"
@@ -191,9 +192,11 @@ int main(int argc, char *argv[])
191 long now; 192 long now;
192 int max_fd; 193 int max_fd;
193 int sig; 194 int sig;
195 int no_clientid = 0;
194 196
195 static const struct option arg_options[] = { 197 static const struct option arg_options[] = {
196 {"clientid", required_argument, 0, 'c'}, 198 {"clientid", required_argument, 0, 'c'},
199 {"clientid-none", no_argument, 0, 'C'},
197 {"foreground", no_argument, 0, 'f'}, 200 {"foreground", no_argument, 0, 'f'},
198 {"background", no_argument, 0, 'b'}, 201 {"background", no_argument, 0, 'b'},
199 {"hostname", required_argument, 0, 'H'}, 202 {"hostname", required_argument, 0, 'H'},
@@ -211,11 +214,12 @@ int main(int argc, char *argv[])
211 /* get options */ 214 /* get options */
212 while (1) { 215 while (1) {
213 int option_index = 0; 216 int option_index = 0;
214 c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index); 217 c = getopt_long(argc, argv, "c:CfbH:h:i:np:qr:s:v", arg_options, &option_index);
215 if (c == -1) break; 218 if (c == -1) break;
216 219
217 switch (c) { 220 switch (c) {
218 case 'c': 221 case 'c':
222 if (no_clientid) show_usage();
219 len = strlen(optarg) > 255 ? 255 : strlen(optarg); 223 len = strlen(optarg) > 255 ? 255 : strlen(optarg);
220 if (client_config.clientid) free(client_config.clientid); 224 if (client_config.clientid) free(client_config.clientid);
221 client_config.clientid = xmalloc(len + 2); 225 client_config.clientid = xmalloc(len + 2);
@@ -224,6 +228,10 @@ int main(int argc, char *argv[])
224 client_config.clientid[OPT_DATA] = '\0'; 228 client_config.clientid[OPT_DATA] = '\0';
225 strncpy(client_config.clientid + OPT_DATA, optarg, len); 229 strncpy(client_config.clientid + OPT_DATA, optarg, len);
226 break; 230 break;
231 case 'C':
232 if (client_config.clientid) show_usage();
233 no_clientid = 1;
234 break;
227 case 'f': 235 case 'f':
228 client_config.foreground = 1; 236 client_config.foreground = 1;
229 break; 237 break;
@@ -273,7 +281,8 @@ int main(int argc, char *argv[])
273 NULL, client_config.arp) < 0) 281 NULL, client_config.arp) < 0)
274 return 1; 282 return 1;
275 283
276 if (!client_config.clientid) { 284 /* if not set, and not suppressed, setup the default client ID */
285 if (!client_config.clientid && !no_clientid) {
277 client_config.clientid = xmalloc(6 + 3); 286 client_config.clientid = xmalloc(6 + 3);
278 client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID; 287 client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
279 client_config.clientid[OPT_LEN] = 7; 288 client_config.clientid[OPT_LEN] = 7;
@@ -420,8 +429,10 @@ int main(int argc, char *argv[])
420 continue; 429 continue;
421 } 430 }
422 /* Ignore packets that aren't for us */ 431 /* Ignore packets that aren't for us */
423 if (memcmp(client_config.arp,packet.chaddr,6)) 432 if (memcmp(packet.chaddr, client_config.arp, 6)) {
433 DEBUG(LOG_INFO, "packet does not have our chaddr -- ignoring");
424 continue; 434 continue;
435 }
425 436
426 if ((message = get_option(&packet, DHCP_MESSAGE_TYPE)) == NULL) { 437 if ((message = get_option(&packet, DHCP_MESSAGE_TYPE)) == NULL) {
427 DEBUG(LOG_ERR, "couldnt get option from packet -- ignoring"); 438 DEBUG(LOG_ERR, "couldnt get option from packet -- ignoring");
diff --git a/busybox/shell/ash.c b/busybox/shell/ash.c
index d9ea2b0f3..f16edbc38 100644
--- a/busybox/shell/ash.c
+++ b/busybox/shell/ash.c
@@ -1353,6 +1353,7 @@ struct builtincmd {
1353 1353
1354#define IS_BUILTIN_SPECIAL(builtincmd) ((builtincmd)->name[0] & 1) 1354#define IS_BUILTIN_SPECIAL(builtincmd) ((builtincmd)->name[0] & 1)
1355#define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2) 1355#define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2)
1356#define IS_BUILTIN_ASSIGN(builtincmd) ((builtincmd)->name[0] & 4)
1356 1357
1357static const struct builtincmd builtincmd[] = { 1358static const struct builtincmd builtincmd[] = {
1358 { BUILTIN_SPEC_REG ".", dotcmd }, 1359 { BUILTIN_SPEC_REG ".", dotcmd },
@@ -3208,7 +3209,14 @@ parse_command_args(char **argv, const char **path)
3208} 3209}
3209#endif 3210#endif
3210 3211
3211 3212static inline int
3213isassignment(const char *p)
3214{
3215 const char *q = endofname(p);
3216 if (p == q)
3217 return 0;
3218 return *q == '=';
3219}
3212 3220
3213/* 3221/*
3214 * Execute a simple command. 3222 * Execute a simple command.
@@ -3232,6 +3240,8 @@ evalcommand(union node *cmd, int flags)
3232 int cmd_is_exec; 3240 int cmd_is_exec;
3233 int status; 3241 int status;
3234 char **nargv; 3242 char **nargv;
3243 struct builtincmd *bcmd;
3244 int pseudovarflag = 0;
3235 3245
3236 /* First expand the arguments. */ 3246 /* First expand the arguments. */
3237 TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags)); 3247 TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags));
@@ -3246,11 +3256,21 @@ evalcommand(union node *cmd, int flags)
3246 *arglist.lastp = NULL; 3256 *arglist.lastp = NULL;
3247 3257
3248 argc = 0; 3258 argc = 0;
3259 if (cmd->ncmd.args)
3260 {
3261 bcmd = find_builtin(cmd->ncmd.args->narg.text);
3262 pseudovarflag = bcmd && IS_BUILTIN_ASSIGN(bcmd);
3263 }
3264
3249 for (argp = cmd->ncmd.args; argp; argp = argp->narg.next) { 3265 for (argp = cmd->ncmd.args; argp; argp = argp->narg.next) {
3250 struct strlist **spp; 3266 struct strlist **spp;
3251 3267
3252 spp = arglist.lastp; 3268 spp = arglist.lastp;
3253 expandarg(argp, &arglist, EXP_FULL | EXP_TILDE); 3269 if (pseudovarflag && isassignment(argp->narg.text))
3270 expandarg(argp, &arglist, EXP_VARTILDE);
3271 else
3272 expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
3273
3254 for (sp = *spp; sp; sp = sp->next) 3274 for (sp = *spp; sp; sp = sp->next)
3255 argc++; 3275 argc++;
3256 } 3276 }
@@ -9370,15 +9390,6 @@ static void setprompt(int);
9370 9390
9371 9391
9372 9392
9373static inline int
9374isassignment(const char *p)
9375{
9376 const char *q = endofname(p);
9377 if (p == q)
9378 return 0;
9379 return *q == '=';
9380}
9381
9382 9393
9383/* 9394/*
9384 * Read and parse a command. Returns NEOF on end of file. (NULL is a 9395 * Read and parse a command. Returns NEOF on end of file. (NULL is a
@@ -12005,7 +12016,7 @@ setvar(const char *name, const char *val, int flags)
12005 INTOFF; 12016 INTOFF;
12006 p = mempcpy(nameeq = ckmalloc(namelen + vallen + 2), name, namelen); 12017 p = mempcpy(nameeq = ckmalloc(namelen + vallen + 2), name, namelen);
12007 *p++ = '\0'; 12018 *p++ = '\0';
12008 if (vallen) { 12019 if (val) {
12009 p[-1] = '='; 12020 p[-1] = '=';
12010 p = mempcpy(p, val, vallen); 12021 p = mempcpy(p, val, vallen);
12011 } 12022 }
diff --git a/busybox/shell/cmdedit.c b/busybox/shell/cmdedit.c
index 56b789ab6..3380dffe9 100644
--- a/busybox/shell/cmdedit.c
+++ b/busybox/shell/cmdedit.c
@@ -782,8 +782,8 @@ static int match_compare(const void *a, const void *b)
782#define QUOT (UCHAR_MAX+1) 782#define QUOT (UCHAR_MAX+1)
783 783
784#define collapse_pos(is, in) { \ 784#define collapse_pos(is, in) { \
785 memcpy(int_buf+(is), int_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); \ 785 memmove(int_buf+(is), int_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); \
786 memcpy(pos_buf+(is), pos_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); } 786 memmove(pos_buf+(is), pos_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); }
787 787
788static int find_match(char *matchBuf, int *len_with_quotes) 788static int find_match(char *matchBuf, int *len_with_quotes)
789{ 789{
diff --git a/busybox/shell/msh.c b/busybox/shell/msh.c
index 2fb0df739..14e875854 100644
--- a/busybox/shell/msh.c
+++ b/busybox/shell/msh.c
@@ -4290,7 +4290,7 @@ int quoted;
4290 } 4290 }
4291 4291
4292 var_name[var_index++] = *src++; 4292 var_name[var_index++] = *src++;
4293 while (isalnum(*src)) 4293 while (isalnum(*src) || *src=='_')
4294 var_name[var_index++] = *src++; 4294 var_name[var_index++] = *src++;
4295 var_name[var_index] = 0; 4295 var_name[var_index] = 0;
4296 4296
diff --git a/busybox/sysklogd/syslogd.c b/busybox/sysklogd/syslogd.c
index 8c6c44ee0..aecd35d58 100644
--- a/busybox/sysklogd/syslogd.c
+++ b/busybox/sysklogd/syslogd.c
@@ -441,7 +441,7 @@ static void logMessage(int pri, char *msg)
441 /* if we have a valid socket, send the message */ 441 /* if we have a valid socket, send the message */
442 if (-1 != remotefd) { 442 if (-1 != remotefd) {
443 now = 1; 443 now = 1;
444 snprintf(line, sizeof(line), "<%d> %s", pri, msg); 444 snprintf(line, sizeof(line), "<%d>%s", pri, msg);
445 445
446 retry: 446 retry:
447 /* send message to remote logger */ 447 /* send message to remote logger */