[BusyBox-cvs] svn commit: branches/busybox_1_00_stable/busybox: include libbb networking networking/udhc etc...

landley at busybox.net landley at busybox.net
Sat Aug 13 00:26:07 UTC 2005


Author: landley
Date: 2005-08-12 18:26:01 -0600 (Fri, 12 Aug 2005)
New Revision: 11127

Log:
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


Modified:
   branches/busybox_1_00_stable/busybox/include/applets.h
   branches/busybox_1_00_stable/busybox/include/usage.h
   branches/busybox_1_00_stable/busybox/libbb/copy_file.c
   branches/busybox_1_00_stable/busybox/networking/ftpgetput.c
   branches/busybox_1_00_stable/busybox/networking/httpd.c
   branches/busybox_1_00_stable/busybox/networking/telnet.c
   branches/busybox_1_00_stable/busybox/networking/udhcp/dhcpc.c
   branches/busybox_1_00_stable/busybox/shell/ash.c
   branches/busybox_1_00_stable/busybox/shell/cmdedit.c
   branches/busybox_1_00_stable/busybox/shell/msh.c
   branches/busybox_1_00_stable/busybox/sysklogd/syslogd.c


Changeset:
Modified: branches/busybox_1_00_stable/busybox/include/applets.h
===================================================================
--- branches/busybox_1_00_stable/busybox/include/applets.h	2005-08-12 23:41:18 UTC (rev 11126)
+++ branches/busybox_1_00_stable/busybox/include/applets.h	2005-08-13 00:26:01 UTC (rev 11127)
@@ -672,7 +672,7 @@
 #endif
 
 #if !defined(PROTOTYPES) && !defined(MAKE_USAGE)
-	{ 0,NULL,0 }
+	{ 0,NULL,0,0 }
 };
 
 #endif

Modified: branches/busybox_1_00_stable/busybox/include/usage.h
===================================================================
--- branches/busybox_1_00_stable/busybox/include/usage.h	2005-08-12 23:41:18 UTC (rev 11126)
+++ branches/busybox_1_00_stable/busybox/include/usage.h	2005-08-13 00:26:01 UTC (rev 11127)
@@ -2610,9 +2610,10 @@
 	"/dev/tty2\n"
 
 #define udhcpc_trivial_usage \
-	"[-fbnqv] [-c CLIENTID] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]"
+	"[-Cfbnqv] [-c CLIENTID] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]"
 #define udhcpc_full_usage \
-	"\t-c,\t--clientid=CLIENTID\tClient identifier\n" \
+	"\t-c,\t--clientid=CLIENTID\tSet client identifier\n" \
+	"\t-C,\t--clientid-none\tSuppress default client identifier\n" \
 	"\t-H,\t--hostname=HOSTNAME\tClient hostname\n" \
 	"\t-h,\t                   \tAlias for -H\n" \
 	"\t-f,\t--foreground\tDo not fork after getting lease\n" \

Modified: branches/busybox_1_00_stable/busybox/libbb/copy_file.c
===================================================================
--- branches/busybox_1_00_stable/busybox/libbb/copy_file.c	2005-08-12 23:41:18 UTC (rev 11126)
+++ branches/busybox_1_00_stable/busybox/libbb/copy_file.c	2005-08-13 00:26:01 UTC (rev 11127)
@@ -146,7 +146,7 @@
 
 		if (dest_exists) {
 			if (flags & FILEUTILS_INTERACTIVE) {
-				bb_error_msg("overwrite `%s'? ", dest);
+				fprintf(stderr, "%s: overwrite `%s'? ", bb_applet_name, dest);
 				if (!bb_ask_confirmation()) {
 					close (src_fd);
 					return 0;

Modified: branches/busybox_1_00_stable/busybox/networking/ftpgetput.c
===================================================================
--- branches/busybox_1_00_stable/busybox/networking/ftpgetput.c	2005-08-12 23:41:18 UTC (rev 11126)
+++ branches/busybox_1_00_stable/busybox/networking/ftpgetput.c	2005-08-13 00:26:01 UTC (rev 11127)
@@ -65,9 +65,9 @@
 
 	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 {

Modified: branches/busybox_1_00_stable/busybox/networking/httpd.c
===================================================================
--- branches/busybox_1_00_stable/busybox/networking/httpd.c	2005-08-12 23:41:18 UTC (rev 11126)
+++ branches/busybox_1_00_stable/busybox/networking/httpd.c	2005-08-13 00:26:01 UTC (rev 11127)
@@ -1259,6 +1259,8 @@
 			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 @@
 		if(count > 0) {
 			post_readed_size += count;
 			bodyLen -= count;
-      } else {
+		} else {
 			bodyLen = 0;    /* closed */
 		}
       }

Modified: branches/busybox_1_00_stable/busybox/networking/telnet.c
===================================================================
--- branches/busybox_1_00_stable/busybox/networking/telnet.c	2005-08-12 23:41:18 UTC (rev 11126)
+++ branches/busybox_1_00_stable/busybox/networking/telnet.c	2005-08-13 00:26:01 UTC (rev 11127)
@@ -96,6 +96,7 @@
 	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 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 @@
 
 	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();

Modified: branches/busybox_1_00_stable/busybox/networking/udhcp/dhcpc.c
===================================================================
--- branches/busybox_1_00_stable/busybox/networking/udhcp/dhcpc.c	2005-08-12 23:41:18 UTC (rev 11126)
+++ branches/busybox_1_00_stable/busybox/networking/udhcp/dhcpc.c	2005-08-13 00:26:01 UTC (rev 11127)
@@ -76,7 +76,8 @@
 {
 	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 @@
 	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 @@
 	/* 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 @@
 			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 @@
 			   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 @@
 				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");

Modified: branches/busybox_1_00_stable/busybox/shell/ash.c
===================================================================
--- branches/busybox_1_00_stable/busybox/shell/ash.c	2005-08-12 23:41:18 UTC (rev 11126)
+++ branches/busybox_1_00_stable/busybox/shell/ash.c	2005-08-13 00:26:01 UTC (rev 11127)
@@ -1353,6 +1353,7 @@
 
 #define IS_BUILTIN_SPECIAL(builtincmd) ((builtincmd)->name[0] & 1)
 #define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2)
+#define IS_BUILTIN_ASSIGN(builtincmd) ((builtincmd)->name[0] & 4)
 
 static const struct builtincmd builtincmd[] = {
 	{ BUILTIN_SPEC_REG      ".", dotcmd },
@@ -3208,8 +3209,15 @@
 }
 #endif
 
+static inline int
+isassignment(const char *p)
+{
+	const char *q = endofname(p);
+	if (p == q)
+		return 0;
+	return *q == '=';
+}
 
-
 /*
  * Execute a simple command.
  */
@@ -3232,6 +3240,8 @@
 	int cmd_is_exec;
 	int status;
 	char **nargv;
+	struct builtincmd *bcmd;
+	int pseudovarflag = 0;
 
 	/* First expand the arguments. */
 	TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags));
@@ -3246,11 +3256,21 @@
 	*arglist.lastp = NULL;
 
 	argc = 0;
+	if (cmd->ncmd.args)
+	{
+		bcmd = find_builtin(cmd->ncmd.args->narg.text);
+		pseudovarflag = bcmd && IS_BUILTIN_ASSIGN(bcmd);
+	}
+
 	for (argp = cmd->ncmd.args; argp; argp = argp->narg.next) {
 		struct strlist **spp;
 
 		spp = arglist.lastp;
-		expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
+		if (pseudovarflag && isassignment(argp->narg.text)) 
+			expandarg(argp, &arglist, EXP_VARTILDE);
+		else
+			expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
+
 		for (sp = *spp; sp; sp = sp->next)
 			argc++;
 	}
@@ -9370,16 +9390,7 @@
 
 
 
-static inline int
-isassignment(const char *p)
-{
-	const char *q = endofname(p);
-	if (p == q)
-		return 0;
-	return *q == '=';
-}
 
-
 /*
  * Read and parse a command.  Returns NEOF on end of file.  (NULL is a
  * valid parse tree indicating a blank line.)
@@ -12005,7 +12016,7 @@
 	INTOFF;
 	p = mempcpy(nameeq = ckmalloc(namelen + vallen + 2), name, namelen);
 	*p++ = '\0';
-	if (vallen) {
+	if (val) {
 		p[-1] = '=';
 		p = mempcpy(p, val, vallen);
 	}

Modified: branches/busybox_1_00_stable/busybox/shell/cmdedit.c
===================================================================
--- branches/busybox_1_00_stable/busybox/shell/cmdedit.c	2005-08-12 23:41:18 UTC (rev 11126)
+++ branches/busybox_1_00_stable/busybox/shell/cmdedit.c	2005-08-13 00:26:01 UTC (rev 11127)
@@ -782,8 +782,8 @@
 #define QUOT    (UCHAR_MAX+1)
 
 #define collapse_pos(is, in) { \
-	memcpy(int_buf+(is), int_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); \
-	memcpy(pos_buf+(is), pos_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); }
+	memmove(int_buf+(is), int_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); \
+	memmove(pos_buf+(is), pos_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); }
 
 static int find_match(char *matchBuf, int *len_with_quotes)
 {

Modified: branches/busybox_1_00_stable/busybox/shell/msh.c
===================================================================
--- branches/busybox_1_00_stable/busybox/shell/msh.c	2005-08-12 23:41:18 UTC (rev 11126)
+++ branches/busybox_1_00_stable/busybox/shell/msh.c	2005-08-13 00:26:01 UTC (rev 11127)
@@ -4290,7 +4290,7 @@
 			}
 
 			var_name[var_index++] = *src++;
-			while (isalnum(*src))
+			while (isalnum(*src) || *src=='_')
 				var_name[var_index++] = *src++;
 			var_name[var_index] = 0;
 

Modified: branches/busybox_1_00_stable/busybox/sysklogd/syslogd.c
===================================================================
--- branches/busybox_1_00_stable/busybox/sysklogd/syslogd.c	2005-08-12 23:41:18 UTC (rev 11126)
+++ branches/busybox_1_00_stable/busybox/sysklogd/syslogd.c	2005-08-13 00:26:01 UTC (rev 11127)
@@ -441,7 +441,7 @@
 		/* if we have a valid socket, send the message */
 		if (-1 != remotefd) {
 			now = 1;
-			snprintf(line, sizeof(line), "<%d> %s", pri, msg);
+			snprintf(line, sizeof(line), "<%d>%s", pri, msg);
 
 		retry:
 			/* send message to remote logger */




More information about the busybox-cvs mailing list