From 0a3ee53b50a10874b0ee0230b022b4277b5a6d96 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 2 Mar 2009 05:04:07 +0100 Subject: Use samba3's own iconv implementation for now, until all changes are merged. --- source3/lib/iconv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/iconv.c b/source3/lib/iconv.c index fa213a37c0..44500542f2 100644 --- a/source3/lib/iconv.c +++ b/source3/lib/iconv.c @@ -207,12 +207,12 @@ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode) from = charsets; to = charsets; - ret = SMB_MALLOC_P(smb_iconv_t); + ret = SMB_MALLOC_P(struct smb_iconv_s); if (!ret) { errno = ENOMEM; return (smb_iconv_t)-1; } - memset(ret, 0, sizeof(smb_iconv_t)); + memset(ret, 0, sizeof(struct smb_iconv_s)); ret->from_name = SMB_STRDUP(fromcode); ret->to_name = SMB_STRDUP(tocode); -- cgit From 67d41d0fc7567cf141b12e866dd227d393e33551 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 28 Feb 2009 15:44:30 -0500 Subject: Make struct tevent_req opaque Move struct tevent_req in tevent_internal, and ad getters and setters for private data and the callback function. This patch also renames 'private_state' into 'data'. What is held in this pointer is in fact data and not a state like enum tevent_req_state. Calling it 'state' is confusing. The functions addedd are: tevent_req_set_callback() - sets req->async.fn and req->async.private_data tevent_req_set_print_fn() - sets req->private_print tevent_req_callback_data() - gets req->async.private_data tevent_req_data() - gets rea->data This way it is much simpler to keep API/ABI compatibility in the future. --- source3/lib/util_sock.c | 25 +++++++++++-------------- source3/lib/wb_reqtrans.c | 28 ++++++++++++---------------- 2 files changed, 23 insertions(+), 30 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 6e75a67a85..3604be369f 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1033,8 +1033,7 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx, timeval_current_ofs(0, state->wait_nsec))) { goto fail; } - subreq->async.fn = open_socket_out_connected; - subreq->async.private_data = result; + tevent_req_set_callback(subreq, open_socket_out_connected, result); return result; post_status: @@ -1047,10 +1046,10 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx, static void open_socket_out_connected(struct tevent_req *subreq) { - struct tevent_req *req = talloc_get_type_abort( - subreq->async.private_data, struct tevent_req); - struct open_socket_out_state *state = talloc_get_type_abort( - req->private_state, struct open_socket_out_state); + struct tevent_req *req = + tevent_req_callback_data(subreq, struct tevent_req); + struct open_socket_out_state *state = + tevent_req_data(req, struct open_socket_out_state); int ret; int sys_errno; @@ -1089,8 +1088,7 @@ static void open_socket_out_connected(struct tevent_req *subreq) tevent_req_nterror(req, NT_STATUS_NO_MEMORY); return; } - subreq->async.fn = open_socket_out_connected; - subreq->async.private_data = req; + tevent_req_set_callback(subreq, open_socket_out_connected, req); return; } @@ -1107,8 +1105,8 @@ static void open_socket_out_connected(struct tevent_req *subreq) NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd) { - struct open_socket_out_state *state = talloc_get_type_abort( - req->private_state, struct open_socket_out_state); + struct open_socket_out_state *state = + tevent_req_data(req, struct open_socket_out_state); NTSTATUS status; if (tevent_req_is_nterror(req, &status)) { @@ -1217,14 +1215,13 @@ static void open_socket_out_defer_waited(struct async_req *subreq) if (async_req_nomem(subreq2, req)) { return; } - subreq2->async.fn = open_socket_out_defer_connected; - subreq2->async.private_data = req; + tevent_req_set_callback(subreq2, open_socket_out_defer_connected, req); } static void open_socket_out_defer_connected(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.private_data, struct async_req); + struct async_req *req = + tevent_req_callback_data(subreq, struct async_req); struct open_socket_out_defer_state *state = talloc_get_type_abort( req->private_data, struct open_socket_out_defer_state); NTSTATUS status; diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index 65906dcb91..63a25fb896 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -103,8 +103,7 @@ struct async_req *wb_req_read_send(TALLOC_CTX *mem_ctx, goto nomem; } - subreq->async.fn = wb_req_read_done; - subreq->async.private_data = result; + tevent_req_set_callback(subreq, wb_req_read_done, result); return result; nomem: TALLOC_FREE(result); @@ -140,8 +139,8 @@ static ssize_t wb_req_more(uint8_t *buf, size_t buflen, void *private_data) static void wb_req_read_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.private_data, struct async_req); + struct async_req *req = + tevent_req_callback_data(subreq, struct async_req); struct req_read_state *state = talloc_get_type_abort( req->private_data, struct req_read_state); int err; @@ -213,8 +212,7 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx, if (subreq == NULL) { goto fail; } - subreq->async.fn = wb_req_write_done; - subreq->async.private_data = result; + tevent_req_set_callback(wb_req_write_done, result); return result; fail: @@ -224,8 +222,8 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx, static void wb_req_write_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.private_data, struct async_req); + struct async_req *req = + tevent_req_callback_data(subreq, struct async_req); int err; ssize_t ret; @@ -266,8 +264,7 @@ struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx, if (subreq == NULL) { goto nomem; } - subreq->async.fn = wb_resp_read_done; - subreq->async.private_data = result; + tevent_req_set_callback(subreq, wb_resp_read_done, result); return result; nomem: @@ -293,8 +290,8 @@ static ssize_t wb_resp_more(uint8_t *buf, size_t buflen, void *private_data) static void wb_resp_read_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.private_data, struct async_req); + struct async_req *req = + tevent_req_callback_data(subreq, struct async_req); struct resp_read_state *state = talloc_get_type_abort( req->private_data, struct resp_read_state); uint8_t *buf; @@ -367,8 +364,7 @@ struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, if (subreq == NULL) { goto fail; } - subreq->async.fn = wb_resp_write_done; - subreq->async.private_data = result; + tevent_req_set_callback(subreq, wb_resp_write_done, result); return result; fail: @@ -378,8 +374,8 @@ struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, static void wb_resp_write_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.private_data, struct async_req); + struct async_req *req = + tevent_re_callback_data(subreq, struct async_req); int err; ssize_t ret; -- cgit From 9cacb49eb623edc1a74c90f4fd407dce334e75e4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 2 Mar 2009 20:10:13 +0100 Subject: Attempt to fix the build Simo, with which compiler did you build this? I'd be curious to learn about the compiler settings that make this build. Thanks, Volker --- source3/lib/wb_reqtrans.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index 63a25fb896..222b64667c 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -212,7 +212,7 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx, if (subreq == NULL) { goto fail; } - tevent_req_set_callback(wb_req_write_done, result); + tevent_req_set_callback(subreq, wb_req_write_done, result); return result; fail: @@ -375,7 +375,7 @@ struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, static void wb_resp_write_done(struct tevent_req *subreq) { struct async_req *req = - tevent_re_callback_data(subreq, struct async_req); + tevent_req_callback_data(subreq, struct async_req); int err; ssize_t ret; -- cgit From 1ea0dca50a0fe724b2e0aaa908a51735e26131dd Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 2 Mar 2009 15:38:45 -0500 Subject: Fix wbclient.c wrt tevent_req changes too. --- source3/lib/wbclient.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index b8d55a944a..7034e668ed 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -224,8 +224,7 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx, if (subreq == NULL) { goto nomem; } - subreq->async.fn = wbc_connect_connected; - subreq->async.private_data = result; + tevent_req_set_callback(subreq, wbc_connect_connected, result); if (!tevent_req_set_endtime(subreq, ev, timeval_current_ofs(30, 0))) { goto nomem; @@ -245,8 +244,8 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx, static void wbc_connect_connected(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.private_data, struct async_req); + struct async_req *req = + tevent_req_callback_data(subreq, struct async_req); int res, err; res = async_connect_recv(subreq, &err); -- cgit From 4b2955aa7dbcf06629d24d3ea35c6dfa8c4156b9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 3 Mar 2009 08:50:35 -0800 Subject: Fix "ignore return" warning. Jeremy. --- source3/lib/events.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/events.c b/source3/lib/events.c index 9e81a47796..f875e0dc0c 100644 --- a/source3/lib/events.c +++ b/source3/lib/events.c @@ -286,8 +286,9 @@ static void s3_event_debug(void *context, enum tevent_debug_level level, break; }; - vasprintf(&s, fmt, ap); - if (!s) return; + if (vasprintf(&s, fmt, ap) == -1) { + return; + } DEBUG(samba_level, ("s3_event: %s", s)); free(s); } -- cgit From fb70a8a255f7fd40c7e578d9d21977259f9aa86c Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 27 Feb 2009 15:28:52 +0100 Subject: s3: Fix a memleak in dbwrap_rbt. The SMB_MALLOC'ed rbt node data was not free'd on talloc free of the db context. This is a quick fix using talloc instead of malloc for allocation of the node data. Since malloc was originally used for performance reasons, one might want to reverse to malloc and create a talloc destructor that walks the tree and frees all the node data if this talloc approach proves to be too slow.. Michael --- source3/lib/dbwrap_rbt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/dbwrap_rbt.c b/source3/lib/dbwrap_rbt.c index 6e09627223..cf4faa25b9 100644 --- a/source3/lib/dbwrap_rbt.c +++ b/source3/lib/dbwrap_rbt.c @@ -131,12 +131,12 @@ static NTSTATUS db_rbt_store(struct db_record *rec, TDB_DATA data, int flag) */ } - node = (struct db_rbt_node *)SMB_MALLOC( + node = (struct db_rbt_node *)talloc_size(rec_priv->db_ctx, offsetof(struct db_rbt_node, data) + rec->key.dsize + data.dsize); if (node == NULL) { - SAFE_FREE(rec_priv->node); + TALLOC_FREE(rec_priv->node); return NT_STATUS_NO_MEMORY; } @@ -148,7 +148,7 @@ static NTSTATUS db_rbt_store(struct db_record *rec, TDB_DATA data, int flag) db_rbt_parse_node(node, &this_key, &this_val); memcpy(this_key.dptr, rec->key.dptr, node->keysize); - SAFE_FREE(rec_priv->node); + TALLOC_FREE(rec_priv->node); memcpy(this_val.dptr, data.dptr, node->valuesize); @@ -194,7 +194,7 @@ static NTSTATUS db_rbt_delete(struct db_record *rec) } rb_erase(&rec_priv->node->rb_node, &rec_priv->db_ctx->tree); - SAFE_FREE(rec_priv->node); + TALLOC_FREE(rec_priv->node); return NT_STATUS_OK; } -- cgit From 5a9f668dabb62efd70054dc35d19c60d027793b5 Mon Sep 17 00:00:00 2001 From: Steven Danneman Date: Wed, 4 Mar 2009 11:04:31 -0800 Subject: s3: Remove madvise support This reverts 193be432. The MADVISE_PROTECT is inherited by all child processes and cannot be unset. The intention of the original patch was to protect the parent process, but allow children to be killed in low memory. Since this isn't possible with the current API, reverting the whole feature. --- source3/lib/util.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index 89f7be8e6c..ec794ca74e 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -899,13 +899,6 @@ bool reinit_after_fork(struct messaging_context *msg_ctx, * numbers as each other */ set_need_random_reseed(); -#ifdef WITH_MADVISE_PROTECTED - /* Protect parent process from being killed by kernel when system - * memory is low. Child processes can still be killed */ - if(!parent_longlived) - madvise(NULL,0,MADV_PROTECT); -#endif - /* tdb needs special fork handling */ if (tdb_reopen_all(parent_longlived ? 1 : 0) == -1) { DEBUG(0,("tdb_reopen_all failed.\n")); -- cgit From 9d798494a90c13d605a52644a1a386a9fb109063 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 4 Mar 2009 22:02:07 +0100 Subject: s3:smbconf: move smbconf_share_exists checks into backend Michael --- source3/lib/smbconf/smbconf_reg.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c index 5a5c0ead65..ae6a41151d 100644 --- a/source3/lib/smbconf/smbconf_reg.c +++ b/source3/lib/smbconf/smbconf_reg.c @@ -80,12 +80,20 @@ static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx, uint32 desired_access, struct registry_key **key) { + WERROR werr; + if (servicename == NULL) { *key = rpd(ctx)->base_key; return WERR_OK; } - return reg_openkey(mem_ctx, rpd(ctx)->base_key, servicename, + werr = reg_openkey(mem_ctx, rpd(ctx)->base_key, servicename, desired_access, key); + + if (W_ERROR_EQUAL(werr, WERR_BADFILE)) { + werr = WERR_NO_SUCH_SERVICE; + } + + return werr; } /** @@ -828,9 +836,6 @@ static WERROR smbconf_reg_get_share(struct smbconf_ctx *ctx, werr = smbconf_reg_open_service_key(tmp_ctx, ctx, servicename, REG_KEY_READ, &key); if (!W_ERROR_IS_OK(werr)) { - if (W_ERROR_EQUAL(werr, WERR_BADFILE)) { - werr = WERR_NO_SUCH_SERVICE; - } goto done; } -- cgit From bb0fb975621f4962fb7e2438396d94818891151b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 4 Mar 2009 22:05:17 +0100 Subject: s3:dbwrap_ctdb_marshall_add: don't leak the ctdb_rec_data to the outside Michael --- source3/lib/dbwrap_ctdb.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c index 03667ff355..4a5bf6d81a 100644 --- a/source3/lib/dbwrap_ctdb.c +++ b/source3/lib/dbwrap_ctdb.c @@ -121,9 +121,9 @@ static struct ctdb_marshall_buffer *db_ctdb_marshall_add(TALLOC_CTX *mem_ctx, { struct ctdb_rec_data *r; size_t m_size, r_size; - struct ctdb_marshall_buffer *m2; + struct ctdb_marshall_buffer *m2 = NULL; - r = db_ctdb_marshall_record(mem_ctx, reqid, key, header, data); + r = db_ctdb_marshall_record(talloc_tos(), reqid, key, header, data); if (r == NULL) { talloc_free(m); return NULL; @@ -133,7 +133,7 @@ static struct ctdb_marshall_buffer *db_ctdb_marshall_add(TALLOC_CTX *mem_ctx, m = (struct ctdb_marshall_buffer *)talloc_zero_size( mem_ctx, offsetof(struct ctdb_marshall_buffer, data)); if (m == NULL) { - return NULL; + goto done; } m->db_id = db_id; } @@ -145,15 +145,15 @@ static struct ctdb_marshall_buffer *db_ctdb_marshall_add(TALLOC_CTX *mem_ctx, mem_ctx, m, m_size + r_size); if (m2 == NULL) { talloc_free(m); - return NULL; + goto done; } memcpy(m_size + (uint8_t *)m2, r, r_size); - talloc_free(r); - m2->count++; +done: + talloc_free(r); return m2; } -- cgit From 4b6cbe80b28b7a99ba8f35190d809f5a439fdd22 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 6 Mar 2009 07:38:41 +0100 Subject: s3:errormap: add ECANCELED, ERRDOS/ERRbadfid, NT_STATUS_CANCELLED mapping If someone knows a better dos error, please tell me... metze --- source3/lib/errmap_unix.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/errmap_unix.c b/source3/lib/errmap_unix.c index 9adb237096..bb09726ee0 100644 --- a/source3/lib/errmap_unix.c +++ b/source3/lib/errmap_unix.c @@ -95,6 +95,9 @@ const struct unix_error_map unix_dos_nt_errmap[] = { #ifdef ENOATTR { ENOATTR, ERRDOS, ERRbadfile, NT_STATUS_NOT_FOUND }, #endif +#ifdef ECANCELED + { ECANCELED, ERRDOS, ERRbadfid, NT_STATUS_CANCELLED}, +#endif { 0, 0, 0, NT_STATUS_OK } }; -- cgit From f992416e23c9baf0e20848ff3c12fcafe1d492aa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 8 Mar 2009 06:57:52 +0100 Subject: Revert accidental reintroduction of void ** bug. --- source3/lib/charcnv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index 81cb9a5094..c3b345142f 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -763,7 +763,7 @@ bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to, * converted. */ bool convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to, - void const *src, size_t srclen, void **dst, + void const *src, size_t srclen, void *dst, size_t *converted_size, bool allow_bad_conv) { void **dest = (void **)dst; -- cgit From fe486d7b9f580a17d23dd57582087c7d28cb738d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 1 Mar 2009 19:43:07 +0100 Subject: Add "queue" to writev_send Unless higher levels queue themselves somehow, writev will *always* be queued. So the queueing should be done at the right level. --- source3/lib/wb_reqtrans.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index 222b64667c..26dfb783ab 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -208,7 +208,7 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx, count = 2; } - subreq = writev_send(state, ev, fd, state->iov, count); + subreq = writev_send(state, ev, NULL, fd, state->iov, count); if (subreq == NULL) { goto fail; } @@ -360,7 +360,7 @@ struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, count = 2; } - subreq = writev_send(state, ev, fd, state->iov, count); + subreq = writev_send(state, ev, NULL, fd, state->iov, count); if (subreq == NULL) { goto fail; } -- cgit From f5ee31602c7880b11dff82258764eb9a76cdc83b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 8 Mar 2009 09:34:35 +0100 Subject: Add tevent_req wbc helpers --- source3/lib/wb_reqtrans.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index 26dfb783ab..2051696a02 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -81,6 +81,43 @@ wbcErr async_req_simple_recv_wbcerr(struct async_req *req) return WBC_ERR_SUCCESS; } +bool tevent_req_is_wbcerr(struct tevent_req *req, wbcErr *pwbc_err) +{ + enum tevent_req_state state; + uint64_t error; + if (!tevent_req_is_error(req, &state, &error)) { + *pwbc_err = WBC_ERR_SUCCESS; + return false; + } + + switch (state) { + case TEVENT_REQ_USER_ERROR: + *pwbc_err = error; + break; + case TEVENT_REQ_TIMED_OUT: + *pwbc_err = WBC_ERR_UNKNOWN_FAILURE; + break; + case TEVENT_REQ_NO_MEMORY: + *pwbc_err = WBC_ERR_NO_MEMORY; + break; + default: + *pwbc_err = WBC_ERR_UNKNOWN_FAILURE; + break; + } + return true; +} + +wbcErr tevent_req_simple_recv_wbcerr(struct tevent_req *req) +{ + wbcErr wbc_err; + + if (tevent_req_is_wbcerr(req, &wbc_err)) { + return wbc_err; + } + + return WBC_ERR_SUCCESS; +} + static ssize_t wb_req_more(uint8_t *buf, size_t buflen, void *private_data); static void wb_req_read_done(struct tevent_req *subreq); -- cgit From 9a64d7cfbedec6fc634b523c2185213c136a5074 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 8 Mar 2009 09:35:13 +0100 Subject: Convert wb_req_write to tevent_req --- source3/lib/wb_reqtrans.c | 28 ++++++++++++++-------------- source3/lib/wbclient.c | 27 ++++++++++++++------------- 2 files changed, 28 insertions(+), 27 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index 2051696a02..9fcef0bb76 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -222,17 +222,17 @@ struct req_write_state { static void wb_req_write_done(struct tevent_req *subreq); -struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, int fd, - struct winbindd_request *wb_req) +struct tevent_req *wb_req_write_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct tevent_queue *queue, int fd, + struct winbindd_request *wb_req) { - struct async_req *result; - struct tevent_req *subreq; + struct tevent_req *result, *subreq; struct req_write_state *state; int count = 1; - if (!async_req_setup(mem_ctx, &result, &state, - struct req_write_state)) { + result = tevent_req_create(mem_ctx, &state, struct req_write_state); + if (result == NULL) { return NULL; } @@ -245,7 +245,7 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx, count = 2; } - subreq = writev_send(state, ev, NULL, fd, state->iov, count); + subreq = writev_send(state, ev, queue, fd, state->iov, count); if (subreq == NULL) { goto fail; } @@ -259,23 +259,23 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx, static void wb_req_write_done(struct tevent_req *subreq) { - struct async_req *req = - tevent_req_callback_data(subreq, struct async_req); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); int err; ssize_t ret; ret = writev_recv(subreq, &err); TALLOC_FREE(subreq); if (ret < 0) { - async_req_error(req, map_wbc_err_from_errno(err)); + tevent_req_error(req, map_wbc_err_from_errno(err)); return; } - async_req_done(req); + tevent_req_done(req); } -wbcErr wb_req_write_recv(struct async_req *req) +wbcErr wb_req_write_recv(struct tevent_req *req) { - return async_req_simple_recv_wbcerr(req); + return tevent_req_simple_recv_wbcerr(req); } struct resp_read_state { diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index 7034e668ed..254e57b5f2 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -294,7 +294,7 @@ struct wb_int_trans_state { struct winbindd_response *wb_resp; }; -static void wb_int_trans_write_done(struct async_req *subreq); +static void wb_int_trans_write_done(struct tevent_req *subreq); static void wb_int_trans_read_done(struct async_req *subreq); static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, @@ -302,7 +302,7 @@ static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, struct winbindd_request *wb_req) { struct async_req *result; - struct async_req *subreq; + struct tevent_req *subreq; struct wb_int_trans_state *state; if (!async_req_setup(mem_ctx, &result, &state, @@ -325,12 +325,12 @@ static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, state->wb_req->length = sizeof(struct winbindd_request); state->wb_req->pid = getpid(); - subreq = wb_req_write_send(state, state->ev, state->fd, state->wb_req); + subreq = wb_req_write_send(state, state->ev, NULL, state->fd, + state->wb_req); if (subreq == NULL) { goto fail; } - subreq->async.fn = wb_int_trans_write_done; - subreq->async.priv = result; + tevent_req_set_callback(subreq, wb_int_trans_write_done, result); return result; @@ -339,12 +339,13 @@ static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, return NULL; } -static void wb_int_trans_write_done(struct async_req *subreq) +static void wb_int_trans_write_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); + struct async_req *req = tevent_req_callback_data( + subreq, struct async_req); struct wb_int_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_int_trans_state); + struct async_req *subreq2; wbcErr wbc_err; wbc_err = wb_req_write_recv(subreq); @@ -354,12 +355,12 @@ static void wb_int_trans_write_done(struct async_req *subreq) return; } - subreq = wb_resp_read_send(state, state->ev, state->fd); - if (subreq == NULL) { - async_req_error(req, WBC_ERR_NO_MEMORY); + subreq2 = wb_resp_read_send(state, state->ev, state->fd); + if (async_req_nomem(subreq2, req)) { + return; } - subreq->async.fn = wb_int_trans_read_done; - subreq->async.priv = req; + subreq2->async.fn = wb_int_trans_read_done; + subreq2->async.priv = req; } static void wb_int_trans_read_done(struct async_req *subreq) -- cgit From 0a3a7d53eb4d573aa6b1a1b9a9d81b848e37ac7f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 8 Mar 2009 10:04:04 +0100 Subject: Convert wb_req_read to tevent_req --- source3/lib/wb_reqtrans.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index 9fcef0bb76..30e5f75062 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -121,16 +121,15 @@ wbcErr tevent_req_simple_recv_wbcerr(struct tevent_req *req) static ssize_t wb_req_more(uint8_t *buf, size_t buflen, void *private_data); static void wb_req_read_done(struct tevent_req *subreq); -struct async_req *wb_req_read_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - int fd, size_t max_extra_data) +struct tevent_req *wb_req_read_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + int fd, size_t max_extra_data) { - struct async_req *result; - struct tevent_req *subreq; + struct tevent_req *result, *subreq; struct req_read_state *state; - if (!async_req_setup(mem_ctx, &result, &state, - struct req_read_state)) { + result = tevent_req_create(mem_ctx, &state, struct req_read_state); + if (result == NULL) { return NULL; } state->max_extra_data = max_extra_data; @@ -176,10 +175,10 @@ static ssize_t wb_req_more(uint8_t *buf, size_t buflen, void *private_data) static void wb_req_read_done(struct tevent_req *subreq) { - struct async_req *req = - tevent_req_callback_data(subreq, struct async_req); - struct req_read_state *state = talloc_get_type_abort( - req->private_data, struct req_read_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct req_read_state *state = tevent_req_data( + req, struct req_read_state); int err; ssize_t ret; uint8_t *buf; @@ -187,7 +186,7 @@ static void wb_req_read_done(struct tevent_req *subreq) ret = read_packet_recv(subreq, state, &buf, &err); TALLOC_FREE(subreq); if (ret == -1) { - async_req_error(req, map_wbc_err_from_errno(err)); + tevent_req_error(req, map_wbc_err_from_errno(err)); return; } @@ -199,17 +198,17 @@ static void wb_req_read_done(struct tevent_req *subreq) } else { state->wb_req->extra_data.data = NULL; } - async_req_done(req); + tevent_req_done(req); } -wbcErr wb_req_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx, +wbcErr wb_req_read_recv(struct tevent_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); + struct req_read_state *state = tevent_req_data( + req, struct req_read_state); wbcErr wbc_err; - if (async_req_is_wbcerr(req, &wbc_err)) { + if (tevent_req_is_wbcerr(req, &wbc_err)) { return wbc_err; } *preq = talloc_move(mem_ctx, &state->wb_req); -- cgit From 80fcd764213afc430f4b4cefec4e251e668bd0ba Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 8 Mar 2009 10:20:27 +0100 Subject: Convert wb_resp_read to tevent_req --- source3/lib/wb_reqtrans.c | 31 +++++++++++++++---------------- source3/lib/wbclient.c | 16 +++++++--------- 2 files changed, 22 insertions(+), 25 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index 30e5f75062..1f7713b02d 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -284,15 +284,14 @@ struct resp_read_state { static ssize_t wb_resp_more(uint8_t *buf, size_t buflen, void *private_data); static void wb_resp_read_done(struct tevent_req *subreq); -struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, int fd) +struct tevent_req *wb_resp_read_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, int fd) { - struct async_req *result; - struct tevent_req *subreq; + struct tevent_req *result, *subreq; struct resp_read_state *state; - if (!async_req_setup(mem_ctx, &result, &state, - struct resp_read_state)) { + result = tevent_req_create(mem_ctx, &state, struct resp_read_state); + if (result == NULL) { return NULL; } @@ -326,10 +325,10 @@ static ssize_t wb_resp_more(uint8_t *buf, size_t buflen, void *private_data) static void wb_resp_read_done(struct tevent_req *subreq) { - struct async_req *req = - tevent_req_callback_data(subreq, struct async_req); - struct resp_read_state *state = talloc_get_type_abort( - req->private_data, struct resp_read_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct resp_read_state *state = tevent_req_data( + req, struct resp_read_state); uint8_t *buf; int err; ssize_t ret; @@ -337,7 +336,7 @@ static void wb_resp_read_done(struct tevent_req *subreq) ret = read_packet_recv(subreq, state, &buf, &err); TALLOC_FREE(subreq); if (ret == -1) { - async_req_error(req, map_wbc_err_from_errno(err)); + tevent_req_error(req, map_wbc_err_from_errno(err)); return; } @@ -349,17 +348,17 @@ static void wb_resp_read_done(struct tevent_req *subreq) } else { state->wb_resp->extra_data.data = NULL; } - async_req_done(req); + tevent_req_done(req); } -wbcErr wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx, +wbcErr wb_resp_read_recv(struct tevent_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); + struct resp_read_state *state = tevent_req_data( + req, struct resp_read_state); wbcErr wbc_err; - if (async_req_is_wbcerr(req, &wbc_err)) { + if (tevent_req_is_wbcerr(req, &wbc_err)) { return wbc_err; } *presp = talloc_move(mem_ctx, &state->wb_resp); diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index 254e57b5f2..d299914c73 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -295,7 +295,7 @@ struct wb_int_trans_state { }; static void wb_int_trans_write_done(struct tevent_req *subreq); -static void wb_int_trans_read_done(struct async_req *subreq); +static void wb_int_trans_read_done(struct tevent_req *subreq); static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, int fd, @@ -345,7 +345,6 @@ static void wb_int_trans_write_done(struct tevent_req *subreq) subreq, struct async_req); struct wb_int_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_int_trans_state); - struct async_req *subreq2; wbcErr wbc_err; wbc_err = wb_req_write_recv(subreq); @@ -355,18 +354,17 @@ static void wb_int_trans_write_done(struct tevent_req *subreq) return; } - subreq2 = wb_resp_read_send(state, state->ev, state->fd); - if (async_req_nomem(subreq2, req)) { + subreq = wb_resp_read_send(state, state->ev, state->fd); + if (async_req_nomem(subreq, req)) { return; } - subreq2->async.fn = wb_int_trans_read_done; - subreq2->async.priv = req; + tevent_req_set_callback(subreq, wb_int_trans_read_done, req); } -static void wb_int_trans_read_done(struct async_req *subreq) +static void wb_int_trans_read_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); + struct async_req *req = tevent_req_callback_data( + subreq, struct async_req); struct wb_int_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_int_trans_state); wbcErr wbc_err; -- cgit From 1611e63ae5abd323502d062d9474acd6648ae959 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 8 Mar 2009 10:28:05 +0100 Subject: Convert wb_resp_write to tevent_req --- source3/lib/wb_reqtrans.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index 1f7713b02d..f1856be6dd 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -371,17 +371,16 @@ struct resp_write_state { static void wb_resp_write_done(struct tevent_req *subreq); -struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, int fd, - struct winbindd_response *wb_resp) +struct tevent_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, int fd, + struct winbindd_response *wb_resp) { - struct async_req *result; - struct tevent_req *subreq; + struct tevent_req *result, *subreq; struct resp_write_state *state; int count = 1; - if (!async_req_setup(mem_ctx, &result, &state, - struct resp_write_state)) { + result = tevent_req_create(mem_ctx, &state, struct resp_write_state); + if (result == NULL) { return NULL; } @@ -409,21 +408,21 @@ struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, static void wb_resp_write_done(struct tevent_req *subreq) { - struct async_req *req = - tevent_req_callback_data(subreq, struct async_req); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); int err; ssize_t ret; ret = writev_recv(subreq, &err); TALLOC_FREE(subreq); if (ret < 0) { - async_req_error(req, map_wbc_err_from_errno(err)); + tevent_req_error(req, map_wbc_err_from_errno(err)); return; } - async_req_done(req); + tevent_req_done(req); } -wbcErr wb_resp_write_recv(struct async_req *req) +wbcErr wb_resp_write_recv(struct tevent_req *req) { - return async_req_simple_recv_wbcerr(req); + return tevent_req_simple_recv_wbcerr(req); } -- cgit From c7df04633969f3d50214fcc5916ed695208b9bf2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 8 Mar 2009 10:29:15 +0100 Subject: Move "struct req_read_state" where it belongs --- source3/lib/wb_reqtrans.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index f1856be6dd..6ae1d1bb9b 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -25,11 +25,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_WINBIND -struct req_read_state { - struct winbindd_request *wb_req; - size_t max_extra_data; -}; - bool async_req_is_wbcerr(struct async_req *req, wbcErr *pwbc_err) { enum async_req_state state; @@ -118,6 +113,11 @@ wbcErr tevent_req_simple_recv_wbcerr(struct tevent_req *req) return WBC_ERR_SUCCESS; } +struct req_read_state { + struct winbindd_request *wb_req; + size_t max_extra_data; +}; + static ssize_t wb_req_more(uint8_t *buf, size_t buflen, void *private_data); static void wb_req_read_done(struct tevent_req *subreq); -- cgit From eb177592b5ab5042719be53df717df91f8cfb6aa Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 8 Mar 2009 11:33:03 +0100 Subject: Add parameter "queue" to wb_int_trans_send --- source3/lib/wbclient.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index d299914c73..10ee4ff205 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -298,7 +298,8 @@ static void wb_int_trans_write_done(struct tevent_req *subreq); static void wb_int_trans_read_done(struct tevent_req *subreq); static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, int fd, + struct tevent_context *ev, + struct tevent_queue *queue, int fd, struct winbindd_request *wb_req) { struct async_req *result; @@ -325,7 +326,7 @@ static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, state->wb_req->length = sizeof(struct winbindd_request); state->wb_req->pid = getpid(); - subreq = wb_req_write_send(state, state->ev, NULL, state->fd, + subreq = wb_req_write_send(state, state->ev, queue, state->fd, state->wb_req); if (subreq == NULL) { goto fail; @@ -476,7 +477,7 @@ static void wb_open_pipe_connect_nonpriv_done(struct async_req *subreq) ZERO_STRUCT(state->wb_req); state->wb_req.cmd = WINBINDD_INTERFACE_VERSION; - subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, + subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, &state->wb_req); if (async_req_nomem(subreq, req)) { return; @@ -509,7 +510,7 @@ static void wb_open_pipe_ping_done(struct async_req *subreq) state->wb_req.cmd = WINBINDD_PRIV_PIPE_DIR; - subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, + subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, &state->wb_req); if (async_req_nomem(subreq, req)) { return; @@ -605,7 +606,7 @@ static void wb_trigger_trans(struct async_req *req) return; } - subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, + subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, state->wb_req); if (async_req_nomem(subreq, req)) { return; @@ -727,7 +728,7 @@ static void wb_trans_connect_done(struct async_req *subreq) return; } - subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->fd, + subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, state->wb_req); if (async_req_nomem(subreq, req)) { return; -- cgit From 549c30e9fe937f5c5aa7d63f5522af47f6fbed5c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 8 Mar 2009 12:10:00 +0100 Subject: Convert wb_int_trans to tevent_req --- source3/lib/wbclient.c | 132 +++++++++++++++++++++++-------------------------- 1 file changed, 63 insertions(+), 69 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index 10ee4ff205..b6966776f0 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -297,32 +297,28 @@ struct wb_int_trans_state { static void wb_int_trans_write_done(struct tevent_req *subreq); static void wb_int_trans_read_done(struct tevent_req *subreq); -static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct tevent_queue *queue, int fd, - struct winbindd_request *wb_req) +static struct tevent_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct tevent_queue *queue, int fd, + struct winbindd_request *wb_req) { - struct async_req *result; - struct tevent_req *subreq; + struct tevent_req *result, *subreq; struct wb_int_trans_state *state; - if (!async_req_setup(mem_ctx, &result, &state, - struct wb_int_trans_state)) { + result = tevent_req_create(mem_ctx, &state, + struct wb_int_trans_state); + if (result == NULL) { return NULL; } if (winbind_closed_fd(fd)) { - if (!async_post_error(result, ev, - WBC_ERR_WINBIND_NOT_AVAILABLE)) { - goto fail; - } - return result; + tevent_req_error(result, WBC_ERR_WINBIND_NOT_AVAILABLE); + return tevent_req_post(result, ev); } state->ev = ev; state->fd = fd; state->wb_req = wb_req; - state->wb_req->length = sizeof(struct winbindd_request); state->wb_req->pid = getpid(); @@ -342,21 +338,21 @@ static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, static void wb_int_trans_write_done(struct tevent_req *subreq) { - struct async_req *req = tevent_req_callback_data( - subreq, struct async_req); - struct wb_int_trans_state *state = talloc_get_type_abort( - req->private_data, struct wb_int_trans_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_int_trans_state *state = tevent_req_data( + req, struct wb_int_trans_state); wbcErr wbc_err; wbc_err = wb_req_write_recv(subreq); TALLOC_FREE(subreq); if (!WBC_ERROR_IS_OK(wbc_err)) { - async_req_error(req, wbc_err); + tevent_req_error(req, wbc_err); return; } subreq = wb_resp_read_send(state, state->ev, state->fd); - if (async_req_nomem(subreq, req)) { + if (tevent_req_nomem(subreq, req)) { return; } tevent_req_set_callback(subreq, wb_int_trans_read_done, req); @@ -364,31 +360,31 @@ static void wb_int_trans_write_done(struct tevent_req *subreq) static void wb_int_trans_read_done(struct tevent_req *subreq) { - struct async_req *req = tevent_req_callback_data( - subreq, struct async_req); - struct wb_int_trans_state *state = talloc_get_type_abort( - req->private_data, struct wb_int_trans_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_int_trans_state *state = tevent_req_data( + req, struct wb_int_trans_state); wbcErr wbc_err; wbc_err = wb_resp_read_recv(subreq, state, &state->wb_resp); TALLOC_FREE(subreq); if (!WBC_ERROR_IS_OK(wbc_err)) { - async_req_error(req, wbc_err); + tevent_req_error(req, wbc_err); return; } - async_req_done(req); + tevent_req_done(req); } -static wbcErr wb_int_trans_recv(struct async_req *req, +static wbcErr wb_int_trans_recv(struct tevent_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); + struct wb_int_trans_state *state = tevent_req_data( + req, struct wb_int_trans_state); wbcErr wbc_err; - if (async_req_is_wbcerr(req, &wbc_err)) { + if (tevent_req_is_wbcerr(req, &wbc_err)) { return wbc_err; } @@ -418,8 +414,8 @@ struct wb_open_pipe_state { }; static void wb_open_pipe_connect_nonpriv_done(struct async_req *subreq); -static void wb_open_pipe_ping_done(struct async_req *subreq); -static void wb_open_pipe_getpriv_done(struct async_req *subreq); +static void wb_open_pipe_ping_done(struct tevent_req *subreq); +static void wb_open_pipe_getpriv_done(struct tevent_req *subreq); static void wb_open_pipe_connect_priv_done(struct async_req *subreq); static struct async_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx, @@ -464,6 +460,7 @@ 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); + struct tevent_req *subreq2; wbcErr wbc_err; wbc_err = wb_connect_recv(subreq); @@ -477,20 +474,18 @@ static void wb_open_pipe_connect_nonpriv_done(struct async_req *subreq) ZERO_STRUCT(state->wb_req); state->wb_req.cmd = WINBINDD_INTERFACE_VERSION; - subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, + subreq2 = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, &state->wb_req); - if (async_req_nomem(subreq, req)) { + if (async_req_nomem(subreq2, req)) { return; } - - subreq->async.fn = wb_open_pipe_ping_done; - subreq->async.priv = req; + tevent_req_set_callback(subreq2, wb_open_pipe_ping_done, req); } -static void wb_open_pipe_ping_done(struct async_req *subreq) +static void wb_open_pipe_ping_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); + struct async_req *req = tevent_req_callback_data( + subreq, struct async_req); struct wb_open_pipe_state *state = talloc_get_type_abort( req->private_data, struct wb_open_pipe_state); struct winbindd_response *wb_resp; @@ -515,18 +510,17 @@ static void wb_open_pipe_ping_done(struct async_req *subreq) if (async_req_nomem(subreq, req)) { return; } - - subreq->async.fn = wb_open_pipe_getpriv_done; - subreq->async.priv = req; + tevent_req_set_callback(subreq, wb_open_pipe_getpriv_done, req); } -static void wb_open_pipe_getpriv_done(struct async_req *subreq) +static void wb_open_pipe_getpriv_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); + struct async_req *req = tevent_req_callback_data( + subreq, struct async_req); struct wb_open_pipe_state *state = talloc_get_type_abort( req->private_data, struct wb_open_pipe_state); struct winbindd_response *wb_resp = NULL; + struct async_req *subreq2; wbcErr wbc_err; wbc_err = wb_int_trans_recv(subreq, state, &wb_resp); @@ -539,15 +533,15 @@ static void wb_open_pipe_getpriv_done(struct async_req *subreq) close(state->wb_ctx->fd); state->wb_ctx->fd = -1; - subreq = wb_connect_send(state, state->ev, state->wb_ctx, - (char *)wb_resp->extra_data.data); + subreq2 = wb_connect_send(state, state->ev, state->wb_ctx, + (char *)wb_resp->extra_data.data); TALLOC_FREE(wb_resp); - if (async_req_nomem(subreq, req)) { + if (async_req_nomem(subreq2, req)) { return; } - subreq->async.fn = wb_open_pipe_connect_priv_done; - subreq->async.priv = req; + subreq2->async.fn = wb_open_pipe_connect_priv_done; + subreq2->async.priv = req; } static void wb_open_pipe_connect_priv_done(struct async_req *subreq) @@ -584,25 +578,27 @@ struct wb_trans_state { }; static void wb_trans_connect_done(struct async_req *subreq); -static void wb_trans_done(struct async_req *subreq); +static void wb_trans_done(struct tevent_req *subreq); static void wb_trans_retry_wait_done(struct async_req *subreq); static void wb_trigger_trans(struct async_req *req) { struct wb_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_trans_state); - struct async_req *subreq; + struct tevent_req *subreq; if ((state->wb_ctx->fd == -1) || (state->need_priv && !state->wb_ctx->is_priv)) { - subreq = wb_open_pipe_send(state, state->ev, state->wb_ctx, - state->need_priv); - if (async_req_nomem(subreq, req)) { + struct async_req *subreq2; + + subreq2 = wb_open_pipe_send(state, state->ev, state->wb_ctx, + state->need_priv); + if (async_req_nomem(subreq2, req)) { return; } - subreq->async.fn = wb_trans_connect_done; - subreq->async.priv = req; + subreq2->async.fn = wb_trans_connect_done; + subreq2->async.priv = req; return; } @@ -611,8 +607,7 @@ static void wb_trigger_trans(struct async_req *req) if (async_req_nomem(subreq, req)) { return; } - subreq->async.fn = wb_trans_done; - subreq->async.priv = req; + tevent_req_set_callback(subreq, wb_trans_done, req); } struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, @@ -719,6 +714,7 @@ 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); + struct tevent_req *subreq2; wbcErr wbc_err; wbc_err = wb_open_pipe_recv(subreq); @@ -728,20 +724,18 @@ static void wb_trans_connect_done(struct async_req *subreq) return; } - subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, - state->wb_req); - if (async_req_nomem(subreq, req)) { + subreq2 = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, + state->wb_req); + if (async_req_nomem(subreq2, req)) { return; } - - subreq->async.fn = wb_trans_done; - subreq->async.priv = req; + tevent_req_set_callback(subreq2, wb_trans_done, req); } -static void wb_trans_done(struct async_req *subreq) +static void wb_trans_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); + struct async_req *req = tevent_req_callback_data( + subreq, struct async_req); struct wb_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_trans_state); wbcErr wbc_err; -- cgit From 33db1e07a7631b7c7370a43747a65a43df88b1b1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 8 Mar 2009 12:15:39 +0100 Subject: Convert wb_connect to tevent_req --- source3/lib/wbclient.c | 68 ++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 38 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index b6966776f0..3480a1dc31 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -153,21 +153,20 @@ struct wb_connect_state { static void wbc_connect_connected(struct tevent_req *subreq); -static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx, +static struct tevent_req *wb_connect_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct wb_context *wb_ctx, const char *dir) { - struct async_req *result; - struct tevent_req *subreq; + struct tevent_req *result, *subreq; struct wb_connect_state *state; struct sockaddr_un sunaddr; struct stat st; char *path = NULL; wbcErr wbc_err; - if (!async_req_setup(mem_ctx, &result, &state, - struct wb_connect_state)) { + result = tevent_req_create(mem_ctx, &state, struct wb_connect_state); + if (result == NULL) { return NULL; } @@ -232,34 +231,32 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx, return result; - nomem: - wbc_err = WBC_ERR_NO_MEMORY; post_status: - if (async_post_error(result, ev, wbc_err)) { - return result; - } + tevent_req_error(result, wbc_err); + return tevent_req_post(result, ev); + nomem: TALLOC_FREE(result); return NULL; } static void wbc_connect_connected(struct tevent_req *subreq) { - struct async_req *req = - tevent_req_callback_data(subreq, struct async_req); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); int res, err; res = async_connect_recv(subreq, &err); TALLOC_FREE(subreq); if (res == -1) { - async_req_error(req, map_wbc_err_from_errno(err)); + tevent_req_error(req, map_wbc_err_from_errno(err)); return; } - async_req_done(req); + tevent_req_done(req); } -static wbcErr wb_connect_recv(struct async_req *req) +static wbcErr wb_connect_recv(struct tevent_req *req) { - return async_req_simple_recv_wbcerr(req); + return tevent_req_simple_recv_wbcerr(req); } static struct winbindd_request *winbindd_request_copy( @@ -413,10 +410,10 @@ struct wb_open_pipe_state { struct winbindd_request wb_req; }; -static void wb_open_pipe_connect_nonpriv_done(struct async_req *subreq); +static void wb_open_pipe_connect_nonpriv_done(struct tevent_req *subreq); static void wb_open_pipe_ping_done(struct tevent_req *subreq); static void wb_open_pipe_getpriv_done(struct tevent_req *subreq); -static void wb_open_pipe_connect_priv_done(struct async_req *subreq); +static void wb_open_pipe_connect_priv_done(struct tevent_req *subreq); static struct async_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, @@ -424,7 +421,7 @@ static struct async_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx, bool need_priv) { struct async_req *result; - struct async_req *subreq; + struct tevent_req *subreq; struct wb_open_pipe_state *state; if (!async_req_setup(mem_ctx, &result, &state, @@ -444,9 +441,8 @@ static struct async_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx, if (subreq == NULL) { goto fail; } - - subreq->async.fn = wb_open_pipe_connect_nonpriv_done; - subreq->async.priv = result; + tevent_req_set_callback(subreq, wb_open_pipe_connect_nonpriv_done, + result); return result; fail: @@ -454,13 +450,12 @@ static struct async_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx, return NULL; } -static void wb_open_pipe_connect_nonpriv_done(struct async_req *subreq) +static void wb_open_pipe_connect_nonpriv_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); + struct async_req *req = tevent_req_callback_data( + subreq, struct async_req); struct wb_open_pipe_state *state = talloc_get_type_abort( req->private_data, struct wb_open_pipe_state); - struct tevent_req *subreq2; wbcErr wbc_err; wbc_err = wb_connect_recv(subreq); @@ -474,12 +469,12 @@ static void wb_open_pipe_connect_nonpriv_done(struct async_req *subreq) ZERO_STRUCT(state->wb_req); state->wb_req.cmd = WINBINDD_INTERFACE_VERSION; - subreq2 = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, + subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, &state->wb_req); - if (async_req_nomem(subreq2, req)) { + if (async_req_nomem(subreq, req)) { return; } - tevent_req_set_callback(subreq2, wb_open_pipe_ping_done, req); + tevent_req_set_callback(subreq, wb_open_pipe_ping_done, req); } static void wb_open_pipe_ping_done(struct tevent_req *subreq) @@ -520,7 +515,6 @@ static void wb_open_pipe_getpriv_done(struct tevent_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; - struct async_req *subreq2; wbcErr wbc_err; wbc_err = wb_int_trans_recv(subreq, state, &wb_resp); @@ -533,21 +527,19 @@ static void wb_open_pipe_getpriv_done(struct tevent_req *subreq) close(state->wb_ctx->fd); state->wb_ctx->fd = -1; - subreq2 = wb_connect_send(state, state->ev, state->wb_ctx, + subreq = wb_connect_send(state, state->ev, state->wb_ctx, (char *)wb_resp->extra_data.data); TALLOC_FREE(wb_resp); - if (async_req_nomem(subreq2, req)) { + if (async_req_nomem(subreq, req)) { return; } - - subreq2->async.fn = wb_open_pipe_connect_priv_done; - subreq2->async.priv = req; + tevent_req_set_callback(subreq, wb_open_pipe_connect_priv_done, req); } -static void wb_open_pipe_connect_priv_done(struct async_req *subreq) +static void wb_open_pipe_connect_priv_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); + struct async_req *req = tevent_req_callback_data( + subreq, struct async_req); struct wb_open_pipe_state *state = talloc_get_type_abort( req->private_data, struct wb_open_pipe_state); wbcErr wbc_err; -- cgit From e503148225a8b634cea57db65983e8dcdf60154d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 8 Mar 2009 12:22:29 +0100 Subject: Convert wb_open_pipe to tevent_req --- source3/lib/wbclient.c | 98 ++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 51 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index 3480a1dc31..d1f3190c79 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -415,17 +415,16 @@ static void wb_open_pipe_ping_done(struct tevent_req *subreq); static void wb_open_pipe_getpriv_done(struct tevent_req *subreq); static void wb_open_pipe_connect_priv_done(struct tevent_req *subreq); -static struct async_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct wb_context *wb_ctx, - bool need_priv) +static struct tevent_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct wb_context *wb_ctx, + bool need_priv) { - struct async_req *result; - struct tevent_req *subreq; + struct tevent_req *result, *subreq; struct wb_open_pipe_state *state; - if (!async_req_setup(mem_ctx, &result, &state, - struct wb_open_pipe_state)) { + result = tevent_req_create(mem_ctx, &state, struct wb_open_pipe_state); + if (result == NULL) { return NULL; } state->wb_ctx = wb_ctx; @@ -452,17 +451,17 @@ static struct async_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx, static void wb_open_pipe_connect_nonpriv_done(struct tevent_req *subreq) { - struct async_req *req = tevent_req_callback_data( - subreq, struct async_req); - struct wb_open_pipe_state *state = talloc_get_type_abort( - req->private_data, struct wb_open_pipe_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_open_pipe_state *state = tevent_req_data( + req, struct wb_open_pipe_state); wbcErr wbc_err; wbc_err = wb_connect_recv(subreq); TALLOC_FREE(subreq); if (!WBC_ERROR_IS_OK(wbc_err)) { state->wb_ctx->is_priv = true; - async_req_error(req, wbc_err); + tevent_req_error(req, wbc_err); return; } @@ -471,7 +470,7 @@ static void wb_open_pipe_connect_nonpriv_done(struct tevent_req *subreq) subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, &state->wb_req); - if (async_req_nomem(subreq, req)) { + if (tevent_req_nomem(subreq, req)) { return; } tevent_req_set_callback(subreq, wb_open_pipe_ping_done, req); @@ -479,22 +478,22 @@ static void wb_open_pipe_connect_nonpriv_done(struct tevent_req *subreq) static void wb_open_pipe_ping_done(struct tevent_req *subreq) { - struct async_req *req = tevent_req_callback_data( - subreq, struct async_req); - struct wb_open_pipe_state *state = talloc_get_type_abort( - req->private_data, struct wb_open_pipe_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_open_pipe_state *state = tevent_req_data( + req, struct wb_open_pipe_state); struct winbindd_response *wb_resp; wbcErr wbc_err; wbc_err = wb_int_trans_recv(subreq, state, &wb_resp); TALLOC_FREE(subreq); if (!WBC_ERROR_IS_OK(wbc_err)) { - async_req_error(req, wbc_err); + tevent_req_error(req, wbc_err); return; } if (!state->need_priv) { - async_req_done(req); + tevent_req_done(req); return; } @@ -502,7 +501,7 @@ static void wb_open_pipe_ping_done(struct tevent_req *subreq) subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, &state->wb_req); - if (async_req_nomem(subreq, req)) { + if (tevent_req_nomem(subreq, req)) { return; } tevent_req_set_callback(subreq, wb_open_pipe_getpriv_done, req); @@ -510,17 +509,17 @@ static void wb_open_pipe_ping_done(struct tevent_req *subreq) static void wb_open_pipe_getpriv_done(struct tevent_req *subreq) { - struct async_req *req = tevent_req_callback_data( - subreq, struct async_req); - struct wb_open_pipe_state *state = talloc_get_type_abort( - req->private_data, struct wb_open_pipe_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_open_pipe_state *state = tevent_req_data( + req, struct wb_open_pipe_state); struct winbindd_response *wb_resp = NULL; wbcErr wbc_err; wbc_err = wb_int_trans_recv(subreq, state, &wb_resp); TALLOC_FREE(subreq); if (!WBC_ERROR_IS_OK(wbc_err)) { - async_req_error(req, wbc_err); + tevent_req_error(req, wbc_err); return; } @@ -530,7 +529,7 @@ static void wb_open_pipe_getpriv_done(struct tevent_req *subreq) subreq = wb_connect_send(state, state->ev, state->wb_ctx, (char *)wb_resp->extra_data.data); TALLOC_FREE(wb_resp); - if (async_req_nomem(subreq, req)) { + if (tevent_req_nomem(subreq, req)) { return; } tevent_req_set_callback(subreq, wb_open_pipe_connect_priv_done, req); @@ -538,25 +537,25 @@ static void wb_open_pipe_getpriv_done(struct tevent_req *subreq) static void wb_open_pipe_connect_priv_done(struct tevent_req *subreq) { - struct async_req *req = tevent_req_callback_data( - subreq, struct async_req); - struct wb_open_pipe_state *state = talloc_get_type_abort( - req->private_data, struct wb_open_pipe_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_open_pipe_state *state = tevent_req_data( + req, struct wb_open_pipe_state); wbcErr wbc_err; wbc_err = wb_connect_recv(subreq); TALLOC_FREE(subreq); if (!WBC_ERROR_IS_OK(wbc_err)) { - async_req_error(req, wbc_err); + tevent_req_error(req, wbc_err); return; } state->wb_ctx->is_priv = true; - async_req_done(req); + tevent_req_done(req); } -static wbcErr wb_open_pipe_recv(struct async_req *req) +static wbcErr wb_open_pipe_recv(struct tevent_req *req) { - return async_req_simple_recv_wbcerr(req); + return tevent_req_simple_recv_wbcerr(req); } struct wb_trans_state { @@ -569,7 +568,7 @@ struct wb_trans_state { bool need_priv; }; -static void wb_trans_connect_done(struct async_req *subreq); +static void wb_trans_connect_done(struct tevent_req *subreq); static void wb_trans_done(struct tevent_req *subreq); static void wb_trans_retry_wait_done(struct async_req *subreq); @@ -582,15 +581,12 @@ static void wb_trigger_trans(struct async_req *req) if ((state->wb_ctx->fd == -1) || (state->need_priv && !state->wb_ctx->is_priv)) { - struct async_req *subreq2; - - subreq2 = wb_open_pipe_send(state, state->ev, state->wb_ctx, - state->need_priv); - if (async_req_nomem(subreq2, req)) { + subreq = wb_open_pipe_send(state, state->ev, state->wb_ctx, + state->need_priv); + if (async_req_nomem(subreq, req)) { return; } - subreq2->async.fn = wb_trans_connect_done; - subreq2->async.priv = req; + tevent_req_set_callback(subreq, wb_trans_connect_done, req); return; } @@ -682,6 +678,7 @@ static void wb_trans_retry_wait_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); + struct tevent_req *subreq2; bool ret; ret = async_wait_recv(subreq); @@ -691,19 +688,18 @@ static void wb_trans_retry_wait_done(struct async_req *subreq) return; } - subreq = wb_open_pipe_send(state, state->ev, state->wb_ctx, - state->need_priv); - if (async_req_nomem(subreq, req)) { + subreq2 = wb_open_pipe_send(state, state->ev, state->wb_ctx, + state->need_priv); + if (async_req_nomem(subreq2, req)) { return; } - subreq->async.fn = wb_trans_connect_done; - subreq->async.priv = req; + tevent_req_set_callback(subreq2, wb_trans_connect_done, req); } -static void wb_trans_connect_done(struct async_req *subreq) +static void wb_trans_connect_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); + struct async_req *req = tevent_req_callback_data( + subreq, struct async_req); struct wb_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_trans_state); struct tevent_req *subreq2; -- cgit From dea9621680062b3726ad15cbec4a9d2cf7ce824e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 8 Mar 2009 12:25:10 +0100 Subject: Don't copy the winbindd_request in wb_trans --- source3/lib/wbclient.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index d1f3190c79..80937641e6 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -259,31 +259,6 @@ static wbcErr wb_connect_recv(struct tevent_req *req) return tevent_req_simple_recv_wbcerr(req); } -static struct winbindd_request *winbindd_request_copy( - TALLOC_CTX *mem_ctx, - const struct winbindd_request *req) -{ - struct winbindd_request *result; - - result = (struct winbindd_request *)TALLOC_MEMDUP( - mem_ctx, req, sizeof(struct winbindd_request)); - if (result == NULL) { - return NULL; - } - - if (result->extra_len == 0) { - return result; - } - - result->extra_data.data = (char *)TALLOC_MEMDUP( - result, result->extra_data.data, result->extra_len); - if (result->extra_data.data == NULL) { - TALLOC_FREE(result); - return NULL; - } - return result; -} - struct wb_int_trans_state { struct tevent_context *ev; int fd; @@ -600,7 +575,7 @@ static void wb_trigger_trans(struct async_req *req) 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) + struct winbindd_request *wb_req) { struct async_req *result; struct wb_trans_state *state; @@ -611,10 +586,7 @@ struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, } state->wb_ctx = wb_ctx; state->ev = ev; - state->wb_req = winbindd_request_copy(state, wb_req); - if (state->wb_req == NULL) { - goto fail; - } + state->wb_req = wb_req; state->num_retries = 10; state->need_priv = need_priv; -- cgit From c3691b839cf6404914ed91ee421692866b44ee85 Mon Sep 17 00:00:00 2001 From: Björn Jacke Date: Sun, 8 Mar 2009 15:36:41 +0100 Subject: fix "dubious escape" warning of Studio compiler --- source3/lib/smbconf/testsuite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/smbconf/testsuite.c b/source3/lib/smbconf/testsuite.c index b31dec0438..c83eeb805d 100644 --- a/source3/lib/smbconf/testsuite.c +++ b/source3/lib/smbconf/testsuite.c @@ -214,7 +214,7 @@ static bool torture_smbconf_txt(void) printf("TEST: init\n"); werr = smbconf_init_txt(mem_ctx, &conf_ctx, filename); if (!W_ERROR_IS_OK(werr)) { - printf("FAIL: text backend\[ failed: %s\n", win_errstr(werr)); + printf("FAIL: text backend failed: %s\n", win_errstr(werr)); ret = false; goto done; } -- cgit From 1410490fe769bc79f98b4ab364685c7aed253e09 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 9 Mar 2009 12:35:21 +0100 Subject: s3:lib: interfaces.c isn't used in the configure tests anymore libreplace always provides the getifaddr() function. This fixes the build on sles8. metze --- source3/lib/interfaces.c | 74 +----------------------------------------------- 1 file changed, 1 insertion(+), 73 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/interfaces.c b/source3/lib/interfaces.c index 4567fe457b..2535418d99 100644 --- a/source3/lib/interfaces.c +++ b/source3/lib/interfaces.c @@ -18,79 +18,7 @@ along with this program. If not, see . */ - -/* working out the interfaces for a OS is an incredibly non-portable - thing. We have several possible implementations below, and autoconf - tries each of them to see what works - - Note that this file does _not_ include includes.h. That is so this code - can be called directly from the autoconf tests. That also means - this code cannot use any of the normal Samba debug stuff or defines. - This is standalone code. - -*/ - -#ifndef AUTOCONF_TEST -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_IFADDRS_H -#include -#endif - -#ifdef HAVE_SYS_TIME_H -#include -#endif - -#ifndef SIOCGIFCONF -#ifdef HAVE_SYS_SOCKIO_H -#include -#endif -#endif - -#ifdef HAVE_STDLIB_H -#include -#endif - -#ifdef HAVE_STRING_H -#include -#endif - -#ifdef HAVE_STRINGS_H -#include -#endif - -#ifdef __COMPAR_FN_T -#define QSORT_CAST (__compar_fn_t) -#endif - -#ifndef QSORT_CAST -#define QSORT_CAST (int (*)(const void *, const void *)) -#endif - -#ifdef HAVE_NET_IF_H -#include -#endif - -#define SOCKET_WRAPPER_NOT_REPLACE -#include "interfaces.h" -#include "../replace/replace.h" - -/**************************************************************************** - Utility functions. -****************************************************************************/ +#include "includes.h" /**************************************************************************** Create a struct sockaddr_storage with the netmask bits set to 1. -- cgit From 6f1f9f6d8d3d25ab6ed5467b81f1eed70e962d27 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Mar 2009 16:45:45 +1100 Subject: fixed a bug in message handling for code the change notify code The change notify code registered a separate message handler for each tree connect. This registration uses the global messaging context. The messaging code would consider a 2nd registration for the same messaging type as being an 'update' of the handler, rather than a new handler. It also would only call the first handler in the linked list for a given message type when dispatching messages. This patch changes the messaging code to allow for multiple registrations of the same message type, and allow for multiple calls to different messaging handler for one incoming message. This fixes the problem with the test_notify_tcon() test that I recently committed to the S4 smbtorture --- source3/lib/messages.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/messages.c b/source3/lib/messages.c index e4b20c7493..5e11dd4e25 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -286,7 +286,15 @@ NTSTATUS messaging_register(struct messaging_context *msg_ctx, */ for (cb = msg_ctx->callbacks; cb != NULL; cb = cb->next) { - if (cb->msg_type == msg_type) { + /* we allow a second registration of the same message + type if it has a different private pointer. This is + needed in, for example, the internal notify code, + which creates a new notify context for each tree + connect, and expects to receive messages to each of + them. */ + if (cb->msg_type == msg_type && private_data == cb->private_data) { + DEBUG(5,("Overriding messaging pointer for type %u - private_data=%p\n", + (unsigned)msg_type, private_data)); cb->fn = fn; cb->private_data = private_data; return NT_STATUS_OK; @@ -317,6 +325,8 @@ void messaging_deregister(struct messaging_context *ctx, uint32_t msg_type, next = cb->next; if ((cb->msg_type == msg_type) && (cb->private_data == private_data)) { + DEBUG(5,("Deregistering messaging pointer for type %u - private_data=%p\n", + (unsigned)msg_type, private_data)); DLIST_REMOVE(ctx->callbacks, cb); TALLOC_FREE(cb); } @@ -362,7 +372,11 @@ void messaging_dispatch_rec(struct messaging_context *msg_ctx, if (cb->msg_type == rec->msg_type) { cb->fn(msg_ctx, cb->private_data, rec->msg_type, rec->src, &rec->buf); - return; + /* we continue looking for matching messages + after finding one. This matters for + subsystems like the internal notify code + which register more than one handler for + the same message type */ } } return; -- cgit From bd0f14c1d782b6afe9455e61819caeb2d480af1e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 12 Mar 2009 09:33:58 +0100 Subject: s3:events: pass __location__ to event_loop_*() metze --- source3/lib/events.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/events.c b/source3/lib/events.c index f875e0dc0c..8c56941829 100644 --- a/source3/lib/events.c +++ b/source3/lib/events.c @@ -145,7 +145,7 @@ struct timeval *get_timed_events_timeout(struct tevent_context *ev, return to_ret; } -static int s3_event_loop_once(struct tevent_context *ev) +static int s3_event_loop_once(struct tevent_context *ev, const char *location) { struct timeval now, to; fd_set r_fds, w_fds; @@ -181,12 +181,12 @@ static int s3_event_loop_once(struct tevent_context *ev) return 0; } -static int s3_event_loop_wait(struct tevent_context *ev) +static int s3_event_loop_wait(struct tevent_context *ev, const char *location) { int ret = 0; while (ret == 0) { - ret = s3_event_loop_once(ev); + ret = s3_event_loop_once(ev, location); } return ret; -- cgit From e5136e984922570ce9992c642c340dd3e937fc4e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 12 Mar 2009 17:59:24 -0700 Subject: Remove the static "struct client_connection" mess which is part of the problem that stops libsmbclient being thread safe. Subsidiary DFS connections are now hung off a list inside the cli_state struct. Much more to do in order to get libsmbclient to thread safety, but this is a good start. Jeremy. --- source3/lib/netapi/cm.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c index 233255fed4..43ebed6c22 100644 --- a/source3/lib/netapi/cm.c +++ b/source3/lib/netapi/cm.c @@ -73,19 +73,10 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx, /******************************************************************** ********************************************************************/ -WERROR libnetapi_shutdown_cm(struct libnetapi_ctx *ctx) -{ - cli_cm_shutdown(); - - return WERR_OK; -} - -/******************************************************************** -********************************************************************/ - struct client_pipe_connection { struct client_pipe_connection *prev, *next; struct rpc_pipe_client *pipe; + struct cli_state *cli; }; static struct client_pipe_connection *pipe_connections; @@ -93,6 +84,20 @@ static struct client_pipe_connection *pipe_connections; /******************************************************************** ********************************************************************/ +WERROR libnetapi_shutdown_cm(struct libnetapi_ctx *ctx) +{ + struct client_pipe_connection *p; + + for (p = pipe_connections; p; p = p->next) { + cli_shutdown(p->cli); + } + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + static NTSTATUS pipe_cm_find(struct cli_state *cli, const struct ndr_syntax_id *interface, struct rpc_pipe_client **presult) @@ -138,6 +143,7 @@ static NTSTATUS pipe_cm_connect(TALLOC_CTX *mem_ctx, return status; } + p->cli = cli; DLIST_ADD(pipe_connections, p); *presult = p->pipe; @@ -193,5 +199,3 @@ WERROR libnetapi_open_pipe(struct libnetapi_ctx *ctx, return WERR_OK; } - - -- cgit From 5fa4cf283f3f8bcf3c3399882f2e08ef902424c5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 15 Mar 2009 11:25:20 +0100 Subject: Add queue argument to wb_resp_write --- source3/lib/wb_reqtrans.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index 6ae1d1bb9b..e1c67491c0 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -372,7 +372,8 @@ struct resp_write_state { static void wb_resp_write_done(struct tevent_req *subreq); struct tevent_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, int fd, + struct tevent_context *ev, + struct tevent_queue *queue, int fd, struct winbindd_response *wb_resp) { struct tevent_req *result, *subreq; @@ -394,7 +395,7 @@ struct tevent_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, count = 2; } - subreq = writev_send(state, ev, NULL, fd, state->iov, count); + subreq = writev_send(state, ev, queue, fd, state->iov, count); if (subreq == NULL) { goto fail; } -- cgit From cb9effdc636731c1eba1101798d30f114fc83e19 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 16 Mar 2009 18:43:57 +0100 Subject: Use tevent_wakeup_send in open_socket_out_defer --- source3/lib/util_sock.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 3604be369f..499fc732f0 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1152,7 +1152,7 @@ struct open_socket_out_defer_state { int fd; }; -static void open_socket_out_defer_waited(struct async_req *subreq); +static void open_socket_out_defer_waited(struct tevent_req *subreq); static void open_socket_out_defer_connected(struct tevent_req *subreq); struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx, @@ -1162,9 +1162,9 @@ struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx, uint16_t port, int timeout) { - struct async_req *result, *subreq; + struct async_req *result; + struct tevent_req *subreq; struct open_socket_out_defer_state *state; - NTSTATUS status; if (!async_req_setup(mem_ctx, &result, &state, struct open_socket_out_defer_state)) { @@ -1175,47 +1175,40 @@ struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx, state->port = port; state->timeout = timeout; - subreq = async_wait_send(state, ev, wait_time); + subreq = tevent_wakeup_send( + state, ev, + timeval_current_ofs(wait_time.tv_sec, wait_time.tv_usec)); if (subreq == NULL) { - status = NT_STATUS_NO_MEMORY; - goto post_status; - } - subreq->async.fn = open_socket_out_defer_waited; - subreq->async.priv = result; - return result; - - post_status: - if (!async_post_ntstatus(result, ev, status)) { goto fail; } + tevent_req_set_callback(subreq, open_socket_out_defer_waited, result); return result; fail: TALLOC_FREE(result); return NULL; } -static void open_socket_out_defer_waited(struct async_req *subreq) +static void open_socket_out_defer_waited(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); + struct async_req *req = tevent_req_callback_data( + subreq, struct async_req); struct open_socket_out_defer_state *state = talloc_get_type_abort( req->private_data, struct open_socket_out_defer_state); - struct tevent_req *subreq2; bool ret; - ret = async_wait_recv(subreq); + ret = tevent_wakeup_recv(subreq); TALLOC_FREE(subreq); if (!ret) { async_req_nterror(req, NT_STATUS_INTERNAL_ERROR); return; } - subreq2 = open_socket_out_send(state, state->ev, &state->ss, - state->port, state->timeout); - if (async_req_nomem(subreq2, req)) { + subreq = open_socket_out_send(state, state->ev, &state->ss, + state->port, state->timeout); + if (async_req_nomem(subreq, req)) { return; } - tevent_req_set_callback(subreq2, open_socket_out_defer_connected, req); + tevent_req_set_callback(subreq, open_socket_out_defer_connected, req); } static void open_socket_out_defer_connected(struct tevent_req *subreq) -- cgit From 20cee26a3dbd231672eec9133c6e84641def298d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 16 Mar 2009 19:15:26 +0100 Subject: Convert open_socket_out_defer to tevent_req --- source3/lib/util_sock.c | 58 ++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 499fc732f0..de5b232aac 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1155,19 +1155,19 @@ struct open_socket_out_defer_state { static void open_socket_out_defer_waited(struct tevent_req *subreq); static void open_socket_out_defer_connected(struct tevent_req *subreq); -struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx, - struct event_context *ev, - struct timeval wait_time, - const struct sockaddr_storage *pss, - uint16_t port, - int timeout) +struct tevent_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx, + struct event_context *ev, + struct timeval wait_time, + const struct sockaddr_storage *pss, + uint16_t port, + int timeout) { - struct async_req *result; - struct tevent_req *subreq; + struct tevent_req *req, *subreq; struct open_socket_out_defer_state *state; - if (!async_req_setup(mem_ctx, &result, &state, - struct open_socket_out_defer_state)) { + req = tevent_req_create(mem_ctx, &state, + struct open_socket_out_defer_state); + if (req == NULL) { return NULL; } state->ev = ev; @@ -1181,31 +1181,31 @@ struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx, if (subreq == NULL) { goto fail; } - tevent_req_set_callback(subreq, open_socket_out_defer_waited, result); - return result; + tevent_req_set_callback(subreq, open_socket_out_defer_waited, req); + return req; fail: - TALLOC_FREE(result); + TALLOC_FREE(req); return NULL; } static void open_socket_out_defer_waited(struct tevent_req *subreq) { - struct async_req *req = tevent_req_callback_data( - subreq, struct async_req); - struct open_socket_out_defer_state *state = talloc_get_type_abort( - req->private_data, struct open_socket_out_defer_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct open_socket_out_defer_state *state = tevent_req_data( + req, struct open_socket_out_defer_state); bool ret; ret = tevent_wakeup_recv(subreq); TALLOC_FREE(subreq); if (!ret) { - async_req_nterror(req, NT_STATUS_INTERNAL_ERROR); + tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR); return; } subreq = open_socket_out_send(state, state->ev, &state->ss, state->port, state->timeout); - if (async_req_nomem(subreq, req)) { + if (tevent_req_nomem(subreq, req)) { return; } tevent_req_set_callback(subreq, open_socket_out_defer_connected, req); @@ -1213,28 +1213,28 @@ static void open_socket_out_defer_waited(struct tevent_req *subreq) static void open_socket_out_defer_connected(struct tevent_req *subreq) { - struct async_req *req = - tevent_req_callback_data(subreq, struct async_req); - struct open_socket_out_defer_state *state = talloc_get_type_abort( - req->private_data, struct open_socket_out_defer_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct open_socket_out_defer_state *state = tevent_req_data( + req, struct open_socket_out_defer_state); NTSTATUS status; status = open_socket_out_recv(subreq, &state->fd); TALLOC_FREE(subreq); if (!NT_STATUS_IS_OK(status)) { - async_req_nterror(req, status); + tevent_req_nterror(req, status); return; } - async_req_done(req); + tevent_req_done(req); } -NTSTATUS open_socket_out_defer_recv(struct async_req *req, int *pfd) +NTSTATUS open_socket_out_defer_recv(struct tevent_req *req, int *pfd) { - struct open_socket_out_defer_state *state = talloc_get_type_abort( - req->private_data, struct open_socket_out_defer_state); + struct open_socket_out_defer_state *state = tevent_req_data( + req, struct open_socket_out_defer_state); NTSTATUS status; - if (async_req_is_nterror(req, &status)) { + if (tevent_req_is_nterror(req, &status)) { return status; } *pfd = state->fd; -- cgit From 5c848e47cc89f5b6658c2de2d742540e56db29dc Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 16 Mar 2009 20:15:23 +0100 Subject: Use tevent_wakeup_send in wb_trans --- source3/lib/wbclient.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index 80937641e6..c2042c23e0 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -545,7 +545,7 @@ struct wb_trans_state { static void wb_trans_connect_done(struct tevent_req *subreq); static void wb_trans_done(struct tevent_req *subreq); -static void wb_trans_retry_wait_done(struct async_req *subreq); +static void wb_trans_retry_wait_done(struct tevent_req *subreq); static void wb_trigger_trans(struct async_req *req) { @@ -604,7 +604,7 @@ static bool wb_trans_retry(struct async_req *req, struct wb_trans_state *state, wbcErr wbc_err) { - struct async_req *subreq; + struct tevent_req *subreq; if (WBC_ERROR_IS_OK(wbc_err)) { return false; @@ -634,38 +634,36 @@ static bool wb_trans_retry(struct async_req *req, state->wb_ctx->fd = -1; } - subreq = async_wait_send(state, state->ev, timeval_set(1, 0)); + subreq = tevent_wakeup_send(state, state->ev, + timeval_current_ofs(1, 0)); if (async_req_nomem(subreq, req)) { return true; } - - subreq->async.fn = wb_trans_retry_wait_done; - subreq->async.priv = req; + tevent_req_set_callback(subreq, wb_trans_retry_wait_done, req); return true; } -static void wb_trans_retry_wait_done(struct async_req *subreq) +static void wb_trans_retry_wait_done(struct tevent_req *subreq) { - struct async_req *req = talloc_get_type_abort( - subreq->async.priv, struct async_req); + struct async_req *req = tevent_req_callback_data( + subreq, struct async_req); struct wb_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_trans_state); - struct tevent_req *subreq2; bool ret; - ret = async_wait_recv(subreq); + ret = tevent_wakeup_recv(subreq); TALLOC_FREE(subreq); - if (ret) { + if (!ret) { async_req_error(req, WBC_ERR_UNKNOWN_FAILURE); return; } - subreq2 = wb_open_pipe_send(state, state->ev, state->wb_ctx, + subreq = wb_open_pipe_send(state, state->ev, state->wb_ctx, state->need_priv); - if (async_req_nomem(subreq2, req)) { + if (async_req_nomem(subreq, req)) { return; } - tevent_req_set_callback(subreq2, wb_trans_connect_done, req); + tevent_req_set_callback(subreq, wb_trans_connect_done, req); } static void wb_trans_connect_done(struct tevent_req *subreq) -- cgit From a58eccfee742bcecbd4a2e5662305c5077024244 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 16 Mar 2009 20:23:37 +0100 Subject: Make struct wb_context private to wbclient.c --- source3/lib/wbclient.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index c2042c23e0..b1a4449734 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -20,6 +20,12 @@ #include "includes.h" #include "wbc_async.h" +struct wb_context { + struct async_req_queue *queue; + int fd; + bool is_priv; +}; + static int make_nonstd_fd(int fd) { int i; -- cgit From 1624b58beb4b3278acf7de721392ccc7dda65013 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 16 Mar 2009 20:25:25 +0100 Subject: Remove an unnecessary variable --- source3/lib/wbclient.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index b1a4449734..4c3dd889e7 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -678,7 +678,6 @@ static void wb_trans_connect_done(struct tevent_req *subreq) subreq, struct async_req); struct wb_trans_state *state = talloc_get_type_abort( req->private_data, struct wb_trans_state); - struct tevent_req *subreq2; wbcErr wbc_err; wbc_err = wb_open_pipe_recv(subreq); @@ -688,12 +687,12 @@ static void wb_trans_connect_done(struct tevent_req *subreq) return; } - subreq2 = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, - state->wb_req); - if (async_req_nomem(subreq2, req)) { + subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, + state->wb_req); + if (async_req_nomem(subreq, req)) { return; } - tevent_req_set_callback(subreq2, wb_trans_done, req); + tevent_req_set_callback(subreq, wb_trans_done, req); } static void wb_trans_done(struct tevent_req *subreq) -- cgit From 05b49fd4c8aaf779b98eb2eabb860295dc1300b9 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 16 Mar 2009 20:38:11 +0100 Subject: Convert wb_trans to tevent_req --- source3/lib/wbclient.c | 112 ++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 63 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index 4c3dd889e7..3cf992c7de 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -21,7 +21,7 @@ #include "wbc_async.h" struct wb_context { - struct async_req_queue *queue; + struct tevent_queue *queue; int fd; bool is_priv; }; @@ -144,7 +144,7 @@ struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx) if (result == NULL) { return NULL; } - result->queue = async_req_queue_init(result); + result->queue = tevent_queue_create(result, "wb_trans"); if (result->queue == NULL) { TALLOC_FREE(result); return NULL; @@ -553,41 +553,16 @@ static void wb_trans_connect_done(struct tevent_req *subreq); static void wb_trans_done(struct tevent_req *subreq); static void wb_trans_retry_wait_done(struct tevent_req *subreq); -static void wb_trigger_trans(struct async_req *req) +struct tevent_req *wb_trans_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct wb_context *wb_ctx, bool need_priv, + struct winbindd_request *wb_req) { - struct wb_trans_state *state = talloc_get_type_abort( - req->private_data, struct wb_trans_state); - struct tevent_req *subreq; - - if ((state->wb_ctx->fd == -1) - || (state->need_priv && !state->wb_ctx->is_priv)) { - - subreq = wb_open_pipe_send(state, state->ev, state->wb_ctx, - state->need_priv); - if (async_req_nomem(subreq, req)) { - return; - } - tevent_req_set_callback(subreq, wb_trans_connect_done, req); - return; - } - - subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, - state->wb_req); - if (async_req_nomem(subreq, req)) { - return; - } - tevent_req_set_callback(subreq, wb_trans_done, req); -} - -struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, - struct wb_context *wb_ctx, bool need_priv, - struct winbindd_request *wb_req) -{ - struct async_req *result; + struct tevent_req *req, *subreq; struct wb_trans_state *state; - if (!async_req_setup(mem_ctx, &result, &state, - struct wb_trans_state)) { + req = tevent_req_create(mem_ctx, &state, struct wb_trans_state); + if (req == NULL) { return NULL; } state->wb_ctx = wb_ctx; @@ -596,17 +571,28 @@ struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, state->num_retries = 10; state->need_priv = need_priv; - if (!async_req_enqueue(wb_ctx->queue, ev, result, wb_trigger_trans)) { - goto fail; + if ((wb_ctx->fd == -1) || (need_priv && !wb_ctx->is_priv)) { + subreq = wb_open_pipe_send(state, ev, wb_ctx, need_priv); + if (subreq == NULL) { + goto fail; + } + tevent_req_set_callback(subreq, wb_trans_connect_done, req); + return req; } - return result; + subreq = wb_int_trans_send(state, ev, wb_ctx->queue, wb_ctx->fd, + wb_req); + if (subreq == NULL) { + goto fail; + } + tevent_req_set_callback(subreq, wb_trans_done, req); + return req; fail: - TALLOC_FREE(result); + TALLOC_FREE(req); return NULL; } -static bool wb_trans_retry(struct async_req *req, +static bool wb_trans_retry(struct tevent_req *req, struct wb_trans_state *state, wbcErr wbc_err) { @@ -621,13 +607,13 @@ static bool wb_trans_retry(struct async_req *req, * Winbind not around or we can't connect to the pipe. Fail * immediately. */ - async_req_error(req, wbc_err); + tevent_req_error(req, wbc_err); return true; } state->num_retries -= 1; if (state->num_retries == 0) { - async_req_error(req, wbc_err); + tevent_req_error(req, wbc_err); return true; } @@ -642,7 +628,7 @@ static bool wb_trans_retry(struct async_req *req, subreq = tevent_wakeup_send(state, state->ev, timeval_current_ofs(1, 0)); - if (async_req_nomem(subreq, req)) { + if (tevent_req_nomem(subreq, req)) { return true; } tevent_req_set_callback(subreq, wb_trans_retry_wait_done, req); @@ -651,22 +637,22 @@ static bool wb_trans_retry(struct async_req *req, static void wb_trans_retry_wait_done(struct tevent_req *subreq) { - struct async_req *req = tevent_req_callback_data( - subreq, struct async_req); - struct wb_trans_state *state = talloc_get_type_abort( - req->private_data, struct wb_trans_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_trans_state *state = tevent_req_data( + req, struct wb_trans_state); bool ret; ret = tevent_wakeup_recv(subreq); TALLOC_FREE(subreq); if (!ret) { - async_req_error(req, WBC_ERR_UNKNOWN_FAILURE); + tevent_req_error(req, WBC_ERR_UNKNOWN_FAILURE); return; } subreq = wb_open_pipe_send(state, state->ev, state->wb_ctx, - state->need_priv); - if (async_req_nomem(subreq, req)) { + state->need_priv); + if (tevent_req_nomem(subreq, req)) { return; } tevent_req_set_callback(subreq, wb_trans_connect_done, req); @@ -674,10 +660,10 @@ static void wb_trans_retry_wait_done(struct tevent_req *subreq) static void wb_trans_connect_done(struct tevent_req *subreq) { - struct async_req *req = tevent_req_callback_data( - subreq, struct async_req); - struct wb_trans_state *state = talloc_get_type_abort( - req->private_data, struct wb_trans_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_trans_state *state = tevent_req_data( + req, struct wb_trans_state); wbcErr wbc_err; wbc_err = wb_open_pipe_recv(subreq); @@ -689,7 +675,7 @@ static void wb_trans_connect_done(struct tevent_req *subreq) subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd, state->wb_req); - if (async_req_nomem(subreq, req)) { + if (tevent_req_nomem(subreq, req)) { return; } tevent_req_set_callback(subreq, wb_trans_done, req); @@ -697,10 +683,10 @@ static void wb_trans_connect_done(struct tevent_req *subreq) static void wb_trans_done(struct tevent_req *subreq) { - struct async_req *req = tevent_req_callback_data( - subreq, struct async_req); - struct wb_trans_state *state = talloc_get_type_abort( - req->private_data, struct wb_trans_state); + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct wb_trans_state *state = tevent_req_data( + req, struct wb_trans_state); wbcErr wbc_err; wbc_err = wb_int_trans_recv(subreq, state, &state->wb_resp); @@ -710,17 +696,17 @@ static void wb_trans_done(struct tevent_req *subreq) return; } - async_req_done(req); + tevent_req_done(req); } -wbcErr wb_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx, +wbcErr wb_trans_recv(struct tevent_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); + struct wb_trans_state *state = tevent_req_data( + req, struct wb_trans_state); wbcErr wbc_err; - if (async_req_is_wbcerr(req, &wbc_err)) { + if (tevent_req_is_wbcerr(req, &wbc_err)) { return wbc_err; } -- cgit From 8a2b7b3e56230c46df9ae3820578a2f3e765d32d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 16 Mar 2009 21:02:26 +0100 Subject: Remove unused async_req references from wb_reqtrans.c --- source3/lib/wb_reqtrans.c | 37 ------------------------------------- 1 file changed, 37 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index e1c67491c0..dbea8b6686 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -25,32 +25,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_WINBIND -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) { @@ -65,17 +39,6 @@ wbcErr map_wbc_err_from_errno(int error) } } -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; -} - bool tevent_req_is_wbcerr(struct tevent_req *req, wbcErr *pwbc_err) { enum tevent_req_state state; -- cgit From 382d8069adcc49e351eef63d86036ae553b119a2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 16 Mar 2009 16:38:15 -0700 Subject: Add some appropriate const. Jeremy. --- source3/lib/util.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index ec794ca74e..613cc1eae7 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -290,7 +290,7 @@ struct user_auth_info *user_auth_info_init(TALLOC_CTX *mem_ctx) return result; } -const char *get_cmdline_auth_info_username(struct user_auth_info *auth_info) +const char *get_cmdline_auth_info_username(const struct user_auth_info *auth_info) { if (!auth_info->username) { return ""; @@ -308,7 +308,7 @@ void set_cmdline_auth_info_username(struct user_auth_info *auth_info, } } -const char *get_cmdline_auth_info_password(struct user_auth_info *auth_info) +const char *get_cmdline_auth_info_password(const struct user_auth_info *auth_info) { if (!auth_info->password) { return ""; @@ -346,7 +346,7 @@ bool set_cmdline_auth_info_signing_state(struct user_auth_info *auth_info, return true; } -int get_cmdline_auth_info_signing_state(struct user_auth_info *auth_info) +int get_cmdline_auth_info_signing_state(const struct user_auth_info *auth_info) { return auth_info->signing_state; } @@ -357,7 +357,7 @@ void set_cmdline_auth_info_use_kerberos(struct user_auth_info *auth_info, auth_info->use_kerberos = b; } -bool get_cmdline_auth_info_use_kerberos(struct user_auth_info *auth_info) +bool get_cmdline_auth_info_use_kerberos(const struct user_auth_info *auth_info) { return auth_info->use_kerberos; } @@ -380,23 +380,23 @@ void set_cmdline_auth_info_use_machine_account(struct user_auth_info *auth_info) auth_info->use_machine_account = true; } -bool get_cmdline_auth_info_got_pass(struct user_auth_info *auth_info) +bool get_cmdline_auth_info_got_pass(const struct user_auth_info *auth_info) { return auth_info->got_pass; } -bool get_cmdline_auth_info_smb_encrypt(struct user_auth_info *auth_info) +bool get_cmdline_auth_info_smb_encrypt(const struct user_auth_info *auth_info) { return auth_info->smb_encrypt; } -bool get_cmdline_auth_info_use_machine_account(struct user_auth_info *auth_info) +bool get_cmdline_auth_info_use_machine_account(const struct user_auth_info *auth_info) { return auth_info->use_machine_account; } struct user_auth_info *get_cmdline_auth_info_copy(TALLOC_CTX *mem_ctx, - struct user_auth_info *src) + const struct user_auth_info *src) { struct user_auth_info *result; -- cgit From d27be1d5fa3fdcaac07b527ad14b0d10ef27c0bb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Mar 2009 14:45:42 +0100 Subject: s3:events: make use of tevent_common_loop_wait() metze --- source3/lib/events.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/events.c b/source3/lib/events.c index 8c56941829..d0374121ce 100644 --- a/source3/lib/events.c +++ b/source3/lib/events.c @@ -181,17 +181,6 @@ static int s3_event_loop_once(struct tevent_context *ev, const char *location) return 0; } -static int s3_event_loop_wait(struct tevent_context *ev, const char *location) -{ - int ret = 0; - - while (ret == 0) { - ret = s3_event_loop_once(ev, location); - } - - return ret; -} - void event_context_reinit(struct tevent_context *ev) { tevent_common_context_destructor(ev); @@ -246,7 +235,7 @@ static const struct tevent_ops s3_event_ops = { .add_timer = tevent_common_add_timer, .add_signal = tevent_common_add_signal, .loop_once = s3_event_loop_once, - .loop_wait = s3_event_loop_wait, + .loop_wait = tevent_common_loop_wait, }; static bool s3_tevent_init(void) -- cgit From 6c290586e41b3f5f7748a5b8c782be67cafe6c57 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 16 Mar 2009 15:06:52 +0100 Subject: s3:events: add support for immediate events metze --- source3/lib/events.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/events.c b/source3/lib/events.c index d0374121ce..90d86c6c79 100644 --- a/source3/lib/events.c +++ b/source3/lib/events.c @@ -91,6 +91,11 @@ bool run_events(struct tevent_context *ev, return true; } + if (ev->immediate_events && + tevent_common_loop_immediate(ev)) { + return true; + } + GetTimeOfDay(&now); if ((ev->timer_events != NULL) @@ -227,15 +232,16 @@ void dump_event_list(struct tevent_context *ev) } static const struct tevent_ops s3_event_ops = { - .context_init = s3_event_context_init, - .add_fd = tevent_common_add_fd, - .set_fd_close_fn= tevent_common_fd_set_close_fn, - .get_fd_flags = tevent_common_fd_get_flags, - .set_fd_flags = tevent_common_fd_set_flags, - .add_timer = tevent_common_add_timer, - .add_signal = tevent_common_add_signal, - .loop_once = s3_event_loop_once, - .loop_wait = tevent_common_loop_wait, + .context_init = s3_event_context_init, + .add_fd = tevent_common_add_fd, + .set_fd_close_fn = tevent_common_fd_set_close_fn, + .get_fd_flags = tevent_common_fd_get_flags, + .set_fd_flags = tevent_common_fd_set_flags, + .add_timer = tevent_common_add_timer, + .schedule_immediate = tevent_common_schedule_immediate, + .add_signal = tevent_common_add_signal, + .loop_once = s3_event_loop_once, + .loop_wait = tevent_common_loop_wait, }; static bool s3_tevent_init(void) -- cgit From 8dd1faaa2992851f6852ba7ea4498445af5faadd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 17 Mar 2009 14:53:06 -0700 Subject: Remove the global "struct cm_cred_struct" and associated calls, make callers pass in a struct user_auth_info * instead. This commit causes smbc_set_credentials() to print out a message telling callers to use smbc_set_credentials_with_fallback() instead, as smbc_set_credentials() has a broken API (no SMBCCTX * pointer). No more global variables used in the connection manager API for client dfs calls. Jeremy. --- source3/lib/netapi/cm.c | 32 ++++++++++++++++---------------- source3/lib/util.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 16 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c index 43ebed6c22..b676ae63dd 100644 --- a/source3/lib/netapi/cm.c +++ b/source3/lib/netapi/cm.c @@ -29,36 +29,36 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx, const char *server_name, struct cli_state **cli) { + struct user_auth_info *auth_info = NULL; struct cli_state *cli_ipc = NULL; if (!ctx || !cli || !server_name) { return WERR_INVALID_PARAM; } - cli_cm_set_signing_state(Undefined); - - if (ctx->use_kerberos) { - cli_cm_set_use_kerberos(); - } - - if (ctx->password) { - cli_cm_set_password(ctx->password); - } - if (ctx->username) { - cli_cm_set_username(ctx->username); + auth_info = user_auth_info_init(NULL); + if (!auth_info) { + return WERR_NOMEM; } + auth_info->signing_state = Undefined; + set_cmdline_auth_info_use_kerberos(auth_info, ctx->use_kerberos); + set_cmdline_auth_info_password(auth_info, ctx->password); + set_cmdline_auth_info_username(auth_info, ctx->username); if (ctx->username && ctx->username[0] && ctx->password && ctx->password[0] && ctx->use_kerberos) { - cli_cm_set_fallback_after_kerberos(); + set_cmdline_auth_info_fallback_after_kerberos(auth_info, true); } cli_ipc = cli_cm_open(ctx, NULL, - server_name, "IPC$", - false, false, - PROTOCOL_NT1, - 0, 0x20); + server_name, "IPC$", + auth_info, + false, false, + PROTOCOL_NT1, + 0, 0x20); + TALLOC_FREE(auth_info); + if (!cli_ipc) { libnetapi_set_error_string(ctx, "Failed to connect to IPC$ share on %s", server_name); diff --git a/source3/lib/util.c b/source3/lib/util.c index 613cc1eae7..80a807d7e4 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -320,6 +320,9 @@ void set_cmdline_auth_info_password(struct user_auth_info *auth_info, const char *password) { TALLOC_FREE(auth_info->password); + if (password == NULL) { + password = ""; + } auth_info->password = talloc_strdup(auth_info, password); if (!auth_info->password) { exit(ENOMEM); @@ -362,6 +365,17 @@ bool get_cmdline_auth_info_use_kerberos(const struct user_auth_info *auth_info) return auth_info->use_kerberos; } +void set_cmdline_auth_info_fallback_after_kerberos(struct user_auth_info *auth_info, + bool b) +{ + auth_info->fallback_after_kerberos = b; +} + +bool get_cmdline_auth_info_fallback_after_kerberos(const struct user_auth_info *auth_info) +{ + return auth_info->fallback_after_kerberos; +} + /* This should only be used by lib/popt_common.c JRA */ void set_cmdline_auth_info_use_krb5_ticket(struct user_auth_info *auth_info) { @@ -455,6 +469,32 @@ bool set_cmdline_auth_info_machine_account_creds(struct user_auth_info *auth_inf return true; } +/**************************************************************************** + Ensure we have a password if one not given. +****************************************************************************/ + +void set_cmdline_auth_info_getpass(struct user_auth_info *auth_info) +{ + char *label = NULL; + char *pass; + TALLOC_CTX *frame; + + if (get_cmdline_auth_info_got_pass(auth_info) || + get_cmdline_auth_info_use_kerberos(auth_info)) { + /* Already got one... */ + return; + } + + frame = talloc_stackframe(); + label = talloc_asprintf(frame, "Enter %s's password: ", + get_cmdline_auth_info_username(auth_info)); + pass = getpass(label); + if (pass) { + set_cmdline_auth_info_password(auth_info, pass); + } + TALLOC_FREE(frame); +} + /**************************************************************************** Add a gid to an array of gids if it's not already there. ****************************************************************************/ -- cgit From 7a85a87edf3a589235b932a3c802278e78da4ec5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 18 Mar 2009 12:22:22 +0100 Subject: s3-rpc_parse: remove unused BUFFER5 and UNISTR3. Guenther --- source3/lib/util_unistr.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index 4e78d1b064..840e8e06da 100644 --- a/source3/lib/util_unistr.c +++ b/source3/lib/util_unistr.c @@ -383,22 +383,6 @@ void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen) pull_ucs2(NULL, dest, str->buffer, maxlen, str->uni_str_len*2, STR_NOALIGN); } -#if 0 -/******************************************************************* - Convert a (little-endian) UNISTR3 structure to an ASCII string. -********************************************************************/ - -void unistr3_to_ascii(char *dest, const UNISTR3 *str, size_t maxlen) -{ - if ((str == NULL) || (str->uni_str_len == 0)) { - *dest='\0'; - return; - } - pull_ucs2(NULL, dest, str->str.buffer, maxlen, str->uni_str_len*2, - STR_NOALIGN); -} -#endif - /******************************************************************* Duplicate a UNISTR2 string into a null terminated char* using a talloc context. -- cgit From 531af136f9dd5c6050f78948837294aed02de440 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 18 Mar 2009 22:49:41 +0100 Subject: s3: remove POLICY_HND. Guenther --- source3/lib/netapi/group.c | 12 ++++++------ source3/lib/netapi/user.c | 4 ++-- source3/lib/util.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/netapi/group.c b/source3/lib/netapi/group.c index 617bde2c9a..189902a78e 100644 --- a/source3/lib/netapi/group.c +++ b/source3/lib/netapi/group.c @@ -33,7 +33,7 @@ WERROR NetGroupAdd_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - POLICY_HND connect_handle, domain_handle, group_handle; + struct policy_handle connect_handle, domain_handle, group_handle; struct lsa_String lsa_group_name; struct dom_sid2 *domain_sid = NULL; uint32_t rid = 0; @@ -223,7 +223,7 @@ WERROR NetGroupDel_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - POLICY_HND connect_handle, domain_handle, group_handle; + struct policy_handle connect_handle, domain_handle, group_handle; struct lsa_String lsa_group_name; struct dom_sid2 *domain_sid = NULL; int i = 0; @@ -384,7 +384,7 @@ WERROR NetGroupSetInfo_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - POLICY_HND connect_handle, domain_handle, group_handle; + struct policy_handle connect_handle, domain_handle, group_handle; struct lsa_String lsa_group_name; struct dom_sid2 *domain_sid = NULL; @@ -624,7 +624,7 @@ WERROR NetGroupGetInfo_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - POLICY_HND connect_handle, domain_handle, group_handle; + struct policy_handle connect_handle, domain_handle, group_handle; struct lsa_String lsa_group_name; struct dom_sid2 *domain_sid = NULL; @@ -742,7 +742,7 @@ WERROR NetGroupAddUser_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - POLICY_HND connect_handle, domain_handle, group_handle; + struct policy_handle connect_handle, domain_handle, group_handle; struct lsa_String lsa_group_name, lsa_user_name; struct dom_sid2 *domain_sid = NULL; @@ -863,7 +863,7 @@ WERROR NetGroupDelUser_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - POLICY_HND connect_handle, domain_handle, group_handle; + struct policy_handle connect_handle, domain_handle, group_handle; struct lsa_String lsa_group_name, lsa_user_name; struct dom_sid2 *domain_sid = NULL; diff --git a/source3/lib/netapi/user.c b/source3/lib/netapi/user.c index 9d7f299f59..8cc65a6e9e 100644 --- a/source3/lib/netapi/user.c +++ b/source3/lib/netapi/user.c @@ -352,7 +352,7 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - POLICY_HND connect_handle, domain_handle, user_handle; + struct policy_handle connect_handle, domain_handle, user_handle; struct lsa_String lsa_account_name; struct dom_sid2 *domain_sid = NULL; union samr_UserInfo *user_info = NULL; @@ -496,7 +496,7 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx, struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; - POLICY_HND connect_handle, builtin_handle, domain_handle, user_handle; + struct policy_handle connect_handle, builtin_handle, domain_handle, user_handle; struct lsa_String lsa_account_name; struct samr_Ids user_rids, name_types; struct dom_sid2 *domain_sid = NULL; diff --git a/source3/lib/util.c b/source3/lib/util.c index 80a807d7e4..75fd82709a 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -3142,9 +3142,9 @@ NTSTATUS split_ntfs_stream_name(TALLOC_CTX *mem_ctx, const char *fname, return NT_STATUS_OK; } -bool is_valid_policy_hnd(const POLICY_HND *hnd) +bool is_valid_policy_hnd(const struct policy_handle *hnd) { - POLICY_HND tmp; + struct policy_handle tmp; ZERO_STRUCT(tmp); return (memcmp(&tmp, hnd, sizeof(tmp)) != 0); } -- cgit From 0dfdb7b911ed4fe013fc4a22a8c3a28620277a67 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 19 Mar 2009 09:06:38 +0100 Subject: s3:lib/util_sock: use sys_recv() instead of sys_read() on sockets This ways the pcap support in socket wrapper sees the received data. metze --- source3/lib/util_sock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index de5b232aac..a0dbca1a00 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -519,7 +519,7 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf, } while (nread < mincnt) { - readret = sys_read(fd, buf + nread, maxcnt - nread); + readret = sys_recv(fd, buf + nread, maxcnt - nread, 0); if (readret == 0) { DEBUG(5,("read_socket_with_timeout: " @@ -588,7 +588,7 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf, return NT_STATUS_IO_TIMEOUT; } - readret = sys_read(fd, buf+nread, maxcnt-nread); + readret = sys_recv(fd, buf+nread, maxcnt-nread, 0); if (readret == 0) { /* we got EOF on the file descriptor */ -- cgit From f603903cb01f0c1e8bba66ab8c5229c3e7724ae3 Mon Sep 17 00:00:00 2001 From: Dan Sledz Date: Thu, 19 Mar 2009 21:53:34 +0000 Subject: s3: Fix a free of an uninitialized variable in winbind_get_sid_aliases --- source3/lib/winbind_util.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/winbind_util.c b/source3/lib/winbind_util.c index 64f5fb421a..df095b9e91 100644 --- a/source3/lib/winbind_util.c +++ b/source3/lib/winbind_util.c @@ -322,7 +322,6 @@ bool winbind_get_sid_aliases(TALLOC_CTX *mem_ctx, &rids, &num_rids); if (ret != WBC_ERR_SUCCESS) { - wbcFreeMemory(rids); return false; } -- cgit From 3a4638db0351368d3b148bf547546f28fa0b1479 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 19 Mar 2009 23:56:12 +0100 Subject: add a versiontest program to print samba_version_string(). This is to allow for testing samba_version_string() without the need to compile any of the larger binaries like smbd or net... Michael --- source3/lib/version_test.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 source3/lib/version_test.c (limited to 'source3/lib') diff --git a/source3/lib/version_test.c b/source3/lib/version_test.c new file mode 100644 index 0000000000..880cfeb084 --- /dev/null +++ b/source3/lib/version_test.c @@ -0,0 +1,26 @@ +/* + * Unix SMB/CIFS implementation. + * version_test - test program for samba_version_strion() + * Copyright (C) Michael Adam 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 . + */ + +#include "includes.h" + +int main(void) +{ + printf("%s\n", samba_version_string()); + return 0; +} -- cgit