1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
From 02084c5ca94910ecedabd0f087b9853a39d396c8 Mon Sep 17 00:00:00 2001
From: Bernhard Schmidt <berni@debian.org>
Date: Wed, 19 Oct 2016 17:19:00 +0200
Subject: [PATCH] exit with EX_TEMPFAIL on LDAP errors (i.e. server
unavailable)
Fixes fln/gnarwl#8
---
src/dbaccess.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/dbaccess.c b/src/dbaccess.c
index 018c9e7..f85c97f 100644
--- a/src/dbaccess.c
+++ b/src/dbaccess.c
@@ -7,6 +7,7 @@
#include <unistd.h>
#include <stdio.h>
#include <string.h>
+#include <sysexits.h>
#include <ldap.h>
#include <lber.h>
@@ -181,7 +182,7 @@ void dbConnect() {
rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, cfg.ca_cert);
if (rc != LDAP_SUCCESS) {
syslog(LOG_MAIL|LOG_ERR,"CRIT/LDAP Set option TLS_CACERTFILE failed: %s",ldap_err2string(rc));
- exit(EXIT_FAILURE);
+ exit(EX_TEMPFAIL);
}
}
@@ -192,7 +193,7 @@ void dbConnect() {
if (ldcon==NULL) {
syslog(LOG_MAIL|LOG_ERR,"CRIT/LDAP Connection failed");
- exit(EXIT_FAILURE);
+ exit(EX_TEMPFAIL);
}
ldap_set_option(ldcon, LDAP_OPT_PROTOCOL_VERSION, &cfg.protver);
@@ -202,14 +203,14 @@ void dbConnect() {
rc = ldap_start_tls_s(ldcon, NULL, NULL);
if (rc != LDAP_SUCCESS) {
syslog(LOG_MAIL|LOG_ERR,"CRIT/LDAP StartTLS failed: %s",ldap_err2string(rc));
- exit(EXIT_FAILURE);
+ exit(EX_TEMPFAIL);
}
}
rc=ldap_simple_bind_s(ldcon,cfg.uid,cfg.pwd);
if (rc!=LDAP_SUCCESS) {
syslog(LOG_MAIL|LOG_ERR,"CRIT/LDAP %s",ldap_err2string(rc));
- exit(EXIT_FAILURE);
+ exit(EX_TEMPFAIL);
}
}
--
2.10.2
|