]> git.proxmox.com Git - pve-access-control.git/commitdiff
fix #4609: allow valid DN in ldap/ad realm config
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 23 Mar 2023 13:14:29 +0000 (14:14 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 23 Mar 2023 14:41:47 +0000 (15:41 +0100)
We previously added support for ',' in the DNS attribute through
allowing a quoted format, but the regex used was made too
restrictive.

In the new quoted attribute we'd only allow \w (alphanumeric and _)
and the restricted characters. This patch now changes that to allow
everything except the quotation mark " itself, which is again closer
to the original regex which did not care for quotation and allowed
everything aside from ','.

The unquoted attributes did not allow spaces anymore, but the RFC [0]
actually makes it clear that spaces are only forbidden at the
beginning and the end (same for #). So, fix the regex to accommodate
for that and allow space and # characters again if not at the end or
beginning.

0: https://www.ietf.org/rfc/rfc2253.txt

Fixes: 1aa2355 ("ldap: Allow quoted values for DN attribute values")
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Friedrich Weber <f.weber@proxmox.com>
 [ T: make fixes a trailer and rework commit message ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/Auth/LDAP.pm

index 4d771e7ff8adde4b3bd8a2c7168e0e8e8859d543..fc82a17ad3baa26e1c5cc1a4fd71d3af105f0c15 100755 (executable)
@@ -10,7 +10,8 @@ use PVE::Tools;
 
 use base qw(PVE::Auth::Plugin);
 
-our $dn_regex = qr!\w+=("[\w ,+/<>;=]+"|[^ ,+"/<>;=]+)(,\s*\w+=("[\w ,+/<>;=]+"|[^ ,+"/<>;=]+))*!;
+my  $dn_part_regex = qr!("[^"]+"|[^ ,+"/<>;=#][^,+"/<>;=]*[^ ,+"/<>;=]|[^ ,+"/<>;=#])!;
+our $dn_regex = qr!\w+=${dn_part_regex}(,\s*\w+=${dn_part_regex})*!;
 
 sub type {
     return 'ldap';