]> git.proxmox.com Git - pve-access-control.git/blobdiff - PVE/AccessControl.pm
allow dots in access paths
[pve-access-control.git] / PVE / AccessControl.pm
index f0c37c7651a6eda6d51ced1bda18022d9ff63068..f03f6b5bba4e67fbb6f2a90d9210d62e344f37be 100644 (file)
@@ -1,6 +1,7 @@
 package PVE::AccessControl;
 
 use strict;
+use warnings;
 use Encode;
 use Crypt::OpenSSL::Random;
 use Crypt::OpenSSL::RSA;
@@ -237,7 +238,7 @@ sub assemble_spice_ticket {
     # Note: RSA signature are too long (>=256 charaters) and makes problems with remote-viewer
 
     my $secret = &$get_csrfr_secret();
-    my $plain = "pvespiceproxy:$timestamp:$vmid:$node";
+    my $plain = "pvespiceproxy:$timestamp:$vmid:" . lc($node);
 
     # produces 40 characters
     my $sig = unpack("H*", Digest::SHA::sha1($plain, &$get_csrfr_secret()));
@@ -305,6 +306,7 @@ sub check_user_enabled {
 }
 
 # password should be utf8 encoded
+# Note: some pluging delay/sleep if auth fails
 sub authenticate_user {
     my ($username, $password) = @_;
 
@@ -316,32 +318,19 @@ sub authenticate_user {
 
     my $usercfg = cfs_read_file('user.cfg');
 
-    eval { check_user_enabled($usercfg, $username); };
-    if (my $err = $@) {
-       sleep(2);
-       die $err;
-    }
+    check_user_enabled($usercfg, $username);
 
     my $ctime = time();
     my $expire = $usercfg->{users}->{$username}->{expire};
 
-    if ($expire && ($expire < $ctime)) {
-       sleep(2);
-       die "account expired\n"
-    }
+    die "account expired\n" if $expire && ($expire < $ctime);
 
     my $domain_cfg = cfs_read_file('domains.cfg');
 
-    eval {
-       my $cfg = $domain_cfg->{ids}->{$realm};
-       die "auth domain '$realm' does not exists\n" if !$cfg;
-       my $plugin = PVE::Auth::Plugin->lookup($cfg->{type});
-       $plugin->authenticate_user($cfg, $realm, $ruid, $password);
-    };
-    if (my $err = $@) {
-       sleep(2); # timeout after failed auth
-       die $err;
-    }
+    my $cfg = $domain_cfg->{ids}->{$realm};
+    die "auth domain '$realm' does not exists\n" if !$cfg;
+    my $plugin = PVE::Auth::Plugin->lookup($cfg->{type});
+    $plugin->authenticate_user($cfg, $realm, $ruid, $password);
 
     return $username;
 }
@@ -554,7 +543,7 @@ sub normalize_path {
 
     $path = "/$path" if $path !~ m|^/|;
 
-    return undef if $path !~ m|^[[:alnum:]\-\_\/]+$|;
+    return undef if $path !~ m|^[[:alnum:]\.\-\_\/]+$|;
 
     return $path;
 }