From a8bee46cfebcf1ae9c3749b820c483054be81295 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 18 Aug 2014 19:10:45 -0500 Subject: Cleanups on useradd/groupadd/groupdel, and put TOYBOX_UID_SYS and TOYBOX_UID_USR in the top level Config. --- toys/pending/groupadd.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'toys/pending/groupadd.c') 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); -- cgit v1.2.3