From 33404a62c01053c6a25b21445bb2731249064618 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Apr 23 2021 15:55:50 +0000 Subject: ipa-otpd: handle LDAP timeout in a better way When LDAP server disconnects ipa-otpd client connection due to a timeout, ipa-otpd instance would stop and report an issue. This confuses systemd service reporting, so for these situations we better to shut down gracefully. Fixes: https://pagure.io/freeipa/issue/6587 Signed-off-by: Alexander Bokovoy Reviewed-By: Rob Crittenden Reviewed-By: Simo Sorce --- diff --git a/daemons/ipa-otpd/bind.c b/daemons/ipa-otpd/bind.c index a98312f..61efe4d 100644 --- a/daemons/ipa-otpd/bind.c +++ b/daemons/ipa-otpd/bind.c @@ -85,9 +85,11 @@ static void on_bind_readable(verto_ctx *vctx, verto_ev *ev) if (rslt <= 0) results = NULL; ldap_msgfree(results); - otpd_log_err(EIO, "IO error received on bind socket"); + otpd_log_err(EIO, "IO error received on bind socket: %s", ldap_err2string(rslt)); verto_break(ctx.vctx); - ctx.exitstatus = 1; + /* if result is -1 or 0, connection was closed by the server side + * or the server is down and we should exit gracefully */ + ctx.exitstatus = (rslt <= 0) ? 0 : 1; return; }