From 856c101e97b1ba45e87a33f44e678f6b3f186e34 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 15 Apr 2020 17:13:59 +0200 Subject: [PATCH] token: avoid undef warning if no tokens are configured 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 --- 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 = {}; - my @lines = split(/\n/, $raw); + return $parsed if !defined($raw); + my @lines = split(/\n/, $raw); foreach my $line (@lines) { next if $line =~ m/^\s*$/; -- 2.39.2