diff options
author | Tim Potter <tpot@samba.org> | 2000-06-14 09:58:12 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2000-06-14 09:58:12 +0000 |
commit | 9ee57562d2cc597fb727a53c3fcea56bbb3276f4 (patch) | |
tree | 92780935f82ec184b2fd44b3b4f71e29ccd1aac9 /source3/nsswitch/common.c | |
parent | 3bf8d26f7c5705f832034cf676942551ba1e1a73 (diff) | |
download | samba-9ee57562d2cc597fb727a53c3fcea56bbb3276f4.tar.gz samba-9ee57562d2cc597fb727a53c3fcea56bbb3276f4.tar.bz2 samba-9ee57562d2cc597fb727a53c3fcea56bbb3276f4.zip |
Merge from TNG.
(This used to be commit e5cb97dda89fe23612b75861232591e4831733e0)
Diffstat (limited to 'source3/nsswitch/common.c')
-rw-r--r-- | source3/nsswitch/common.c | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/source3/nsswitch/common.c b/source3/nsswitch/common.c index 9719f07385..f93c0e0d11 100644 --- a/source3/nsswitch/common.c +++ b/source3/nsswitch/common.c @@ -242,7 +242,7 @@ static int read_sock(void *buffer, int count) int read_reply(struct winbindd_response *response) { - int result1, result2; + int result1, result2 = 0; if (!response) { return -1; @@ -270,7 +270,6 @@ int read_reply(struct winbindd_response *response) if ((result2 = read_sock(response->extra_data, extra_data_len)) == -1) { - return -1; } } @@ -280,3 +279,56 @@ int read_reply(struct winbindd_response *response) return result1 + result2; } +/* Free a response structure */ + +void free_response(struct winbindd_response *response) +{ + /* Free any allocated extra_data */ + + if (response && response->extra_data) { + free(response->extra_data); + } +} + +/* Handle simple types of requests */ + +enum nss_status generic_request(int req_type, + struct winbindd_request *request, + struct winbindd_response *response) +{ + struct winbindd_request lrequest; + struct winbindd_response lresponse; + + /* Check for our tricky environment variable */ + + if (getenv(WINBINDD_DONT_ENV)) { + return NSS_STATUS_NOTFOUND; + } + + if (!response) response = &lresponse; + if (!request) request = &lrequest; + + /* Fill in request and send down pipe */ + init_request(request, req_type); + + if (write_sock(request, sizeof(*request)) == -1) { + return NSS_STATUS_UNAVAIL; + } + + /* Wait for reply */ + if (read_reply(response) == -1) { + return NSS_STATUS_UNAVAIL; + } + + /* Throw away extra data if client didn't request it */ + if (response == &lresponse) { + free_response(response); + } + + /* Copy reply data from socket */ + if (response->result != WINBINDD_OK) { + return NSS_STATUS_NOTFOUND; + } + + return NSS_STATUS_SUCCESS; +} |