]> git.proxmox.com Git - qemu-server.git/commitdiff
cloudinit: hide password on the api
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 15 Mar 2018 14:36:50 +0000 (15:36 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 16 Mar 2018 09:03:57 +0000 (10:03 +0100)
since password is easily decrypted, hide it on the api
if someone needs it, they can get it directly from the
config

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PVE/API2/Qemu.pm

index b1c689697b090b7d1f53f83b6c9d97415961a197..06ce00c0d1e4d0e0597c19cf0c2c3b31e1edc0c1 100644 (file)
@@ -807,6 +807,11 @@ __PACKAGE__->register_method({
 
        delete $conf->{pending};
 
+       # hide cloudinit password
+       if ($conf->{cipassword}) {
+           $conf->{cipassword} = '**********';
+       }
+
        return $conf;
     }});
 
@@ -871,6 +876,13 @@ __PACKAGE__->register_method({
            $item->{value} = $conf->{$opt} if defined($conf->{$opt});
            $item->{pending} = $conf->{pending}->{$opt} if defined($conf->{pending}->{$opt});
            $item->{delete} = ($pending_delete_hash->{$opt} ? 2 : 1) if exists $pending_delete_hash->{$opt};
+
+           # hide cloudinit password
+           if ($opt eq 'cipassword') {
+               $item->{value} = '**********' if defined($item->{value});
+               # the trailing space so that the pending string is different
+               $item->{pending} = '********** ' if defined($item->{pending});
+           }
            push @$res, $item;
        }
 
@@ -880,6 +892,11 @@ __PACKAGE__->register_method({
            next if defined($conf->{$opt});
            my $item = { key => $opt };
            $item->{pending} = $conf->{pending}->{$opt};
+
+           # hide cloudinit password
+           if ($opt eq 'cipassword') {
+               $item->{pending} = '**********' if defined($item->{pending});
+           }
            push @$res, $item;
        }