aboutsummaryrefslogtreecommitdiff
path: root/toys/pending/groupadd.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-08-18 19:10:45 -0500
committerRob Landley <rob@landley.net>2014-08-18 19:10:45 -0500
commita8bee46cfebcf1ae9c3749b820c483054be81295 (patch)
treed6286350a097b5a4829c0817a7228d61d5b45946 /toys/pending/groupadd.c
parent5cf4bd1922e6a87b5d0e14403e55cce2ab74bb12 (diff)
downloadtoybox-a8bee46cfebcf1ae9c3749b820c483054be81295.tar.gz
Cleanups on useradd/groupadd/groupdel, and put TOYBOX_UID_SYS and TOYBOX_UID_USR in the top level Config.
Diffstat (limited to 'toys/pending/groupadd.c')
-rw-r--r--toys/pending/groupadd.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/toys/pending/groupadd.c b/toys/pending/groupadd.c
index c19e1eef..04c31ee5 100644
--- a/toys/pending/groupadd.c
+++ b/toys/pending/groupadd.c
@@ -38,25 +38,15 @@ GLOBALS(
static void new_group()
{
char *entry = NULL;
- int max = INT_MAX;
if (toys.optflags & FLAG_g) {
if (TT.gid > INT_MAX) error_exit("gid should be less than '%d' ", INT_MAX);
if (getgrgid(TT.gid)) error_exit("group '%ld' is in use", TT.gid);
} else {
- if (toys.optflags & FLAG_S) {
- TT.gid = SYS_FIRST_ID;
- max = SYS_LAST_ID;
- } else {
- TT.gid = SYS_LAST_ID + 1; //i.e. starting from 1000
- max = 60000; // as per config file on Linux desktop
- }
+ if (toys.optflags & FLAG_S) TT.gid = CFG_TOYBOX_UID_SYS;
+ else TT.gid = CFG_TOYBOX_UID_USR;
//find unused gid
- while (TT.gid <= max) {
- if (!getgrgid(TT.gid)) break;
- if (TT.gid == max) error_exit("no more free gids left");
- TT.gid++;
- }
+ while (getgrgid(TT.gid)) TT.gid++;
}
entry = xmprintf("%s:%s:%d:", *toys.optargs, "x", TT.gid);