On 2023/05/19 10:24:58 -0600, Todd C. Miller <[email protected]> wrote:
> If /etc/usermgmt.conf has a line like:
> 
>       group   =uid
> 
> where a new user's group ID in the passwd file is the same as their
> user ID, remove that group when the user is removed.  The group is
> only removed if it matches the login name, has a gid that matches
> the user's uid, and has no other members.
> 
> This makes our userdel(8) behave more like the version on other
> systems.
> 
> Opinions?  This is something that has always bothered me and can
> result in uid/gid mismatches if you remove a user, then re-add them
> without removing the login group first.

I have been bitten by this too and later been (pleasently) surprised
when found that on other systems removing a users removes the group
too.  It makes sense to me.

> Thoughts or strong opinions?

fwiw i like the change, ok for me.

However I never did anything "crazy" with usermgmt.conf(5) so don't
know if this could break existing setups, althought I highly doubt:
the worst could be getting some errors from groupdel(8) due to an
already deleted group.

As Aisha pointed out, pkg_delete hints could be updated too.

one minor style nit below, hope you'll excuse my nitpicking.

> [...]
> @@ -1366,6 +1366,15 @@ rm_user_from_groups(char *login_name)
>                       warnx("Malformed entry `%s'. Skipping", buf);
>                       continue;
>               }
> +             if (rm_login_group && strncmp(buf, login_name, login_len) == 0
> +                 && buf[login_len] == ':') {
> +                     /* remove login group if empty or user is only member */
> +                     if (*cp == '\n')
> +                             continue;
> +                     if (strncmp(cp, login_name, login_len) == 0 && 
> +                         cp [login_len] == '\n')
                            ^^^^
extra space

> +                             continue;
> +             }

Reply via email to