[pmg-devel] [PATCH pmg-api] LDAPCache: combine ldaps/starttls branches for connect

Dominik Csapak d.csapak at proxmox.com
Fri Apr 3 14:29:57 CEST 2020


they are similar except the setting of the verify options, so
combine them as

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

diff --git a/src/PMG/LDAPCache.pm b/src/PMG/LDAPCache.pm
index 3045c27..df61454 100755
--- a/src/PMG/LDAPCache.pm
+++ b/src/PMG/LDAPCache.pm
@@ -257,15 +257,12 @@ sub ldap_connect {
     my $opts = {};
     my $scheme = $self->{mode};
 
-    if ($scheme eq 'ldaps') {
-	$opts->{verify} = 'require' if $self->{verify};
-	if ($self->{cafile}) {
-	    $opts->{cafile} = $self->{cafile};
-	} else {
-	    $opts->{capath} = '/etc/ssl/certs/';
+    if ($scheme eq 'ldaps' || $scheme eq 'ldap+starttls') {
+	if ($self->{verify}) {
+	    $opts->{verify} = 'require';
+	} elsif ($scheme eq 'ldap+starttls') {
+	    $opts->{verify} = 'none';
 	}
-    } elsif ($self->{mode} eq 'ldap+starttls') {
-	$opts->{verify} = $self->{verify} ? 'require' : 'none';
 
 	if ($self->{cafile}) {
 	    $opts->{cafile} = $self->{cafile};
-- 
2.20.1




More information about the pmg-devel mailing list