mirror of
https://github.com/samba-team/samba.git
synced 2025-02-22 05:57:43 +03:00
async_sock: Use unix errnos instead of NTSTATUS
This also switches wb_reqtrans to use wbcErr instead of NTSTATUS as it would be pointless to convert to errno first and to wbcErr later.
This commit is contained in:
parent
3a4c8cd492
commit
c3b9b6c8aa
@ -94,6 +94,51 @@ struct async_syscall_state {
|
||||
int sys_errno;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Map async_req states to unix-style errnos
|
||||
* @param[in] req The async req to get the state from
|
||||
* @param[out] err Pointer to take the unix-style errno
|
||||
*
|
||||
* @return true if the async_req is in an error state, false otherwise
|
||||
*/
|
||||
|
||||
bool async_req_is_errno(struct async_req *req, int *err)
|
||||
{
|
||||
enum async_req_state state;
|
||||
uint64_t error;
|
||||
|
||||
if (!async_req_is_error(req, &state, &error)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case ASYNC_REQ_USER_ERROR:
|
||||
*err = (int)error;
|
||||
break;
|
||||
case ASYNC_REQ_TIMED_OUT:
|
||||
*err = ETIME;
|
||||
break;
|
||||
case ASYNC_REQ_NO_MEMORY:
|
||||
*err = ENOMEM;
|
||||
break;
|
||||
default:
|
||||
*err = EIO;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int async_req_simple_recv_errno(struct async_req *req)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (async_req_is_errno(req, &err)) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create a new async syscall req
|
||||
* @param[in] mem_ctx The memory context to hang the result off
|
||||
@ -239,7 +284,7 @@ static void async_send_callback(struct tevent_context *ev,
|
||||
struct param_send *p = &state->param.param_send;
|
||||
|
||||
if (state->syscall_type != ASYNC_SYSCALL_SEND) {
|
||||
async_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
|
||||
async_req_error(req, EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -306,7 +351,7 @@ static void async_sendall_callback(struct tevent_context *ev,
|
||||
struct param_sendall *p = &state->param.param_sendall;
|
||||
|
||||
if (state->syscall_type != ASYNC_SYSCALL_SENDALL) {
|
||||
async_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
|
||||
async_req_error(req, EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -316,18 +361,18 @@ static void async_sendall_callback(struct tevent_context *ev,
|
||||
state->sys_errno = errno;
|
||||
|
||||
if (state->result.result_ssize_t == -1) {
|
||||
async_req_nterror(req, map_nt_error_from_unix(state->sys_errno));
|
||||
async_req_error(req, state->sys_errno);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state->result.result_ssize_t == 0) {
|
||||
async_req_nterror(req, NT_STATUS_END_OF_FILE);
|
||||
async_req_error(req, EOF);
|
||||
return;
|
||||
}
|
||||
|
||||
p->sent += state->result.result_ssize_t;
|
||||
if (p->sent > p->length) {
|
||||
async_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
|
||||
async_req_error(req, EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -374,9 +419,20 @@ struct async_req *sendall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
|
||||
return result;
|
||||
}
|
||||
|
||||
NTSTATUS sendall_recv(struct async_req *req)
|
||||
ssize_t sendall_recv(struct async_req *req, int *perr)
|
||||
{
|
||||
return async_req_simple_recv_ntstatus(req);
|
||||
struct async_syscall_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct async_syscall_state);
|
||||
int err;
|
||||
|
||||
err = async_req_simple_recv_errno(req);
|
||||
|
||||
if (err != 0) {
|
||||
*perr = err;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return state->result.result_ssize_t;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -398,7 +454,7 @@ static void async_recv_callback(struct tevent_context *ev,
|
||||
struct param_recv *p = &state->param.param_recv;
|
||||
|
||||
if (state->syscall_type != ASYNC_SYSCALL_RECV) {
|
||||
async_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
|
||||
async_req_error(req, EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -466,7 +522,7 @@ static void async_recvall_callback(struct tevent_context *ev,
|
||||
struct param_recvall *p = &state->param.param_recvall;
|
||||
|
||||
if (state->syscall_type != ASYNC_SYSCALL_RECVALL) {
|
||||
async_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
|
||||
async_req_error(req, EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -476,18 +532,18 @@ static void async_recvall_callback(struct tevent_context *ev,
|
||||
state->sys_errno = errno;
|
||||
|
||||
if (state->result.result_ssize_t == -1) {
|
||||
async_req_nterror(req, map_nt_error_from_unix(state->sys_errno));
|
||||
async_req_error(req, state->sys_errno);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state->result.result_ssize_t == 0) {
|
||||
async_req_nterror(req, NT_STATUS_END_OF_FILE);
|
||||
async_req_error(req, EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
p->received += state->result.result_ssize_t;
|
||||
if (p->received > p->length) {
|
||||
async_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
|
||||
async_req_error(req, EIO);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -533,9 +589,20 @@ struct async_req *recvall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
|
||||
return result;
|
||||
}
|
||||
|
||||
NTSTATUS recvall_recv(struct async_req *req)
|
||||
ssize_t recvall_recv(struct async_req *req, int *perr)
|
||||
{
|
||||
return async_req_simple_recv_ntstatus(req);
|
||||
struct async_syscall_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct async_syscall_state);
|
||||
int err;
|
||||
|
||||
err = async_req_simple_recv_errno(req);
|
||||
|
||||
if (err != 0) {
|
||||
*perr = err;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return state->result.result_ssize_t;
|
||||
}
|
||||
|
||||
struct async_connect_state {
|
||||
@ -570,7 +637,6 @@ struct async_req *async_connect_send(TALLOC_CTX *mem_ctx,
|
||||
struct async_req *result;
|
||||
struct async_connect_state *state;
|
||||
struct tevent_fd *fde;
|
||||
NTSTATUS status;
|
||||
|
||||
if (!async_req_setup(mem_ctx, &result, &state,
|
||||
struct async_connect_state)) {
|
||||
@ -595,7 +661,6 @@ struct async_req *async_connect_send(TALLOC_CTX *mem_ctx,
|
||||
state->result = connect(fd, address, address_len);
|
||||
if (state->result == 0) {
|
||||
state->sys_errno = 0;
|
||||
status = NT_STATUS_OK;
|
||||
goto post_status;
|
||||
}
|
||||
|
||||
@ -617,17 +682,16 @@ struct async_req *async_connect_send(TALLOC_CTX *mem_ctx,
|
||||
fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ | TEVENT_FD_WRITE,
|
||||
async_connect_connected, result);
|
||||
if (fde == NULL) {
|
||||
status = NT_STATUS_NO_MEMORY;
|
||||
state->sys_errno = ENOMEM;
|
||||
goto post_status;
|
||||
}
|
||||
return result;
|
||||
|
||||
post_errno:
|
||||
state->sys_errno = errno;
|
||||
status = map_nt_error_from_unix(state->sys_errno);
|
||||
post_status:
|
||||
fcntl(fd, F_SETFL, state->old_sockflags);
|
||||
if (!async_post_ntstatus(result, ev, status)) {
|
||||
if (!async_post_error(result, ev, state->sys_errno)) {
|
||||
goto fail;
|
||||
}
|
||||
return result;
|
||||
@ -675,7 +739,7 @@ static void async_connect_connected(struct tevent_context *ev,
|
||||
DEBUG(10, ("connect returned %s\n", strerror(errno)));
|
||||
|
||||
fcntl(state->fd, F_SETFL, state->old_sockflags);
|
||||
async_req_nterror(req, map_nt_error_from_unix(state->sys_errno));
|
||||
async_req_error(req, state->sys_errno);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -683,21 +747,23 @@ static void async_connect_connected(struct tevent_context *ev,
|
||||
async_req_done(req);
|
||||
}
|
||||
|
||||
NTSTATUS async_connect_recv(struct async_req *req, int *perrno)
|
||||
int async_connect_recv(struct async_req *req, int *perrno)
|
||||
{
|
||||
struct async_connect_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct async_connect_state);
|
||||
NTSTATUS status;
|
||||
int err;
|
||||
|
||||
fcntl(state->fd, F_SETFL, state->old_sockflags);
|
||||
|
||||
*perrno = state->sys_errno;
|
||||
|
||||
if (async_req_is_nterror(req, &status)) {
|
||||
return status;
|
||||
if (async_req_is_errno(req, &err)) {
|
||||
*perrno = err;
|
||||
return -1;
|
||||
}
|
||||
if (state->sys_errno == 0) {
|
||||
return NT_STATUS_OK;
|
||||
return 0;
|
||||
}
|
||||
return map_nt_error_from_unix(state->sys_errno);
|
||||
|
||||
*perrno = state->sys_errno;
|
||||
return -1;
|
||||
}
|
||||
|
@ -22,6 +22,9 @@
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
bool async_req_is_errno(struct async_req *req, int *err);
|
||||
int async_req_simple_recv_errno(struct async_req *req);
|
||||
|
||||
ssize_t async_syscall_result_ssize_t(struct async_req *req, int *perrno);
|
||||
size_t async_syscall_result_size_t(struct async_req *req, int *perrno);
|
||||
int async_syscall_result_int(struct async_req *req, int *perrno);
|
||||
@ -36,16 +39,16 @@ struct async_req *async_connect_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev,
|
||||
int fd, const struct sockaddr *address,
|
||||
socklen_t address_len);
|
||||
NTSTATUS async_connect_recv(struct async_req *req, int *perrno);
|
||||
int async_connect_recv(struct async_req *req, int *perrno);
|
||||
|
||||
struct async_req *sendall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
|
||||
int fd, const void *buffer, size_t length,
|
||||
int flags);
|
||||
NTSTATUS sendall_recv(struct async_req *req);
|
||||
ssize_t sendall_recv(struct async_req *req, int *perr);
|
||||
|
||||
struct async_req *recvall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
|
||||
int fd, void *buffer, size_t length,
|
||||
int flags);
|
||||
NTSTATUS recvall_recv(struct async_req *req);
|
||||
ssize_t recvall_recv(struct async_req *req, int *perr);
|
||||
|
||||
#endif
|
||||
|
@ -944,6 +944,7 @@ SMBTORTURE_OBJ1 = torture/torture.o torture/nbio.o torture/scanner.o torture/uta
|
||||
SMBTORTURE_OBJ = $(SMBTORTURE_OBJ1) $(PARAM_OBJ) \
|
||||
$(LIBSMB_OBJ) $(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) \
|
||||
lib/wb_reqtrans.o lib/wbclient.o \
|
||||
@LIBWBCLIENT_STATIC@ \
|
||||
$(LIBNDR_GEN_OBJ0)
|
||||
|
||||
MASKTEST_OBJ = torture/masktest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \
|
||||
@ -1467,11 +1468,11 @@ bin/nmblookup@EXEEXT@: $(BINARY_PREREQS) $(NMBLOOKUP_OBJ) @BUILD_POPT@ @LIBTALLO
|
||||
@$(CC) -o $@ $(NMBLOOKUP_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) \
|
||||
$(POPT_LIBS) $(LDAP_LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS)
|
||||
|
||||
bin/smbtorture@EXEEXT@: $(BINARY_PREREQS) $(SMBTORTURE_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@
|
||||
bin/smbtorture@EXEEXT@: $(BINARY_PREREQS) $(SMBTORTURE_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ @LIBWBCLIENT_SHARED@
|
||||
@echo Linking $@
|
||||
@$(CC) -o $@ $(SMBTORTURE_OBJ) $(LDFLAGS) $(DYNEXP) \
|
||||
$(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(POPT_LIBS) $(LIBTALLOC_LIBS) \
|
||||
$(LIBTDB_LIBS) $(ZLIB_LIBS)
|
||||
$(LIBTDB_LIBS) $(ZLIB_LIBS) $(WINBIND_LIBS)
|
||||
|
||||
bin/talloctort@EXEEXT@: $(BINARY_PREREQS) $(TALLOCTORT_OBJ) @BUILD_POPT@ @LIBTALLOC_SHARED@ @LIBTDB_SHARED@
|
||||
@echo Linking $@
|
||||
|
@ -7563,12 +7563,4 @@ NTSTATUS nss_info_template_init( void );
|
||||
|
||||
/* Misc protos */
|
||||
|
||||
struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
|
||||
struct wb_context *wb_ctx, bool need_priv,
|
||||
const struct winbindd_request *wb_req);
|
||||
NTSTATUS wb_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_response **presponse);
|
||||
struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx);
|
||||
|
||||
|
||||
#endif /* _PROTO_H_ */
|
||||
|
68
source3/include/wbc_async.h
Normal file
68
source3/include/wbc_async.h
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
Headers for the async winbind client library
|
||||
Copyright (C) Kai Blin 2009
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _WBC_ASYNC_H_
|
||||
#define _WBC_ASYNC_H_
|
||||
|
||||
#include "nsswitch/libwbclient/wbclient.h"
|
||||
|
||||
struct wb_context {
|
||||
struct async_req_queue *queue;
|
||||
int fd;
|
||||
bool is_priv;
|
||||
};
|
||||
|
||||
struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
|
||||
struct wb_context *wb_ctx, bool need_priv,
|
||||
const struct winbindd_request *wb_req);
|
||||
wbcErr wb_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_response **presponse);
|
||||
struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx);
|
||||
|
||||
/* Definitions from wb_reqtrans.c */
|
||||
bool async_req_is_wbcerr(struct async_req *req, wbcErr *pwbc_err);
|
||||
wbcErr map_wbc_err_from_errno(int error);
|
||||
wbcErr async_req_simple_recv_wbcerr(struct async_req *req);
|
||||
|
||||
struct async_req *wb_req_read_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev,
|
||||
int fd, size_t max_extra_data);
|
||||
|
||||
wbcErr wb_req_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_request **preq);
|
||||
|
||||
struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev, int fd,
|
||||
struct winbindd_request *wb_req);
|
||||
|
||||
wbcErr wb_req_write_recv(struct async_req *req);
|
||||
|
||||
struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev, int fd);
|
||||
|
||||
wbcErr wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_response **presp);
|
||||
|
||||
struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx,
|
||||
struct tevent_context *ev, int fd,
|
||||
struct winbindd_response *wb_resp);
|
||||
|
||||
wbcErr wb_resp_write_recv(struct async_req *req);
|
||||
|
||||
#endif /*_WBC_ASYNC_H_*/
|
@ -1051,17 +1051,17 @@ static void open_socket_out_connected(struct async_req *subreq)
|
||||
subreq->async.priv, struct async_req);
|
||||
struct open_socket_out_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct open_socket_out_state);
|
||||
NTSTATUS status;
|
||||
int err;
|
||||
int sys_errno;
|
||||
|
||||
status = async_connect_recv(subreq, &sys_errno);
|
||||
err = async_connect_recv(subreq, &sys_errno);
|
||||
TALLOC_FREE(subreq);
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
if (err == 0) {
|
||||
async_req_done(req);
|
||||
return;
|
||||
}
|
||||
|
||||
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)
|
||||
if ((sys_errno == ETIME)
|
||||
|| (sys_errno == EINPROGRESS)
|
||||
|| (sys_errno == EALREADY)
|
||||
|| (sys_errno == EAGAIN)) {
|
||||
@ -1082,7 +1082,7 @@ static void open_socket_out_connected(struct async_req *subreq)
|
||||
}
|
||||
if (!async_req_set_timeout(subreq, state->ev,
|
||||
timeval_set(0, state->wait_nsec))) {
|
||||
async_req_nterror(req, NT_STATUS_NO_MEMORY);
|
||||
async_req_error(req, ENOMEM);
|
||||
return;
|
||||
}
|
||||
subreq->async.fn = open_socket_out_connected;
|
||||
@ -1098,17 +1098,17 @@ static void open_socket_out_connected(struct async_req *subreq)
|
||||
#endif
|
||||
|
||||
/* real error */
|
||||
async_req_nterror(req, map_nt_error_from_unix(sys_errno));
|
||||
async_req_error(req, sys_errno);
|
||||
}
|
||||
|
||||
NTSTATUS open_socket_out_recv(struct async_req *req, int *pfd)
|
||||
{
|
||||
struct open_socket_out_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct open_socket_out_state);
|
||||
NTSTATUS status;
|
||||
int err;
|
||||
|
||||
if (async_req_is_nterror(req, &status)) {
|
||||
return status;
|
||||
if (async_req_is_errno(req, &err)) {
|
||||
return map_nt_error_from_unix(err);
|
||||
}
|
||||
*pfd = state->fd;
|
||||
state->fd = -1;
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "winbindd/winbindd.h"
|
||||
#include "wbc_async.h"
|
||||
|
||||
#undef DBGC_CLASS
|
||||
#define DBGC_CLASS DBGC_WINBIND
|
||||
@ -32,6 +32,57 @@ struct req_read_state {
|
||||
int fd;
|
||||
};
|
||||
|
||||
bool async_req_is_wbcerr(struct async_req *req, wbcErr *pwbc_err)
|
||||
{
|
||||
enum async_req_state state;
|
||||
uint64_t error;
|
||||
if (!async_req_is_error(req, &state, &error)) {
|
||||
*pwbc_err = WBC_ERR_SUCCESS;
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case ASYNC_REQ_USER_ERROR:
|
||||
*pwbc_err = error;
|
||||
break;
|
||||
case ASYNC_REQ_TIMED_OUT:
|
||||
*pwbc_err = WBC_ERR_UNKNOWN_FAILURE;
|
||||
break;
|
||||
case ASYNC_REQ_NO_MEMORY:
|
||||
*pwbc_err = WBC_ERR_NO_MEMORY;
|
||||
break;
|
||||
default:
|
||||
*pwbc_err = WBC_ERR_UNKNOWN_FAILURE;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
wbcErr map_wbc_err_from_errno(int error)
|
||||
{
|
||||
switch(error) {
|
||||
case EPERM:
|
||||
case EACCES:
|
||||
return WBC_ERR_AUTH_ERROR;
|
||||
case ENOMEM:
|
||||
return WBC_ERR_NO_MEMORY;
|
||||
case EIO:
|
||||
default:
|
||||
return WBC_ERR_UNKNOWN_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
wbcErr async_req_simple_recv_wbcerr(struct async_req *req)
|
||||
{
|
||||
wbcErr wbc_err;
|
||||
|
||||
if (async_req_is_wbcerr(req, &wbc_err)) {
|
||||
return wbc_err;
|
||||
}
|
||||
|
||||
return WBC_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
static void wb_req_read_len(struct async_req *subreq);
|
||||
static void wb_req_read_main(struct async_req *subreq);
|
||||
static void wb_req_read_extra(struct async_req *subreq);
|
||||
@ -76,12 +127,13 @@ static void wb_req_read_len(struct async_req *subreq)
|
||||
subreq->async.priv, struct async_req);
|
||||
struct req_read_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct req_read_state);
|
||||
NTSTATUS status;
|
||||
int err;
|
||||
ssize_t ret;
|
||||
|
||||
status = recvall_recv(subreq);
|
||||
ret = recvall_recv(subreq, &err);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (ret < 0) {
|
||||
async_req_error(req, map_wbc_err_from_errno(err));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -89,7 +141,7 @@ static void wb_req_read_len(struct async_req *subreq)
|
||||
DEBUG(0, ("wb_req_read_len: Invalid request size received: "
|
||||
"%d (expected %d)\n", (int)state->wb_req->length,
|
||||
(int)sizeof(struct winbindd_request)));
|
||||
async_req_nterror(req, NT_STATUS_INVALID_BUFFER_SIZE);
|
||||
async_req_error(req, WBC_ERR_INVALID_RESPONSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -110,12 +162,13 @@ static void wb_req_read_main(struct async_req *subreq)
|
||||
subreq->async.priv, struct async_req);
|
||||
struct req_read_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct req_read_state);
|
||||
NTSTATUS status;
|
||||
int err;
|
||||
ssize_t ret;
|
||||
|
||||
status = recvall_recv(subreq);
|
||||
ret = recvall_recv(subreq, &err);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (ret < 0) {
|
||||
async_req_error(req, map_wbc_err_from_errno(err));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -124,7 +177,7 @@ static void wb_req_read_main(struct async_req *subreq)
|
||||
DEBUG(3, ("Got request with %d bytes extra data on "
|
||||
"unprivileged socket\n",
|
||||
(int)state->wb_req->extra_len));
|
||||
async_req_nterror(req, NT_STATUS_INVALID_BUFFER_SIZE);
|
||||
async_req_error(req, WBC_ERR_INVALID_RESPONSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -156,30 +209,31 @@ static void wb_req_read_extra(struct async_req *subreq)
|
||||
{
|
||||
struct async_req *req = talloc_get_type_abort(
|
||||
subreq->async.priv, struct async_req);
|
||||
NTSTATUS status;
|
||||
int err;
|
||||
ssize_t ret;
|
||||
|
||||
status = recvall_recv(subreq);
|
||||
ret = recvall_recv(subreq, &err);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (ret < 0) {
|
||||
async_req_error(req, map_wbc_err_from_errno(err));
|
||||
return;
|
||||
}
|
||||
async_req_done(req);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS wb_req_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_request **preq)
|
||||
wbcErr wb_req_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_request **preq)
|
||||
{
|
||||
struct req_read_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct req_read_state);
|
||||
NTSTATUS status;
|
||||
wbcErr wbc_err;
|
||||
|
||||
if (async_req_is_nterror(req, &status)) {
|
||||
return status;
|
||||
if (async_req_is_wbcerr(req, &wbc_err)) {
|
||||
return wbc_err;
|
||||
}
|
||||
*preq = talloc_move(mem_ctx, &state->wb_req);
|
||||
return NT_STATUS_OK;
|
||||
return WBC_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
struct req_write_state {
|
||||
@ -227,12 +281,13 @@ static void wb_req_write_main(struct async_req *subreq)
|
||||
subreq->async.priv, struct async_req);
|
||||
struct req_write_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct req_write_state);
|
||||
NTSTATUS status;
|
||||
int err;
|
||||
ssize_t ret;
|
||||
|
||||
status = sendall_recv(subreq);
|
||||
ret = sendall_recv(subreq, &err);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (ret < 0) {
|
||||
async_req_error(req, map_wbc_err_from_errno(err));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -256,21 +311,22 @@ static void wb_req_write_extra(struct async_req *subreq)
|
||||
{
|
||||
struct async_req *req = talloc_get_type_abort(
|
||||
subreq->async.priv, struct async_req);
|
||||
NTSTATUS status;
|
||||
int err;
|
||||
ssize_t ret;
|
||||
|
||||
status = sendall_recv(subreq);
|
||||
ret = sendall_recv(subreq, &err);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (ret < 0) {
|
||||
async_req_error(req, map_wbc_err_from_errno(err));
|
||||
return;
|
||||
}
|
||||
|
||||
async_req_done(req);
|
||||
}
|
||||
|
||||
NTSTATUS wb_req_write_recv(struct async_req *req)
|
||||
wbcErr wb_req_write_recv(struct async_req *req)
|
||||
{
|
||||
return async_req_simple_recv_ntstatus(req);
|
||||
return async_req_simple_recv_wbcerr(req);
|
||||
}
|
||||
|
||||
struct resp_read_state {
|
||||
@ -322,12 +378,13 @@ static void wb_resp_read_len(struct async_req *subreq)
|
||||
subreq->async.priv, struct async_req);
|
||||
struct resp_read_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct resp_read_state);
|
||||
NTSTATUS status;
|
||||
int err;
|
||||
ssize_t ret;
|
||||
|
||||
status = recvall_recv(subreq);
|
||||
ret = recvall_recv(subreq, &err);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (ret < 0) {
|
||||
async_req_error(req, map_wbc_err_from_errno(err));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -336,7 +393,7 @@ static void wb_resp_read_len(struct async_req *subreq)
|
||||
"%d (expected at least%d)\n",
|
||||
(int)state->wb_resp->length,
|
||||
(int)sizeof(struct winbindd_response)));
|
||||
async_req_nterror(req, NT_STATUS_INVALID_BUFFER_SIZE);
|
||||
async_req_error(req, WBC_ERR_INVALID_RESPONSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -357,13 +414,14 @@ static void wb_resp_read_main(struct async_req *subreq)
|
||||
subreq->async.priv, struct async_req);
|
||||
struct resp_read_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct resp_read_state);
|
||||
NTSTATUS status;
|
||||
int err;
|
||||
ssize_t ret;
|
||||
size_t extra_len;
|
||||
|
||||
status = recvall_recv(subreq);
|
||||
ret = recvall_recv(subreq, &err);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (ret < 0) {
|
||||
async_req_error(req, map_wbc_err_from_errno(err));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -395,30 +453,31 @@ static void wb_resp_read_extra(struct async_req *subreq)
|
||||
{
|
||||
struct async_req *req = talloc_get_type_abort(
|
||||
subreq->async.priv, struct async_req);
|
||||
NTSTATUS status;
|
||||
int err;
|
||||
ssize_t ret;
|
||||
|
||||
status = recvall_recv(subreq);
|
||||
ret = recvall_recv(subreq, &err);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (ret < 0) {
|
||||
async_req_error(req, map_wbc_err_from_errno(err));
|
||||
return;
|
||||
}
|
||||
async_req_done(req);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_response **presp)
|
||||
wbcErr wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_response **presp)
|
||||
{
|
||||
struct resp_read_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct resp_read_state);
|
||||
NTSTATUS status;
|
||||
wbcErr wbc_err;
|
||||
|
||||
if (async_req_is_nterror(req, &status)) {
|
||||
return status;
|
||||
if (async_req_is_wbcerr(req, &wbc_err)) {
|
||||
return wbc_err;
|
||||
}
|
||||
*presp = talloc_move(mem_ctx, &state->wb_resp);
|
||||
return NT_STATUS_OK;
|
||||
return WBC_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
struct resp_write_state {
|
||||
@ -466,12 +525,13 @@ static void wb_resp_write_main(struct async_req *subreq)
|
||||
subreq->async.priv, struct async_req);
|
||||
struct resp_write_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct resp_write_state);
|
||||
NTSTATUS status;
|
||||
int err;
|
||||
ssize_t ret;
|
||||
|
||||
status = sendall_recv(subreq);
|
||||
ret = sendall_recv(subreq, &err);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (ret < 0) {
|
||||
async_req_error(req, map_wbc_err_from_errno(err));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -496,19 +556,20 @@ static void wb_resp_write_extra(struct async_req *subreq)
|
||||
{
|
||||
struct async_req *req = talloc_get_type_abort(
|
||||
subreq->async.priv, struct async_req);
|
||||
NTSTATUS status;
|
||||
int err;
|
||||
ssize_t ret;
|
||||
|
||||
status = sendall_recv(subreq);
|
||||
ret = sendall_recv(subreq, &err);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (err < 0) {
|
||||
async_req_error(req, map_wbc_err_from_errno(err));
|
||||
return;
|
||||
}
|
||||
|
||||
async_req_done(req);
|
||||
}
|
||||
|
||||
NTSTATUS wb_resp_write_recv(struct async_req *req)
|
||||
wbcErr wb_resp_write_recv(struct async_req *req)
|
||||
{
|
||||
return async_req_simple_recv_ntstatus(req);
|
||||
return async_req_simple_recv_wbcerr(req);
|
||||
}
|
||||
|
@ -18,8 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "winbindd/winbindd.h"
|
||||
#include "winbindd/winbindd_proto.h"
|
||||
#include "wbc_async.h"
|
||||
|
||||
static int make_nonstd_fd(int fd)
|
||||
{
|
||||
@ -131,12 +130,6 @@ static bool winbind_closed_fd(int fd)
|
||||
return false;
|
||||
}
|
||||
|
||||
struct wb_context {
|
||||
struct async_req_queue *queue;
|
||||
int fd;
|
||||
bool is_priv;
|
||||
};
|
||||
|
||||
struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
struct wb_context *result;
|
||||
@ -163,7 +156,7 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx,
|
||||
struct sockaddr_un sunaddr;
|
||||
struct stat st;
|
||||
char *path = NULL;
|
||||
NTSTATUS status;
|
||||
wbcErr wbc_err;
|
||||
|
||||
if (wb_ctx->fd != -1) {
|
||||
close(wb_ctx->fd);
|
||||
@ -173,13 +166,13 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx,
|
||||
/* Check permissions on unix socket directory */
|
||||
|
||||
if (lstat(dir, &st) == -1) {
|
||||
status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
wbc_err = WBC_ERR_WINBIND_NOT_AVAILABLE;
|
||||
goto post_status;
|
||||
}
|
||||
|
||||
if (!S_ISDIR(st.st_mode) ||
|
||||
(st.st_uid != 0 && st.st_uid != geteuid())) {
|
||||
status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
wbc_err = WBC_ERR_WINBIND_NOT_AVAILABLE;
|
||||
goto post_status;
|
||||
}
|
||||
|
||||
@ -202,13 +195,13 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx,
|
||||
if ((lstat(sunaddr.sun_path, &st) == -1)
|
||||
|| !S_ISSOCK(st.st_mode)
|
||||
|| (st.st_uid != 0 && st.st_uid != geteuid())) {
|
||||
status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
wbc_err = WBC_ERR_WINBIND_NOT_AVAILABLE;
|
||||
goto post_status;
|
||||
}
|
||||
|
||||
wb_ctx->fd = make_safe_fd(socket(AF_UNIX, SOCK_STREAM, 0));
|
||||
if (wb_ctx->fd == -1) {
|
||||
status = map_nt_error_from_unix(errno);
|
||||
wbc_err = map_wbc_err_from_errno(errno);
|
||||
goto post_status;
|
||||
}
|
||||
|
||||
@ -226,24 +219,22 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx,
|
||||
return req;
|
||||
|
||||
nomem:
|
||||
status = NT_STATUS_NO_MEMORY;
|
||||
wbc_err = WBC_ERR_NO_MEMORY;
|
||||
post_status:
|
||||
req = async_req_new(mem_ctx);
|
||||
if (req == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (async_post_ntstatus(req, ev, status)) {
|
||||
if (async_post_error(req, ev, wbc_err)) {
|
||||
return req;
|
||||
}
|
||||
TALLOC_FREE(req);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static NTSTATUS wb_connect_recv(struct async_req *req)
|
||||
static wbcErr wb_connect_recv(struct async_req *req)
|
||||
{
|
||||
int dummy;
|
||||
|
||||
return async_connect_recv(req, &dummy);
|
||||
return async_req_simple_recv_wbcerr(req);
|
||||
}
|
||||
|
||||
static struct winbindd_request *winbindd_request_copy(
|
||||
@ -295,8 +286,8 @@ static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx,
|
||||
}
|
||||
|
||||
if (winbind_closed_fd(fd)) {
|
||||
if (!async_post_ntstatus(result, ev,
|
||||
NT_STATUS_PIPE_DISCONNECTED)) {
|
||||
if (!async_post_error(result, ev,
|
||||
WBC_ERR_WINBIND_NOT_AVAILABLE)) {
|
||||
goto fail;
|
||||
}
|
||||
return result;
|
||||
@ -329,18 +320,18 @@ static void wb_int_trans_write_done(struct async_req *subreq)
|
||||
subreq->async.priv, struct async_req);
|
||||
struct wb_int_trans_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct wb_int_trans_state);
|
||||
NTSTATUS status;
|
||||
wbcErr wbc_err;
|
||||
|
||||
status = wb_req_write_recv(subreq);
|
||||
wbc_err = wb_req_write_recv(subreq);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (!WBC_ERROR_IS_OK(wbc_err)) {
|
||||
async_req_error(req, wbc_err);
|
||||
return;
|
||||
}
|
||||
|
||||
subreq = wb_resp_read_send(state, state->ev, state->fd);
|
||||
if (subreq == NULL) {
|
||||
async_req_nterror(req, NT_STATUS_NO_MEMORY);
|
||||
async_req_error(req, WBC_ERR_NO_MEMORY);
|
||||
}
|
||||
subreq->async.fn = wb_int_trans_read_done;
|
||||
subreq->async.priv = req;
|
||||
@ -352,32 +343,32 @@ static void wb_int_trans_read_done(struct async_req *subreq)
|
||||
subreq->async.priv, struct async_req);
|
||||
struct wb_int_trans_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct wb_int_trans_state);
|
||||
NTSTATUS status;
|
||||
wbcErr wbc_err;
|
||||
|
||||
status = wb_resp_read_recv(subreq, state, &state->wb_resp);
|
||||
wbc_err = wb_resp_read_recv(subreq, state, &state->wb_resp);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (!WBC_ERROR_IS_OK(wbc_err)) {
|
||||
async_req_error(req, wbc_err);
|
||||
return;
|
||||
}
|
||||
|
||||
async_req_done(req);
|
||||
}
|
||||
|
||||
static NTSTATUS wb_int_trans_recv(struct async_req *req,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_response **presponse)
|
||||
static wbcErr wb_int_trans_recv(struct async_req *req,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_response **presponse)
|
||||
{
|
||||
struct wb_int_trans_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct wb_int_trans_state);
|
||||
NTSTATUS status;
|
||||
wbcErr wbc_err;
|
||||
|
||||
if (async_req_is_nterror(req, &status)) {
|
||||
return status;
|
||||
if (async_req_is_wbcerr(req, &wbc_err)) {
|
||||
return wbc_err;
|
||||
}
|
||||
|
||||
*presponse = talloc_move(mem_ctx, &state->wb_resp);
|
||||
return NT_STATUS_OK;
|
||||
return WBC_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
static const char *winbindd_socket_dir(void)
|
||||
@ -448,13 +439,13 @@ static void wb_open_pipe_connect_nonpriv_done(struct async_req *subreq)
|
||||
subreq->async.priv, struct async_req);
|
||||
struct wb_open_pipe_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct wb_open_pipe_state);
|
||||
NTSTATUS status;
|
||||
wbcErr wbc_err;
|
||||
|
||||
status = wb_connect_recv(subreq);
|
||||
wbc_err = wb_connect_recv(subreq);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
if (!WBC_ERROR_IS_OK(wbc_err)) {
|
||||
state->wb_ctx->is_priv = true;
|
||||
async_req_nterror(req, status);
|
||||
async_req_error(req, wbc_err);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -478,12 +469,12 @@ static void wb_open_pipe_ping_done(struct async_req *subreq)
|
||||
struct wb_open_pipe_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct wb_open_pipe_state);
|
||||
struct winbindd_response *wb_resp;
|
||||
NTSTATUS status;
|
||||
wbcErr wbc_err;
|
||||
|
||||
status = wb_int_trans_recv(subreq, state, &wb_resp);
|
||||
wbc_err = wb_int_trans_recv(subreq, state, &wb_resp);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (!WBC_ERROR_IS_OK(wbc_err)) {
|
||||
async_req_error(req, wbc_err);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -511,12 +502,12 @@ static void wb_open_pipe_getpriv_done(struct async_req *subreq)
|
||||
struct wb_open_pipe_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct wb_open_pipe_state);
|
||||
struct winbindd_response *wb_resp = NULL;
|
||||
NTSTATUS status;
|
||||
wbcErr wbc_err;
|
||||
|
||||
status = wb_int_trans_recv(subreq, state, &wb_resp);
|
||||
wbc_err = wb_int_trans_recv(subreq, state, &wb_resp);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (!WBC_ERROR_IS_OK(wbc_err)) {
|
||||
async_req_error(req, wbc_err);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -540,21 +531,21 @@ static void wb_open_pipe_connect_priv_done(struct async_req *subreq)
|
||||
subreq->async.priv, struct async_req);
|
||||
struct wb_open_pipe_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct wb_open_pipe_state);
|
||||
NTSTATUS status;
|
||||
wbcErr wbc_err;
|
||||
|
||||
status = wb_connect_recv(subreq);
|
||||
wbc_err = wb_connect_recv(subreq);
|
||||
TALLOC_FREE(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
if (!WBC_ERROR_IS_OK(wbc_err)) {
|
||||
async_req_error(req, wbc_err);
|
||||
return;
|
||||
}
|
||||
state->wb_ctx->is_priv = true;
|
||||
async_req_done(req);
|
||||
}
|
||||
|
||||
static NTSTATUS wb_open_pipe_recv(struct async_req *req)
|
||||
static wbcErr wb_open_pipe_recv(struct async_req *req)
|
||||
{
|
||||
return async_req_simple_recv_ntstatus(req);
|
||||
return async_req_simple_recv_wbcerr(req);
|
||||
}
|
||||
|
||||
struct wb_trans_state {
|
||||
@ -631,27 +622,26 @@ struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
|
||||
|
||||
static bool wb_trans_retry(struct async_req *req,
|
||||
struct wb_trans_state *state,
|
||||
NTSTATUS status)
|
||||
wbcErr wbc_err)
|
||||
{
|
||||
struct async_req *subreq;
|
||||
|
||||
if (NT_STATUS_IS_OK(status)) {
|
||||
if (WBC_ERROR_IS_OK(wbc_err)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)
|
||||
|| NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
|
||||
if (wbc_err == WBC_ERR_WINBIND_NOT_AVAILABLE) {
|
||||
/*
|
||||
* Winbind not around or we can't connect to the pipe. Fail
|
||||
* immediately.
|
||||
*/
|
||||
async_req_nterror(req, status);
|
||||
async_req_error(req, wbc_err);
|
||||
return true;
|
||||
}
|
||||
|
||||
state->num_retries -= 1;
|
||||
if (state->num_retries == 0) {
|
||||
async_req_nterror(req, status);
|
||||
async_req_error(req, wbc_err);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -685,7 +675,7 @@ static void wb_trans_retry_wait_done(struct async_req *subreq)
|
||||
ret = async_wait_recv(subreq);
|
||||
TALLOC_FREE(subreq);
|
||||
if (ret) {
|
||||
async_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
|
||||
async_req_error(req, WBC_ERR_UNKNOWN_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -704,12 +694,12 @@ static void wb_trans_connect_done(struct async_req *subreq)
|
||||
subreq->async.priv, struct async_req);
|
||||
struct wb_trans_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct wb_trans_state);
|
||||
NTSTATUS status;
|
||||
wbcErr wbc_err;
|
||||
|
||||
status = wb_open_pipe_recv(subreq);
|
||||
wbc_err = wb_open_pipe_recv(subreq);
|
||||
TALLOC_FREE(subreq);
|
||||
|
||||
if (wb_trans_retry(req, state, status)) {
|
||||
if (wb_trans_retry(req, state, wbc_err)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -729,29 +719,29 @@ static void wb_trans_done(struct async_req *subreq)
|
||||
subreq->async.priv, struct async_req);
|
||||
struct wb_trans_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct wb_trans_state);
|
||||
NTSTATUS status;
|
||||
wbcErr wbc_err;
|
||||
|
||||
status = wb_int_trans_recv(subreq, state, &state->wb_resp);
|
||||
wbc_err = wb_int_trans_recv(subreq, state, &state->wb_resp);
|
||||
TALLOC_FREE(subreq);
|
||||
|
||||
if (wb_trans_retry(req, state, status)) {
|
||||
if (wb_trans_retry(req, state, wbc_err)) {
|
||||
return;
|
||||
}
|
||||
|
||||
async_req_done(req);
|
||||
}
|
||||
|
||||
NTSTATUS wb_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_response **presponse)
|
||||
wbcErr wb_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_response **presponse)
|
||||
{
|
||||
struct wb_trans_state *state = talloc_get_type_abort(
|
||||
req->private_data, struct wb_trans_state);
|
||||
NTSTATUS status;
|
||||
wbcErr wbc_err;
|
||||
|
||||
if (async_req_is_nterror(req, &status)) {
|
||||
return status;
|
||||
if (async_req_is_wbcerr(req, &wbc_err)) {
|
||||
return wbc_err;
|
||||
}
|
||||
|
||||
*presponse = talloc_move(mem_ctx, &state->wb_resp);
|
||||
return NT_STATUS_OK;
|
||||
return WBC_ERR_SUCCESS;
|
||||
}
|
||||
|
@ -1220,11 +1220,12 @@ static void np_write_done(struct async_req *subreq)
|
||||
{
|
||||
struct async_req *req = talloc_get_type_abort(
|
||||
subreq->async.priv, struct async_req);
|
||||
NTSTATUS status;
|
||||
int err;
|
||||
ssize_t ret;
|
||||
|
||||
status = sendall_recv(subreq);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
async_req_nterror(req, status);
|
||||
ret = sendall_recv(subreq, &err);
|
||||
if (ret < 0) {
|
||||
async_req_nterror(req, map_nt_error_from_unix(err));
|
||||
return;
|
||||
}
|
||||
async_req_done(req);
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "wbc_async.h"
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
@ -5497,14 +5498,14 @@ static bool run_local_memcache(int dummy)
|
||||
|
||||
static void wbclient_done(struct async_req *req)
|
||||
{
|
||||
NTSTATUS status;
|
||||
wbcErr wbc_err;
|
||||
struct winbindd_response *wb_resp;
|
||||
int *i = (int *)req->async.priv;
|
||||
|
||||
status = wb_trans_recv(req, req, &wb_resp);
|
||||
wbc_err = wb_trans_recv(req, req, &wb_resp);
|
||||
TALLOC_FREE(req);
|
||||
*i += 1;
|
||||
d_printf("wb_trans_recv %d returned %s\n", *i, nt_errstr(status));
|
||||
d_printf("wb_trans_recv %d returned %s\n", *i, wbcErrorString(wbc_err));
|
||||
}
|
||||
|
||||
static bool run_local_wbclient(int dummy)
|
||||
|
@ -67,27 +67,6 @@ bool winbindd_setup_sig_term_handler(bool parent);
|
||||
bool winbindd_setup_sig_hup_handler(const char *lfile);
|
||||
int main(int argc, char **argv, char **envp);
|
||||
|
||||
/* The following definitions come from winbindd/winbindd_reqtrans.c */
|
||||
|
||||
struct async_req *wb_req_read_send(TALLOC_CTX *mem_ctx,
|
||||
struct event_context *ev,
|
||||
int fd, size_t max_extra_data);
|
||||
NTSTATUS wb_req_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_request **preq);
|
||||
struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
|
||||
struct event_context *ev, int fd,
|
||||
struct winbindd_request *wb_req);
|
||||
NTSTATUS wb_req_write_recv(struct async_req *req);
|
||||
|
||||
struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx,
|
||||
struct event_context *ev, int fd);
|
||||
NTSTATUS wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
|
||||
struct winbindd_response **presp);
|
||||
struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx,
|
||||
struct event_context *ev, int fd,
|
||||
struct winbindd_response *wb_resp);
|
||||
NTSTATUS wb_resp_write_recv(struct async_req *req);
|
||||
|
||||
/* The following definitions come from winbindd/winbindd_ads.c */
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user