[PATCH] make system uid/gid range configurable

Tito farmatito at tiscali.it
Tue May 5 21:22:17 UTC 2009


Hi,
this patch makes FIRST_SYSTEM_UID, LAST_SYSTEM_UID, FIRST_SYSTEM_GID, LAST_SYSTEM_GID
used by adduser and addgroup --system configurable to allow different values
for exotic systems like the Android Dev 1 Phone.
The patch was tested a little for the Config part and compile tested for adduser and addgroup.
The Config system gurus maybe could take a look at the relevant Config part as
i did it by intuition ;-) (was not able to find docs about it....).

Ciao,
TIto

--- busybox.orig/loginutils/Config.in	2009-04-23 14:54:09.000000000 +0200
+++ busybox/loginutils/Config.in	2009-05-05 21:51:15.000000000 +0200
@@ -152,6 +152,22 @@
 	help
 	  Support long options for the adduser applet.
 
+config FIRST_SYSTEM_ID
+	int "First valid system uid or gid for adduser and addgroup"
+	depends on ADDUSER || ADDGROUP
+	range 0 LAST_SYSTEM_ID
+	default 100
+	help
+	  First valid system uid or gid for adduser and addgroup
+
+config LAST_SYSTEM_ID
+	int "Last  valid system uid or gid for adduser and addgroup"
+	depends on ADDUSER || ADDGROUP
+	range FIRST_SYSTEM_ID 64999
+	default 999
+	help
+	  Last valid system uid or gid for adduser and addgroup
+
 config DELUSER
 	bool "deluser"
 	default n
--- busybox.orig/loginutils/adduser.c	2009-04-23 14:54:09.000000000 +0200
+++ busybox/loginutils/adduser.c	2009-05-05 21:56:57.000000000 +0200
@@ -32,10 +32,10 @@
 
 	if (!(option_mask32 & OPT_UID)) {
 		if (option_mask32 & OPT_SYSTEM_ACCOUNT) {
-			p->pw_uid = 100; /* FIRST_SYSTEM_UID */
-			max = 999;       /* LAST_SYSTEM_UID */
+			p->pw_uid = CONFIG_FIRST_SYSTEM_ID; /* FIRST_SYSTEM_UID */
+			max = CONFIG_LAST_SYSTEM_ID;       /* LAST_SYSTEM_UID */
 		} else {
-			p->pw_uid = 1000; /* FIRST_UID */
+			p->pw_uid = CONFIG_LAST_SYSTEM_ID + 1; /* FIRST_UID */
 			max = 64999;      /* LAST_UID */
 		}
 	}
--- busybox.orig/loginutils/addgroup.c	2009-04-23 14:54:09.000000000 +0200
+++ busybox/loginutils/addgroup.c	2009-05-05 21:57:17.000000000 +0200
@@ -30,10 +30,10 @@
 	/* gid values is set to [0, INT_MAX] */
 	if (!(option_mask32 & OPT_GID)) {
 		if (option_mask32 & OPT_SYSTEM_ACCOUNT) {
-			g->gr_gid = 100; /* FIRST_SYSTEM_GID */
-			max = 999;       /* LAST_SYSTEM_GID */
+			g->gr_gid = CONFIG_FIRST_SYSTEM_ID; /* FIRST_SYSTEM_GID */
+			max = CONFIG_LAST_SYSTEM_ID;       /* LAST_SYSTEM_GID */
 		} else {
-			g->gr_gid = 1000; /* FIRST_GID */
+			g->gr_gid = CONFIG_LAST_SYSTEM_ID + 1; /* FIRST_GID */
 			max = 64999;      /* LAST_GID */
 		}
 	}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: system_id_range.patch
Type: text/x-diff
Size: 1990 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20090505/a9924a5e/attachment.bin>


More information about the busybox mailing list