|
|
9eb798 |
From 53f7f75ebf2a5086d63989bdf1da0d42983d6448 Mon Sep 17 00:00:00 2001
|
|
|
9eb798 |
From: Alexander Bokovoy <abokovoy@redhat.com>
|
|
|
9eb798 |
Date: Fri, 3 Nov 2017 23:49:19 +0200
|
|
|
9eb798 |
Subject: [PATCH 17/18] Fix nss_sss callers
|
|
|
9eb798 |
|
|
|
9eb798 |
---
|
|
|
9eb798 |
src/back-sch-nss_sss.c | 82 +++++++++++++++++++++++++++++++++++---------------
|
|
|
9eb798 |
1 file changed, 57 insertions(+), 25 deletions(-)
|
|
|
9eb798 |
|
|
|
9eb798 |
diff --git a/src/back-sch-nss_sss.c b/src/back-sch-nss_sss.c
|
|
|
9eb798 |
index e3e6628..2b1b8b0 100644
|
|
|
9eb798 |
--- a/src/back-sch-nss_sss.c
|
|
|
9eb798 |
+++ b/src/back-sch-nss_sss.c
|
|
|
9eb798 |
@@ -52,6 +52,20 @@ struct nss_ops_ctx {
|
|
|
9eb798 |
int *errnop);
|
|
|
9eb798 |
};
|
|
|
9eb798 |
|
|
|
9eb798 |
+void backend_nss_free_context(struct nss_ops_ctx **nss_context)
|
|
|
9eb798 |
+{
|
|
|
9eb798 |
+ if (nss_context == NULL) {
|
|
|
9eb798 |
+ return;
|
|
|
9eb798 |
+ }
|
|
|
9eb798 |
+
|
|
|
9eb798 |
+ if ((*nss_context)->dl_handle != NULL) {
|
|
|
9eb798 |
+ dlclose((*nss_context)->dl_handle);
|
|
|
9eb798 |
+ }
|
|
|
9eb798 |
+
|
|
|
9eb798 |
+ free((*nss_context));
|
|
|
9eb798 |
+ *nss_context = NULL;
|
|
|
9eb798 |
+}
|
|
|
9eb798 |
+
|
|
|
9eb798 |
void backend_nss_init_context(struct nss_ops_ctx **nss_context)
|
|
|
9eb798 |
{
|
|
|
9eb798 |
struct nss_ops_ctx *ctx = NULL;
|
|
|
9eb798 |
@@ -105,21 +119,6 @@ fail:
|
|
|
9eb798 |
return;
|
|
|
9eb798 |
}
|
|
|
9eb798 |
|
|
|
9eb798 |
-void
|
|
|
9eb798 |
-backend_nss_free_context(struct nss_ops_ctx **nss_context)
|
|
|
9eb798 |
-{
|
|
|
9eb798 |
- if (nss_context == NULL) {
|
|
|
9eb798 |
- return;
|
|
|
9eb798 |
- }
|
|
|
9eb798 |
-
|
|
|
9eb798 |
- if ((*nss_context)->dl_handle != NULL) {
|
|
|
9eb798 |
- dlclose((*nss_context)->dl_handle);
|
|
|
9eb798 |
- }
|
|
|
9eb798 |
-
|
|
|
9eb798 |
- free((*nss_context));
|
|
|
9eb798 |
- *nss_context = NULL;
|
|
|
9eb798 |
-}
|
|
|
9eb798 |
-
|
|
|
9eb798 |
|
|
|
9eb798 |
/* Following three functions cannot be implemented with nss_sss.so.2
|
|
|
9eb798 |
* As result, we simply do nothing here */
|
|
|
9eb798 |
@@ -144,15 +143,22 @@ enum nss_status backend_nss_getpwnam(struct nss_ops_ctx *nss_context,
|
|
|
9eb798 |
char *buffer, size_t buflen,
|
|
|
9eb798 |
struct passwd **result,
|
|
|
9eb798 |
int *lerrno) {
|
|
|
9eb798 |
+ enum nss_status ret;
|
|
|
9eb798 |
|
|
|
9eb798 |
if (nss_context == NULL) {
|
|
|
9eb798 |
return NSS_STATUS_UNAVAIL;
|
|
|
9eb798 |
}
|
|
|
9eb798 |
|
|
|
9eb798 |
- return (enum nss_status)
|
|
|
9eb798 |
+ ret = (enum nss_status)
|
|
|
9eb798 |
nss_context->getpwnam_r(name, pwd,
|
|
|
9eb798 |
buffer, buflen,
|
|
|
9eb798 |
- result, lerrno);
|
|
|
9eb798 |
+ lerrno);
|
|
|
9eb798 |
+
|
|
|
9eb798 |
+ if ((ret == NSS_STATUS_SUCCESS) && (result != NULL)) {
|
|
|
9eb798 |
+ *result = pwd;
|
|
|
9eb798 |
+ }
|
|
|
9eb798 |
+
|
|
|
9eb798 |
+ return ret;
|
|
|
9eb798 |
}
|
|
|
9eb798 |
|
|
|
9eb798 |
enum nss_status backend_nss_getpwuid(struct nss_ops_ctx *nss_context,
|
|
|
9eb798 |
@@ -160,15 +166,22 @@ enum nss_status backend_nss_getpwuid(struct nss_ops_ctx *nss_context,
|
|
|
9eb798 |
char *buffer, size_t buflen,
|
|
|
9eb798 |
struct passwd **result,
|
|
|
9eb798 |
int *lerrno) {
|
|
|
9eb798 |
+ enum nss_status ret;
|
|
|
9eb798 |
|
|
|
9eb798 |
if (nss_context == NULL) {
|
|
|
9eb798 |
return NSS_STATUS_UNAVAIL;
|
|
|
9eb798 |
}
|
|
|
9eb798 |
|
|
|
9eb798 |
- return (enum nss_status)
|
|
|
9eb798 |
+ ret = (enum nss_status)
|
|
|
9eb798 |
nss_context->getpwuid_r(uid, pwd,
|
|
|
9eb798 |
buffer, buflen,
|
|
|
9eb798 |
- result, lerrno);
|
|
|
9eb798 |
+ lerrno);
|
|
|
9eb798 |
+
|
|
|
9eb798 |
+ if ((ret == NSS_STATUS_SUCCESS) && (result != NULL)) {
|
|
|
9eb798 |
+ *result = pwd;
|
|
|
9eb798 |
+ }
|
|
|
9eb798 |
+
|
|
|
9eb798 |
+ return ret;
|
|
|
9eb798 |
}
|
|
|
9eb798 |
|
|
|
9eb798 |
enum nss_status backend_nss_getgrnam(struct nss_ops_ctx *nss_context,
|
|
|
9eb798 |
@@ -176,15 +189,22 @@ enum nss_status backend_nss_getgrnam(struct nss_ops_ctx *nss_context,
|
|
|
9eb798 |
char *buffer, size_t buflen,
|
|
|
9eb798 |
struct group **result,
|
|
|
9eb798 |
int *lerrno) {
|
|
|
9eb798 |
+ enum nss_status ret;
|
|
|
9eb798 |
|
|
|
9eb798 |
if (nss_context == NULL) {
|
|
|
9eb798 |
return NSS_STATUS_UNAVAIL;
|
|
|
9eb798 |
}
|
|
|
9eb798 |
|
|
|
9eb798 |
- return (enum nss_status)
|
|
|
9eb798 |
+ ret = (enum nss_status)
|
|
|
9eb798 |
nss_context->getgrnam_r(name, grp,
|
|
|
9eb798 |
buffer, buflen,
|
|
|
9eb798 |
- result, lerrno);
|
|
|
9eb798 |
+ lerrno);
|
|
|
9eb798 |
+
|
|
|
9eb798 |
+ if ((ret == NSS_STATUS_SUCCESS) && (result != NULL)) {
|
|
|
9eb798 |
+ *result = grp;
|
|
|
9eb798 |
+ }
|
|
|
9eb798 |
+
|
|
|
9eb798 |
+ return ret;
|
|
|
9eb798 |
}
|
|
|
9eb798 |
|
|
|
9eb798 |
enum nss_status backend_nss_getgrgid(struct nss_ops_ctx *nss_context,
|
|
|
9eb798 |
@@ -193,21 +213,31 @@ enum nss_status backend_nss_getgrgid(struct nss_ops_ctx *nss_context,
|
|
|
9eb798 |
struct group **result,
|
|
|
9eb798 |
int *lerrno) {
|
|
|
9eb798 |
|
|
|
9eb798 |
+ enum nss_status ret;
|
|
|
9eb798 |
+
|
|
|
9eb798 |
if (nss_context == NULL) {
|
|
|
9eb798 |
return NSS_STATUS_UNAVAIL;
|
|
|
9eb798 |
}
|
|
|
9eb798 |
|
|
|
9eb798 |
- return (enum nss_status)
|
|
|
9eb798 |
+ ret = (enum nss_status)
|
|
|
9eb798 |
nss_context->getgrgid_r(gid, grp,
|
|
|
9eb798 |
buffer, buflen,
|
|
|
9eb798 |
- result, lerrno);
|
|
|
9eb798 |
+ lerrno);
|
|
|
9eb798 |
+
|
|
|
9eb798 |
+ if ((ret == NSS_STATUS_SUCCESS) && (result != NULL)) {
|
|
|
9eb798 |
+ *result = grp;
|
|
|
9eb798 |
+ }
|
|
|
9eb798 |
+
|
|
|
9eb798 |
+ return ret;
|
|
|
9eb798 |
}
|
|
|
9eb798 |
|
|
|
9eb798 |
enum nss_status backend_nss_getgrouplist(struct nss_ops_ctx *nss_context,
|
|
|
9eb798 |
const char *name, gid_t group,
|
|
|
9eb798 |
gid_t *groups, int *ngroups,
|
|
|
9eb798 |
int *lerrno) {
|
|
|
9eb798 |
+
|
|
|
9eb798 |
enum nss_status ret = NSS_STATUS_UNAVAIL;
|
|
|
9eb798 |
+ long int size = 0;
|
|
|
9eb798 |
|
|
|
9eb798 |
if (nss_context == NULL) {
|
|
|
9eb798 |
return NSS_STATUS_UNAVAIL;
|
|
|
9eb798 |
@@ -220,12 +250,14 @@ enum nss_status backend_nss_getgrouplist(struct nss_ops_ctx *nss_context,
|
|
|
9eb798 |
|
|
|
9eb798 |
ret = nss_context->initgroups_dyn(name, group,
|
|
|
9eb798 |
&nss_context->initgroups_start,
|
|
|
9eb798 |
- &ngroups, &groups,
|
|
|
9eb798 |
- -1, &lerrno);
|
|
|
9eb798 |
+ &size, &groups,
|
|
|
9eb798 |
+ -1, lerrno);
|
|
|
9eb798 |
if (ret == NSS_STATUS_SUCCESS) {
|
|
|
9eb798 |
nss_context->initgroups_start = 0;
|
|
|
9eb798 |
}
|
|
|
9eb798 |
|
|
|
9eb798 |
+ *ngroups = (int) size;
|
|
|
9eb798 |
+
|
|
|
9eb798 |
return ret;
|
|
|
9eb798 |
}
|
|
|
9eb798 |
|
|
|
9eb798 |
--
|
|
|
9eb798 |
2.13.6
|
|
|
9eb798 |
|