[pve-devel] applied: [PATCH access-control] token: avoid undef warning if no tokens are configured

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Apr 15 17:16:22 CEST 2020


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.lamprecht at 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





More information about the pve-devel mailing list