aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-05-14 00:23:34 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-05-14 00:23:34 +0200
commit1b0a93edb93a93c30d7fbb35571f109ddf8a67a2 (patch)
tree73326fed28844ea23c13d4bbfe7abdd7b64bd270
parent810b7161dcace56709038bf0cad93c925669c3b8 (diff)
downloadbusybox-w32-1b0a93edb93a93c30d7fbb35571f109ddf8a67a2.tar.gz
busybox-w32-1b0a93edb93a93c30d7fbb35571f109ddf8a67a2.tar.bz2
busybox-w32-1b0a93edb93a93c30d7fbb35571f109ddf8a67a2.zip
adduser/addgroup: make system id range configurable.
By Tito (farmatito AT tiscali.it). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--loginutils/Config.in16
-rw-r--r--loginutils/addgroup.c12
-rw-r--r--loginutils/adduser.c12
3 files changed, 32 insertions, 8 deletions
diff --git a/loginutils/Config.in b/loginutils/Config.in
index 9430bfa09..e11503665 100644
--- a/loginutils/Config.in
+++ b/loginutils/Config.in
@@ -152,6 +152,22 @@ config FEATURE_ADDUSER_LONG_OPTIONS
152 help 152 help
153 Support long options for the adduser applet. 153 Support long options for the adduser applet.
154 154
155config FIRST_SYSTEM_ID
156 int "First valid system uid or gid for adduser and addgroup"
157 depends on ADDUSER || ADDGROUP
158 range 0 64900
159 default 100
160 help
161 First valid system uid or gid for adduser and addgroup
162
163config LAST_SYSTEM_ID
164 int "Last valid system uid or gid for adduser and addgroup"
165 depends on ADDUSER || ADDGROUP
166 range 0 64900
167 default 999
168 help
169 Last valid system uid or gid for adduser and addgroup
170
155config DELUSER 171config DELUSER
156 bool "deluser" 172 bool "deluser"
157 default n 173 default n
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index cb839290d..dc60788e0 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -11,6 +11,10 @@
11 */ 11 */
12#include "libbb.h" 12#include "libbb.h"
13 13
14#if CONFIG_LAST_SYSTEM_ID < CONFIG_FIRST_SYSTEM_ID
15#error Bad LAST_SYSTEM_ID or FIRST_SYSTEM_ID in .config
16#endif
17
14#define OPT_GID (1 << 0) 18#define OPT_GID (1 << 0)
15#define OPT_SYSTEM_ACCOUNT (1 << 1) 19#define OPT_SYSTEM_ACCOUNT (1 << 1)
16 20
@@ -30,11 +34,11 @@ static void xgroup_study(struct group *g)
30 /* gid values is set to [0, INT_MAX] */ 34 /* gid values is set to [0, INT_MAX] */
31 if (!(option_mask32 & OPT_GID)) { 35 if (!(option_mask32 & OPT_GID)) {
32 if (option_mask32 & OPT_SYSTEM_ACCOUNT) { 36 if (option_mask32 & OPT_SYSTEM_ACCOUNT) {
33 g->gr_gid = 100; /* FIRST_SYSTEM_GID */ 37 g->gr_gid = CONFIG_FIRST_SYSTEM_ID;
34 max = 999; /* LAST_SYSTEM_GID */ 38 max = CONFIG_LAST_SYSTEM_ID;
35 } else { 39 } else {
36 g->gr_gid = 1000; /* FIRST_GID */ 40 g->gr_gid = CONFIG_LAST_SYSTEM_ID + 1;
37 max = 64999; /* LAST_GID */ 41 max = 64999;
38 } 42 }
39 } 43 }
40 /* Check if the desired gid is free 44 /* Check if the desired gid is free
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index a399d9e4c..00232375b 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -9,6 +9,10 @@
9 */ 9 */
10#include "libbb.h" 10#include "libbb.h"
11 11
12#if CONFIG_LAST_SYSTEM_ID < CONFIG_FIRST_SYSTEM_ID
13#error Bad LAST_SYSTEM_ID or FIRST_SYSTEM_ID in .config
14#endif
15
12/* #define OPT_HOME (1 << 0) */ /* unused */ 16/* #define OPT_HOME (1 << 0) */ /* unused */
13/* #define OPT_GECOS (1 << 1) */ /* unused */ 17/* #define OPT_GECOS (1 << 1) */ /* unused */
14#define OPT_SHELL (1 << 2) 18#define OPT_SHELL (1 << 2)
@@ -32,11 +36,11 @@ static void passwd_study(struct passwd *p)
32 36
33 if (!(option_mask32 & OPT_UID)) { 37 if (!(option_mask32 & OPT_UID)) {
34 if (option_mask32 & OPT_SYSTEM_ACCOUNT) { 38 if (option_mask32 & OPT_SYSTEM_ACCOUNT) {
35 p->pw_uid = 100; /* FIRST_SYSTEM_UID */ 39 p->pw_uid = CONFIG_FIRST_SYSTEM_ID;
36 max = 999; /* LAST_SYSTEM_UID */ 40 max = CONFIG_LAST_SYSTEM_ID;
37 } else { 41 } else {
38 p->pw_uid = 1000; /* FIRST_UID */ 42 p->pw_uid = CONFIG_LAST_SYSTEM_ID + 1;
39 max = 64999; /* LAST_UID */ 43 max = 64999;
40 } 44 }
41 } 45 }
42 /* check for a free uid (and maybe gid) */ 46 /* check for a free uid (and maybe gid) */