[PATCH 2/6] Use global context for winbindd_request_response
Matthew Newton
mcn4 at leicester.ac.uk
Sun Feb 22 18:19:50 MST 2015
Updating API call in libwbclient, wbinfo, ntlm_auth and
winbind_nss_* as per previous commit to wb_common.c.
Signed-off-by: Matthew Newton <matthew-git at newtoncomputing.co.uk>
---
nsswitch/libwbclient/wbclient.c | 10 ++++----
nsswitch/wbinfo.c | 4 ++--
nsswitch/winbind_nss_aix.c | 30 ++++++++++++++++--------
nsswitch/winbind_nss_linux.c | 49 ++++++++++++++++++++++++---------------
nsswitch/winbind_nss_netbsd.c | 3 ++-
nsswitch/winbind_nss_solaris.c | 9 ++++---
source3/utils/ntlm_auth.c | 16 ++++++-------
7 files changed, 74 insertions(+), 47 deletions(-)
diff --git a/nsswitch/libwbclient/wbclient.c b/nsswitch/libwbclient/wbclient.c
index 19bb3e9..93c0318e 100644
--- a/nsswitch/libwbclient/wbclient.c
+++ b/nsswitch/libwbclient/wbclient.c
@@ -27,10 +27,12 @@
/* From wb_common.c */
-NSS_STATUS winbindd_request_response(int req_type,
+NSS_STATUS winbindd_request_response(struct winbindd_context *wbctx,
+ int req_type,
struct winbindd_request *request,
struct winbindd_response *response);
-NSS_STATUS winbindd_priv_request_response(int req_type,
+NSS_STATUS winbindd_priv_request_response(struct winbindd_context *wbctx,
+ int req_type,
struct winbindd_request *request,
struct winbindd_response *response);
@@ -51,7 +53,7 @@ static wbcErr wbcRequestResponseInt(
int cmd,
struct winbindd_request *request,
struct winbindd_response *response,
- NSS_STATUS (*fn)(int req_type,
+ NSS_STATUS (*fn)(struct winbindd_context *wbctx, int req_type,
struct winbindd_request *request,
struct winbindd_response *response))
{
@@ -60,7 +62,7 @@ static wbcErr wbcRequestResponseInt(
/* for some calls the request and/or response can be NULL */
- nss_status = fn(cmd, request, response);
+ nss_status = fn(NULL, cmd, request, response);
switch (nss_status) {
case NSS_STATUS_SUCCESS:
diff --git a/nsswitch/wbinfo.c b/nsswitch/wbinfo.c
index a31fbdf..216379f 100644
--- a/nsswitch/wbinfo.c
+++ b/nsswitch/wbinfo.c
@@ -688,7 +688,7 @@ static bool wbinfo_getdcname(const char *domain_name)
/* Send request */
- if (winbindd_request_response(WINBINDD_GETDCNAME, &request,
+ if (winbindd_request_response(NULL, WINBINDD_GETDCNAME, &request,
&response) != NSS_STATUS_SUCCESS) {
d_fprintf(stderr, "Could not get dc name for %s\n",domain_name);
return false;
@@ -1898,7 +1898,7 @@ static bool wbinfo_klog(char *username)
request.flags |= WBFLAG_PAM_AFS_TOKEN;
- result = winbindd_request_response(WINBINDD_PAM_AUTH, &request,
+ result = winbindd_request_response(NULL, WINBINDD_PAM_AUTH, &request,
&response);
/* Display response */
diff --git a/nsswitch/winbind_nss_aix.c b/nsswitch/winbind_nss_aix.c
index 66200f3..7a847b2 100644
--- a/nsswitch/winbind_nss_aix.c
+++ b/nsswitch/winbind_nss_aix.c
@@ -279,7 +279,8 @@ static struct group *wb_aix_getgrgid(gid_t gid)
request.data.gid = gid;
- ret = winbindd_request_response(WINBINDD_GETGRGID, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_GETGRGID,
+ &request, &response);
logit("getgrgid ret=%d\n", ret);
@@ -311,7 +312,8 @@ static struct group *wb_aix_getgrnam(const char *name)
STRCPY_RETNULL(request.data.groupname, name);
- ret = winbindd_request_response(WINBINDD_GETGRNAM, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_GETGRNAM,
+ &request, &response);
HANDLE_ERRORS(ret);
@@ -370,7 +372,8 @@ static char *wb_aix_getgrset(char *user)
free(r_user);
}
- ret = winbindd_request_response(WINBINDD_GETGROUPS, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_GETGROUPS,
+ &request, &response);
HANDLE_ERRORS(ret);
@@ -409,7 +412,8 @@ static struct passwd *wb_aix_getpwuid(uid_t uid)
request.data.uid = uid;
- ret = winbindd_request_response(WINBINDD_GETPWUID, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_GETPWUID,
+ &request, &response);
HANDLE_ERRORS(ret);
@@ -442,7 +446,8 @@ static struct passwd *wb_aix_getpwnam(const char *name)
STRCPY_RETNULL(request.data.username, name);
- ret = winbindd_request_response(WINBINDD_GETPWNAM, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_GETPWNAM,
+ &request, &response);
HANDLE_ERRORS(ret);
@@ -475,7 +480,8 @@ static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size)
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- ret = winbindd_request_response(WINBINDD_LIST_USERS, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_LIST_USERS,
+ &request, &response);
if (ret != 0) {
errno = EINVAL;
return -1;
@@ -523,7 +529,8 @@ static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size)
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- ret = winbindd_request_response(WINBINDD_LIST_GROUPS, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_LIST_GROUPS,
+ &request, &response);
if (ret != 0) {
errno = EINVAL;
return -1;
@@ -602,7 +609,8 @@ static attrval_t pwd_to_sid(struct passwd *pwd)
request.data.uid = pwd->pw_uid;
- if (winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response) !=
+ if (winbindd_request_response(NULL, WINBINDD_UID_TO_SID,
+ &request, &response) !=
NSS_STATUS_SUCCESS) {
r.attr_flag = ENOENT;
} else {
@@ -888,7 +896,8 @@ static int wb_aix_authenticate(char *user, char *pass,
free(r_user);
}
- result = winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response);
+ result = winbindd_request_response(NULL, WINBINDD_PAM_AUTH,
+ &request, &response);
winbindd_free_response(&response);
@@ -937,7 +946,8 @@ static int wb_aix_chpass(char *user, char *oldpass, char *newpass, char **messag
free(r_user);
}
- result = winbindd_request_response(WINBINDD_PAM_CHAUTHTOK, &request, &response);
+ result = winbindd_request_response(NULL, WINBINDD_PAM_CHAUTHTOK,
+ &request, &response);
winbindd_free_response(&response);
diff --git a/nsswitch/winbind_nss_linux.c b/nsswitch/winbind_nss_linux.c
index 70ede3e..58020e3 100644
--- a/nsswitch/winbind_nss_linux.c
+++ b/nsswitch/winbind_nss_linux.c
@@ -401,7 +401,7 @@ _nss_winbind_setpwent(void)
winbindd_free_response(&getpwent_response);
}
- ret = winbindd_request_response(WINBINDD_SETPWENT, NULL, NULL);
+ ret = winbindd_request_response(NULL, WINBINDD_SETPWENT, NULL, NULL);
#ifdef DEBUG_NSS
fprintf(stderr, "[%5d]: setpwent returns %s (%d)\n", getpid(),
nss_err_str(ret), ret);
@@ -432,7 +432,7 @@ _nss_winbind_endpwent(void)
winbindd_free_response(&getpwent_response);
}
- ret = winbindd_request_response(WINBINDD_ENDPWENT, NULL, NULL);
+ ret = winbindd_request_response(NULL, WINBINDD_ENDPWENT, NULL, NULL);
#ifdef DEBUG_NSS
fprintf(stderr, "[%5d]: endpwent returns %s (%d)\n", getpid(),
nss_err_str(ret), ret);
@@ -481,7 +481,7 @@ _nss_winbind_getpwent_r(struct passwd *result, char *buffer,
request.data.num_entries = MAX_GETPWENT_USERS;
- ret = winbindd_request_response(WINBINDD_GETPWENT, &request,
+ ret = winbindd_request_response(NULL, WINBINDD_GETPWENT, &request,
&getpwent_response);
if (ret == NSS_STATUS_SUCCESS) {
@@ -569,7 +569,7 @@ _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result, char *buffer,
request.data.uid = uid;
- ret = winbindd_request_response(WINBINDD_GETPWUID, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_GETPWUID, &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
ret = fill_pwent(result, &response.data.pw,
@@ -645,7 +645,7 @@ _nss_winbind_getpwnam_r(const char *name, struct passwd *result, char *buffer,
request.data.username
[sizeof(request.data.username) - 1] = '\0';
- ret = winbindd_request_response(WINBINDD_GETPWNAM, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_GETPWNAM, &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
ret = fill_pwent(result, &response.data.pw, &buffer,
@@ -716,7 +716,7 @@ _nss_winbind_setgrent(void)
winbindd_free_response(&getgrent_response);
}
- ret = winbindd_request_response(WINBINDD_SETGRENT, NULL, NULL);
+ ret = winbindd_request_response(NULL, WINBINDD_SETGRENT, NULL, NULL);
#ifdef DEBUG_NSS
fprintf(stderr, "[%5d]: setgrent returns %s (%d)\n", getpid(),
nss_err_str(ret), ret);
@@ -748,7 +748,7 @@ _nss_winbind_endgrent(void)
winbindd_free_response(&getgrent_response);
}
- ret = winbindd_request_response(WINBINDD_ENDGRENT, NULL, NULL);
+ ret = winbindd_request_response(NULL, WINBINDD_ENDGRENT, NULL, NULL);
#ifdef DEBUG_NSS
fprintf(stderr, "[%5d]: endgrent returns %s (%d)\n", getpid(),
nss_err_str(ret), ret);
@@ -799,7 +799,7 @@ winbind_getgrent(enum winbindd_cmd cmd,
request.data.num_entries = MAX_GETGRENT_USERS;
- ret = winbindd_request_response(cmd, &request,
+ ret = winbindd_request_response(NULL, cmd, &request,
&getgrent_response);
if (ret == NSS_STATUS_SUCCESS) {
@@ -918,7 +918,8 @@ _nss_winbind_getgrnam_r(const char *name,
request.data.groupname
[sizeof(request.data.groupname) - 1] = '\0';
- ret = winbindd_request_response(WINBINDD_GETGRNAM, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_GETGRNAM,
+ &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
ret = fill_grent(result, &response.data.gr,
@@ -996,7 +997,8 @@ _nss_winbind_getgrgid_r(gid_t gid,
request.data.gid = gid;
- ret = winbindd_request_response(WINBINDD_GETGRGID, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_GETGRGID,
+ &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
@@ -1069,7 +1071,8 @@ _nss_winbind_initgroups_dyn(char *user, gid_t group, long int *start,
strncpy(request.data.username, user,
sizeof(request.data.username) - 1);
- ret = winbindd_request_response(WINBINDD_GETGROUPS, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_GETGROUPS,
+ &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
int num_gids = response.data.num_entries;
@@ -1181,7 +1184,8 @@ _nss_winbind_getusersids(const char *user_sid, char **group_sids,
strncpy(request.data.sid, user_sid,sizeof(request.data.sid) - 1);
request.data.sid[sizeof(request.data.sid) - 1] = '\0';
- ret = winbindd_request_response(WINBINDD_GETUSERSIDS, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_GETUSERSIDS,
+ &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
goto done;
@@ -1233,7 +1237,8 @@ _nss_winbind_nametosid(const char *name, char **sid, char *buffer,
sizeof(request.data.name.name) - 1);
request.data.name.name[sizeof(request.data.name.name) - 1] = '\0';
- ret = winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_LOOKUPNAME,
+ &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
*errnop = errno = EINVAL;
goto failed;
@@ -1283,7 +1288,8 @@ _nss_winbind_sidtoname(const char *sid, char **name, char *buffer,
/* we need to fetch the separator first time through */
if (!sep_char) {
- ret = winbindd_request_response(WINBINDD_INFO, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_INFO,
+ &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
*errnop = errno = EINVAL;
goto failed;
@@ -1298,7 +1304,8 @@ _nss_winbind_sidtoname(const char *sid, char **name, char *buffer,
sizeof(request.data.sid) - 1);
request.data.sid[sizeof(request.data.sid) - 1] = '\0';
- ret = winbindd_request_response(WINBINDD_LOOKUPSID, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_LOOKUPSID,
+ &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
*errnop = errno = EINVAL;
goto failed;
@@ -1354,7 +1361,8 @@ _nss_winbind_sidtouid(const char *sid, uid_t *uid, int *errnop)
strncpy(request.data.sid, sid, sizeof(request.data.sid) - 1);
request.data.sid[sizeof(request.data.sid) - 1] = '\0';
- ret = winbindd_request_response(WINBINDD_SID_TO_UID, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_SID_TO_UID,
+ &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
*errnop = errno = EINVAL;
goto failed;
@@ -1393,7 +1401,8 @@ _nss_winbind_sidtogid(const char *sid, gid_t *gid, int *errnop)
strncpy(request.data.sid, sid, sizeof(request.data.sid) - 1);
request.data.sid[sizeof(request.data.sid) - 1] = '\0';
- ret = winbindd_request_response(WINBINDD_SID_TO_GID, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_SID_TO_GID,
+ &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
*errnop = errno = EINVAL;
goto failed;
@@ -1432,7 +1441,8 @@ _nss_winbind_uidtosid(uid_t uid, char **sid, char *buffer,
request.data.uid = uid;
- ret = winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_UID_TO_SID,
+ &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
*errnop = errno = EINVAL;
goto failed;
@@ -1480,7 +1490,8 @@ _nss_winbind_gidtosid(gid_t gid, char **sid, char *buffer,
request.data.gid = gid;
- ret = winbindd_request_response(WINBINDD_GID_TO_SID, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_GID_TO_SID,
+ &request, &response);
if (ret != NSS_STATUS_SUCCESS) {
*errnop = errno = EINVAL;
goto failed;
diff --git a/nsswitch/winbind_nss_netbsd.c b/nsswitch/winbind_nss_netbsd.c
index f673806..eb843ee 100644
--- a/nsswitch/winbind_nss_netbsd.c
+++ b/nsswitch/winbind_nss_netbsd.c
@@ -228,7 +228,8 @@ netbsdwinbind_getgroupmembership(void *nsrv, void *nscb, va_list ap)
ZERO_STRUCT(response);
strncpy(request.data.username, uname,
sizeof(request.data.username) - 1);
- i = winbindd_request_response(WINBINDD_GETGROUPS, &request, &response);
+ i = winbindd_request_response(NULL, WINBINDD_GETGROUPS,
+ &request, &response);
if (i != NSS_STATUS_SUCCESS)
return NS_NOTFOUND;
wblistv = (gid_t *)response.extra_data.data;
diff --git a/nsswitch/winbind_nss_solaris.c b/nsswitch/winbind_nss_solaris.c
index 6d3c8a9..1d0ac90 100644
--- a/nsswitch/winbind_nss_solaris.c
+++ b/nsswitch/winbind_nss_solaris.c
@@ -515,7 +515,8 @@ _nss_winbind_ipnodes_getbyname(nss_backend_t* be, void *args)
strncpy(request.data.winsreq, argp->key.name, sizeof(request.data.winsreq) - 1);
request.data.winsreq[sizeof(request.data.winsreq) - 1] = '\0';
- if( (ret = winbindd_request_response(WINBINDD_WINS_BYNAME, &request, &response))
+ if( (ret = winbindd_request_response(NULL, WINBINDD_WINS_BYNAME,
+ &request, &response))
== NSS_STATUS_SUCCESS ) {
ret = parse_response(af, argp, &response);
}
@@ -538,7 +539,8 @@ _nss_winbind_hosts_getbyname(nss_backend_t* be, void *args)
strncpy(request.data.winsreq, argp->key.name, sizeof(request.data.winsreq) - 1);
request.data.winsreq[sizeof(request.data.winsreq) - 1] = '\0';
- if( (ret = winbindd_request_response(WINBINDD_WINS_BYNAME, &request, &response))
+ if( (ret = winbindd_request_response(NULL, WINBINDD_WINS_BYNAME,
+ &request, &response))
== NSS_STATUS_SUCCESS ) {
ret = parse_response(AF_INET, argp, &response);
}
@@ -577,7 +579,8 @@ _nss_winbind_hosts_getbyaddr(nss_backend_t* be, void *args)
((unsigned char *)argp->key.hostaddr.addr)[3]);
#endif
- ret = winbindd_request_response(WINBINDD_WINS_BYIP, &request, &response);
+ ret = winbindd_request_response(NULL, WINBINDD_WINS_BYIP,
+ &request, &response);
if( ret == NSS_STATUS_SUCCESS) {
parse_response(argp->key.hostaddr.type, argp, &response);
diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
index f907742..3906f38 100644
--- a/source3/utils/ntlm_auth.c
+++ b/source3/utils/ntlm_auth.c
@@ -269,7 +269,7 @@ static char winbind_separator(void)
/* Send off request */
- if (winbindd_request_response(WINBINDD_INFO, NULL, &response) !=
+ if (winbindd_request_response(NULL, WINBINDD_INFO, NULL, &response) !=
NSS_STATUS_SUCCESS) {
d_printf("could not obtain winbind separator!\n");
return *lp_winbind_separator();
@@ -299,7 +299,7 @@ const char *get_winbind_domain(void)
/* Send off request */
- if (winbindd_request_response(WINBINDD_DOMAIN_NAME, NULL, &response) !=
+ if (winbindd_request_response(NULL, WINBINDD_DOMAIN_NAME, NULL, &response) !=
NSS_STATUS_SUCCESS) {
DEBUG(1, ("could not obtain winbind domain name!\n"));
return lp_workgroup();
@@ -325,7 +325,7 @@ const char *get_winbind_netbios_name(void)
/* Send off request */
- if (winbindd_request_response(WINBINDD_NETBIOS_NAME, NULL, &response) !=
+ if (winbindd_request_response(NULL, WINBINDD_NETBIOS_NAME, NULL, &response) !=
NSS_STATUS_SUCCESS) {
DEBUG(1, ("could not obtain winbind netbios name!\n"));
return lp_netbios_name();
@@ -393,7 +393,7 @@ static bool get_require_membership_sid(void) {
return False;
}
- if (winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response) !=
+ if (winbindd_request_response(NULL, WINBINDD_LOOKUPNAME, &request, &response) !=
NSS_STATUS_SUCCESS) {
DEBUG(0, ("Winbindd lookupname failed to resolve %s into a SID!\n",
require_membership_of));
@@ -463,7 +463,7 @@ static bool check_plaintext_auth(const char *user, const char *pass,
sizeof(request.data.auth.require_membership_of_sid));
}
- result = winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response);
+ result = winbindd_request_response(NULL, WINBINDD_PAM_AUTH, &request, &response);
/* Display response */
@@ -558,7 +558,7 @@ NTSTATUS contact_winbind_auth_crap(const char *username,
request.data.auth_crap.nt_resp_len = nt_response->length;
}
- result = winbindd_request_response(WINBINDD_PAM_AUTH_CRAP, &request, &response);
+ result = winbindd_request_response(NULL, WINBINDD_PAM_AUTH_CRAP, &request, &response);
SAFE_FREE(request.extra_data.data);
/* Display response */
@@ -653,7 +653,7 @@ static NTSTATUS contact_winbind_change_pswd_auth_crap(const char *username,
request.data.chng_pswd_auth_crap.old_lm_hash_enc_len = old_lm_hash_enc.length;
}
- result = winbindd_request_response(WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP, &request, &response);
+ result = winbindd_request_response(NULL, WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP, &request, &response);
/* Display response */
@@ -1194,7 +1194,7 @@ static NTSTATUS do_ccache_ntlm_auth(DATA_BLOB initial_msg, DATA_BLOB challenge_m
challenge_msg.data, challenge_msg.length);
}
- result = winbindd_request_response(WINBINDD_CCACHE_NTLMAUTH, &wb_request, &wb_response);
+ result = winbindd_request_response(NULL, WINBINDD_CCACHE_NTLMAUTH, &wb_request, &wb_response);
SAFE_FREE(wb_request.extra_data.data);
if (result != NSS_STATUS_SUCCESS) {
--
1.7.10.4
--
Matthew Newton, Ph.D. <mcn4 at le.ac.uk>
Systems Specialist, Infrastructure Services,
I.T. Services, University of Leicester, Leicester LE1 7RH, United Kingdom
For IT help contact helpdesk extn. 2253, <ithelp at le.ac.uk>
More information about the samba-technical
mailing list