On Monday 08 November 2010 00:50:01 you wrote:
> On Monday 08 November 2010 00:42, Tito wrote:
> > > > I think I can demostrate it does:
> > > >
> > > > /etc/passwd:prova:x:1004:1006:,,,:/home/prova:/bin/bash
> > > > /etc/passwd:prova2:x:1005:1006:,,,:/home/prova2:/bin/bash
> > > > /etc/group:prova:x:1006:
> > >
> > > In order to check my theory, you should add (say, by hand)
> > > another line to /etc/group:
> > >
> > > prova2:x:1234:
> > >
> > > and _then_ run "deluser prova2".
> > >
> > >
> > > > Now let's remove user prova2:
> > > >
> > > > deluser prova2
> > > > Removing user `prova2' ...
> > > > Warning: group `prova' has no more members.
> > > > Done.
> > > >
> > > > And check:
> > > >
> > > > /etc/passwd:prova:x:1004:1006:,,,:/home/prova:/bin/bash
> > > > /etc/group:prova:x:1006:
> > > >
> > > > group was not removed as not matching username.
> > >
> > > I think that group was not removed because another user
> > > (prova2) exists who has primary GID=<primary GID of prova2>.
> > >
> > > Can you repeat the experiment, but with artificially added
> > > prova2 group, as described above?
> >
> >
> > Hi,
> > so here we go:
> >
> > adduser prova
> > Adding user `prova' ...
> > Adding new group `prova' (1006) ...
> > Adding new user `prova' (1004) with group `prova' ...
> > adduser prova2 --ingroup prova
> > Adding user `prova2' ...
> > Adding new user `prova2' (1005) with group `prova' ...
> > echo "prova2:x:1234:" >> /etc/group
> >
> > grep prova /etc/passwd /etc/group
> > /etc/passwd:prova:x:1004:1006:,,,:/home/prova:/bin/bash
> > /etc/passwd:prova2:x:1005:1006:,,,:/home/prova2:/bin/bash
> > /etc/group:prova:x:1006:
> > /etc/group:prova2:x:1234:
> >
> > deluser prova2
> > Removing user `prova2' ...
> > Warning: group `prova' has no more members.
> > Done.
> >
> > grep prova /etc/passwd /etc/group
> > /etc/passwd:prova:x:1004:1006:,,,:/home/prova:/bin/bash
> > /etc/group:prova:x:1006:
> >
> > Looks to me it is removed by name
>
> Ok, you are right about this.
> I am still puzzled why "Warning: group `prova' has no more members"
> message appears.
>
> Can you do another experiment: as above, but delete user prova's
> record in /etc/passwd by hand:
>
> adduser prova
> adduser prova2 --ingroup prova
> echo "prova2:x:1234:" >> /etc/group
> sed '/^prova:/d' -i /etc/passwd
>
> grep prova /etc/passwd /etc/group
>
> deluser prova2
>
> grep prova /etc/passwd /etc/group
>
>
Here some interesting stuff from man userdel
DESCRIPTION
userdel is a low level utility for removing users. On Debian,
administrators should usually use deluser(8) instead.
If USERGROUPS_ENAB is defined to yes in /etc/login.defs, userdel will
delete the group with the same name as the user. To avoid
inconsistencies in the passwd and group databases, userdel will check
that this group is not used as a primary group for another user, and
will just warn without deleting the user otherwise. The -f option can
force the deletion of this group.
On debian deluser is a perl script that calls userdel.
The "Warning: group `prova' has no more members"
could be found in this perl script and looks
as it is there just for verbosity.
s_printf (gtx("Removing user `%s' ...\n"),$user);
my @members = get_group_members($maingroup);
if (@members == 0) {
s_printf (gtx("Warning: group `%s' has no more members.\n"),
$maingroup);
}
my $userdel = &which('userdel');
&systemcall($userdel, $user);
Ciao,
Tito
P.S.: going to bed now, more on this tomorrow.
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox