access: lookup: avoid reading user.cfg from cfs unnecessarily

Given that the information is only needed for case-sensitive realms,
move the read into the conditional.

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
This commit is contained in:
Christoph Heiss 2025-03-25 11:38:32 +01:00 committed by Thomas Lamprecht
parent 1471e1e822
commit 6e0d55a587

View File

@ -1223,9 +1223,9 @@ sub lookup_username {
my $realm = $2; my $realm = $2;
my $domain_cfg = cfs_read_file("domains.cfg"); my $domain_cfg = cfs_read_file("domains.cfg");
my $casesensitive = $domain_cfg->{ids}->{$realm}->{'case-sensitive'} // 1; my $casesensitive = $domain_cfg->{ids}->{$realm}->{'case-sensitive'} // 1;
my $usercfg = cfs_read_file('user.cfg');
if (!$casesensitive) { if (!$casesensitive) {
my $usercfg = cfs_read_file('user.cfg');
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"