On Sun, Nov 7, 2010 at 12:06 AM, Tito <[email protected]> wrote:
> /BUG: check should be done by GID, not by matching name!
> //1. find GROUP's GID
> //2. check that /etc/passwd doesn't have lines of the form
> //   user:pwd:uid:GID:...
> //3. bail out if at least one such line exists
>
> I think the check should not be done by gid as
> at creation time you could add the user to an
> existing group (eventually with no other occurences in /etc/passwd):
>
>>adduser prova --ingroup users
>>Adding user `prova' ...
>>Adding new user `prova' (1004) with group `users' ...
>>Creating home directory `/home/prova' ...
>
> that you don't want to be removed at user deletion time.

I don't understand how this is relevant to the alleged BUG
above.

>
> OTOH man adduser says:
>
> " By  default,  each  user  in  Debian GNU/Linux is given a corresponding
> group with the same name."

*By default*. But tools should work correctly on any valid /etc/passwd
+ /etc/group
combination.

> so checking by name seems the right thing to do,
> but maybe I'm missing something obvious
> (non Debian systems behave differently?)
> This could be demostrated by a little experiment:
>
>>adduser prova
>>Adding user `prova' ...
>>Adding new group `prova' (1006) ...
>>Adding new user `prova' (1004) with group `prova' ...
>
> now rename prova to aprova in /etc/group and /etc/gshadow and
>
>>deluser prova
>>Removing user `prova' ...
>>Warning: group `aprova' has no more members.
>>Done.
>
> and
>
>>grep aprova /etc/group
>>aprova:x:1006:
>
> so the group is removed by name.

Gosh. I'm not saying that it does not.


I am saying that "delgroup foo" (delgroup, not deluser)
should not check whether *user named foo* exists;
but should check that deleting group foo doesn't
leave users with "deleted" GIDs.

Example:

/etc/passwd
haldaemon:x:68:490:HAL daemon:/:/sbin/nologin
foo:x:496:1234::/:/sbin/nologin

/etc/group
foo:490:

What "standard" delgroup foo will do? I suspect it will
complain that haldaemon user's primary GID is 490
and therefore group foo can't be deleted.

If you remove haldaemon line from /etc/passwd,
delgroup foo will succeed despite the fact that _user_ foo exists.
Because in this example, _user_ foo and _group_ foo
are completely unrelated.

Our version gets this wrong, I think.

My machine has no native deluser/delgroup.
Can you test this example on your side?

-- 
vda
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to