all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH access-control 1/1] fix #4609: allow valid DN in ldap/ad realm config
Date: Thu, 23 Mar 2023 14:14:29 +0100	[thread overview]
Message-ID: <20230323131430.3185211-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20230323131430.3185211-1-d.csapak@proxmox.com>

we previously added support for ',' in the dns attribute by allowing a
quoted format. the regex was sadly too restrictive:

in a quoted attribute we'd only allow \w (alphanumeric + _) and the
restricted characters. this patch now changes that to everything
except " (nearer to the original regex which allowed everything aside
from ',')

the unquoted attributes now did not allow spaces, but reading the RFC[0]
again, spaces are only forbidden at the beginning (also #) and end
so fix the regex to accommodate for that

Fixes 1aa2355 ("ldap: Allow quoted values for DN attribute values")

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

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/PVE/Auth/LDAP.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/PVE/Auth/LDAP.pm b/src/PVE/Auth/LDAP.pm
index 4d771e7..57782ad 100755
--- a/src/PVE/Auth/LDAP.pm
+++ b/src/PVE/Auth/LDAP.pm
@@ -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';
-- 
2.30.2





  reply	other threads:[~2023-03-23 13:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 13:14 [pve-devel] [PATCH access-control/docs] fix #4609: fix ldap regex Dominik Csapak
2023-03-23 13:14 ` Dominik Csapak [this message]
2023-03-23 13:43   ` [pve-devel] [PATCH access-control 1/1] fix #4609: allow valid DN in ldap/ad realm config Thomas Lamprecht
2023-03-23 14:09   ` Friedrich Weber
2023-03-23 14:49   ` [pve-devel] applied: " Thomas Lamprecht
2023-03-23 13:14 ` [pve-devel] [PATCH docs 1/1] user management: ldap: specify space and number sign escaping Dominik Csapak
2023-03-23 16:15   ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230323131430.3185211-2-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal