The branch, master has been updated via 5ad0ed2 libwbclient: Remove half-finished async implementation from f768b32 libcli/security Provide a common, top level libcli/security/security.h
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 5ad0ed21814e721cc36b72bf2ed13d9b37c4b7d2 Author: Kai Blin <k...@samba.org> Date: Tue Oct 12 06:13:57 2010 +0200 libwbclient: Remove half-finished async implementation The old approach on doing async libwbclient was never really finished. Go ahead and remove this implementation. Autobuild-User: Kai Blin <k...@samba.org> Autobuild-Date: Tue Oct 12 07:05:31 UTC 2010 on sn-devel-104 ----------------------------------------------------------------------- Summary of changes: nsswitch/libwbclient/config.mk | 14 - nsswitch/libwbclient/tests/wbclient.c | 103 ---- nsswitch/libwbclient/wbc_idmap_async.c | 448 ----------------- nsswitch/libwbclient/wbc_pam_async.c | 484 ------------------ nsswitch/libwbclient/wbc_sid_async.c | 291 ----------- nsswitch/libwbclient/wbc_util_async.c | 836 -------------------------------- nsswitch/libwbclient/wscript_build | 8 - source4/torture/winbind/config.mk | 2 +- source4/torture/winbind/wscript_build | 2 +- 9 files changed, 2 insertions(+), 2186 deletions(-) delete mode 100644 nsswitch/libwbclient/wbc_idmap_async.c delete mode 100644 nsswitch/libwbclient/wbc_pam_async.c delete mode 100644 nsswitch/libwbclient/wbc_sid_async.c delete mode 100644 nsswitch/libwbclient/wbc_util_async.c Changeset truncated at 500 lines: diff --git a/nsswitch/libwbclient/config.mk b/nsswitch/libwbclient/config.mk index 1c7a4b3..2b7b0f4 100644 --- a/nsswitch/libwbclient/config.mk +++ b/nsswitch/libwbclient/config.mk @@ -8,17 +8,3 @@ LIBWBCLIENT_OBJ_FILES = $(addprefix $(libwbclientsrcdir)/, wbc_guid.o \ wbc_pwd.o \ wbc_sid.o \ wbc_util.o ) - -[SUBSYSTEM::LIBWBCLIENT_ASYNC] -PUBLIC_DEPENDENCIES = LIBASYNC_REQ \ - LIBTEVENT \ - LIBTALLOC \ - UTIL_TEVENT \ - LIBWBCLIENT - -LIBWBCLIENT_ASYNC_OBJ_FILES = $(addprefix $(libwbclientsrcdir)/, wbc_async.o \ - wbc_idmap_async.o \ - wbc_pam_async.o \ - wbc_sid_async.o \ - wbc_util_async.o \ - wb_reqtrans.o ) diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c index 948081b..200805e 100644 --- a/nsswitch/libwbclient/tests/wbclient.c +++ b/nsswitch/libwbclient/tests/wbclient.c @@ -23,7 +23,6 @@ #include "lib/util/data_blob.h" #include "lib/util/time.h" #include "nsswitch/libwbclient/wbclient.h" -#include "nsswitch/libwbclient/wbc_async.h" #include "torture/smbtorture.h" #include "torture/winbind/proto.h" #include "lib/util/util_net.h" @@ -46,17 +45,6 @@ #define torture_assert_wbc_ok(torture_ctx,expr,cmt) \ torture_assert_wbc_equal(torture_ctx,expr,WBC_ERR_SUCCESS,cmt) - -static void wbc_debug_torture(void *private_data, enum wbcDebugLevel level, - const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0); -static void wbc_debug_torture(void *private_data, enum wbcDebugLevel level, - const char *fmt, va_list ap) -{ - struct torture_context *tctx = talloc_get_type_abort(private_data, - struct torture_context); - torture_comment(tctx, "%s", talloc_vasprintf(tctx, fmt, ap)); -} - static bool test_wbc_ping(struct torture_context *tctx) { torture_assert_wbc_ok(tctx, wbcPing(), @@ -65,24 +53,6 @@ static bool test_wbc_ping(struct torture_context *tctx) return true; } -static bool test_wbc_ping_async(struct torture_context *tctx) -{ - struct wb_context *wb_ctx; - struct tevent_req *req; - - wb_ctx = wb_context_init(tctx, NULL); - - req = wbcPing_send(tctx, tctx->ev, wb_ctx); - torture_assert(tctx, req, "wbcPing_send failed"); - - if(!tevent_req_poll(req, tctx->ev)) { - return false; - } - torture_assert_wbc_ok(tctx, wbcPing_recv(req), "wbcPing_recv failed"); - return true; -} - - static bool test_wbc_pingdc(struct torture_context *tctx) { torture_assert_wbc_equal(tctx, wbcPingDc("random_string", NULL), WBC_ERR_NOT_IMPLEMENTED, @@ -253,77 +223,6 @@ static bool test_wbc_users(struct torture_context *tctx) return true; } -static bool test_wbc_users_async(struct torture_context *tctx) -{ - struct wb_context *wb_ctx; - struct tevent_req *req; - const char *domain_name = NULL; - uint32_t num_users; - const char **users; - int i; - struct wbcInterfaceDetails *details; - - wb_ctx = wb_context_init(tctx, NULL); - wbcSetDebug(wb_ctx, wbc_debug_torture, tctx); - - req = wbcInterfaceDetails_send(tctx, tctx->ev, wb_ctx); - torture_assert(tctx, req, "wbcInterfaceDetails_send failed"); - - if(!tevent_req_poll(req, tctx->ev)) { - return false; - } - torture_assert_wbc_ok(tctx, - wbcInterfaceDetails_recv(req, tctx, &details), - "wbcInterfaceDetails_recv failed"); - - domain_name = talloc_strdup(tctx, details->netbios_domain); - wbcFreeMemory(details); - - /* No async implementation of this yet. */ - torture_assert_wbc_ok(tctx, wbcListUsers(domain_name, &num_users, &users), - "wbcListUsers failed"); - torture_assert(tctx, !(num_users > 0 && !users), - "wbcListUsers returned invalid results"); - - for (i=0; i < MIN(num_users,100); i++) { - - struct wbcDomainSid sid, *sids; - enum wbcSidType name_type; - char *domain; - char *name; - uint32_t num_sids; - - req = wbcLookupName_send(tctx, tctx->ev, wb_ctx, domain_name, - users[i]); - torture_assert(tctx, req, "wbcLookupName_send failed"); - - if(!tevent_req_poll(req, tctx->ev)) { - return false; - } - - torture_assert_wbc_ok(tctx, - wbcLookupName_recv(req, &sid, &name_type), - "wbcLookupName_recv failed"); - - torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_USER, - "wbcLookupName expected WBC_SID_NAME_USER"); - torture_assert_wbc_ok(tctx, wbcLookupSid(&sid, &domain, &name, &name_type), - "wbcLookupSid failed"); - torture_assert_int_equal(tctx, name_type, WBC_SID_NAME_USER, - "wbcLookupSid expected WBC_SID_NAME_USER"); - torture_assert(tctx, name, - "wbcLookupSid returned no name"); - wbcFreeMemory(domain); - wbcFreeMemory(name); - torture_assert_wbc_ok(tctx, wbcLookupUserSids(&sid, true, &num_sids, &sids), - "wbcLookupUserSids failed"); - wbcFreeMemory(sids); - } - wbcFreeMemory(users); - - return true; -} - static bool test_wbc_groups(struct torture_context *tctx) { const char *domain_name = NULL; @@ -782,7 +681,6 @@ struct torture_suite *torture_wbclient(void) struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "WBCLIENT"); torture_suite_add_simple_test(suite, "wbcPing", test_wbc_ping); - torture_suite_add_simple_test(suite, "wbcPing_async", test_wbc_ping_async); torture_suite_add_simple_test(suite, "wbcPingDc", test_wbc_pingdc); torture_suite_add_simple_test(suite, "wbcLibraryDetails", test_wbc_library_details); torture_suite_add_simple_test(suite, "wbcInterfaceDetails", test_wbc_interface_details); @@ -791,7 +689,6 @@ struct torture_suite *torture_wbclient(void) torture_suite_add_simple_test(suite, "wbcGuidToString", test_wbc_guidtostring); torture_suite_add_simple_test(suite, "wbcDomainInfo", test_wbc_domain_info); torture_suite_add_simple_test(suite, "wbcListUsers", test_wbc_users); - torture_suite_add_simple_test(suite, "wbcListUsers_async", test_wbc_users_async); torture_suite_add_simple_test(suite, "wbcListGroups", test_wbc_groups); torture_suite_add_simple_test(suite, "wbcListTrusts", test_wbc_trusts); torture_suite_add_simple_test(suite, "wbcLookupDomainController", test_wbc_lookupdc); diff --git a/nsswitch/libwbclient/wbc_idmap_async.c b/nsswitch/libwbclient/wbc_idmap_async.c deleted file mode 100644 index dcf59cb..0000000 --- a/nsswitch/libwbclient/wbc_idmap_async.c +++ /dev/null @@ -1,448 +0,0 @@ -/* - Unix SMB/CIFS implementation. - - Winbind client API - - Copyright (C) 2009,2010 Kai Blin <k...@samba.org> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* Required Headers */ - -#include "replace.h" -#include "libwbclient.h" -#include "wbc_async.h" - -struct wbc_sid_to_uid_state { - struct winbindd_request req; - uid_t uid; -}; - -static void wbcSidToUid_done(struct tevent_req *subreq); - -/** - * @brief Convert a Windows SID to a Unix uid, allocating an uid if needed - * - * @param mem_ctx talloc context to allocate the request from - * @param ev tevent context to use for async operation - * @param wb_ctx winbind context to use - * @param *sid pointer to the domain SID to be resolved - * - * @return tevent_req on success, NULL on error - */ - -struct tevent_req *wbcSidToUid_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct wb_context *wb_ctx, - const struct wbcDomainSid *sid) -{ - struct tevent_req *req, *subreq; - struct wbc_sid_to_uid_state *state; - char *sid_string; - wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; - - req = tevent_req_create(mem_ctx, &state, struct wbc_sid_to_uid_state); - if (req == NULL) { - return NULL; - } - - ZERO_STRUCT(state->req); - - state->req.cmd = WINBINDD_SID_TO_UID; - wbc_status = wbcSidToString(sid, &sid_string); - if (!WBC_ERROR_IS_OK(wbc_status)) { - return tevent_req_post(req, ev); - } - strncpy(state->req.data.sid, sid_string, sizeof(state->req.data.sid)-1); - wbcFreeMemory(sid_string); - - subreq = wb_trans_send(state, ev, wb_ctx, false, &state->req); - if (tevent_req_nomem(subreq, req)) { - return tevent_req_post(req, ev); - } - - tevent_req_set_callback(subreq, wbcSidToUid_done, req); - return req; -} - -static void wbcSidToUid_done(struct tevent_req *subreq) -{ - struct tevent_req *req = tevent_req_callback_data( - subreq, struct tevent_req); - struct wbc_sid_to_uid_state *state = tevent_req_data( - req, struct wbc_sid_to_uid_state); - struct winbindd_response *resp; - wbcErr wbc_status; - - wbc_status = wb_trans_recv(subreq, state, &resp); - TALLOC_FREE(subreq); - if (!WBC_ERROR_IS_OK(wbc_status)) { - tevent_req_error(req, wbc_status); - return; - } - state->uid = resp->data.uid; - TALLOC_FREE(resp); - - tevent_req_done(req); -} - -/** - * @brief Receive a Unix uid mapped to a Windows SID - * - * @param req tevent_req containing the request - * @param *puid pointer to hold the resolved uid_t value - * - * @return #wbcErr - */ - -wbcErr wbcSidToUid_recv(struct tevent_req *req, uid_t *puid) -{ - struct wbc_sid_to_uid_state *state = tevent_req_data( - req, struct wbc_sid_to_uid_state); - wbcErr wbc_status; - - if (tevent_req_is_wbcerr(req, &wbc_status)) { - tevent_req_received(req); - return wbc_status; - } - - *puid = state->uid; - - tevent_req_received(req); - return WBC_ERR_SUCCESS; -} - - -struct wbc_uid_to_sid_state { - struct winbindd_request req; - struct wbcDomainSid *sid; -}; - -static void wbcUidToSid_done(struct tevent_req *subreq); - -/** - * @brief Request a Windows SID for an Unix uid, allocating an SID if needed - * - * @param mem_ctx talloc context to allocate the request from - * @param ev tevent context to use for async operation - * @param wb_ctx winbind context to use - * @param uid uid to be resolved to a SID - * - * @return tevent_req on success, NULL on error - */ - -struct tevent_req *wbcUidToSid_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct wb_context *wb_ctx, - uid_t uid) -{ - struct tevent_req *req, *subreq; - struct wbc_uid_to_sid_state *state; - - req = tevent_req_create(mem_ctx, &state, struct wbc_uid_to_sid_state); - if (req == NULL) { - return NULL; - } - - ZERO_STRUCT(state->req); - - state->req.cmd = WINBINDD_UID_TO_SID; - state->req.data.uid = uid; - - subreq = wb_trans_send(state, ev, wb_ctx, false, &state->req); - if (tevent_req_nomem(subreq, req)) { - return tevent_req_post(req, ev); - } - - tevent_req_set_callback(subreq, wbcUidToSid_done, req); - return req; -} - -static void wbcUidToSid_done(struct tevent_req *subreq) -{ - struct tevent_req *req = tevent_req_callback_data( - subreq, struct tevent_req); - struct wbc_uid_to_sid_state *state = tevent_req_data( - req, struct wbc_uid_to_sid_state); - struct winbindd_response *resp; - wbcErr wbc_status; - - wbc_status = wb_trans_recv(subreq, state, &resp); - TALLOC_FREE(subreq); - if (!WBC_ERROR_IS_OK(wbc_status)) { - tevent_req_error(req, wbc_status); - return; - } - - state->sid = talloc(state, struct wbcDomainSid); - if (state->sid == NULL) { - TALLOC_FREE(resp); - tevent_req_error(req, WBC_ERR_NO_MEMORY); - return; - } - - wbc_status = wbcStringToSid(resp->data.sid.sid, state->sid); - TALLOC_FREE(resp); - - if (!WBC_ERROR_IS_OK(wbc_status)) { - tevent_req_error(req, wbc_status); - return; - } - - tevent_req_done(req); -} - -/** - * @brief Receive a Unix uid mapped to a Windows SID - * - * @param req tevent_req containing the request - * @param *psid pointer to hold the resolved SID - * - * @return #wbcErr - */ - -wbcErr wbcUidToSid_recv(struct tevent_req *req, struct wbcDomainSid *psid) -{ - struct wbc_uid_to_sid_state *state = tevent_req_data( - req, struct wbc_uid_to_sid_state); - wbcErr wbc_status; - - if (psid == NULL) { - tevent_req_received(req); - return WBC_ERR_INVALID_PARAM; - } - - if (tevent_req_is_wbcerr(req, &wbc_status)) { - tevent_req_received(req); - return wbc_status; - } - - memcpy(psid, state->sid, sizeof(struct wbcDomainSid)); - - tevent_req_received(req); - return WBC_ERR_SUCCESS; -} - - -struct wbc_sid_to_gid_state { - struct winbindd_request req; - gid_t gid; -}; - -static void wbcSidToGid_done(struct tevent_req *subreq); - -/** - * @brief Request to convert a Windows SID to a Unix gid, - * allocating a gid if needed - * - * @param mem_ctx talloc context to allocate the request from - * @param ev tevent context to use for async operation - * @param wb_ctx winbind context to use - * @param *sid pointer to the domain SID to be resolved - * - * @return tevent_req on success, NULL on error - */ - -struct tevent_req *wbcSidToGid_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct wb_context *wb_ctx, - const struct wbcDomainSid *sid) -{ - struct tevent_req *req, *subreq; - struct wbc_sid_to_gid_state *state; - char *sid_string; - wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE; - - req = tevent_req_create(mem_ctx, &state, struct wbc_sid_to_gid_state); - if (req == NULL) { - return NULL; - } - - ZERO_STRUCT(state->req); - - state->req.cmd = WINBINDD_SID_TO_GID; - wbc_status = wbcSidToString(sid, &sid_string); - if (!WBC_ERROR_IS_OK(wbc_status)) { - return tevent_req_post(req, ev); - } - strncpy(state->req.data.sid, sid_string, sizeof(state->req.data.sid)-1); - wbcFreeMemory(sid_string); - - subreq = wb_trans_send(state, ev, wb_ctx, false, &state->req); - if (tevent_req_nomem(subreq, req)) { - return tevent_req_post(req, ev); - } - - tevent_req_set_callback(subreq, wbcSidToGid_done, req); - return req; -} - -static void wbcSidToGid_done(struct tevent_req *subreq) -{ - struct tevent_req *req = tevent_req_callback_data( - subreq, struct tevent_req); - struct wbc_sid_to_gid_state *state = tevent_req_data( - req, struct wbc_sid_to_gid_state); - struct winbindd_response *resp; - wbcErr wbc_status; - - wbc_status = wb_trans_recv(subreq, state, &resp); - TALLOC_FREE(subreq); - if (!WBC_ERROR_IS_OK(wbc_status)) { - tevent_req_error(req, wbc_status); - return; - } - state->gid = resp->data.gid; - TALLOC_FREE(resp); - - tevent_req_done(req); -} - -/** - * @brief Receive a Unix gid mapped to a Windows SID - * - * @param req tevent_req containing the request - * @param *pgid pointer to hold the resolved gid_t value - * - * @return #wbcErr - */ - -wbcErr wbcSidToGid_recv(struct tevent_req *req, gid_t *pgid) -{ -- Samba Shared Repository