]> git.proxmox.com Git - pve-access-control.git/commitdiff
Whitespace fixes
authorPhilip Abernethy <p.abernethy@proxmox.com>
Thu, 21 Sep 2017 09:09:16 +0000 (11:09 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 22 Sep 2017 06:38:50 +0000 (08:38 +0200)
Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/ACL.pm
PVE/API2/Role.pm
PVE/API2/User.pm
PVE/AccessControl.pm
PVE/Auth/Plugin.pm

index fb4fbce11b567d4721ce9c35fd84731368c752bf..d37771b029b425297c8d03aae310f94882582d33 100644 (file)
@@ -14,11 +14,11 @@ use PVE::RESTHandler;
 use base qw(PVE::RESTHandler);
 
 __PACKAGE__->register_method ({
 use base qw(PVE::RESTHandler);
 
 __PACKAGE__->register_method ({
-    name => 'read_acl', 
-    path => '', 
+    name => 'read_acl',
+    path => '',
     method => 'GET',
     description => "Get Access Control List (ACLs).",
     method => 'GET',
     description => "Get Access Control List (ACLs).",
-    permissions => { 
+    permissions => {
        description => "The returned list is restricted to objects where you have rights to modify permissions.",
        user => 'all',
     },
        description => "The returned list is restricted to objects where you have rights to modify permissions.",
        user => 'all',
     },
@@ -42,7 +42,7 @@ __PACKAGE__->register_method ({
     },
     code => sub {
        my ($param) = @_;
     },
     code => sub {
        my ($param) = @_;
-    
+
        my $rpcenv = PVE::RPCEnvironment::get();
        my $authuser = $rpcenv->get_user();
        my $res = [];
        my $rpcenv = PVE::RPCEnvironment::get();
        my $authuser = $rpcenv->get_user();
        my $res = [];
@@ -79,44 +79,44 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
-    name => 'update_acl', 
+    name => 'update_acl',
     protected => 1,
     protected => 1,
-    path => '', 
+    path => '',
     method => 'PUT',
     method => 'PUT',
-    permissions => { 
+    permissions => {
        check => ['perm-modify', '{path}'],
     },
     description => "Update Access Control List (add or remove permissions).",
     parameters => {
        check => ['perm-modify', '{path}'],
     },
     description => "Update Access Control List (add or remove permissions).",
     parameters => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            path => {
                description => "Access control path",
                type => 'string',
            },
        properties => {
            path => {
                description => "Access control path",
                type => 'string',
            },
-           users => { 
+           users => {
                description => "List of users.",
                description => "List of users.",
-               type => 'string',  format => 'pve-userid-list',  
+               type => 'string',  format => 'pve-userid-list',
                optional => 1,
            },
                optional => 1,
            },
-           groups => { 
+           groups => {
                description => "List of groups.",
                type => 'string', format => 'pve-groupid-list',
                description => "List of groups.",
                type => 'string', format => 'pve-groupid-list',
-               optional => 1,  
+               optional => 1,
            },
            },
-           roles => { 
+           roles => {
                description => "List of roles.",
                type => 'string', format => 'pve-roleid-list',
            },
                description => "List of roles.",
                type => 'string', format => 'pve-roleid-list',
            },
-           propagate => { 
+           propagate => {
                description => "Allow to propagate (inherit) permissions.",
                description => "Allow to propagate (inherit) permissions.",
-               type => 'boolean', 
+               type => 'boolean',
                optional => 1,
                default => 1,
            },
            delete => {
                description => "Remove permissions (instead of adding it).",
                optional => 1,
                default => 1,
            },
            delete => {
                description => "Remove permissions (instead of adding it).",
-               type => 'boolean', 
+               type => 'boolean',
                optional => 1,
            },
        },
                optional => 1,
            },
        },
@@ -126,8 +126,8 @@ __PACKAGE__->register_method ({
        my ($param) = @_;
 
        if (!($param->{users} || $param->{groups})) {
        my ($param) = @_;
 
        if (!($param->{users} || $param->{groups})) {
-           raise_param_exc({ 
-               users => "either 'users' or 'groups' is required.", 
+           raise_param_exc({
+               users => "either 'users' or 'groups' is required.",
                groups => "either 'users' or 'groups' is required." });
        }
 
                groups => "either 'users' or 'groups' is required." });
        }
 
@@ -136,17 +136,17 @@ __PACKAGE__->register_method ({
 
        PVE::AccessControl::lock_user_config(
            sub {
 
        PVE::AccessControl::lock_user_config(
            sub {
-                       
+
                my $cfg = cfs_read_file("user.cfg");
 
                my $propagate = 1;
                my $cfg = cfs_read_file("user.cfg");
 
                my $propagate = 1;
-               
+
                if (defined($param->{propagate})) {
                    $propagate = $param->{propagate} ? 1 : 0;
                }
 
                foreach my $role (split_list($param->{roles})) {
                if (defined($param->{propagate})) {
                    $propagate = $param->{propagate} ? 1 : 0;
                }
 
                foreach my $role (split_list($param->{roles})) {
-                   die "role '$role' does not exist\n" 
+                   die "role '$role' does not exist\n"
                        if !$cfg->{roles}->{$role};
 
                    foreach my $group (split_list($param->{groups})) {
                        if !$cfg->{roles}->{$role};
 
                    foreach my $group (split_list($param->{groups})) {
@@ -171,7 +171,7 @@ __PACKAGE__->register_method ({
                            delete($cfg->{acl}->{$path}->{users}->{$username}->{$role});
                        } else {
                            $cfg->{acl}->{$path}->{users}->{$username}->{$role} = $propagate;
                            delete($cfg->{acl}->{$path}->{users}->{$username}->{$role});
                        } else {
                            $cfg->{acl}->{$path}->{users}->{$username}->{$role} = $propagate;
-                       } 
+                       }
                    }
                }
 
                    }
                }
 
index 895da8282a6d9fc403fd039c4c55ecfee03909ab..452fc6d5e1437173306a96431f92c5eaba7bf645 100644 (file)
@@ -12,11 +12,11 @@ use PVE::RESTHandler;
 use base qw(PVE::RESTHandler);
 
 __PACKAGE__->register_method ({
 use base qw(PVE::RESTHandler);
 
 __PACKAGE__->register_method ({
-    name => 'index', 
-    path => '', 
+    name => 'index',
+    path => '',
     method => 'GET',
     description => "Role index.",
     method => 'GET',
     description => "Role index.",
-    permissions => { 
+    permissions => {
        user => 'all',
     },
     parameters => {
        user => 'all',
     },
     parameters => {
@@ -35,11 +35,11 @@ __PACKAGE__->register_method ({
     },
     code => sub {
        my ($param) = @_;
     },
     code => sub {
        my ($param) = @_;
-    
+
        my $res = [];
 
        my $usercfg = cfs_read_file("user.cfg");
        my $res = [];
 
        my $usercfg = cfs_read_file("user.cfg");
+
        foreach my $role (keys %{$usercfg->{roles}}) {
            my $privs = join(',', sort keys %{$usercfg->{roles}->{$role}});
            push @$res, { roleid => $role, privs => $privs,
        foreach my $role (keys %{$usercfg->{roles}}) {
            my $privs = join(',', sort keys %{$usercfg->{roles}->{$role}});
            push @$res, { roleid => $role, privs => $privs,
@@ -47,19 +47,19 @@ __PACKAGE__->register_method ({
        }
 
        return $res;
        }
 
        return $res;
-    }});
+}});
 
 __PACKAGE__->register_method ({
 
 __PACKAGE__->register_method ({
-    name => 'create_role', 
+    name => 'create_role',
     protected => 1,
     protected => 1,
-    path => '', 
+    path => '',
     method => 'POST',
     method => 'POST',
-    permissions => { 
+    permissions => {
        check => ['perm', '/access', ['Sys.Modify']],
     },
     description => "Create new role.",
     parameters => {
        check => ['perm', '/access', ['Sys.Modify']],
     },
     description => "Create new role.",
     parameters => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            roleid => { type => 'string', format => 'pve-roleid' },
            privs => { type => 'string' , format => 'pve-priv-list', optional => 1 },
        properties => {
            roleid => { type => 'string', format => 'pve-roleid' },
            privs => { type => 'string' , format => 'pve-priv-list', optional => 1 },
@@ -71,12 +71,12 @@ __PACKAGE__->register_method ({
 
        PVE::AccessControl::lock_user_config(
            sub {
 
        PVE::AccessControl::lock_user_config(
            sub {
-                       
+
                my $usercfg = cfs_read_file("user.cfg");
 
                my $role = $param->{roleid};
 
                my $usercfg = cfs_read_file("user.cfg");
 
                my $role = $param->{roleid};
 
-               die "role '$role' already exists\n" 
+               die "role '$role' already exists\n"
                    if $usercfg->{roles}->{$role};
 
                $usercfg->{roles}->{$role} = {};
                    if $usercfg->{roles}->{$role};
 
                $usercfg->{roles}->{$role} = {};
@@ -87,24 +87,24 @@ __PACKAGE__->register_method ({
            }, "create role failed");
 
        return undef;
            }, "create role failed");
 
        return undef;
-    }});
+}});
 
 __PACKAGE__->register_method ({
 
 __PACKAGE__->register_method ({
-    name => 'update_role', 
+    name => 'update_role',
     protected => 1,
     protected => 1,
-    path => '{roleid}', 
+    path => '{roleid}',
     method => 'PUT',
     method => 'PUT',
-    permissions => { 
+    permissions => {
        check => ['perm', '/access', ['Sys.Modify']],
     },
     description => "Create new role.",
     parameters => {
        check => ['perm', '/access', ['Sys.Modify']],
     },
     description => "Create new role.",
     parameters => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            roleid => { type => 'string', format => 'pve-roleid' },
            privs => { type => 'string' , format => 'pve-priv-list' },
        properties => {
            roleid => { type => 'string', format => 'pve-roleid' },
            privs => { type => 'string' , format => 'pve-priv-list' },
-           append => { 
-               type => 'boolean', 
+           append => {
+               type => 'boolean',
                optional => 1,
                requires => 'privs',
            },
                optional => 1,
                requires => 'privs',
            },
@@ -116,12 +116,12 @@ __PACKAGE__->register_method ({
 
        PVE::AccessControl::lock_user_config(
            sub {
 
        PVE::AccessControl::lock_user_config(
            sub {
-                       
+
                my $role = $param->{roleid};
 
                my $usercfg = cfs_read_file("user.cfg");
                my $role = $param->{roleid};
 
                my $usercfg = cfs_read_file("user.cfg");
-       
-               die "role '$role' does not exist\n" 
+
+               die "role '$role' does not exist\n"
                    if !$usercfg->{roles}->{$role};
 
                $usercfg->{roles}->{$role} = {} if !$param->{append};
                    if !$usercfg->{roles}->{$role};
 
                $usercfg->{roles}->{$role} = {} if !$param->{append};
@@ -132,19 +132,19 @@ __PACKAGE__->register_method ({
            }, "update role failed");
 
        return undef;
            }, "update role failed");
 
        return undef;
-    }});
+}});
 
 # fixme: return format!
 __PACKAGE__->register_method ({
 
 # fixme: return format!
 __PACKAGE__->register_method ({
-    name => 'read_role', 
-    path => '{roleid}', 
+    name => 'read_role',
+    path => '{roleid}',
     method => 'GET',
     method => 'GET',
-    permissions => { 
+    permissions => {
        user => 'all',
     },
     description => "Get role configuration.",
     parameters => {
        user => 'all',
     },
     description => "Get role configuration.",
     parameters => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            roleid => { type => 'string' , format => 'pve-roleid' },
        },
        properties => {
            roleid => { type => 'string' , format => 'pve-roleid' },
        },
@@ -162,20 +162,19 @@ __PACKAGE__->register_method ({
        die "role '$role' does not exist\n" if !$data;
 
        return $data;
        die "role '$role' does not exist\n" if !$data;
 
        return $data;
-    }});
-
+}});
 
 __PACKAGE__->register_method ({
 
 __PACKAGE__->register_method ({
-    name => 'delete_role', 
+    name => 'delete_role',
     protected => 1,
     protected => 1,
-    path => '{roleid}', 
+    path => '{roleid}',
     method => 'DELETE',
     method => 'DELETE',
-    permissions => { 
+    permissions => {
        check => ['perm', '/access', ['Sys.Modify']],
     },
     description => "Delete role.",
     parameters => {
        check => ['perm', '/access', ['Sys.Modify']],
     },
     description => "Delete role.",
     parameters => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            roleid => { type => 'string', format => 'pve-roleid' },
        }
        properties => {
            roleid => { type => 'string', format => 'pve-roleid' },
        }
@@ -193,7 +192,7 @@ __PACKAGE__->register_method ({
 
                die "role '$role' does not exist\n"
                    if !$usercfg->{roles}->{$role};
 
                die "role '$role' does not exist\n"
                    if !$usercfg->{roles}->{$role};
-       
+
                die "auto-generated role '$role' can not be deleted\n"
                    if PVE::AccessControl::role_is_special($role);
 
                die "auto-generated role '$role' can not be deleted\n"
                    if PVE::AccessControl::role_is_special($role);
 
@@ -203,8 +202,8 @@ __PACKAGE__->register_method ({
 
                cfs_write_file("user.cfg", $usercfg);
            }, "delete role failed");
 
                cfs_write_file("user.cfg", $usercfg);
            }, "delete role failed");
-       
+
        return undef;
        return undef;
-    }});
+}});
 
 1;
 
 1;
index 602e3f030ba4bc990adf7717e659f1007cf1b7f5..1dc0293287a03829f8ea0812e12dbec8963c2a26 100644 (file)
@@ -31,11 +31,11 @@ my $extract_user_data = sub {
 };
 
 __PACKAGE__->register_method ({
 };
 
 __PACKAGE__->register_method ({
-    name => 'index', 
-    path => '', 
+    name => 'index',
+    path => '',
     method => 'GET',
     description => "User index.",
     method => 'GET',
     description => "User index.",
-    permissions => { 
+    permissions => {
        description => "The returned list is restricted to users where you have 'User.Modify' or 'Sys.Audit' permissions on '/access/groups' or on a group the user belongs too. But it always includes the current (authenticated) user.",
        user => 'all',
     },
        description => "The returned list is restricted to users where you have 'User.Modify' or 'Sys.Audit' permissions on '/access/groups' or on a group the user belongs too. But it always includes the current (authenticated) user.",
        user => 'all',
     },
@@ -61,7 +61,7 @@ __PACKAGE__->register_method ({
     },
     code => sub {
        my ($param) = @_;
     },
     code => sub {
        my ($param) = @_;
-    
+
        my $rpcenv = PVE::RPCEnvironment::get();
        my $usercfg = $rpcenv->{user_cfg};
        my $authuser = $rpcenv->get_user();
        my $rpcenv = PVE::RPCEnvironment::get();
        my $usercfg = $rpcenv->{user_cfg};
        my $authuser = $rpcenv->get_user();
@@ -71,7 +71,7 @@ __PACKAGE__->register_method ({
        my $privs = [ 'User.Modify', 'Sys.Audit' ];
        my $canUserMod = $rpcenv->check_any($authuser, "/access/groups", $privs, 1);
        my $groups = $rpcenv->filter_groups($authuser, $privs, 1);
        my $privs = [ 'User.Modify', 'Sys.Audit' ];
        my $canUserMod = $rpcenv->check_any($authuser, "/access/groups", $privs, 1);
        my $groups = $rpcenv->filter_groups($authuser, $privs, 1);
-       my $allowed_users = $rpcenv->group_member_join([keys %$groups]);      
+       my $allowed_users = $rpcenv->group_member_join([keys %$groups]);
 
        foreach my $user (keys %{$usercfg->{users}}) {
 
 
        foreach my $user (keys %{$usercfg->{users}}) {
 
@@ -94,11 +94,11 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
-    name => 'create_user', 
+    name => 'create_user',
     protected => 1,
     protected => 1,
-    path => '', 
+    path => '',
     method => 'POST',
     method => 'POST',
-    permissions => { 
+    permissions => {
        description => "You need 'Realm.AllocateUser' on '/access/realm/<realm>' on the realm of user <userid>, and 'User.Modify' permissions to '/access/groups/<group>' for any group specified (or 'User.Modify' on '/access/groups' if you pass no groups.",
        check => [ 'and',
                   [ 'userid-param', 'Realm.AllocateUser'],
        description => "You need 'Realm.AllocateUser' on '/access/realm/<realm>' on the realm of user <userid>, and 'User.Modify' permissions to '/access/groups/<group>' for any group specified (or 'User.Modify' on '/access/groups' if you pass no groups.",
        check => [ 'and',
                   [ 'userid-param', 'Realm.AllocateUser'],
@@ -107,15 +107,15 @@ __PACKAGE__->register_method ({
     },
     description => "Create new user.",
     parameters => {
     },
     description => "Create new user.",
     parameters => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            userid => get_standard_option('userid'),
            password => {
                description => "Initial password.",
        properties => {
            userid => get_standard_option('userid'),
            password => {
                description => "Initial password.",
-               type => 'string', 
-               optional => 1, 
-               minLength => 5, 
-               maxLength => 64 
+               type => 'string',
+               optional => 1,
+               minLength => 5,
+               maxLength => 64
            },
            groups => {
                type => 'string', format => 'pve-groupid-list',
            },
            groups => {
                type => 'string', format => 'pve-groupid-list',
@@ -128,12 +128,12 @@ __PACKAGE__->register_method ({
            comment => { type => 'string', optional => 1 },
            keys => {
                description => "Keys for two factor auth (yubico).",
            comment => { type => 'string', optional => 1 },
            keys => {
                description => "Keys for two factor auth (yubico).",
-               type => 'string', 
+               type => 'string',
                optional => 1,
            },
                optional => 1,
            },
-           expire => { 
+           expire => {
                description => "Account expiration date (seconds since epoch). '0' means no expiration date.",
                description => "Account expiration date (seconds since epoch). '0' means no expiration date.",
-               type => 'integer', 
+               type => 'integer',
                minimum => 0,
                optional => 1,
            },
                minimum => 0,
                optional => 1,
            },
@@ -151,14 +151,14 @@ __PACKAGE__->register_method ({
 
        PVE::AccessControl::lock_user_config(
            sub {
 
        PVE::AccessControl::lock_user_config(
            sub {
-                       
+
                my ($username, $ruid, $realm) = PVE::AccessControl::verify_username($param->{userid});
                my ($username, $ruid, $realm) = PVE::AccessControl::verify_username($param->{userid});
-       
+
                my $usercfg = cfs_read_file("user.cfg");
 
                my $usercfg = cfs_read_file("user.cfg");
 
-               die "user '$username' already exists\n" 
+               die "user '$username' already exists\n"
                    if $usercfg->{users}->{$username};
                    if $usercfg->{users}->{$username};
-                        
+
                PVE::AccessControl::domain_set_password($realm, $ruid, $param->{password})
                    if defined($param->{password});
 
                PVE::AccessControl::domain_set_password($realm, $ruid, $param->{password})
                    if defined($param->{password});
 
@@ -189,56 +189,56 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
-    name => 'read_user', 
-    path => '{userid}', 
+    name => 'read_user',
+    path => '{userid}',
     method => 'GET',
     description => "Get user configuration.",
     method => 'GET',
     description => "Get user configuration.",
-    permissions => { 
+    permissions => {
        check => ['userid-group', ['User.Modify', 'Sys.Audit']],
     },
     parameters => {
        check => ['userid-group', ['User.Modify', 'Sys.Audit']],
     },
     parameters => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            userid => get_standard_option('userid'),
        },
     },
     returns => {
        properties => {
            userid => get_standard_option('userid'),
        },
     },
     returns => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            enable => { type => 'boolean' },
            expire => { type => 'integer', optional => 1 },
            firstname => { type => 'string', optional => 1 },
            lastname => { type => 'string', optional => 1 },
            email => { type => 'string', optional => 1 },
        properties => {
            enable => { type => 'boolean' },
            expire => { type => 'integer', optional => 1 },
            firstname => { type => 'string', optional => 1 },
            lastname => { type => 'string', optional => 1 },
            email => { type => 'string', optional => 1 },
-           comment => { type => 'string', optional => 1 },    
-           keys => { type => 'string', optional => 1 },    
+           comment => { type => 'string', optional => 1 },
+           keys => { type => 'string', optional => 1 },
            groups => { type => 'array' },
        }
     },
     code => sub {
        my ($param) = @_;
 
            groups => { type => 'array' },
        }
     },
     code => sub {
        my ($param) = @_;
 
-       my ($username, undef, $domain) = 
+       my ($username, undef, $domain) =
            PVE::AccessControl::verify_username($param->{userid});
 
        my $usercfg = cfs_read_file("user.cfg");
 
        my $data = PVE::AccessControl::check_user_exist($usercfg, $username);
            PVE::AccessControl::verify_username($param->{userid});
 
        my $usercfg = cfs_read_file("user.cfg");
 
        my $data = PVE::AccessControl::check_user_exist($usercfg, $username);
+
        return &$extract_user_data($data, 1);
     }});
 
 __PACKAGE__->register_method ({
        return &$extract_user_data($data, 1);
     }});
 
 __PACKAGE__->register_method ({
-    name => 'update_user', 
+    name => 'update_user',
     protected => 1,
     protected => 1,
-    path => '{userid}', 
+    path => '{userid}',
     method => 'PUT',
     method => 'PUT',
-    permissions => { 
+    permissions => {
        check => ['userid-group', ['User.Modify'], groups_param => 1 ],
     },
     description => "Update user configuration.",
     parameters => {
        check => ['userid-group', ['User.Modify'], groups_param => 1 ],
     },
     description => "Update user configuration.",
     parameters => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            userid => get_standard_option('userid', {
                completion => \&PVE::AccessControl::complete_username,
        properties => {
            userid => get_standard_option('userid', {
                completion => \&PVE::AccessControl::complete_username,
@@ -248,8 +248,8 @@ __PACKAGE__->register_method ({
                optional => 1,
                completion => \&PVE::AccessControl::complete_group,
            },
                optional => 1,
                completion => \&PVE::AccessControl::complete_group,
            },
-           append => { 
-               type => 'boolean', 
+           append => {
+               type => 'boolean',
                optional => 1,
                requires => 'groups',
            },
                optional => 1,
                requires => 'groups',
            },
@@ -264,14 +264,14 @@ __PACKAGE__->register_method ({
            comment => { type => 'string', optional => 1 },
            keys => {
                description => "Keys for two factor auth (yubico).",
            comment => { type => 'string', optional => 1 },
            keys => {
                description => "Keys for two factor auth (yubico).",
-               type => 'string', 
+               type => 'string',
                optional => 1,
            },
                optional => 1,
            },
-           expire => { 
+           expire => {
                description => "Account expiration date (seconds since epoch). '0' means no expiration date.",
                description => "Account expiration date (seconds since epoch). '0' means no expiration date.",
-               type => 'integer', 
+               type => 'integer',
                minimum => 0,
                minimum => 0,
-               optional => 1 
+               optional => 1
            },
        },
     },
            },
        },
     },
@@ -279,12 +279,12 @@ __PACKAGE__->register_method ({
     code => sub {
        my ($param) = @_;
 
     code => sub {
        my ($param) = @_;
 
-       my ($username, $ruid, $realm) = 
+       my ($username, $ruid, $realm) =
            PVE::AccessControl::verify_username($param->{userid});
            PVE::AccessControl::verify_username($param->{userid});
-       
+
        PVE::AccessControl::lock_user_config(
            sub {
        PVE::AccessControl::lock_user_config(
            sub {
-       
+
                my $usercfg = cfs_read_file("user.cfg");
 
                PVE::AccessControl::check_user_exist($usercfg, $username);
                my $usercfg = cfs_read_file("user.cfg");
 
                PVE::AccessControl::check_user_exist($usercfg, $username);
@@ -293,7 +293,7 @@ __PACKAGE__->register_method ({
 
                $usercfg->{users}->{$username}->{expire} = $param->{expire} if defined($param->{expire});
 
 
                $usercfg->{users}->{$username}->{expire} = $param->{expire} if defined($param->{expire});
 
-               PVE::AccessControl::delete_user_group($username, $usercfg) 
+               PVE::AccessControl::delete_user_group($username, $usercfg)
                    if (!$param->{append} && defined($param->{groups}));
 
                if ($param->{groups}) {
                    if (!$param->{append} && defined($param->{groups}));
 
                if ($param->{groups}) {
@@ -314,24 +314,24 @@ __PACKAGE__->register_method ({
 
                cfs_write_file("user.cfg", $usercfg);
            }, "update user failed");
 
                cfs_write_file("user.cfg", $usercfg);
            }, "update user failed");
-       
+
        return undef;
     }});
 
 __PACKAGE__->register_method ({
        return undef;
     }});
 
 __PACKAGE__->register_method ({
-    name => 'delete_user', 
+    name => 'delete_user',
     protected => 1,
     protected => 1,
-    path => '{userid}', 
+    path => '{userid}',
     method => 'DELETE',
     description => "Delete user.",
     method => 'DELETE',
     description => "Delete user.",
-    permissions => { 
+    permissions => {
        check => [ 'and',
                   [ 'userid-param', 'Realm.AllocateUser'],
                   [ 'userid-group', ['User.Modify']],
            ],
     },
     parameters => {
        check => [ 'and',
                   [ 'userid-param', 'Realm.AllocateUser'],
                   [ 'userid-group', ['User.Modify']],
            ],
     },
     parameters => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            userid => get_standard_option('userid', {
                completion => \&PVE::AccessControl::complete_username,
        properties => {
            userid => get_standard_option('userid', {
                completion => \&PVE::AccessControl::complete_username,
@@ -341,11 +341,11 @@ __PACKAGE__->register_method ({
     returns => { type => 'null' },
     code => sub {
        my ($param) = @_;
     returns => { type => 'null' },
     code => sub {
        my ($param) = @_;
-       
+
        my $rpcenv = PVE::RPCEnvironment::get();
        my $authuser = $rpcenv->get_user();
 
        my $rpcenv = PVE::RPCEnvironment::get();
        my $authuser = $rpcenv->get_user();
 
-       my ($userid, $ruid, $realm) = 
+       my ($userid, $ruid, $realm) =
            PVE::AccessControl::verify_username($param->{userid});
 
        PVE::AccessControl::lock_user_config(
            PVE::AccessControl::verify_username($param->{userid});
 
        PVE::AccessControl::lock_user_config(
@@ -366,7 +366,7 @@ __PACKAGE__->register_method ({
 
                cfs_write_file("user.cfg", $usercfg);
            }, "delete user failed");
 
                cfs_write_file("user.cfg", $usercfg);
            }, "delete user failed");
-       
+
        return undef;
     }});
 
        return undef;
     }});
 
index b45abda9cfa52d466313b56766a31216411347ad..29c50ce97f7c7094abf2d287c86dde9ca95284b6 100644 (file)
@@ -45,7 +45,6 @@ cfs_register_file('user.cfg',
                  \&parse_user_config,
                  \&write_user_config);
 
                  \&parse_user_config,
                  \&write_user_config);
 
-
 sub verify_username {
     PVE::Auth::Plugin::verify_username(@_);
 }
 sub verify_username {
     PVE::Auth::Plugin::verify_username(@_);
 }
@@ -172,7 +171,6 @@ sub assemble_spice_ticket {
        $secret, $username, $vmid, $node);
 }
 
        $secret, $username, $vmid, $node);
 }
 
-
 sub verify_spice_connect_url {
     my ($connect_str) = @_;
 
 sub verify_spice_connect_url {
     my ($connect_str) = @_;
 
@@ -537,7 +535,6 @@ sub normalize_path {
     return $path;
 }
 
     return $path;
 }
 
-
 PVE::JSONSchema::register_format('pve-groupid', \&verify_groupname);
 sub verify_groupname {
     my ($groupname, $noerr) = @_;
 PVE::JSONSchema::register_format('pve-groupid', \&verify_groupname);
 sub verify_groupname {
     my ($groupname, $noerr) = @_;
index 16ef046b4ecc69ccf0974ff13c1f0e0a17d7ac13..d5d2c06971357b57bd15937f4a641608efbfe958 100755 (executable)
@@ -13,7 +13,7 @@ use base qw(PVE::SectionConfig);
 
 my $domainconfigfile = "domains.cfg";
 
 
 my $domainconfigfile = "domains.cfg";
 
-cfs_register_file($domainconfigfile, 
+cfs_register_file($domainconfigfile,
                  sub { __PACKAGE__->parse_config(@_); },
                  sub { __PACKAGE__->write_config(@_); });
 
                  sub { __PACKAGE__->parse_config(@_); },
                  sub { __PACKAGE__->write_config(@_); });
 
@@ -32,10 +32,10 @@ my $realm_regex = qr/[A-Za-z][A-Za-z0-9\.\-_]+/;
 PVE::JSONSchema::register_format('pve-realm', \&pve_verify_realm);
 sub pve_verify_realm {
     my ($realm, $noerr) = @_;
 PVE::JSONSchema::register_format('pve-realm', \&pve_verify_realm);
 sub pve_verify_realm {
     my ($realm, $noerr) = @_;
+
     if ($realm !~ m/^${realm_regex}$/) {
        return undef if $noerr;
     if ($realm !~ m/^${realm_regex}$/) {
        return undef if $noerr;
-       die "value does not look like a valid realm\n"; 
+       die "value does not look like a valid realm\n";
     }
     return $realm;
 }
     }
     return $realm;
 }
@@ -62,10 +62,10 @@ sub verify_username {
     }
 
     # we only allow a limited set of characters
     }
 
     # we only allow a limited set of characters
-    # colon is not allowed, because we store usernames in 
+    # colon is not allowed, because we store usernames in
     # colon separated lists)!
     # slash is not allowed because it is used as pve API delimiter
     # colon separated lists)!
     # slash is not allowed because it is used as pve API delimiter
-    # also see "man useradd" 
+    # also see "man useradd"
     if ($username =~ m!^([^\s:/]+)\@(${realm_regex})$!) {
        return wantarray ? ($username, $1, $2) : $username;
     }
     if ($username =~ m!^([^\s:/]+)\@(${realm_regex})$!) {
        return wantarray ? ($username, $1, $2) : $username;
     }
@@ -120,7 +120,7 @@ sub parse_tfa_config {
            $res->{step} = $1;
        } else {
            return undef;
            $res->{step} = $1;
        } else {
            return undef;
-       }           
+       }
     }
 
     return undef if !$res->{type};
     }
 
     return undef if !$res->{type};
@@ -199,7 +199,7 @@ sub write_config {
            $data->{comment} = PVE::Tools::encode_text($data->{comment});
        }
     }
            $data->{comment} = PVE::Tools::encode_text($data->{comment});
        }
     }
-    
+
     $class->SUPER::write_config($filename, $cfg);
 }
 
     $class->SUPER::write_config($filename, $cfg);
 }