svn commit: trunk/busybox: editors include loginutils networking/ud etc...

vda at busybox.net vda at busybox.net
Tue Sep 26 17:41:02 UTC 2006


Author: vda
Date: 2006-09-26 10:41:00 -0700 (Tue, 26 Sep 2006)
New Revision: 16229

Log:
several fixes from openWRT project


Modified:
   trunk/busybox/editors/awk.c
   trunk/busybox/include/usage.h
   trunk/busybox/loginutils/passwd.c
   trunk/busybox/networking/udhcp/dhcpc.c
   trunk/busybox/networking/udhcp/dhcpc.h
   trunk/busybox/networking/udhcp/options.c
   trunk/busybox/networking/udhcp/options.h
   trunk/busybox/shell/ash.c


Changeset:
Modified: trunk/busybox/editors/awk.c
===================================================================
--- trunk/busybox/editors/awk.c	2006-09-26 16:31:01 UTC (rev 16228)
+++ trunk/busybox/editors/awk.c	2006-09-26 17:41:00 UTC (rev 16229)
@@ -249,7 +249,8 @@
 /* builtins */
 enum {
 	B_a2=0,	B_ix,	B_ma,	B_sp,	B_ss,	B_ti,	B_lo,	B_up,
-	B_ge,	B_gs,	B_su
+	B_ge,	B_gs,	B_su,
+	B_an,	B_co,	B_ls,	B_or,	B_rs,	B_xo,
 };
 
 /* tokens and their corresponding info values */
@@ -289,6 +290,8 @@
 	"\5while"	NTC
 	"\4else"	NTC
 
+	"\3and"		"\5compl"	"\6lshift"	"\2or"
+	"\6rshift"	"\3xor"
 	"\5close"	"\6system"	"\6fflush"	"\5atan2"	/* BUILTIN */
 	"\3cos"		"\3exp"		"\3int"		"\3log"
 	"\4rand"	"\3sin"		"\4sqrt"	"\5srand"
@@ -342,6 +345,8 @@
 	ST_WHILE,
 	0,
 
+	OC_B|B_an|P(0x83), OC_B|B_co|P(0x41), OC_B|B_ls|P(0x83), OC_B|B_or|P(0x83),
+	OC_B|B_rs|P(0x83), OC_B|B_xo|P(0x83),
 	OC_FBLTIN|Sx|F_cl, OC_FBLTIN|Sx|F_sy, OC_FBLTIN|Sx|F_ff, OC_B|B_a2|P(0x83),
 	OC_FBLTIN|Nx|F_co, OC_FBLTIN|Nx|F_ex, OC_FBLTIN|Nx|F_in, OC_FBLTIN|Nx|F_lg,
 	OC_FBLTIN|F_rn,    OC_FBLTIN|Nx|F_si, OC_FBLTIN|Nx|F_sq, OC_FBLTIN|Nx|F_sr,
@@ -1923,7 +1928,31 @@
 		s[n] = '\0';
 		setvar_p(res, s);
 		break;
+		
+	 case B_an:
+		setvar_i(res, (long)getvar_i(av[0]) & (long)getvar_i(av[1]));
+		break;
+		
+	 case B_co:
+		setvar_i(res, ~(long)getvar_i(av[0]));
+		break;
 
+	 case B_ls:
+		setvar_i(res, (long)getvar_i(av[0]) << (long)getvar_i(av[1]));
+		break;
+
+	 case B_or:
+		setvar_i(res, (long)getvar_i(av[0]) | (long)getvar_i(av[1]));
+		break;
+
+	 case B_rs:
+		setvar_i(res, (long)((unsigned long)getvar_i(av[0]) >> (unsigned long)getvar_i(av[1])));
+		break;
+
+	 case B_xo:
+		setvar_i(res, (long)getvar_i(av[0]) ^ (long)getvar_i(av[1]));
+		break;
+
 	  case B_lo:
 		to_xxx = tolower;
 		goto lo_cont;

Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h	2006-09-26 16:31:01 UTC (rev 16228)
+++ trunk/busybox/include/usage.h	2006-09-26 17:41:00 UTC (rev 16229)
@@ -3211,6 +3211,7 @@
 	"\t-n,\t--now\tExit with failure if lease cannot be immediately negotiated\n" \
 	"\t-p,\t--pidfile=file\tStore process ID of daemon in file\n" \
 	"\t-q,\t--quit\tQuit after obtaining lease\n" \
+	"\t-R,\t--release\tRelease IP on quit\n" \
 	"\t-r,\t--request=IP\tIP address to request (default: none)\n" \
 	"\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \
 	"\t-t,\t--retries=NUM\tSend up to NUM request packets\n"\

Modified: trunk/busybox/loginutils/passwd.c
===================================================================
--- trunk/busybox/loginutils/passwd.c	2006-09-26 16:31:01 UTC (rev 16228)
+++ trunk/busybox/loginutils/passwd.c	2006-09-26 17:41:00 UTC (rev 16229)
@@ -318,7 +318,7 @@
 	} else {
 		orig[0] = '\0';
 	}
-	cp = bb_askpass(0, "Enter the new password (minimum of 5, maximum of 8 characters).\n"
+	cp = bb_askpass(0, "Enter the new password (minimum of 5 characters).\n"
 	                   "Please use a combination of upper and lower case letters and numbers.\n"
 	                   "Enter new password: ");
 	if (!cp ) {

Modified: trunk/busybox/networking/udhcp/dhcpc.c
===================================================================
--- trunk/busybox/networking/udhcp/dhcpc.c	2006-09-26 16:31:01 UTC (rev 16228)
+++ trunk/busybox/networking/udhcp/dhcpc.c	2006-09-26 17:41:00 UTC (rev 16229)
@@ -53,6 +53,7 @@
 	.abort_if_no_lease = 0,
 	.foreground = 0,
 	.quit_after_lease = 0,
+	.release_on_quit = 0,
 	.background_if_no_lease = 0,
 	.interface = "eth0",
 	.pidfile = NULL,
@@ -169,6 +170,7 @@
 		{"now",		no_argument,		0, 'n'},
 		{"pidfile",	required_argument,	0, 'p'},
 		{"quit",	no_argument,		0, 'q'},
+		{"release",	no_argument,		0, 'R'},
 		{"request",	required_argument,	0, 'r'},
 		{"script",	required_argument,	0, 's'},
 		{"timeout",	required_argument,	0, 'T'},
@@ -180,7 +182,7 @@
 	/* get options */
 	while (1) {
 		int option_index = 0;
-		c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qr:s:T:t:v", arg_options, &option_index);
+		c = getopt_long(argc, argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:v", arg_options, &option_index);
 		if (c == -1) break;
 
 		switch (c) {
@@ -250,6 +252,9 @@
 		case 'q':
 			client_config.quit_after_lease = 1;
 			break;
+		case 'R':
+			client_config.release_on_quit = 1;
+			break;
 		case 'r':
 			requested_ip = inet_addr(optarg);
 			break;
@@ -495,8 +500,11 @@
 
 					state = BOUND;
 					change_mode(LISTEN_NONE);
-					if (client_config.quit_after_lease)
+					if (client_config.quit_after_lease) {
+						if (client_config.release_on_quit)
+							perform_release();
 						return 0;
+					}
 					if (!client_config.foreground)
 						client_background();
 
@@ -526,6 +534,8 @@
 				break;
 			case SIGTERM:
 				bb_info_msg("Received SIGTERM");
+				if (client_config.release_on_quit)
+					perform_release();
 				return 0;
 			}
 		} else if (retval == -1 && errno == EINTR) {

Modified: trunk/busybox/networking/udhcp/dhcpc.h
===================================================================
--- trunk/busybox/networking/udhcp/dhcpc.h	2006-09-26 16:31:01 UTC (rev 16228)
+++ trunk/busybox/networking/udhcp/dhcpc.h	2006-09-26 17:41:00 UTC (rev 16229)
@@ -19,6 +19,7 @@
 struct client_config_t {
 	char foreground;		/* Do not fork */
 	char quit_after_lease;		/* Quit after obtaining lease */
+	char release_on_quit;		/* perform release on quit */
 	char abort_if_no_lease;		/* Abort if no lease */
 	char background_if_no_lease;	/* Fork to background if no lease */
 	char *interface;		/* The name of the interface to use */

Modified: trunk/busybox/networking/udhcp/options.c
===================================================================
--- trunk/busybox/networking/udhcp/options.c	2006-09-26 16:31:01 UTC (rev 16228)
+++ trunk/busybox/networking/udhcp/options.c	2006-09-26 17:41:00 UTC (rev 16229)
@@ -42,8 +42,11 @@
 	{"dhcptype",	OPTION_U8,				0x35},
 	{"serverid",	OPTION_IP,				0x36},
 	{"message",	OPTION_STRING,				0x38},
+	{"vendorclass", OPTION_STRING,                          0x3C},
+	{"clientid",    OPTION_STRING,                          0x3D},
 	{"tftp",	OPTION_STRING,				0x42},
 	{"bootfile",	OPTION_STRING,				0x43},
+	{"userclass",   OPTION_STRING,                          0x4D},
 	{"",		0x00,				0x00}
 };
 

Modified: trunk/busybox/networking/udhcp/options.h
===================================================================
--- trunk/busybox/networking/udhcp/options.h	2006-09-26 16:31:01 UTC (rev 16228)
+++ trunk/busybox/networking/udhcp/options.h	2006-09-26 17:41:00 UTC (rev 16229)
@@ -23,7 +23,7 @@
 #define OPTION_LIST	0x20 /* There can be a list of 1 or more of these */
 
 struct dhcp_option {
-	char name[10];
+	char name[12];
 	char flags;
 	uint8_t code;
 };

Modified: trunk/busybox/shell/ash.c
===================================================================
--- trunk/busybox/shell/ash.c	2006-09-26 16:31:01 UTC (rev 16228)
+++ trunk/busybox/shell/ash.c	2006-09-26 17:41:00 UTC (rev 16229)
@@ -1384,6 +1384,13 @@
 
 #define NUMBUILTINS  (sizeof (builtincmd) / sizeof (struct builtincmd) )
 
+static const char *safe_applets[] = { 
+	"[", "test", "echo", "cat",
+	"ln", "cp", "touch", "mkdir", "rm",
+	"cut", "hexdump", "awk", "sort",
+	"find", "xargs", "ls", "dd",
+	"chown", "chmod"
+};
 
 
 struct cmdentry {
@@ -2034,6 +2041,19 @@
 static void setinteractive(int);
 static void exitshell(void) ATTRIBUTE_NORETURN;
 
+
+static int is_safe_applet(char *name)
+{
+	int n = sizeof(safe_applets) / sizeof(char *);
+	int i;
+	for (i = 0; i < n; i++)
+		if (strcmp(safe_applets[i], name) == 0)
+			return 1;
+
+	return 0;
+}
+
+
 /*
  * This routine is called when an error or an interrupt occurs in an
  * interactive shell and control is returned to the main command loop.
@@ -3681,6 +3701,7 @@
 	clearredir(1);
 	envp = environment();
 	if (strchr(argv[0], '/') != NULL
+		|| is_safe_applet(argv[0])
 #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
 		|| find_applet_by_name(argv[0])
 #endif
@@ -3723,6 +3744,18 @@
 tryexec(char *cmd, char **argv, char **envp)
 {
 	int repeated = 0;
+	struct BB_applet *a;
+	int argc = 0;
+	char **c;
+	
+	if(strchr(cmd, '/') == NULL && is_safe_applet(cmd) && (a = find_applet_by_name(cmd)) != NULL) {
+		c = argv;
+		while (*c != NULL) {
+			c++; argc++;
+		}
+		bb_applet_name = cmd;
+		exit(a->main(argc, argv));
+	}
 #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
 	if(find_applet_by_name(cmd) != NULL) {
 		/* re-exec ourselves with the new arguments */
@@ -3905,6 +3938,12 @@
 	}
 #endif
 
+	if (is_safe_applet(name)) {
+		entry->cmdtype = CMDNORMAL;
+		entry->u.index = -1;
+		return;
+	}
+
 	updatetbl = (path == pathval());
 	if (!updatetbl) {
 		act |= DO_ALTPATH;




More information about the busybox-cvs mailing list