mirror of
https://git.proxmox.com/git/pve-access-control
synced 2025-07-15 09:57:48 +00:00
api/users: catch existing user also on case insensitive realm
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
2dd1e1d41e
commit
f335d265b8
@ -234,8 +234,9 @@ __PACKAGE__->register_method ({
|
|||||||
|
|
||||||
my $usercfg = cfs_read_file("user.cfg");
|
my $usercfg = cfs_read_file("user.cfg");
|
||||||
|
|
||||||
die "user '$username' already exists\n"
|
# ensure "user exists" check works for case insensitive realms
|
||||||
if $usercfg->{users}->{$username};
|
$username = PVE::AccessControl::lookup_username($username, 1);
|
||||||
|
die "user '$username' already exists\n" if $usercfg->{users}->{$username};
|
||||||
|
|
||||||
PVE::AccessControl::domain_set_password($realm, $ruid, $param->{password})
|
PVE::AccessControl::domain_set_password($realm, $ruid, $param->{password})
|
||||||
if defined($param->{password});
|
if defined($param->{password});
|
||||||
|
@ -892,7 +892,7 @@ sub add_role_privs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub lookup_username {
|
sub lookup_username {
|
||||||
my ($username) = @_;
|
my ($username, $noerr) = @_;
|
||||||
|
|
||||||
$username =~ m!^(${PVE::Auth::Plugin::user_regex})\@(${PVE::Auth::Plugin::realm_regex})$!;
|
$username =~ m!^(${PVE::Auth::Plugin::user_regex})\@(${PVE::Auth::Plugin::realm_regex})$!;
|
||||||
|
|
||||||
@ -905,7 +905,7 @@ sub lookup_username {
|
|||||||
my @matches = grep { lc $username eq lc $_ } (keys %{$usercfg->{users}});
|
my @matches = grep { lc $username eq lc $_ } (keys %{$usercfg->{users}});
|
||||||
|
|
||||||
die "ambiguous case insensitive match of username '$username', cannot safely grant access!\n"
|
die "ambiguous case insensitive match of username '$username', cannot safely grant access!\n"
|
||||||
if scalar @matches > 1;
|
if scalar @matches > 1 && !$noerr;
|
||||||
|
|
||||||
return $matches[0]
|
return $matches[0]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user