1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

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 8a95d7a7ed)
This commit is contained in:
Stefan Metzmacher 2007-09-14 07:07:59 +00:00 committed by Gerald (Jerry) Carter
parent 45a2713b47
commit 28d076d20f
8 changed files with 100 additions and 93 deletions

View File

@ -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) {

View File

@ -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 */

View File

@ -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);

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -363,7 +363,7 @@ NTSTATUS contact_winbind_auth_crap(const char *username,
nt_status = NT_STATUS_UNSUCCESSFUL;
if (error_string)
*error_string = smb_xstrdup("Reading winbind reply failed!");
free_response(&response);
winbindd_free_response(&response);
return nt_status;
}
@ -371,7 +371,7 @@ NTSTATUS contact_winbind_auth_crap(const char *username,
if (!NT_STATUS_IS_OK(nt_status)) {
if (error_string)
*error_string = smb_xstrdup(response.data.auth.error_string);
free_response(&response);
winbindd_free_response(&response);
return nt_status;
}
@ -387,12 +387,12 @@ NTSTATUS contact_winbind_auth_crap(const char *username,
if (flags & WBFLAG_PAM_UNIX_NAME) {
*unix_name = SMB_STRDUP((char *)response.extra_data.data);
if (!*unix_name) {
free_response(&response);
winbindd_free_response(&response);
return NT_STATUS_NO_MEMORY;
}
}
free_response(&response);
winbindd_free_response(&response);
return nt_status;
}
@ -458,7 +458,7 @@ static NTSTATUS contact_winbind_change_pswd_auth_crap(const char *username,
nt_status = NT_STATUS_UNSUCCESSFUL;
if (error_string)
*error_string = smb_xstrdup("Reading winbind reply failed!");
free_response(&response);
winbindd_free_response(&response);
return nt_status;
}
@ -467,11 +467,11 @@ static NTSTATUS contact_winbind_change_pswd_auth_crap(const char *username,
{
if (error_string)
*error_string = smb_xstrdup(response.data.auth.error_string);
free_response(&response);
winbindd_free_response(&response);
return nt_status;
}
free_response(&response);
winbindd_free_response(&response);
return nt_status;
}
@ -658,7 +658,7 @@ static NTSTATUS do_ccache_ntlm_auth(DATA_BLOB initial_msg, DATA_BLOB challenge_m
SAFE_FREE(wb_request.extra_data.data);
if (result != NSS_STATUS_SUCCESS) {
free_response(&wb_response);
winbindd_free_response(&wb_response);
return NT_STATUS_UNSUCCESSFUL;
}
@ -667,12 +667,12 @@ static NTSTATUS do_ccache_ntlm_auth(DATA_BLOB initial_msg, DATA_BLOB challenge_m
wb_response.data.ccache_ntlm_auth.auth_blob_len);
if (wb_response.data.ccache_ntlm_auth.auth_blob_len > 0 &&
reply->data == NULL) {
free_response(&wb_response);
winbindd_free_response(&wb_response);
return NT_STATUS_NO_MEMORY;
}
}
free_response(&wb_response);
winbindd_free_response(&wb_response);
return NT_STATUS_MORE_PROCESSING_REQUIRED;
}