X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=loginutils%2Faddgroup.c;h=215e4a9e0ee74817cb6e7c99fba00f22efe4b80c;hb=2d3253d1f93fbffb62c7521d41eed0102747d949;hp=cb839290d6115a9a836f21fd20b87388090c90ff;hpb=c2931aa2df2ddc6a627f3c40eb1cf5c221067092;p=oweals%2Fbusybox.git diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c index cb839290d..215e4a9e0 100644 --- a/loginutils/addgroup.c +++ b/loginutils/addgroup.c @@ -11,6 +11,10 @@ */ #include "libbb.h" +#if CONFIG_LAST_SYSTEM_ID < CONFIG_FIRST_SYSTEM_ID +#error Bad LAST_SYSTEM_ID or FIRST_SYSTEM_ID in .config +#endif + #define OPT_GID (1 << 0) #define OPT_SYSTEM_ACCOUNT (1 << 1) @@ -26,15 +30,15 @@ static void xgroup_study(struct group *g) } /* if a specific gid is requested, the --system switch and */ - /* min and max values are overriden, and the range of valid */ + /* min and max values are overridden, and the range of valid */ /* 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; + max = CONFIG_LAST_SYSTEM_ID; } else { - g->gr_gid = 1000; /* FIRST_GID */ - max = 64999; /* LAST_GID */ + g->gr_gid = CONFIG_LAST_SYSTEM_ID + 1; + max = 64999; } } /* Check if the desired gid is free @@ -75,7 +79,22 @@ static void new_group(char *group, gid_t gid) if (ENABLE_FEATURE_CLEAN_UP) free(p); #if ENABLE_FEATURE_SHADOWPASSWDS - /* Ignore errors: if file is missing we suppose admin doesn't want it */ + /* /etc/gshadow fields: + * 1. Group name. + * 2. Encrypted password. + * If set, non-members of the group can join the group + * by typing the password for that group using the newgrp command. + * If the value is of this field ! then no user is allowed + * to access the group using the newgrp command. A value of !! + * is treated the same as a value of ! only it indicates + * that a password has never been set before. If the value is null, + * only group members can log into the group. + * 3. Group administrators (comma delimited list). + * Group members listed here can add or remove group members + * using the gpasswd command. + * 4. Group members (comma delimited list). + */ + /* Ignore errors: if file is missing we assume admin doesn't want it */ update_passwd(bb_path_gshadow_file, group, "!::", NULL); #endif }