]> git.proxmox.com Git - pve-access-control.git/blobdiff - PVE/Auth/PVE.pm
improve parse_user_config, parse_shadow_config
[pve-access-control.git] / PVE / Auth / PVE.pm
index 7f771fafde56c74e4241ce73f99dcdd1e5177f0f..71479979eea163f47787f9d2e96fe0d869121f55 100755 (executable)
@@ -1,6 +1,8 @@
 package PVE::Auth::PVE;
 
 use strict;
+use warnings;
+
 use PVE::Auth::Plugin;
 use PVE::Cluster qw(cfs_register_file cfs_read_file cfs_write_file cfs_lock_file);
 
@@ -17,11 +19,9 @@ sub parse_shadow_passwd {
 
     my $shadow = {};
 
-    while ($raw && $raw =~ s/^(.*?)(\n|$)//) {
+    while ($raw =~ /^\s*(.+?)\s*$/gm) {
        my $line = $1;
 
-       next if $line =~ m/^\s*$/; # skip empty lines
-
        if ($line !~ m/^\S+:\S+:$/) {
            warn "pve shadow password: ignore invalid line $.\n";
            next;
@@ -60,10 +60,11 @@ sub type {
     return 'pve';
 }
 
-sub defaults {
+sub options {
     return {
        default => { optional => 1 },
        comment => { optional => 1 },
+       tfa => { optional => 1 },
     };
 }