Hi, Denys maybe this patch slipped through ? Ciao, Tito
On Sunday 22 December 2013 15:22:41 Tito wrote: > On Sunday 22 December 2013 12:05:04 you wrote: > > Hi Tito ! > > > > >Wew could also add a config option as we already have > > > > > > (100) First valid system uid or gid for adduser and addgroup > > > (999) Last valid system uid or gid for adduser and addgroup > > >+ (60000) Last valid uid for adduser and addgroup > > > > Would be better to have separate system UID and GID values as > > user and group id ranges may vary. I know this increases the > > number of config options, but having only single system values > > for user and group may not match everybody need. Think of system > > group id range of 50..99, using group 100 and higher for user > > groups, where user numbers need a bigger space and use 100..999 > > as system range and 1000 onwards for normal users. > > > > ... but assigning IDs to user and groups is a philosophical > > problem, which could be done in so many ways. As far as I know > > there exist no regulatory (yet) on how user and group values are > > assigned. It's the admins property to assign appropriate values > > > > >The attached patch changes adduser.c, addgroup.c > > >and Config.src to set and use CONFIG_LAST_ID. > > > > Looks fine on a quick look, but didn't do deep analyze. > > > > > > -- > > Harald > > > Hi, > looks good but was not so good as some last moment > changes made adduser segfault (my shame!!), attached a corrected > and improved version that actually works with better > menuconfig logic. > At the moment I will stick with a single UID/GID value > as on my debian box the values are the same, probably due to the > policy to give a corresponding group with the same name > to every user. > If Denys wants separate values they could be easily added. > > Ciao, > Tito > > > # Min/max values for automatic uid selection in useradd > # > UID_MIN 1000 > UID_MAX 60000 > # System accounts > #SYS_UID_MIN 100 > #SYS_UID_MAX 999 > > # > # Min/max values for automatic gid selection in groupadd > # > GID_MIN 1000 > GID_MAX 60000 > # System accounts > #SYS_GID_MIN 100 > #SYS_GID_MAX 999 > > > --- loginutils/adduser.c.orig 2013-12-21 12:52:52.000000000 +0100 > +++ loginutils/adduser.c 2013-12-22 14:42:03.256088649 +0100 > @@ -26,6 +26,10 @@ > #if CONFIG_LAST_SYSTEM_ID < CONFIG_FIRST_SYSTEM_ID > #error Bad LAST_SYSTEM_ID or FIRST_SYSTEM_ID in .config > #endif > +#if CONFIG_LAST_ID < CONFIG_LAST_SYSTEM_ID > +#error Bad LAST_ID or LAST_SYSTEM_ID in .config > +#endif > + > > /* #define OPT_HOME (1 << 0) */ /* unused */ > /* #define OPT_GECOS (1 << 1) */ /* unused */ > @@ -36,12 +40,11 @@ > #define OPT_DONT_MAKE_HOME (1 << 6) > #define OPT_UID (1 << 7) > > -/* We assume UID_T_MAX == INT_MAX */ > /* remix */ > /* recoded such that the uid may be passed in *p */ > static void passwd_study(struct passwd *p) > { > - int max = UINT_MAX; > + int max = CONFIG_LAST_ID; > > if (getpwnam(p->pw_name)) { > bb_error_msg_and_die("%s '%s' in use", "user", p->pw_name); > @@ -54,7 +57,6 @@ static void passwd_study(struct passwd * > max = CONFIG_LAST_SYSTEM_ID; > } else { > p->pw_uid = CONFIG_LAST_SYSTEM_ID + 1; > - max = 64999; > } > } > /* check for a free uid (and maybe gid) */ > @@ -147,6 +149,7 @@ int adduser_main(int argc UNUSED_PARAM, > const char *usegroup = NULL; > char *p; > unsigned opts; > + char *uid; > > #if ENABLE_FEATURE_ADDUSER_LONG_OPTIONS > applet_long_options = adduser_longopts; > @@ -164,16 +167,11 @@ int adduser_main(int argc UNUSED_PARAM, > > /* at least one and at most two non-option args */ > /* disable interactive passwd for system accounts */ > - opt_complementary = "-1:?2:SD:u+"; > - if (sizeof(pw.pw_uid) == sizeof(int)) { > - opts = getopt32(argv, "h:g:s:G:DSHu:", &pw.pw_dir, > &pw.pw_gecos, &pw.pw_shell, &usegroup, &pw.pw_uid); > - } else { > - unsigned uid; > - opts = getopt32(argv, "h:g:s:G:DSHu:", &pw.pw_dir, > &pw.pw_gecos, &pw.pw_shell, &usegroup, &uid); > - if (opts & OPT_UID) { > - pw.pw_uid = uid; > - } > - } > + opt_complementary = "-1:?2:SD"; > + opts = getopt32(argv, "h:g:s:G:DSHu:", &pw.pw_dir, &pw.pw_gecos, > &pw.pw_shell, &usegroup, &uid); > + if (opts & OPT_UID) > + pw.pw_uid = xatou_range(uid, 0, CONFIG_LAST_ID); > + > argv += optind; > pw.pw_name = argv[0]; > > --- loginutils/addgroup.c.orig 2013-12-21 19:08:38.000000000 +0100 > +++ loginutils/addgroup.c 2013-12-22 14:54:07.553056897 +0100 > @@ -22,14 +22,16 @@ > #if CONFIG_LAST_SYSTEM_ID < CONFIG_FIRST_SYSTEM_ID > #error Bad LAST_SYSTEM_ID or FIRST_SYSTEM_ID in .config > #endif > +#if CONFIG_LAST_ID < CONFIG_LAST_SYSTEM_ID > +#error Bad LAST_ID or LAST_SYSTEM_ID in .config > +#endif > > #define OPT_GID (1 << 0) > #define OPT_SYSTEM_ACCOUNT (1 << 1) > > -/* We assume GID_T_MAX == INT_MAX */ > static void xgroup_study(struct group *g) > { > - unsigned max = INT_MAX; > + unsigned max = CONFIG_LAST_ID; > > /* Make sure gr_name is unused */ > if (getgrnam(g->gr_name)) { > @@ -46,7 +48,6 @@ static void xgroup_study(struct group *g > max = CONFIG_LAST_SYSTEM_ID; > } else { > g->gr_gid = CONFIG_LAST_SYSTEM_ID + 1; > - max = 64999; > } > } > /* Check if the desired gid is free > @@ -125,7 +126,7 @@ int addgroup_main(int argc, char **argv) > int addgroup_main(int argc UNUSED_PARAM, char **argv) > { > unsigned opts; > - unsigned gid = 0; > + char *gid; > > /* need to be root */ > if (geteuid()) { > @@ -139,7 +140,7 @@ int addgroup_main(int argc UNUSED_PARAM, > * addgroup -g num group > * addgroup user group > * Check for min, max and missing args */ > - opt_complementary = "-1:?2:g+"; > + opt_complementary = "-1:?2"; > opts = getopt32(argv, "g:S", &gid); > /* move past the commandline options */ > argv += optind; > @@ -175,7 +176,7 @@ int addgroup_main(int argc UNUSED_PARAM, > #endif /* ENABLE_FEATURE_ADDUSER_TO_GROUP */ > { > die_if_bad_username(argv[0]); > - new_group(argv[0], gid); > + new_group(argv[0], (opts & OPT_GID) ? xatou_range(gid, 0, > CONFIG_LAST_ID) : 0); > } > /* Reached only on success */ > return EXIT_SUCCESS; > --- loginutils/Config.src.orig 2013-06-02 13:56:34.000000000 +0200 > +++ loginutils/Config.src 2013-12-22 14:24:03.843335468 +0100 > @@ -118,10 +118,17 @@ config FEATURE_CHECK_NAMES > For compatibility with Samba machine accounts "$" is also supported > at the end of the user or group name. > > +config LAST_ID > + int "Last valid uid or gid for adduser and addgroup" > + depends on ADDUSER || ADDGROUP > + default 60000 > + help > + Last valid uid or gid for adduser and addgroup > + > config FIRST_SYSTEM_ID > int "First valid system uid or gid for adduser and addgroup" > depends on ADDUSER || ADDGROUP > - range 0 64900 > + range 0 LAST_ID > default 100 > help > First valid system uid or gid for adduser and addgroup > @@ -129,7 +136,7 @@ config FIRST_SYSTEM_ID > config LAST_SYSTEM_ID > int "Last valid system uid or gid for adduser and addgroup" > depends on ADDUSER || ADDGROUP > - range 0 64900 > + range FIRST_SYSTEM_ID LAST_ID > default 999 > help > Last valid system uid or gid for adduser and addgroup > > > _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox