autofs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oscar Salvador <osalvador@suse.com>
To: autofs@vger.kernel.org
Cc: Oscar Salvador <osalvador@suse.com>, Jeff Mahoney <jeffm@suse.com>
Subject: [PATCH] Test for ldap connectivity during lookup_ldap initialization
Date: Thu, 10 Aug 2017 23:15:21 +0200	[thread overview]
Message-ID: <1502399721-2491-1-git-send-email-osalvador@suse.com> (raw)

Right now we are just checking and parsing the ldap's configuration
in lookup_init() function, and if everything goes well we return a zero
value indicating that everything worked fine.

This has a problem, because in the case we set ldap method in
/etc/nsswitch.conf, configuration parsing goes fine but ldap is not working,
we will return a zero value in lookup_init() function, so autofs will move on,
but then we will return NSS_STATUS_UNAVAIL in lookup_read_master() function
once do_reconnect() fails, and because of this autofs will not be able to
reread the maps.

NIS already handles this by testing for server connectivity during initialization.
This patch does the same thing for LDAP.

Signed-off-by: Oscar Salvador <osalvador@suse.com>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 modules/lookup_ldap.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
index 98701e5..29a67a5 100644
--- a/modules/lookup_ldap.c
+++ b/modules/lookup_ldap.c
@@ -1681,6 +1681,7 @@ static int do_init(const char *mapfmt,
 		   int argc, const char *const *argv,
 		   struct lookup_context *ctxt, unsigned int reinit)
 {
+	struct ldap_conn conn;
 	unsigned int is_amd_format;
 	int ret;
 
@@ -1810,6 +1811,12 @@ static int do_init(const char *mapfmt,
 		}
 	}
 
+	memset(&conn, 0, sizeof(struct ldap_conn));
+	ret = do_reconnect (LOGOPT_ANY, &conn, ctxt);
+	if (ret != NSS_STATUS_SUCCESS)
+		return 1;
+
+	unbind_ldap_connection(LOGOPT_ANY, &conn, ctxt);
 	return ret;
 }
 
-- 
2.12.3

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

             reply	other threads:[~2017-08-10 21:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-10 21:15 Oscar Salvador [this message]
2017-08-16  5:02 ` [PATCH] Test for ldap connectivity during lookup_ldap initialization Ian Kent
2017-08-16  5:46   ` Ian Kent
2017-08-16  7:21     ` Oscar Salvador
2017-08-16  8:25       ` Ian Kent
2017-08-16  9:39         ` Ian Kent
2017-08-16  9:43           ` Ian Kent
2017-08-16 10:00             ` Ian Kent
2017-08-17  9:48               ` Oscar Salvador
2017-08-18  7:35                 ` Ian Kent
2017-08-18  7:54                   ` Ian Kent
2017-08-18  8:03                   ` Oscar Salvador

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1502399721-2491-1-git-send-email-osalvador@suse.com \
    --to=osalvador@suse.com \
    --cc=autofs@vger.kernel.org \
    --cc=jeffm@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).