public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH access-control 0/3] fix undef warning on login for case-insensitive realms
@ 2025-03-25 10:38 Christoph Heiss
  2025-03-25 10:38 ` [pve-devel] [PATCH access-control 1/3] access: lookup: fix undef warning " Christoph Heiss
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Christoph Heiss @ 2025-03-25 10:38 UTC (permalink / raw)
  To: pve-devel

This primarily fixes a Perl warning in the syslog about a undef
variable, with no impact on the actual functionality though.

The two other patches #2 and #3 just clean up some small things I came
across while at it.

Christoph Heiss (3):
  access: lookup: fix undef warning for case-insensitive realms
  access: lookup: avoid reading user.cfg from cfs unnecessarily
  gitignore: add rules for dpkg build artifacts

 .gitignore               | 7 +++++++
 src/PVE/AccessControl.pm | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

-- 
2.48.1



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] [PATCH access-control 1/3] access: lookup: fix undef warning for case-insensitive realms
  2025-03-25 10:38 [pve-devel] [PATCH access-control 0/3] fix undef warning on login for case-insensitive realms Christoph Heiss
@ 2025-03-25 10:38 ` Christoph Heiss
  2025-03-25 10:38 ` [pve-devel] [PATCH access-control 2/3] access: lookup: avoid reading user.cfg from cfs unnecessarily Christoph Heiss
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Heiss @ 2025-03-25 10:38 UTC (permalink / raw)
  To: pve-devel

Originally reported in the forum [0].

This is only a cosmetic fix and has no user-visible impact, just fixing
a code warning in the syslog. Applies only for case-insensitive realms
too, where Active Directory is the only type to support that.

When looking up a non-existing username on case-insensitive realms, it
currently returns `undef`, which then causes the following warning in
the syslog:

  Use of uninitialized value $username in concatenation (.) or string at /usr/share/perl5/PVE/API2/AccessControl.pm line 303.
  authentication failure; rhost=::ffff:10.0.0.1 user= msg=user name '' is too short

This now follows the logic from the common, case-sensitive path, to just
return the original, given username (which is then later on validated in
the auth chain).

No functional changes.

[0] https://forum.proxmox.com/threads/new-ad-realm-not-working-blank-username.157859/

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
 src/PVE/AccessControl.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm
index 47f2d38..d1e7d56 100644
--- a/src/PVE/AccessControl.pm
+++ b/src/PVE/AccessControl.pm
@@ -1231,7 +1231,7 @@ sub lookup_username {
 	die "ambiguous case insensitive match of username '$username', cannot safely grant access!\n"
 	    if scalar @matches > 1 && !$noerr;
 
-	return $matches[0]
+	return $matches[0] if defined($matches[0]);
     }
 
     return $username;
-- 
2.48.1



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] [PATCH access-control 2/3] access: lookup: avoid reading user.cfg from cfs unnecessarily
  2025-03-25 10:38 [pve-devel] [PATCH access-control 0/3] fix undef warning on login for case-insensitive realms Christoph Heiss
  2025-03-25 10:38 ` [pve-devel] [PATCH access-control 1/3] access: lookup: fix undef warning " Christoph Heiss
@ 2025-03-25 10:38 ` Christoph Heiss
  2025-03-25 10:38 ` [pve-devel] [PATCH access-control 3/3] gitignore: add rules for dpkg build artifacts Christoph Heiss
  2025-04-04 16:55 ` [pve-devel] applied:-series [PATCH access-control 0/3] fix undef warning on login for case-insensitive realms Thomas Lamprecht
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Heiss @ 2025-03-25 10:38 UTC (permalink / raw)
  To: pve-devel

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>
---
 src/PVE/AccessControl.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm
index d1e7d56..2ac4f71 100644
--- a/src/PVE/AccessControl.pm
+++ b/src/PVE/AccessControl.pm
@@ -1223,9 +1223,9 @@ sub lookup_username {
     my $realm = $2;
     my $domain_cfg = cfs_read_file("domains.cfg");
     my $casesensitive = $domain_cfg->{ids}->{$realm}->{'case-sensitive'} // 1;
-    my $usercfg = cfs_read_file('user.cfg');
 
     if (!$casesensitive) {
+	my $usercfg = cfs_read_file('user.cfg');
 	my @matches = grep { lc $username eq lc $_ } (keys %{$usercfg->{users}});
 
 	die "ambiguous case insensitive match of username '$username', cannot safely grant access!\n"
-- 
2.48.1



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] [PATCH access-control 3/3] gitignore: add rules for dpkg build artifacts
  2025-03-25 10:38 [pve-devel] [PATCH access-control 0/3] fix undef warning on login for case-insensitive realms Christoph Heiss
  2025-03-25 10:38 ` [pve-devel] [PATCH access-control 1/3] access: lookup: fix undef warning " Christoph Heiss
  2025-03-25 10:38 ` [pve-devel] [PATCH access-control 2/3] access: lookup: avoid reading user.cfg from cfs unnecessarily Christoph Heiss
@ 2025-03-25 10:38 ` Christoph Heiss
  2025-04-04 16:55 ` [pve-devel] applied:-series [PATCH access-control 0/3] fix undef warning on login for case-insensitive realms Thomas Lamprecht
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Heiss @ 2025-03-25 10:38 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
 .gitignore | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/.gitignore b/.gitignore
index e1fc9d6..8e46926 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,10 @@ build
 *.deb
 *.1.pod
 *.1.gz
+/libpve-access-control-[0-9]*/
+/libpve-access-control_[0-9]
+*.buildinfo
+*.build
+*.changes
+*.dsc
+*.tar.xz
-- 
2.48.1



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] applied:-series [PATCH access-control 0/3] fix undef warning on login for case-insensitive realms
  2025-03-25 10:38 [pve-devel] [PATCH access-control 0/3] fix undef warning on login for case-insensitive realms Christoph Heiss
                   ` (2 preceding siblings ...)
  2025-03-25 10:38 ` [pve-devel] [PATCH access-control 3/3] gitignore: add rules for dpkg build artifacts Christoph Heiss
@ 2025-04-04 16:55 ` Thomas Lamprecht
  3 siblings, 0 replies; 5+ messages in thread
From: Thomas Lamprecht @ 2025-04-04 16:55 UTC (permalink / raw)
  To: Proxmox VE development discussion, Christoph Heiss

Am 25.03.25 um 11:38 schrieb Christoph Heiss:
> This primarily fixes a Perl warning in the syslog about a undef
> variable, with no impact on the actual functionality though.
> 
> The two other patches #2 and #3 just clean up some small things I came
> across while at it.
> 
> Christoph Heiss (3):
>   access: lookup: fix undef warning for case-insensitive realms
>   access: lookup: avoid reading user.cfg from cfs unnecessarily
>   gitignore: add rules for dpkg build artifacts
> 
>  .gitignore               | 7 +++++++
>  src/PVE/AccessControl.pm | 4 ++--
>  2 files changed, 9 insertions(+), 2 deletions(-)
> 


applied series, thanks!


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-04 16:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-25 10:38 [pve-devel] [PATCH access-control 0/3] fix undef warning on login for case-insensitive realms Christoph Heiss
2025-03-25 10:38 ` [pve-devel] [PATCH access-control 1/3] access: lookup: fix undef warning " Christoph Heiss
2025-03-25 10:38 ` [pve-devel] [PATCH access-control 2/3] access: lookup: avoid reading user.cfg from cfs unnecessarily Christoph Heiss
2025-03-25 10:38 ` [pve-devel] [PATCH access-control 3/3] gitignore: add rules for dpkg build artifacts Christoph Heiss
2025-04-04 16:55 ` [pve-devel] applied:-series [PATCH access-control 0/3] fix undef warning on login for case-insensitive realms Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal