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