|
|
63b9c2 |
autofs-5.1.6 - add support for new sss autofs proto version call
|
|
|
63b9c2 |
|
|
|
63b9c2 |
From: Ian Kent <raven@themaw.net>
|
|
|
63b9c2 |
|
|
|
63b9c2 |
Add sss protocol feature version function existence check and local get
|
|
|
63b9c2 |
function.
|
|
|
63b9c2 |
|
|
|
63b9c2 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
63b9c2 |
---
|
|
|
63b9c2 |
CHANGELOG | 1 +
|
|
|
63b9c2 |
modules/lookup_sss.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
|
|
|
63b9c2 |
2 files changed, 45 insertions(+)
|
|
|
63b9c2 |
|
|
|
63b9c2 |
diff --git a/CHANGELOG b/CHANGELOG
|
|
|
63b9c2 |
index 1830730..7c22aa1 100644
|
|
|
63b9c2 |
--- a/CHANGELOG
|
|
|
63b9c2 |
+++ b/CHANGELOG
|
|
|
63b9c2 |
@@ -96,6 +96,7 @@ xx/xx/2018 autofs-5.1.5
|
|
|
63b9c2 |
- fix sss_master_map_wait timing.
|
|
|
63b9c2 |
- add sss ECONREFUSED return handling.
|
|
|
63b9c2 |
- use mapname in sss context for setautomntent().
|
|
|
63b9c2 |
+- add support for new sss autofs proto version call.
|
|
|
63b9c2 |
|
|
|
63b9c2 |
19/12/2017 autofs-5.1.4
|
|
|
63b9c2 |
- fix spec file url.
|
|
|
63b9c2 |
diff --git a/modules/lookup_sss.c b/modules/lookup_sss.c
|
|
|
63b9c2 |
index c44c55d..3819981 100644
|
|
|
63b9c2 |
--- a/modules/lookup_sss.c
|
|
|
63b9c2 |
+++ b/modules/lookup_sss.c
|
|
|
63b9c2 |
@@ -37,11 +37,29 @@
|
|
|
63b9c2 |
|
|
|
63b9c2 |
#define SSS_SO_NAME "libsss_autofs"
|
|
|
63b9c2 |
|
|
|
63b9c2 |
+/* If the sss library protocol version is greater than 0 there are
|
|
|
63b9c2 |
+ * more possibile error returns from the sss autofs library calls.
|
|
|
63b9c2 |
+ *
|
|
|
63b9c2 |
+ * If ECONNREFUSED is returned then sssd is not running or not
|
|
|
63b9c2 |
+ * configured on the system, immediately return an unavailable
|
|
|
63b9c2 |
+ * status.
|
|
|
63b9c2 |
+ *
|
|
|
63b9c2 |
+ * A return of EHOSTDOWN means sss backend server is down so we
|
|
|
63b9c2 |
+ * should retry.
|
|
|
63b9c2 |
+ *
|
|
|
63b9c2 |
+ * With older sss ilibrary we can get a return of ENOENT for the
|
|
|
63b9c2 |
+ * above cases so also wait in that case since we can't be sure
|
|
|
63b9c2 |
+ * the map doesn't exist.
|
|
|
63b9c2 |
+ */
|
|
|
63b9c2 |
+#define SSS_PROTO_VERSION 1
|
|
|
63b9c2 |
+
|
|
|
63b9c2 |
+unsigned int _sss_auto_protocol_version(unsigned int);
|
|
|
63b9c2 |
int _sss_setautomntent(const char *, void **);
|
|
|
63b9c2 |
int _sss_getautomntent_r(char **, char **, void *);
|
|
|
63b9c2 |
int _sss_getautomntbyname_r(char *, char **, void *);
|
|
|
63b9c2 |
int _sss_endautomntent(void **);
|
|
|
63b9c2 |
|
|
|
63b9c2 |
+typedef unsigned int (*protocol_version_t) (unsigned int);
|
|
|
63b9c2 |
typedef int (*setautomntent_t) (const char *, void **);
|
|
|
63b9c2 |
typedef int (*getautomntent_t) (char **, char **, void *);
|
|
|
63b9c2 |
typedef int (*getautomntbyname_t) (char *, char **, void *);
|
|
|
63b9c2 |
@@ -50,6 +68,7 @@ typedef int (*endautomntent_t) (void **);
|
|
|
63b9c2 |
struct lookup_context {
|
|
|
63b9c2 |
const char *mapname;
|
|
|
63b9c2 |
void *dlhandle;
|
|
|
63b9c2 |
+ protocol_version_t protocol_version;
|
|
|
63b9c2 |
setautomntent_t setautomntent;
|
|
|
63b9c2 |
getautomntent_t getautomntent_r;
|
|
|
63b9c2 |
getautomntbyname_t getautomntbyname_r;
|
|
|
63b9c2 |
@@ -58,6 +77,8 @@ struct lookup_context {
|
|
|
63b9c2 |
};
|
|
|
63b9c2 |
|
|
|
63b9c2 |
int lookup_version = AUTOFS_LOOKUP_VERSION; /* Required by protocol */
|
|
|
63b9c2 |
+int sss_proto_version = SSS_PROTO_VERSION; /* 0 => initial version,
|
|
|
63b9c2 |
+ * >= 1 => new error handling. */
|
|
|
63b9c2 |
|
|
|
63b9c2 |
static int open_sss_lib(struct lookup_context *ctxt)
|
|
|
63b9c2 |
{
|
|
|
63b9c2 |
@@ -78,6 +99,11 @@ static int open_sss_lib(struct lookup_context *ctxt)
|
|
|
63b9c2 |
return 1;
|
|
|
63b9c2 |
ctxt->dlhandle = dh;
|
|
|
63b9c2 |
|
|
|
63b9c2 |
+ /* Don't fail on NULL, it's simply not present in this version of the
|
|
|
63b9c2 |
+ * sss autofs library.
|
|
|
63b9c2 |
+ */
|
|
|
63b9c2 |
+ ctxt->protocol_version = (protocol_version_t) dlsym(dh, "_sss_auto_protocol_version");
|
|
|
63b9c2 |
+
|
|
|
63b9c2 |
ctxt->setautomntent = (setautomntent_t) dlsym(dh, "_sss_setautomntent");
|
|
|
63b9c2 |
if (!ctxt->setautomntent)
|
|
|
63b9c2 |
goto lib_names_fail;
|
|
|
63b9c2 |
@@ -193,6 +219,7 @@ int lookup_reinit(const char *mapfmt,
|
|
|
63b9c2 |
}
|
|
|
63b9c2 |
|
|
|
63b9c2 |
new->dlhandle = ctxt->dlhandle;
|
|
|
63b9c2 |
+ new->protocol_version = ctxt->protocol_version;
|
|
|
63b9c2 |
new->setautomntent = ctxt->setautomntent;
|
|
|
63b9c2 |
new->getautomntent_r = ctxt->getautomntent_r;
|
|
|
63b9c2 |
new->getautomntbyname_r = ctxt->getautomntbyname_r;
|
|
|
63b9c2 |
@@ -219,6 +246,23 @@ static int setautomntent(unsigned int logopt,
|
|
|
63b9c2 |
return ret;
|
|
|
63b9c2 |
}
|
|
|
63b9c2 |
|
|
|
63b9c2 |
+static unsigned int proto_version(struct lookup_context *ctxt)
|
|
|
63b9c2 |
+{
|
|
|
63b9c2 |
+ unsigned int proto_version = 0;
|
|
|
63b9c2 |
+
|
|
|
63b9c2 |
+ if (ctxt->protocol_version) {
|
|
|
63b9c2 |
+ /* If ctxt->protocol_version() is defined it's assumed
|
|
|
63b9c2 |
+ * that for sss_proto_version <= sss autofs library
|
|
|
63b9c2 |
+ * protocol version ctxt->protocol_version() will
|
|
|
63b9c2 |
+ * return the version requested by autofs to indicate
|
|
|
63b9c2 |
+ * it userstands what the autofs module is capable of
|
|
|
63b9c2 |
+ * handling.
|
|
|
63b9c2 |
+ */
|
|
|
63b9c2 |
+ proto_version = ctxt->protocol_version(sss_proto_version);
|
|
|
63b9c2 |
+ }
|
|
|
63b9c2 |
+ return proto_version;
|
|
|
63b9c2 |
+}
|
|
|
63b9c2 |
+
|
|
|
63b9c2 |
static int setautomntent_wait(unsigned int logopt,
|
|
|
63b9c2 |
struct lookup_context *ctxt,
|
|
|
63b9c2 |
void **sss_ctxt, unsigned int retries)
|