forked from josch/mmdebstrap
use $username for subgid check
/etc/subgid contains a mapping of user names (not group names) to group ids as defined in man subgid.
This commit is contained in:
parent
1f15194a6e
commit
374ae3dc99
1 changed files with 5 additions and 7 deletions
12
mmdebstrap
12
mmdebstrap
|
@ -421,8 +421,6 @@ sub read_subuid_subgid() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $groupname = getgrgid $REAL_GROUP_ID;
|
|
||||||
|
|
||||||
if (!-e "/etc/subgid") {
|
if (!-e "/etc/subgid") {
|
||||||
warning "/etc/subgid doesn't exist";
|
warning "/etc/subgid doesn't exist";
|
||||||
return;
|
return;
|
||||||
|
@ -436,25 +434,25 @@ sub read_subuid_subgid() {
|
||||||
or error "cannot open /etc/subgid for reading: $!";
|
or error "cannot open /etc/subgid for reading: $!";
|
||||||
while (my $line = <$fh>) {
|
while (my $line = <$fh>) {
|
||||||
($n, $subid, $num_subid) = split(/:/, $line, 3);
|
($n, $subid, $num_subid) = split(/:/, $line, 3);
|
||||||
last if ($n eq $groupname);
|
last if ($n eq $username);
|
||||||
}
|
}
|
||||||
close $fh;
|
close $fh;
|
||||||
if (!length $subid) {
|
if (!length $subid) {
|
||||||
warning "/etc/subgid is empty";
|
warning "/etc/subgid is empty";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($n ne $groupname) {
|
if ($n ne $username) {
|
||||||
warning "no entry in /etc/subgid for $groupname";
|
warning "no entry in /etc/subgid for $username";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
push @result, ["g", 0, $subid, $num_subid];
|
push @result, ["g", 0, $subid, $num_subid];
|
||||||
|
|
||||||
if (scalar(@result) < 2) {
|
if (scalar(@result) < 2) {
|
||||||
warning "/etc/subgid does not contain an entry for $groupname";
|
warning "/etc/subgid does not contain an entry for $username";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (scalar(@result) > 2) {
|
if (scalar(@result) > 2) {
|
||||||
warning "/etc/subgid contains multiple entries for $groupname";
|
warning "/etc/subgid contains multiple entries for $username";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue