]> git.proxmox.com Git - pve-container.git/commitdiff
pct: fix edge case for 'pct push' with root uid/gid
authorOguz Bektas <o.bektas@proxmox.com>
Tue, 6 Apr 2021 11:56:16 +0000 (13:56 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 6 Apr 2021 13:19:59 +0000 (15:19 +0200)
we should check if the variable is defined in the end (because root
uid:gid is 0:0, this causes perl to get confused and die, eventhough the
uid:gid was obtained correctly)

reported here:
https://forum.proxmox.com/threads/pct-push-fails-to-get-uid-gid.87065/

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/CLI/pct.pm

index 69faf8d01f8e063b7f8e9075434542426b056907..6b63915a095aff72a2d43d7ffbbcf9bd01239c83 100755 (executable)
@@ -422,14 +422,16 @@ sub create_file {
        if ($user =~ /^\d+$/) {
            $uid = int($user);
        } else {
-           $uid = getpwnam($user) or die "failed to get uid for: $user\n"
+           $uid = getpwnam($user);
+           die "failed to get uid for: $user\n" if !defined($uid);
        }
     }
     if (defined($group)) {
        if ($group =~ /^\d+$/) {
            $gid = int($group);
        } else {
-           $gid = getgrnam($group) or die "failed to get gid for: $group\n"
+           $gid = getgrnam($group);
+           die "failed to get gid for: $group\n" if !defined($gid);
        }
     }