summaryrefslogtreecommitdiff
path: root/busybox/networking
diff options
context:
space:
mode:
authorRob Landley2005-08-13 00:26:01 +0000
committerRob Landley2005-08-13 00:26:01 +0000
commitfc455b2101edbf97331384831de2989ce9cdb731 (patch)
tree521f09b4ca5cb42280e51c7618930ea4f0e68dfb /busybox/networking
parent365a345e92c25c60c977aa1596e31a1e6b9cea80 (diff)
downloadbusybox-fc455b2101edbf97331384831de2989ce9cdb731.zip
busybox-fc455b2101edbf97331384831de2989ce9cdb731.tar.gz
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
Diffstat (limited to 'busybox/networking')
-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
4 files changed, 28 insertions, 13 deletions
diff --git a/busybox/networking/ftpgetput.c b/busybox/networking/ftpgetput.c
index f6bd82b..02c21d9 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)
if (s1) {
if (s2) {
- fprintf(stream, "%s%s\n", s1, s2);
+ fprintf(stream, "%s%s\r\n", s1, s2);
} else {
- fprintf(stream, "%s\n", s1);
+ fprintf(stream, "%s\r\n", s1);
}
}
do {
diff --git a/busybox/networking/httpd.c b/busybox/networking/httpd.c
index 94fcfc8..e3f4027 100644
--- a/busybox/networking/httpd.c
+++ b/busybox/networking/httpd.c
@@ -1259,6 +1259,8 @@ static int sendCgi(const char *url,
post_readed_idx += count;
if(post_readed_size == 0)
post_readed_idx = 0;
+ } else {
+ post_readed_size = post_readed_idx = bodyLen = 0; /* broken pipe to CGI */
}
} else if(bodyLen > 0 && post_readed_size == 0 && FD_ISSET(a_c_r, &readSet)) {
count = bodyLen > sizeof(wbuf) ? sizeof(wbuf) : bodyLen;
@@ -1266,7 +1268,7 @@ static int sendCgi(const char *url,
if(count > 0) {
post_readed_size += count;
bodyLen -= count;
- } else {
+ } else {
bodyLen = 0; /* closed */
}
}
diff --git a/busybox/networking/telnet.c b/busybox/networking/telnet.c
index 6ad7712..2416005 100644
--- a/busybox/networking/telnet.c
+++ b/busybox/networking/telnet.c
@@ -96,6 +96,7 @@ static struct Globalvars {
byte charmode;
byte telflags;
byte gotsig;
+ byte do_termios;
/* buffer to handle telnet negotiations */
char iacbuf[IACBUFSIZE];
short iaclen; /* could even use byte */
@@ -616,12 +617,12 @@ static void fgotsig(int sig)
static void rawmode(void)
{
- tcsetattr(0, TCSADRAIN, &G.termios_raw);
+ if (G.do_termios) tcsetattr(0, TCSADRAIN, &G.termios_raw);
}
static void cookmode(void)
{
- tcsetattr(0, TCSADRAIN, &G.termios_def);
+ if (G.do_termios) tcsetattr(0, TCSADRAIN, &G.termios_def);
}
extern int telnet_main(int argc, char** argv)
@@ -649,11 +650,12 @@ extern int telnet_main(int argc, char** argv)
memset(&G, 0, sizeof G);
- if (tcgetattr(0, &G.termios_def) < 0)
- exit(1);
+ if (tcgetattr(0, &G.termios_def) >= 0) {
+ G.do_termios = 1;
- G.termios_raw = G.termios_def;
- cfmakeraw(&G.termios_raw);
+ G.termios_raw = G.termios_def;
+ cfmakeraw(&G.termios_raw);
+ }
if (argc < 2)
bb_show_usage();
diff --git a/busybox/networking/udhcp/dhcpc.c b/busybox/networking/udhcp/dhcpc.c
index 91af915..e89affe 100644
--- a/busybox/networking/udhcp/dhcpc.c
+++ b/busybox/networking/udhcp/dhcpc.c
@@ -76,7 +76,8 @@ static void __attribute__ ((noreturn)) show_usage(void)
{
printf(
"Usage: udhcpc [OPTIONS]\n\n"
-" -c, --clientid=CLIENTID Client identifier\n"
+" -c, --clientid=CLIENTID Set client identifier\n"
+" -C, --clientid-none Suppress default client identifier\n"
" -H, --hostname=HOSTNAME Client hostname\n"
" -h Alias for -H\n"
" -f, --foreground Do not fork after getting lease\n"
@@ -191,9 +192,11 @@ int main(int argc, char *argv[])
long now;
int max_fd;
int sig;
+ int no_clientid = 0;
static const struct option arg_options[] = {
{"clientid", required_argument, 0, 'c'},
+ {"clientid-none", no_argument, 0, 'C'},
{"foreground", no_argument, 0, 'f'},
{"background", no_argument, 0, 'b'},
{"hostname", required_argument, 0, 'H'},
@@ -211,11 +214,12 @@ int main(int argc, char *argv[])
/* get options */
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index);
+ c = getopt_long(argc, argv, "c:CfbH:h:i:np:qr:s:v", arg_options, &option_index);
if (c == -1) break;
switch (c) {
case 'c':
+ if (no_clientid) show_usage();
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
if (client_config.clientid) free(client_config.clientid);
client_config.clientid = xmalloc(len + 2);
@@ -224,6 +228,10 @@ int main(int argc, char *argv[])
client_config.clientid[OPT_DATA] = '\0';
strncpy(client_config.clientid + OPT_DATA, optarg, len);
break;
+ case 'C':
+ if (client_config.clientid) show_usage();
+ no_clientid = 1;
+ break;
case 'f':
client_config.foreground = 1;
break;
@@ -273,7 +281,8 @@ int main(int argc, char *argv[])
NULL, client_config.arp) < 0)
return 1;
- if (!client_config.clientid) {
+ /* if not set, and not suppressed, setup the default client ID */
+ if (!client_config.clientid && !no_clientid) {
client_config.clientid = xmalloc(6 + 3);
client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
client_config.clientid[OPT_LEN] = 7;
@@ -420,8 +429,10 @@ int main(int argc, char *argv[])
continue;
}
/* Ignore packets that aren't for us */
- if (memcmp(client_config.arp,packet.chaddr,6))
+ if (memcmp(packet.chaddr, client_config.arp, 6)) {
+ DEBUG(LOG_INFO, "packet does not have our chaddr -- ignoring");
continue;
+ }
if ((message = get_option(&packet, DHCP_MESSAGE_TYPE)) == NULL) {
DEBUG(LOG_ERR, "couldnt get option from packet -- ignoring");