[pve-devel] [PATCH common 3/3] add ldap-simple-attr from pmg

Dominik Csapak d.csapak at proxmox.com
Fri Mar 6 11:05:36 CET 2020


we also need it in pve

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PVE/JSONSchema.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 599dd09..fa405ac 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -265,6 +265,19 @@ sub pve_verify_ip {
     return $ip;
 }
 
+PVE::JSONSchema::register_format('ldap-simple-attr', \&verify_ldap_simple_attr);
+sub verify_ldap_simple_attr {
+    my ($attr, $noerr) = @_;
+
+    if ($attr =~ m/^[a-zA-Z0-9]+$/) {
+	return $attr;
+    }
+
+    die "value '$attr' does not look like a simple ldap attribute name\n" if !$noerr;
+
+    return undef;
+}
+
 my $ipv4_mask_hash = {
     '0.0.0.0' => 0,
     '128.0.0.0' => 1,
-- 
2.20.1





More information about the pve-devel mailing list