diff options
author | Stefan Metzmacher <metze@samba.org> | 2007-09-14 07:07:59 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:30:45 -0500 |
commit | 28d076d20f9ce8afbee9a5de157ec0c9e308c9cf (patch) | |
tree | 8e552ea1b57562a6b2eca6ad16489d7fd6dd6ebf /source3/nsswitch | |
parent | 45a2713b475e66a880b4c6f019dc22119444dc7b (diff) | |
download | samba-28d076d20f9ce8afbee9a5de157ec0c9e308c9cf.tar.gz samba-28d076d20f9ce8afbee9a5de157ec0c9e308c9cf.tar.bz2 samba-28d076d20f9ce8afbee9a5de157ec0c9e308c9cf.zip |
r25143: rename public functions from winbind_client.h
init_request => winbindd_init_request
free_response => winbindd_free_response
read_reply => winbindd_read_reply
write_sock => winbind_write_sock
read_sock => winbind_read_sock
close_sock => winbind_close_sock(void)
metze
(This used to be commit 8a95d7a7edcfa5e45bccc6eda5c45d9c308cb95d)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r-- | source3/nsswitch/pam_winbind.c | 12 | ||||
-rw-r--r-- | source3/nsswitch/wb_common.c | 60 | ||||
-rw-r--r-- | source3/nsswitch/winbind_client.h | 15 | ||||
-rw-r--r-- | source3/nsswitch/winbind_nss_aix.c | 22 | ||||
-rw-r--r-- | source3/nsswitch/winbind_nss_irix.c | 22 | ||||
-rw-r--r-- | source3/nsswitch/winbind_nss_linux.c | 36 | ||||
-rw-r--r-- | source3/nsswitch/winbind_nss_solaris.c | 6 |
7 files changed, 90 insertions, 83 deletions
diff --git a/source3/nsswitch/pam_winbind.c b/source3/nsswitch/pam_winbind.c index ab9be566da..f4793f77c8 100644 --- a/source3/nsswitch/pam_winbind.c +++ b/source3/nsswitch/pam_winbind.c @@ -440,23 +440,23 @@ static int pam_winbind_request(pam_handle_t * pamh, int ctrl, struct winbindd_response *response) { /* Fill in request and send down pipe */ - init_request(request, req_type); + winbindd_init_request(request, req_type); - if (write_sock(request, sizeof(*request), 0, 0) == -1) { + if (winbind_write_sock(request, sizeof(*request), 0, 0) == -1) { _pam_log(pamh, ctrl, LOG_ERR, "pam_winbind_request: write to socket failed!"); - close_sock(); + winbind_close_sock(); return PAM_SERVICE_ERR; } /* Wait for reply */ - if (read_reply(response) == -1) { + if (winbindd_read_reply(response) == -1) { _pam_log(pamh, ctrl, LOG_ERR, "pam_winbind_request: read from socket failed!"); - close_sock(); + winbind_close_sock(); return PAM_SERVICE_ERR; } /* We are done with the socket - close it and avoid mischeif */ - close_sock(); + winbind_close_sock(); /* Copy reply data from socket */ if (response->result == WINBINDD_OK) { diff --git a/source3/nsswitch/wb_common.c b/source3/nsswitch/wb_common.c index 9f02b9b7c7..bc65239b1b 100644 --- a/source3/nsswitch/wb_common.c +++ b/source3/nsswitch/wb_common.c @@ -31,7 +31,7 @@ static int is_privileged = 0; /* Free a response structure */ -void free_response(struct winbindd_response *response) +void winbindd_free_response(struct winbindd_response *response) { /* Free any allocated extra_data */ @@ -41,7 +41,7 @@ void free_response(struct winbindd_response *response) /* Initialise a request structure */ -void init_request(struct winbindd_request *request, int request_type) +void winbindd_init_request(struct winbindd_request *request, int request_type) { request->length = sizeof(struct winbindd_request); @@ -61,7 +61,7 @@ static void init_response(struct winbindd_response *response) /* Close established socket */ -void close_sock(void) +void winbind_close_sock(void) { if (winbindd_fd != -1) { close(winbindd_fd); @@ -292,12 +292,12 @@ static int winbind_open_pipe_sock(int recursing, int need_priv) ZERO_STRUCT(response); if (our_pid != getpid()) { - close_sock(); + winbind_close_sock(); our_pid = getpid(); } if ((need_priv != 0) && (is_privileged == 0)) { - close_sock(); + winbind_close_sock(); } if (winbindd_fd != -1) { @@ -318,7 +318,7 @@ static int winbind_open_pipe_sock(int recursing, int need_priv) request.wb_flags = WBFLAG_RECURSE; if ((winbindd_request_response(WINBINDD_INTERFACE_VERSION, &request, &response) != NSS_STATUS_SUCCESS) || (response.data.interface_version != WINBIND_INTERFACE_VERSION)) { - close_sock(); + winbind_close_sock(); return -1; } @@ -348,7 +348,7 @@ static int winbind_open_pipe_sock(int recursing, int need_priv) /* Write data to winbindd socket */ -int write_sock(void *buffer, int count, int recursing, int need_priv) +int winbind_write_sock(void *buffer, int count, int recursing, int need_priv) { int result, nwritten; @@ -376,7 +376,7 @@ int write_sock(void *buffer, int count, int recursing, int need_priv) ZERO_STRUCT(tv); if (select(winbindd_fd + 1, &r_fds, NULL, NULL, &tv) == -1) { - close_sock(); + winbind_close_sock(); return -1; /* Select error */ } @@ -394,7 +394,7 @@ int write_sock(void *buffer, int count, int recursing, int need_priv) /* Write failed */ - close_sock(); + winbind_close_sock(); return -1; } @@ -404,7 +404,7 @@ int write_sock(void *buffer, int count, int recursing, int need_priv) /* Pipe has closed on remote end */ - close_sock(); + winbind_close_sock(); goto restart; } } @@ -414,7 +414,7 @@ int write_sock(void *buffer, int count, int recursing, int need_priv) /* Read data from winbindd socket */ -static int read_sock(void *buffer, int count) +int winbind_read_sock(void *buffer, int count) { int nread = 0; int total_time = 0, selret; @@ -438,7 +438,7 @@ static int read_sock(void *buffer, int count) tv.tv_sec = 5; if ((selret = select(winbindd_fd + 1, &r_fds, NULL, NULL, &tv)) == -1) { - close_sock(); + winbind_close_sock(); return -1; /* Select error */ } @@ -446,7 +446,7 @@ static int read_sock(void *buffer, int count) /* Not ready for read yet... */ if (total_time >= 30) { /* Timeout */ - close_sock(); + winbind_close_sock(); return -1; } total_time += 5; @@ -466,7 +466,7 @@ static int read_sock(void *buffer, int count) can do here is just return -1 and fail since the transaction has failed half way through. */ - close_sock(); + winbind_close_sock(); return -1; } @@ -480,7 +480,7 @@ static int read_sock(void *buffer, int count) /* Read reply */ -int read_reply(struct winbindd_response *response) +int winbindd_read_reply(struct winbindd_response *response) { int result1, result2 = 0; @@ -490,9 +490,9 @@ int read_reply(struct winbindd_response *response) /* Read fixed length response */ - if ((result1 = read_sock(response, sizeof(struct winbindd_response))) - == -1) { - + result1 = winbind_read_sock(response, + sizeof(struct winbindd_response)); + if (result1 == -1) { return -1; } @@ -514,9 +514,10 @@ int read_reply(struct winbindd_response *response) return -1; } - if ((result2 = read_sock(response->extra_data.data, extra_data_len)) - == -1) { - free_response(response); + result2 = winbind_read_sock(response->extra_data.data, + extra_data_len); + if (result2 == -1) { + winbindd_free_response(response); return -1; } } @@ -560,16 +561,19 @@ NSS_STATUS winbindd_send_request(int req_type, int need_priv, /* Fill in request and send down pipe */ - init_request(request, req_type); + winbindd_init_request(request, req_type); - if (write_sock(request, sizeof(*request), - request->wb_flags & WBFLAG_RECURSE, need_priv) == -1) { + if (winbind_write_sock(request, sizeof(*request), + request->wb_flags & WBFLAG_RECURSE, + need_priv) == -1) { return NSS_STATUS_UNAVAIL; } if ((request->extra_len != 0) && - (write_sock(request->extra_data.data, request->extra_len, - request->wb_flags & WBFLAG_RECURSE, need_priv) == -1)) { + (winbind_write_sock(request->extra_data.data, + request->extra_len, + request->wb_flags & WBFLAG_RECURSE, + need_priv) == -1)) { return NSS_STATUS_UNAVAIL; } @@ -592,13 +596,13 @@ NSS_STATUS winbindd_get_response(struct winbindd_response *response) init_response(response); /* Wait for reply */ - if (read_reply(response) == -1) { + if (winbindd_read_reply(response) == -1) { return NSS_STATUS_UNAVAIL; } /* Throw away extra data if client didn't request it */ if (response == &lresponse) { - free_response(response); + winbindd_free_response(response); } /* Copy reply data from socket */ diff --git a/source3/nsswitch/winbind_client.h b/source3/nsswitch/winbind_client.h index 01e46a2203..7c955a1cc3 100644 --- a/source3/nsswitch/winbind_client.h +++ b/source3/nsswitch/winbind_client.h @@ -1,7 +1,8 @@ #include "winbind_nss_config.h" #include "winbindd_nss.h" -void init_request(struct winbindd_request *req,int rq_type); +void winbindd_init_request(struct winbindd_request *req,int rq_type); +void winbindd_free_response(struct winbindd_response *response); NSS_STATUS winbindd_send_request(int req_type, int need_priv, struct winbindd_request *request); NSS_STATUS winbindd_get_response(struct winbindd_response *response); @@ -11,12 +12,14 @@ NSS_STATUS winbindd_request_response(int req_type, NSS_STATUS winbindd_priv_request_response(int req_type, struct winbindd_request *request, struct winbindd_response *response); -int write_sock(void *buffer, int count, int recursing, int need_priv); -int read_reply(struct winbindd_response *response); -void close_sock(void); -void free_response(struct winbindd_response *response); -const char *nss_err_str(NSS_STATUS ret); +int winbindd_read_reply(struct winbindd_response *response); + bool winbind_env_set(void); bool winbind_off(void); bool winbind_on(void); +int winbind_write_sock(void *buffer, int count, int recursing, int need_priv); +int winbind_read_sock(void *buffer, int count); +void winbind_close_sock(void); + +const char *nss_err_str(NSS_STATUS ret); diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index 0ddd6de53f..9c84e5f8aa 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -284,7 +284,7 @@ static struct group *wb_aix_getgrgid(gid_t gid) grp = fill_grent(&response.data.gr, response.extra_data.data); - free_response(&response); + winbindd_free_response(&response); return grp; } @@ -314,7 +314,7 @@ static struct group *wb_aix_getgrnam(const char *name) grp = fill_grent(&response.data.gr, response.extra_data.data); - free_response(&response); + winbindd_free_response(&response); return grp; } @@ -385,7 +385,7 @@ static char *wb_aix_getgrset(char *user) } idx += sprintf(tmpbuf+idx, "%u", gid_list[i]); - free_response(&response); + winbindd_free_response(&response); return tmpbuf; } @@ -412,7 +412,7 @@ static struct passwd *wb_aix_getpwuid(uid_t uid) pwd = fill_pwent(&response.data.pw); - free_response(&response); + winbindd_free_response(&response); logit("getpwuid gave ptr %p\n", pwd); @@ -445,7 +445,7 @@ static struct passwd *wb_aix_getpwnam(const char *name) pwd = fill_pwent(&response.data.pw); - free_response(&response); + winbindd_free_response(&response); logit("getpwnam gave ptr %p\n", pwd); @@ -482,7 +482,7 @@ static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size) s = malloc(len+2); if (!s) { - free_response(&response); + winbindd_free_response(&response); errno = ENOMEM; return -1; } @@ -494,7 +494,7 @@ static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size) results[0].attr_un.au_char = s; results[0].attr_flag = 0; - free_response(&response); + winbindd_free_response(&response); return 0; } @@ -530,7 +530,7 @@ static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size) s = malloc(len+2); if (!s) { - free_response(&response); + winbindd_free_response(&response); errno = ENOMEM; return -1; } @@ -542,7 +542,7 @@ static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size) results[0].attr_un.au_char = s; results[0].attr_flag = 0; - free_response(&response); + winbindd_free_response(&response); return 0; } @@ -887,7 +887,7 @@ static int wb_aix_authenticate(char *user, char *pass, result = winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response); - free_response(&response); + winbindd_free_response(&response); logit("auth result %d for '%s'\n", result, user); @@ -936,7 +936,7 @@ static int wb_aix_chpass(char *user, char *oldpass, char *newpass, char **messag result = winbindd_request_response(WINBINDD_PAM_CHAUTHTOK, &request, &response); - free_response(&response); + winbindd_free_response(&response); if (result == NSS_STATUS_SUCCESS) { errno = 0; diff --git a/source3/nsswitch/winbind_nss_irix.c b/source3/nsswitch/winbind_nss_irix.c index b0277db559..4726c1e13f 100644 --- a/source3/nsswitch/winbind_nss_irix.c +++ b/source3/nsswitch/winbind_nss_irix.c @@ -195,7 +195,7 @@ winbind_callback(nsd_file_t **rqp, int fd) if (status != NSS_STATUS_SUCCESS) { /* free any extra data area in response structure */ - free_response(&response); + winbindd_free_response(&response); nsd_logprintf(NSD_LOG_MIN, "callback (winbind) returning not found, status = %d\n", status); @@ -227,7 +227,7 @@ winbind_callback(nsd_file_t **rqp, int fd) return NSD_ERROR; } - free_response(&response); + winbindd_free_response(&response); nsd_logprintf(NSD_LOG_MIN, " %s\n", result); nsd_set_result(rq, NS_SUCCESS, result, rlen, DYNAMIC); @@ -252,7 +252,7 @@ winbind_callback(nsd_file_t **rqp, int fd) if (rlen == 0 || result == NULL) return NSD_ERROR; - free_response(&response); + winbindd_free_response(&response); nsd_logprintf(NSD_LOG_MIN, " %s\n", result); nsd_set_result(rq, NS_SUCCESS, result, rlen, DYNAMIC); @@ -279,7 +279,7 @@ winbind_callback(nsd_file_t **rqp, int fd) if (rlen == 0 || result == NULL) return NSD_ERROR; - free_response(&response); + winbindd_free_response(&response); nsd_logprintf(NSD_LOG_MIN, " %s\n", result); nsd_set_result(rq, NS_SUCCESS, result, rlen, DYNAMIC); @@ -290,7 +290,7 @@ winbind_callback(nsd_file_t **rqp, int fd) case WINBINDD_SETPWENT: nsd_logprintf(NSD_LOG_MIN, "callback (winbind) SETGRENT | SETPWENT\n"); - free_response(&response); + winbindd_free_response(&response); return(do_list(1,rq)); case WINBINDD_GETGRENT: @@ -311,7 +311,7 @@ winbind_callback(nsd_file_t **rqp, int fd) gr = (struct winbindd_gr *)response.extra_data.data; if (! gr ) { nsd_logprintf(NSD_LOG_MIN, " no extra_data\n"); - free_response(&response); + winbindd_free_response(&response); return NSD_ERROR; } @@ -338,7 +338,7 @@ winbind_callback(nsd_file_t **rqp, int fd) } entries = response.data.num_entries; - free_response(&response); + winbindd_free_response(&response); if (entries < MAX_GETPWENT_USERS) return(do_list(2,rq)); else @@ -360,7 +360,7 @@ winbind_callback(nsd_file_t **rqp, int fd) pw = (struct winbindd_pw *)response.extra_data.data; if (! pw ) { nsd_logprintf(NSD_LOG_MIN, " no extra_data\n"); - free_response(&response); + winbindd_free_response(&response); return NSD_ERROR; } for (i = 0; i < response.data.num_entries; i++) { @@ -385,7 +385,7 @@ winbind_callback(nsd_file_t **rqp, int fd) } entries = response.data.num_entries; - free_response(&response); + winbindd_free_response(&response); if (entries < MAX_GETPWENT_USERS) return(do_list(2,rq)); else @@ -396,11 +396,11 @@ winbind_callback(nsd_file_t **rqp, int fd) case WINBINDD_ENDPWENT: nsd_logprintf(NSD_LOG_MIN, "callback (winbind) ENDGRENT | ENDPWENT\n"); nsd_append_element(rq, NS_SUCCESS, "\n", 1); - free_response(&response); + winbindd_free_response(&response); return NSD_NEXT; default: - free_response(&response); + winbindd_free_response(&response); nsd_logprintf(NSD_LOG_MIN, "callback (winbind) invalid command %d\n", (int)rq->f_cmd_data); return NSD_NEXT; } diff --git a/source3/nsswitch/winbind_nss_linux.c b/source3/nsswitch/winbind_nss_linux.c index acef1d53fe..ac53979ced 100644 --- a/source3/nsswitch/winbind_nss_linux.c +++ b/source3/nsswitch/winbind_nss_linux.c @@ -334,7 +334,7 @@ _nss_winbind_setpwent(void) if (num_pw_cache > 0) { ndx_pw_cache = num_pw_cache = 0; - free_response(&getpwent_response); + winbindd_free_response(&getpwent_response); } ret = winbindd_request_response(WINBINDD_SETPWENT, NULL, NULL); @@ -357,7 +357,7 @@ _nss_winbind_endpwent(void) if (num_pw_cache > 0) { ndx_pw_cache = num_pw_cache = 0; - free_response(&getpwent_response); + winbindd_free_response(&getpwent_response); } ret = winbindd_request_response(WINBINDD_ENDPWENT, NULL, NULL); @@ -392,7 +392,7 @@ _nss_winbind_getpwent_r(struct passwd *result, char *buffer, /* Else call winbindd to get a bunch of entries */ if (num_pw_cache > 0) { - free_response(&getpwent_response); + winbindd_free_response(&getpwent_response); } ZERO_STRUCT(request); @@ -444,7 +444,7 @@ _nss_winbind_getpwent_r(struct passwd *result, char *buffer, if (ndx_pw_cache == num_pw_cache) { ndx_pw_cache = num_pw_cache = 0; - free_response(&getpwent_response); + winbindd_free_response(&getpwent_response); } } done: @@ -509,7 +509,7 @@ _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result, char *buffer, *errnop = errno = 0; } - free_response(&response); + winbindd_free_response(&response); done: #ifdef DEBUG_NSS @@ -576,7 +576,7 @@ _nss_winbind_getpwnam_r(const char *name, struct passwd *result, char *buffer, *errnop = errno = 0; } - free_response(&response); + winbindd_free_response(&response); done: #ifdef DEBUG_NSS fprintf(stderr, "[%5d]: getpwnam %s returns %s (%d)\n", getpid(), @@ -606,7 +606,7 @@ _nss_winbind_setgrent(void) if (num_gr_cache > 0) { ndx_gr_cache = num_gr_cache = 0; - free_response(&getgrent_response); + winbindd_free_response(&getgrent_response); } ret = winbindd_request_response(WINBINDD_SETGRENT, NULL, NULL); @@ -629,7 +629,7 @@ _nss_winbind_endgrent(void) if (num_gr_cache > 0) { ndx_gr_cache = num_gr_cache = 0; - free_response(&getgrent_response); + winbindd_free_response(&getgrent_response); } ret = winbindd_request_response(WINBINDD_ENDGRENT, NULL, NULL); @@ -666,7 +666,7 @@ winbind_getgrent(enum winbindd_cmd cmd, /* Else call winbindd to get a bunch of entries */ if (num_gr_cache > 0) { - free_response(&getgrent_response); + winbindd_free_response(&getgrent_response); } ZERO_STRUCT(request); @@ -727,7 +727,7 @@ winbind_getgrent(enum winbindd_cmd cmd, if (ndx_gr_cache == num_gr_cache) { ndx_gr_cache = num_gr_cache = 0; - free_response(&getgrent_response); + winbindd_free_response(&getgrent_response); } } done: @@ -815,7 +815,7 @@ _nss_winbind_getgrnam_r(const char *name, *errnop = 0; } - free_response(&response); + winbindd_free_response(&response); done: #ifdef DEBUG_NSS fprintf(stderr, "[%5d]: getgrnam %s returns %s (%d)\n", getpid(), @@ -884,7 +884,7 @@ _nss_winbind_getgrgid_r(gid_t gid, *errnop = 0; } - free_response(&response); + winbindd_free_response(&response); done: #ifdef DEBUG_NSS fprintf(stderr, "[%5d]: getgrgid %d returns %s (%d)\n", getpid(), @@ -1032,7 +1032,7 @@ _nss_winbind_getusersids(const char *user_sid, char **group_sids, errno = *errnop = 0; done: - free_response(&response); + winbindd_free_response(&response); return ret; } @@ -1074,7 +1074,7 @@ _nss_winbind_nametosid(const char *name, char **sid, char *buffer, strcpy(*sid, response.data.sid.sid); failed: - free_response(&response); + winbindd_free_response(&response); return ret; } @@ -1105,7 +1105,7 @@ _nss_winbind_sidtoname(const char *sid, char **name, char *buffer, } sep_char = response.data.info.winbind_separator; - free_response(&response); + winbindd_free_response(&response); } @@ -1138,7 +1138,7 @@ _nss_winbind_sidtoname(const char *sid, char **name, char *buffer, *errnop = errno = 0; failed: - free_response(&response); + winbindd_free_response(&response); return ret; } @@ -1237,7 +1237,7 @@ _nss_winbind_uidtosid(uid_t uid, char **sid, char *buffer, strcpy(*sid, response.data.sid.sid); failed: - free_response(&response); + winbindd_free_response(&response); return ret; } @@ -1276,6 +1276,6 @@ _nss_winbind_gidtosid(gid_t gid, char **sid, char *buffer, strcpy(*sid, response.data.sid.sid); failed: - free_response(&response); + winbindd_free_response(&response); return ret; } diff --git a/source3/nsswitch/winbind_nss_solaris.c b/source3/nsswitch/winbind_nss_solaris.c index 55678ef7b0..5a72393788 100644 --- a/source3/nsswitch/winbind_nss_solaris.c +++ b/source3/nsswitch/winbind_nss_solaris.c @@ -500,7 +500,7 @@ _nss_winbind_ipnodes_getbyname(nss_backend_t* be, void *args) ret = parse_response(af, argp, &response); } - free_response(&response); + winbindd_free_response(&response); return ret; } @@ -523,7 +523,7 @@ _nss_winbind_hosts_getbyname(nss_backend_t* be, void *args) ret = parse_response(AF_INET, argp, &response); } - free_response(&response); + winbindd_free_response(&response); return ret; } @@ -553,7 +553,7 @@ _nss_winbind_hosts_getbyaddr(nss_backend_t* be, void *args) if( ret == NSS_STATUS_SUCCESS) { parse_response(argp->key.hostaddr.type, argp, &response); } - free_response(&response); + winbindd_free_response(&response); return ret; } |