mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-08-26 08:51:25 +02:00
55 lines
1.5 KiB
Diff
55 lines
1.5 KiB
Diff
From 04e4c521b34d1987af915ff97dcb0d87daf122b0 Mon Sep 17 00:00:00 2001
|
|
From: ID Fake <idfake@gmx.net>
|
|
Date: Thu, 27 Jul 2017 23:55:12 +0200
|
|
Subject: [PATCH] table-ldap reconnect
|
|
|
|
Patch-Source: https://github.com/OpenSMTPD/OpenSMTPD-extras/commit/04e4c521b34d1987af915ff97dcb0d87daf122b0
|
|
https://github.com/OpenSMTPD/OpenSMTPD-extras/commit/07764840916e4d0ca0925dcc8722dd20d8347e95
|
|
---
|
|
extras/tables/table-ldap/table_ldap.c | 16 +++++++++++++++-
|
|
1 file changed, 15 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/extras/tables/table-ldap/table_ldap.c b/extras/tables/table-ldap/table_ldap.c
|
|
index 5b54c86..5e9152f 100644
|
|
--- a/extras/tables/table-ldap/table_ldap.c
|
|
+++ b/extras/tables/table-ldap/table_ldap.c
|
|
@@ -77,13 +77,22 @@ table_ldap_update(void)
|
|
static int
|
|
table_ldap_check(int service, struct dict *params, const char *key)
|
|
{
|
|
+ int ret;
|
|
+
|
|
switch(service) {
|
|
case K_ALIAS:
|
|
case K_DOMAIN:
|
|
case K_CREDENTIALS:
|
|
case K_USERINFO:
|
|
case K_MAILADDR:
|
|
- return ldap_run_query(service, key, NULL, 0);
|
|
+ if ((ret = ldap_run_query(service, key, NULL, 0)) >= 0) {
|
|
+ return ret;
|
|
+ }
|
|
+ log_debug("debug: table-ldap: reconnecting");
|
|
+ if (!(ret = ldap_open())) {
|
|
+ log_warnx("warn: table-ldap: failed to connect");
|
|
+ }
|
|
+ return ret;
|
|
default:
|
|
return -1;
|
|
}
|
|
@@ -306,6 +315,11 @@ ldap_open(void)
|
|
{
|
|
struct aldap_message *amsg = NULL;
|
|
|
|
+ if (aldap) {
|
|
+ aldap_close(aldap);
|
|
+ log_info("info: table-ldap: closed previous connection");
|
|
+ }
|
|
+
|
|
aldap = ldap_connect(url);
|
|
if (aldap == NULL) {
|
|
log_warnx("warn: ldap_connect error");
|
|
--
|
|
2.18.0
|
|
|