mirror of
https://github.com/freebsd/freebsd-src
synced 2024-11-05 18:22:52 +00:00
Do not add an user to a group if the group is also the login group.
This commit is contained in:
parent
7ba57172c1
commit
8a368b34b0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=17598
1 changed files with 14 additions and 11 deletions
|
@ -32,7 +32,7 @@
|
||||||
#
|
#
|
||||||
# Email: Wolfram Schneider <wosch@cs.tu-berlin.de>
|
# Email: Wolfram Schneider <wosch@cs.tu-berlin.de>
|
||||||
#
|
#
|
||||||
# $Id: adduser.perl,v 1.11 1996/05/06 06:15:19 gclarkii Exp $
|
# $Id: adduser.perl,v 1.12 1996/08/13 21:50:51 wosch Exp $
|
||||||
#
|
#
|
||||||
|
|
||||||
# read variables
|
# read variables
|
||||||
|
@ -442,9 +442,9 @@ sub new_users_grplogin {
|
||||||
warn "Group does not exist!\a\n";
|
warn "Group does not exist!\a\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($groupname{$group_login})) {
|
#if (defined($groupname{$group_login})) {
|
||||||
&add_group($groupname{$group_login}, $name);
|
# &add_group($groupname{$group_login}, $name);
|
||||||
}
|
#}
|
||||||
|
|
||||||
return ($group_login, $group_uniq) if $group_login eq $name;
|
return ($group_login, $group_uniq) if $group_login eq $name;
|
||||||
return ($group_login, $group_login);
|
return ($group_login, $group_login);
|
||||||
|
@ -463,9 +463,9 @@ sub new_users_grplogin_batch {
|
||||||
$group_login = $gid{$group_login};
|
$group_login = $gid{$group_login};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($groupname{$group_login})) {
|
# if (defined($groupname{$group_login})) {
|
||||||
&add_group($groupname{$group_login}, $name);
|
# &add_group($groupname{$group_login}, $name);
|
||||||
}
|
# }
|
||||||
|
|
||||||
return $group_login
|
return $group_login
|
||||||
if defined($groupname{$group_login}) || $group_login eq $name;
|
if defined($groupname{$group_login}) || $group_login eq $name;
|
||||||
|
@ -507,7 +507,10 @@ sub new_users_groups_valid {
|
||||||
$e = $gid{$e};
|
$e = $gid{$e};
|
||||||
}
|
}
|
||||||
if (defined($groupname{$e})) {
|
if (defined($groupname{$e})) {
|
||||||
if (&add_group($groupname{$e}, $name)) {
|
if ($e eq $group_login) {
|
||||||
|
# do not add user to a group if this group
|
||||||
|
# is also the login group.
|
||||||
|
} elsif (&add_group($groupname{$e}, $name)) {
|
||||||
$new_groups .= "$e ";
|
$new_groups .= "$e ";
|
||||||
} else {
|
} else {
|
||||||
warn "$name is already member of group ``$e''\n";
|
warn "$name is already member of group ``$e''\n";
|
||||||
|
@ -566,10 +569,10 @@ sub new_users_group_update {
|
||||||
# Add *new* group
|
# Add *new* group
|
||||||
if (!defined($groupname{$group_login}) &&
|
if (!defined($groupname{$group_login}) &&
|
||||||
!defined($gid{$groupname{$group_login}})) {
|
!defined($gid{$groupname{$group_login}})) {
|
||||||
push(@group_backup, "$group_login:*:$g_id:$group_login");
|
push(@group_backup, "$group_login:*:$g_id:");
|
||||||
$groupname{$group_login} = $g_id;
|
$groupname{$group_login} = $g_id;
|
||||||
$gid{$g_id} = $group_login;
|
$gid{$g_id} = $group_login;
|
||||||
$groupmembers{$g_id} = $group_login;
|
# $groupmembers{$g_id} = $group_login;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($new_groups || defined($groupname{$group_login}) ||
|
if ($new_groups || defined($groupname{$group_login}) ||
|
||||||
|
@ -583,7 +586,7 @@ sub new_users_group_update {
|
||||||
}
|
}
|
||||||
&append_file($group, @a);
|
&append_file($group, @a);
|
||||||
} else {
|
} else {
|
||||||
&append_file($group, "$group_login:*:$g_id:$group_login");
|
&append_file($group, "$group_login:*:$g_id:");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue