Initially the config may not even exist, and so the first token
create would give one then a ugly warning like:
> Use of uninitialized value $raw in split at ..

Handle that case, empty config (where we get '') was fine already, so
explicitly check for definedness, not truthiness.

Signed-off-by: Thomas Lamprecht <t.lampre...@proxmox.com>
---
 PVE/TokenConfig.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/PVE/TokenConfig.pm b/PVE/TokenConfig.pm
index 94d87e5..cfc60cc 100644
--- a/PVE/TokenConfig.pm
+++ b/PVE/TokenConfig.pm
@@ -12,8 +12,9 @@ my $parse_token_cfg = sub {
     my ($filename, $raw) = @_;
 
     my $parsed = {};
+    return $parsed if !defined($raw);
+
     my @lines = split(/\n/, $raw);
-
     foreach my $line (@lines) {
        next if $line =~ m/^\s*$/;
 
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to