b346a32
From 3615f3ec7dd3c867a8394640c0fc4736189315df Mon Sep 17 00:00:00 2001
b346a32
From: Jan Kara <jack@suse.cz>
b346a32
Date: Thu, 5 Sep 2019 16:29:08 +0200
b346a32
Subject: [PATCH] warnquota: Properly detect LDAP errors
b346a32
MIME-Version: 1.0
b346a32
Content-Type: text/plain; charset=UTF-8
b346a32
Content-Transfer-Encoding: 8bit
b346a32
b346a32
ldap_search_ext_s() and ldap_sasl_bind_s() can return also positive
b346a32
error result codes. Catch them properly.
b346a32
b346a32
Signed-off-by: Jan Kara <jack@suse.cz>
b346a32
Signed-off-by: Petr Písař <ppisar@redhat.com>
b346a32
---
b346a32
 warnquota.c | 4 ++--
b346a32
 1 file changed, 2 insertions(+), 2 deletions(-)
b346a32
b346a32
diff --git a/warnquota.c b/warnquota.c
b346a32
index 53da671..24d7410 100644
b346a32
--- a/warnquota.c
b346a32
+++ b/warnquota.c
b346a32
@@ -201,7 +201,7 @@ static int setup_ldap(struct configparams *config)
b346a32
 		}
b346a32
 	}
b346a32
 	ret = ldap_sasl_bind_s(ldapconn, config->ldap_binddn, LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL);
b346a32
-	if(ret < 0) {
b346a32
+	if (ret != LDAP_SUCCESS) {
b346a32
 		errstr(_("ldap_sasl_bind_s() failed: %s\n"), ldap_err2string(ret));
b346a32
 		return -1;
b346a32
 	}
b346a32
@@ -426,7 +426,7 @@ static char *lookup_user(struct configparams *config, char *user)
b346a32
 		searchbuf, NULL, 0, NULL, NULL, NULL,
b346a32
 		0, &result);
b346a32
 
b346a32
-	if (ret < 0) {
b346a32
+	if (ret != LDAP_SUCCESS) {
b346a32
 		errstr(_("Error with %s.\n"), user);
b346a32
 		errstr(_("ldap_search_ext_s() failed: %s\n"), ldap_err2string(ret));
b346a32
 		return NULL;
b346a32
-- 
b346a32
2.21.0
b346a32