diff options
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/async_req.c | 25 | ||||
-rw-r--r-- | source3/lib/async_sock.c | 20 | ||||
-rw-r--r-- | source3/lib/gencache.c | 170 | ||||
-rw-r--r-- | source3/lib/netapi/cm.c | 2 | ||||
-rw-r--r-- | source3/lib/netapi/file.c | 18 | ||||
-rw-r--r-- | source3/lib/netapi/getdc.c | 6 | ||||
-rw-r--r-- | source3/lib/netapi/group.c | 54 | ||||
-rw-r--r-- | source3/lib/netapi/joindomain.c | 34 | ||||
-rw-r--r-- | source3/lib/netapi/localgroup.c | 37 | ||||
-rw-r--r-- | source3/lib/netapi/netapi_private.h | 1 | ||||
-rw-r--r-- | source3/lib/netapi/serverinfo.c | 6 | ||||
-rw-r--r-- | source3/lib/netapi/share.c | 30 | ||||
-rw-r--r-- | source3/lib/netapi/user.c | 70 | ||||
-rw-r--r-- | source3/lib/util_sock.c | 20 | ||||
-rw-r--r-- | source3/lib/util_tdb.c | 68 | ||||
-rw-r--r-- | source3/lib/wb_reqtrans.c | 44 | ||||
-rw-r--r-- | source3/lib/wbclient.c | 29 |
17 files changed, 143 insertions, 491 deletions
diff --git a/source3/lib/async_req.c b/source3/lib/async_req.c index 13b64ba79a..011948a158 100644 --- a/source3/lib/async_req.c +++ b/source3/lib/async_req.c @@ -313,3 +313,28 @@ bool async_req_enqueue(struct async_req_queue *queue, struct event_context *ev, return true; } + +bool _async_req_setup(TALLOC_CTX *mem_ctx, struct async_req **preq, + void *pstate, size_t state_size, const char *typename) +{ + struct async_req *req; + void **ppstate = (void **)pstate; + void *state; + + req = async_req_new(mem_ctx); + if (req == NULL) { + return false; + } + state = talloc_size(req, state_size); + if (state == NULL) { + TALLOC_FREE(req); + return false; + } + talloc_set_name(state, typename); + req->private_data = state; + + *preq = req; + *ppstate = state; + + return true; +} diff --git a/source3/lib/async_sock.c b/source3/lib/async_sock.c index bb89a1353a..73ff6f2870 100644 --- a/source3/lib/async_sock.c +++ b/source3/lib/async_sock.c @@ -106,17 +106,10 @@ static struct async_req *async_syscall_new(TALLOC_CTX *mem_ctx, struct async_req *result; struct async_syscall_state *state; - result = async_req_new(mem_ctx); - if (result == NULL) { - return NULL; - } - - state = talloc(result, struct async_syscall_state); - if (state == NULL) { - TALLOC_FREE(result); + if (!async_req_setup(mem_ctx, &result, &state, + struct async_syscall_state)) { return NULL; } - state->syscall_type = type; result->private_data = state; @@ -569,15 +562,10 @@ struct async_req *async_connect_send(TALLOC_CTX *mem_ctx, struct fd_event *fde; NTSTATUS status; - result = async_req_new(mem_ctx); - if (result == NULL) { + if (!async_req_setup(mem_ctx, &result, &state, + struct async_connect_state)) { return NULL; } - state = talloc(result, struct async_connect_state); - if (state == NULL) { - goto fail; - } - result->private_data = state; /** * We have to set the socket to nonblocking for async connect(2). Keep diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index b773f83c58..7f133f20b0 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -5,17 +5,17 @@ by various parts of the Samba code Copyright (C) Rafal Szczesniak 2002 - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ @@ -52,7 +52,7 @@ static TDB_CONTEXT *cache; bool gencache_init(void) { char* cache_fname = NULL; - + /* skip file open if it's already opened */ if (cache) return True; @@ -84,7 +84,7 @@ bool gencache_init(void) * @return true on successful closing the cache or * false on failure during cache shutdown **/ - + bool gencache_shutdown(void) { int ret; @@ -108,18 +108,18 @@ bool gencache_shutdown(void) * @retval true when entry is successfuly stored * @retval false on failure **/ - + bool gencache_set(const char *keystr, const char *value, time_t timeout) { int ret; TDB_DATA databuf; char* valstr = NULL; - + /* fail completely if get null pointers passed */ SMB_ASSERT(keystr && value); if (!gencache_init()) return False; - + if (asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value) == -1) { return False; } @@ -132,7 +132,7 @@ bool gencache_set(const char *keystr, const char *value, time_t timeout) ret = tdb_store_bystring(cache, keystr, databuf, 0); SAFE_FREE(valstr); - + return ret == 0; } @@ -148,15 +148,15 @@ bool gencache_set(const char *keystr, const char *value, time_t timeout) bool gencache_del(const char *keystr) { int ret; - + /* fail completely if get null pointers passed */ SMB_ASSERT(keystr); if (!gencache_init()) return False; - + DEBUG(10, ("Deleting cache entry (key = %s)\n", keystr)); ret = tdb_delete_bystring(cache, keystr); - + return ret == 0; } @@ -224,7 +224,7 @@ bool gencache_get(const char *keystr, char **valstr, time_t *timeout) return False; } } - + SAFE_FREE(databuf.dptr); if (timeout) { @@ -396,15 +396,74 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, time_t ti * **/ +struct gencache_iterate_state { + void (*fn)(const char *key, const char *value, time_t timeout, + void *priv); + const char *pattern; + void *priv; +}; + +static int gencache_iterate_fn(struct tdb_context *tdb, TDB_DATA key, + TDB_DATA value, void *priv) +{ + struct gencache_iterate_state *state = + (struct gencache_iterate_state *)priv; + char *keystr; + char *free_key = NULL; + char *valstr; + char *free_val = NULL; + unsigned long u; + time_t timeout; + char *timeout_endp; + + if (key.dptr[key.dsize-1] == '\0') { + keystr = (char *)key.dptr; + } else { + /* ensure 0-termination */ + keystr = SMB_STRNDUP((char *)key.dptr, key.dsize); + free_key = keystr; + } + + if ((value.dptr == NULL) || (value.dsize <= TIMEOUT_LEN)) { + goto done; + } + + if (fnmatch(state->pattern, keystr, 0) != 0) { + goto done; + } + + if (value.dptr[value.dsize-1] == '\0') { + valstr = (char *)value.dptr; + } else { + /* ensure 0-termination */ + valstr = SMB_STRNDUP((char *)value.dptr, value.dsize); + free_val = valstr; + } + + u = strtoul(valstr, &timeout_endp, 10); + + if ((*timeout_endp != '/') || ((timeout_endp-valstr) != TIMEOUT_LEN)) { + goto done; + } + + timeout = u; + timeout_endp += 1; + + DEBUG(10, ("Calling function with arguments " + "(key = %s, value = %s, timeout = %s)\n", + keystr, timeout_endp, ctime(&timeout))); + state->fn(keystr, timeout_endp, timeout, state->priv); + + done: + SAFE_FREE(free_key); + SAFE_FREE(free_val); + return 0; +} + void gencache_iterate(void (*fn)(const char* key, const char *value, time_t timeout, void* dptr), void* data, const char* keystr_pattern) { - TDB_LIST_NODE *node, *first_node; - TDB_DATA databuf; - char *keystr = NULL, *valstr = NULL, *entry = NULL; - time_t timeout = 0; - int status; - unsigned u; + struct gencache_iterate_state state; /* fail completely if get null pointers passed */ SMB_ASSERT(fn && keystr_pattern); @@ -412,72 +471,11 @@ void gencache_iterate(void (*fn)(const char* key, const char *value, time_t time if (!gencache_init()) return; DEBUG(5, ("Searching cache keys with pattern %s\n", keystr_pattern)); - node = tdb_search_keys(cache, keystr_pattern); - first_node = node; - - while (node) { - char *fmt; - - /* ensure null termination of the key string */ - keystr = SMB_STRNDUP((const char *)node->node_key.dptr, node->node_key.dsize); - if (!keystr) { - break; - } - - /* - * We don't use gencache_get function, because we need to iterate through - * all of the entries. Validity verification is up to fn routine. - */ - databuf = tdb_fetch(cache, node->node_key); - if (!databuf.dptr || databuf.dsize <= TIMEOUT_LEN) { - SAFE_FREE(databuf.dptr); - SAFE_FREE(keystr); - node = node->next; - continue; - } - entry = SMB_STRNDUP((const char *)databuf.dptr, databuf.dsize); - if (!entry) { - SAFE_FREE(databuf.dptr); - SAFE_FREE(keystr); - break; - } - - SAFE_FREE(databuf.dptr); - valstr = (char *)SMB_MALLOC(databuf.dsize + 1 - TIMEOUT_LEN); - if (!valstr) { - SAFE_FREE(entry); - SAFE_FREE(keystr); - break; - } - - if (asprintf(&fmt, READ_CACHE_DATA_FMT_TEMPLATE, - (unsigned int)databuf.dsize - TIMEOUT_LEN) - == -1) { - SAFE_FREE(valstr); - SAFE_FREE(entry); - SAFE_FREE(keystr); - break; - } - status = sscanf(entry, fmt, &u, valstr); - SAFE_FREE(fmt); - - if ( status != 2 ) { - DEBUG(0,("gencache_iterate: invalid return from sscanf %d\n",status)); - } - timeout = u; - - DEBUG(10, ("Calling function with arguments (key = %s, value = %s, timeout = %s)\n", - keystr, valstr, ctime(&timeout))); - fn(keystr, valstr, timeout, data); - - SAFE_FREE(valstr); - SAFE_FREE(entry); - SAFE_FREE(keystr); - node = node->next; - } - - tdb_search_list_free(first_node); + state.fn = fn; + state.pattern = keystr_pattern; + state.priv = data; + tdb_traverse(cache, gencache_iterate_fn, &state); } /******************************************************************** @@ -488,7 +486,7 @@ int gencache_lock_entry( const char *key ) { if (!gencache_init()) return -1; - + return tdb_lock_bystring(cache, key); } @@ -500,7 +498,7 @@ void gencache_unlock_entry( const char *key ) { if (!gencache_init()) return; - + tdb_unlock_bystring(cache, key); return; } diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c index 0e059edb29..e616a2509f 100644 --- a/source3/lib/netapi/cm.c +++ b/source3/lib/netapi/cm.c @@ -165,7 +165,6 @@ static NTSTATUS pipe_cm_open(TALLOC_CTX *ctx, WERROR libnetapi_open_pipe(struct libnetapi_ctx *ctx, const char *server_name, const struct ndr_syntax_id *interface, - struct cli_state **pcli, struct rpc_pipe_client **presult) { struct rpc_pipe_client *result = NULL; @@ -192,7 +191,6 @@ WERROR libnetapi_open_pipe(struct libnetapi_ctx *ctx, } *presult = result; - *pcli = cli; return WERR_OK; } diff --git a/source3/lib/netapi/file.c b/source3/lib/netapi/file.c index 0d66be0eb1..0d1bc08ad3 100644 --- a/source3/lib/netapi/file.c +++ b/source3/lib/netapi/file.c @@ -32,12 +32,10 @@ WERROR NetFileClose_r(struct libnetapi_ctx *ctx, { WERROR werr; NTSTATUS status; - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -53,10 +51,6 @@ WERROR NetFileClose_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - return werr; } @@ -118,7 +112,6 @@ WERROR NetFileGetInfo_r(struct libnetapi_ctx *ctx, { WERROR werr; NTSTATUS status; - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; union srvsvc_NetFileInfo info; uint32_t num_entries = 0; @@ -137,7 +130,6 @@ WERROR NetFileGetInfo_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -163,10 +155,6 @@ WERROR NetFileGetInfo_r(struct libnetapi_ctx *ctx, goto done; } done: - if (!cli) { - return werr; - } - return werr; } @@ -187,7 +175,6 @@ WERROR NetFileEnum_r(struct libnetapi_ctx *ctx, { WERROR werr; NTSTATUS status; - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct srvsvc_NetFileInfoCtr info_ctr; struct srvsvc_NetFileCtr2 ctr2; @@ -209,7 +196,6 @@ WERROR NetFileEnum_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -273,10 +259,6 @@ WERROR NetFileEnum_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - return werr; } diff --git a/source3/lib/netapi/getdc.c b/source3/lib/netapi/getdc.c index 76c0d0be2a..d3f58f6684 100644 --- a/source3/lib/netapi/getdc.c +++ b/source3/lib/netapi/getdc.c @@ -40,14 +40,12 @@ WERROR NetGetDCName_l(struct libnetapi_ctx *ctx, WERROR NetGetDCName_r(struct libnetapi_ctx *ctx, struct NetGetDCName *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_netlogon.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -82,14 +80,12 @@ WERROR NetGetAnyDCName_l(struct libnetapi_ctx *ctx, WERROR NetGetAnyDCName_r(struct libnetapi_ctx *ctx, struct NetGetAnyDCName *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_netlogon.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -141,12 +137,10 @@ WERROR DsGetDcName_r(struct libnetapi_ctx *ctx, { WERROR werr; NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND; - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_netlogon.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; diff --git a/source3/lib/netapi/group.c b/source3/lib/netapi/group.c index 95c012a7f6..617bde2c9a 100644 --- a/source3/lib/netapi/group.c +++ b/source3/lib/netapi/group.c @@ -30,7 +30,6 @@ WERROR NetGroupAdd_r(struct libnetapi_ctx *ctx, struct NetGroupAdd *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -73,7 +72,6 @@ WERROR NetGroupAdd_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -195,10 +193,6 @@ WERROR NetGroupAdd_r(struct libnetapi_ctx *ctx, &group_handle); done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } @@ -226,7 +220,6 @@ WERROR NetGroupAdd_l(struct libnetapi_ctx *ctx, WERROR NetGroupDel_r(struct libnetapi_ctx *ctx, struct NetGroupDel *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -250,7 +243,6 @@ WERROR NetGroupDel_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -362,10 +354,6 @@ WERROR NetGroupDel_r(struct libnetapi_ctx *ctx, werr = WERR_OK; done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } @@ -393,7 +381,6 @@ WERROR NetGroupDel_l(struct libnetapi_ctx *ctx, WERROR NetGroupSetInfo_r(struct libnetapi_ctx *ctx, struct NetGroupSetInfo *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -421,7 +408,6 @@ WERROR NetGroupSetInfo_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -547,10 +533,6 @@ WERROR NetGroupSetInfo_r(struct libnetapi_ctx *ctx, werr = WERR_OK; done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } @@ -639,7 +621,6 @@ static WERROR map_group_info_to_buffer(TALLOC_CTX *mem_ctx, WERROR NetGroupGetInfo_r(struct libnetapi_ctx *ctx, struct NetGroupGetInfo *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -662,7 +643,6 @@ WERROR NetGroupGetInfo_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -732,10 +712,6 @@ WERROR NetGroupGetInfo_r(struct libnetapi_ctx *ctx, goto done; } done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } @@ -763,7 +739,6 @@ WERROR NetGroupGetInfo_l(struct libnetapi_ctx *ctx, WERROR NetGroupAddUser_r(struct libnetapi_ctx *ctx, struct NetGroupAddUser *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -784,7 +759,6 @@ WERROR NetGroupAddUser_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -859,10 +833,6 @@ WERROR NetGroupAddUser_r(struct libnetapi_ctx *ctx, werr = WERR_OK; done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } @@ -890,7 +860,6 @@ WERROR NetGroupAddUser_l(struct libnetapi_ctx *ctx, WERROR NetGroupDelUser_r(struct libnetapi_ctx *ctx, struct NetGroupDelUser *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -911,7 +880,6 @@ WERROR NetGroupDelUser_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -985,10 +953,6 @@ WERROR NetGroupDelUser_r(struct libnetapi_ctx *ctx, werr = WERR_OK; done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } @@ -1166,7 +1130,6 @@ static WERROR convert_samr_disp_groups_to_GROUP_INFO_buffer(TALLOC_CTX *mem_ctx, WERROR NetGroupEnum_r(struct libnetapi_ctx *ctx, struct NetGroupEnum *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct policy_handle connect_handle; struct dom_sid2 *domain_sid = NULL; @@ -1195,7 +1158,6 @@ WERROR NetGroupEnum_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -1260,10 +1222,6 @@ WERROR NetGroupEnum_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - /* if last query */ if (NT_STATUS_IS_OK(status) || NT_STATUS_IS_ERR(status)) { @@ -1294,7 +1252,6 @@ WERROR NetGroupGetUsers_r(struct libnetapi_ctx *ctx, { /* FIXME: this call needs to cope with large replies */ - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct policy_handle connect_handle, domain_handle, group_handle; struct lsa_String lsa_account_name; @@ -1331,7 +1288,6 @@ WERROR NetGroupGetUsers_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -1419,10 +1375,6 @@ WERROR NetGroupGetUsers_r(struct libnetapi_ctx *ctx, werr = WERR_OK; done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } @@ -1450,7 +1402,6 @@ WERROR NetGroupGetUsers_l(struct libnetapi_ctx *ctx, WERROR NetGroupSetUsers_r(struct libnetapi_ctx *ctx, struct NetGroupSetUsers *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct policy_handle connect_handle, domain_handle, group_handle; struct lsa_String lsa_account_name; @@ -1494,7 +1445,6 @@ WERROR NetGroupSetUsers_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -1665,10 +1615,6 @@ WERROR NetGroupSetUsers_r(struct libnetapi_ctx *ctx, werr = WERR_OK; done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index d15e2e733c..9eedc5de03 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -98,7 +98,6 @@ WERROR NetJoinDomain_l(struct libnetapi_ctx *mem_ctx, WERROR NetJoinDomain_r(struct libnetapi_ctx *ctx, struct NetJoinDomain *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct wkssvc_PasswordBuffer *encrypted_password = NULL; NTSTATUS status; @@ -107,7 +106,6 @@ WERROR NetJoinDomain_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server, &ndr_table_wkssvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -116,11 +114,11 @@ WERROR NetJoinDomain_r(struct libnetapi_ctx *ctx, if (r->in.password) { encode_wkssvc_join_password_buffer(ctx, r->in.password, - &cli->user_session_key, + &pipe_cli->auth->user_session_key, &encrypted_password); } - old_timeout = cli_set_timeout(cli, 600000); + old_timeout = rpccli_set_timeout(pipe_cli, 600000); status = rpccli_wkssvc_NetrJoinDomain2(pipe_cli, ctx, r->in.server, @@ -136,10 +134,8 @@ WERROR NetJoinDomain_r(struct libnetapi_ctx *ctx, } done: - if (cli) { - if (old_timeout) { - cli_set_timeout(cli, old_timeout); - } + if (pipe_cli && old_timeout) { + rpccli_set_timeout(pipe_cli, old_timeout); } return werr; @@ -227,7 +223,6 @@ WERROR NetUnjoinDomain_l(struct libnetapi_ctx *mem_ctx, WERROR NetUnjoinDomain_r(struct libnetapi_ctx *ctx, struct NetUnjoinDomain *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct wkssvc_PasswordBuffer *encrypted_password = NULL; NTSTATUS status; @@ -236,7 +231,6 @@ WERROR NetUnjoinDomain_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_wkssvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -245,11 +239,11 @@ WERROR NetUnjoinDomain_r(struct libnetapi_ctx *ctx, if (r->in.password) { encode_wkssvc_join_password_buffer(ctx, r->in.password, - &cli->user_session_key, + &pipe_cli->auth->user_session_key, &encrypted_password); } - old_timeout = cli_set_timeout(cli, 60000); + old_timeout = rpccli_set_timeout(pipe_cli, 60000); status = rpccli_wkssvc_NetrUnjoinDomain2(pipe_cli, ctx, r->in.server_name, @@ -263,10 +257,8 @@ WERROR NetUnjoinDomain_r(struct libnetapi_ctx *ctx, } done: - if (cli) { - if (old_timeout) { - cli_set_timeout(cli, old_timeout); - } + if (pipe_cli && old_timeout) { + rpccli_set_timeout(pipe_cli, old_timeout); } return werr; @@ -278,7 +270,6 @@ WERROR NetUnjoinDomain_r(struct libnetapi_ctx *ctx, WERROR NetGetJoinInformation_r(struct libnetapi_ctx *ctx, struct NetGetJoinInformation *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -286,7 +277,6 @@ WERROR NetGetJoinInformation_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_wkssvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -410,7 +400,6 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx, WERROR NetGetJoinableOUs_r(struct libnetapi_ctx *ctx, struct NetGetJoinableOUs *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct wkssvc_PasswordBuffer *encrypted_password = NULL; NTSTATUS status; @@ -418,7 +407,6 @@ WERROR NetGetJoinableOUs_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_wkssvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -427,7 +415,7 @@ WERROR NetGetJoinableOUs_r(struct libnetapi_ctx *ctx, if (r->in.password) { encode_wkssvc_join_password_buffer(ctx, r->in.password, - &cli->user_session_key, + &pipe_cli->auth->user_session_key, &encrypted_password); } @@ -454,7 +442,6 @@ WERROR NetGetJoinableOUs_r(struct libnetapi_ctx *ctx, WERROR NetRenameMachineInDomain_r(struct libnetapi_ctx *ctx, struct NetRenameMachineInDomain *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct wkssvc_PasswordBuffer *encrypted_password = NULL; NTSTATUS status; @@ -462,7 +449,6 @@ WERROR NetRenameMachineInDomain_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_wkssvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -471,7 +457,7 @@ WERROR NetRenameMachineInDomain_r(struct libnetapi_ctx *ctx, if (r->in.password) { encode_wkssvc_join_password_buffer(ctx, r->in.password, - &cli->user_session_key, + &pipe_cli->auth->user_session_key, &encrypted_password); } diff --git a/source3/lib/netapi/localgroup.c b/source3/lib/netapi/localgroup.c index 5e738e1262..13405b553e 100644 --- a/source3/lib/netapi/localgroup.c +++ b/source3/lib/netapi/localgroup.c @@ -113,7 +113,6 @@ static NTSTATUS libnetapi_samr_open_alias_queryinfo(TALLOC_CTX *mem_ctx, WERROR NetLocalGroupAdd_r(struct libnetapi_ctx *ctx, struct NetLocalGroupAdd *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -152,7 +151,6 @@ WERROR NetLocalGroupAdd_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -227,10 +225,6 @@ WERROR NetLocalGroupAdd_r(struct libnetapi_ctx *ctx, werr = WERR_OK; done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&alias_handle)) { rpccli_samr_Close(pipe_cli, ctx, &alias_handle); } @@ -260,7 +254,6 @@ WERROR NetLocalGroupAdd_l(struct libnetapi_ctx *ctx, WERROR NetLocalGroupDel_r(struct libnetapi_ctx *ctx, struct NetLocalGroupDel *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -278,7 +271,6 @@ WERROR NetLocalGroupDel_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -349,10 +341,6 @@ WERROR NetLocalGroupDel_r(struct libnetapi_ctx *ctx, werr = WERR_OK; done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&alias_handle)) { rpccli_samr_Close(pipe_cli, ctx, &alias_handle); } @@ -427,7 +415,6 @@ static WERROR map_alias_info_to_buffer(TALLOC_CTX *mem_ctx, WERROR NetLocalGroupGetInfo_r(struct libnetapi_ctx *ctx, struct NetLocalGroupGetInfo *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -456,7 +443,6 @@ WERROR NetLocalGroupGetInfo_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -530,10 +516,6 @@ WERROR NetLocalGroupGetInfo_r(struct libnetapi_ctx *ctx, r->out.buffer); done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&alias_handle)) { rpccli_samr_Close(pipe_cli, ctx, &alias_handle); } @@ -603,7 +585,6 @@ static WERROR map_buffer_to_alias_info(TALLOC_CTX *mem_ctx, WERROR NetLocalGroupSetInfo_r(struct libnetapi_ctx *ctx, struct NetLocalGroupSetInfo *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -633,7 +614,6 @@ WERROR NetLocalGroupSetInfo_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -710,10 +690,6 @@ WERROR NetLocalGroupSetInfo_r(struct libnetapi_ctx *ctx, werr = WERR_OK; done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&alias_handle)) { rpccli_samr_Close(pipe_cli, ctx, &alias_handle); } @@ -742,7 +718,6 @@ WERROR NetLocalGroupSetInfo_l(struct libnetapi_ctx *ctx, WERROR NetLocalGroupEnum_r(struct libnetapi_ctx *ctx, struct NetLocalGroupEnum *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -781,7 +756,6 @@ WERROR NetLocalGroupEnum_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -911,10 +885,6 @@ WERROR NetLocalGroupEnum_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - if (ctx->disable_policy_handle_cache) { libnetapi_samr_close_domain_handle(ctx, &domain_handle); libnetapi_samr_close_builtin_handle(ctx, &builtin_handle); @@ -997,7 +967,6 @@ static WERROR NetLocalGroupModifyMembers_r(struct libnetapi_ctx *ctx, { struct NetLocalGroupAddMembers *r = NULL; - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct rpc_pipe_client *lsa_pipe = NULL; NTSTATUS status; @@ -1074,7 +1043,6 @@ static WERROR NetLocalGroupModifyMembers_r(struct libnetapi_ctx *ctx, if (r->in.level == 3) { werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_lsarpc.syntax_id, - &cli, &lsa_pipe); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -1094,7 +1062,6 @@ static WERROR NetLocalGroupModifyMembers_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -1267,10 +1234,6 @@ static WERROR NetLocalGroupModifyMembers_r(struct libnetapi_ctx *ctx, werr = WERR_OK; done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&alias_handle)) { rpccli_samr_Close(pipe_cli, ctx, &alias_handle); } diff --git a/source3/lib/netapi/netapi_private.h b/source3/lib/netapi/netapi_private.h index e6a2eb8e99..effe2eb9a0 100644 --- a/source3/lib/netapi/netapi_private.h +++ b/source3/lib/netapi/netapi_private.h @@ -54,7 +54,6 @@ WERROR libnetapi_shutdown_cm(struct libnetapi_ctx *ctx); WERROR libnetapi_open_pipe(struct libnetapi_ctx *ctx, const char *server_name, const struct ndr_syntax_id *interface, - struct cli_state **pcli, struct rpc_pipe_client **presult); WERROR libnetapi_samr_open_domain(struct libnetapi_ctx *mem_ctx, struct rpc_pipe_client *pipe_cli, diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c index b2a134b0af..d77145eef3 100644 --- a/source3/lib/netapi/serverinfo.c +++ b/source3/lib/netapi/serverinfo.c @@ -161,7 +161,6 @@ static NTSTATUS map_server_info_to_SERVER_INFO_buffer(TALLOC_CTX *mem_ctx, WERROR NetServerGetInfo_r(struct libnetapi_ctx *ctx, struct NetServerGetInfo *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -183,7 +182,6 @@ WERROR NetServerGetInfo_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -274,7 +272,6 @@ WERROR NetServerSetInfo_l(struct libnetapi_ctx *ctx, WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx, struct NetServerSetInfo *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -282,7 +279,6 @@ WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -318,7 +314,6 @@ WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx, WERROR NetRemoteTOD_r(struct libnetapi_ctx *ctx, struct NetRemoteTOD *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -326,7 +321,6 @@ WERROR NetRemoteTOD_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; diff --git a/source3/lib/netapi/share.c b/source3/lib/netapi/share.c index e6aed36064..84c275248d 100644 --- a/source3/lib/netapi/share.c +++ b/source3/lib/netapi/share.c @@ -181,7 +181,6 @@ WERROR NetShareAdd_r(struct libnetapi_ctx *ctx, { WERROR werr; NTSTATUS status; - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; union srvsvc_NetShareInfo info; @@ -201,7 +200,6 @@ WERROR NetShareAdd_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -227,10 +225,6 @@ WERROR NetShareAdd_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - return werr; } @@ -251,7 +245,6 @@ WERROR NetShareDel_r(struct libnetapi_ctx *ctx, { WERROR werr; NTSTATUS status; - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; if (!r->in.net_name) { @@ -260,7 +253,6 @@ WERROR NetShareDel_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -277,10 +269,6 @@ WERROR NetShareDel_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - return werr; } @@ -301,7 +289,6 @@ WERROR NetShareEnum_r(struct libnetapi_ctx *ctx, { WERROR werr; NTSTATUS status; - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct srvsvc_NetShareInfoCtr info_ctr; struct srvsvc_NetShareCtr0 ctr0; @@ -329,7 +316,6 @@ WERROR NetShareEnum_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -387,10 +373,6 @@ WERROR NetShareEnum_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - return werr; } @@ -411,7 +393,6 @@ WERROR NetShareGetInfo_r(struct libnetapi_ctx *ctx, { WERROR werr; NTSTATUS status; - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; union srvsvc_NetShareInfo info; uint32_t num_entries = 0; @@ -436,7 +417,6 @@ WERROR NetShareGetInfo_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -463,10 +443,6 @@ WERROR NetShareGetInfo_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - return werr; } @@ -487,7 +463,6 @@ WERROR NetShareSetInfo_r(struct libnetapi_ctx *ctx, { WERROR werr; NTSTATUS status; - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; union srvsvc_NetShareInfo info; @@ -512,7 +487,6 @@ WERROR NetShareSetInfo_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_srvsvc.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -539,10 +513,6 @@ WERROR NetShareSetInfo_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - return werr; } diff --git a/source3/lib/netapi/user.c b/source3/lib/netapi/user.c index 770ffe3263..9d7f299f59 100644 --- a/source3/lib/netapi/user.c +++ b/source3/lib/netapi/user.c @@ -349,7 +349,6 @@ static NTSTATUS set_user_info_USER_INFO_X(TALLOC_CTX *ctx, WERROR NetUserAdd_r(struct libnetapi_ctx *ctx, struct NetUserAdd *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -383,7 +382,6 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -452,7 +450,7 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx, uX.usriX_flags |= ACB_NORMAL; status = set_user_info_USER_INFO_X(ctx, pipe_cli, - &cli->user_session_key, + &pipe_cli->auth->user_session_key, &user_handle, &uX); if (!NT_STATUS_IS_OK(status)) { @@ -468,10 +466,6 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx, &user_handle); done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&user_handle)) { rpccli_samr_Close(pipe_cli, ctx, &user_handle); } @@ -499,7 +493,6 @@ WERROR NetUserAdd_l(struct libnetapi_ctx *ctx, WERROR NetUserDel_r(struct libnetapi_ctx *ctx, struct NetUserDel *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -516,7 +509,6 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { @@ -587,10 +579,6 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx, werr = WERR_OK; done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&user_handle)) { rpccli_samr_Close(pipe_cli, ctx, &user_handle); } @@ -1188,7 +1176,6 @@ static NTSTATUS libnetapi_samr_lookup_user_map_USER_INFO(TALLOC_CTX *mem_ctx, WERROR NetUserEnum_r(struct libnetapi_ctx *ctx, struct NetUserEnum *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct policy_handle connect_handle; struct dom_sid2 *domain_sid = NULL; @@ -1229,7 +1216,6 @@ WERROR NetUserEnum_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -1310,10 +1296,6 @@ WERROR NetUserEnum_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - /* if last query */ if (NT_STATUS_IS_OK(status) || NT_STATUS_IS_ERR(status)) { @@ -1504,7 +1486,6 @@ static WERROR convert_samr_dispinfo_to_NET_DISPLAY(TALLOC_CTX *mem_ctx, WERROR NetQueryDisplayInformation_r(struct libnetapi_ctx *ctx, struct NetQueryDisplayInformation *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct policy_handle connect_handle; struct dom_sid2 *domain_sid = NULL; @@ -1531,7 +1512,6 @@ WERROR NetQueryDisplayInformation_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -1570,10 +1550,6 @@ WERROR NetQueryDisplayInformation_r(struct libnetapi_ctx *ctx, r->out.entries_read, r->out.buffer); done: - if (!cli) { - return werr; - } - /* if last query */ if (NT_STATUS_IS_OK(status) || NT_STATUS_IS_ERR(status)) { @@ -1622,7 +1598,6 @@ WERROR NetUserChangePassword_l(struct libnetapi_ctx *ctx, WERROR NetUserGetInfo_r(struct libnetapi_ctx *ctx, struct NetUserGetInfo *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -1660,7 +1635,6 @@ WERROR NetUserGetInfo_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -1716,10 +1690,6 @@ WERROR NetUserGetInfo_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&user_handle)) { rpccli_samr_Close(pipe_cli, ctx, &user_handle); } @@ -1747,7 +1717,6 @@ WERROR NetUserGetInfo_l(struct libnetapi_ctx *ctx, WERROR NetUserSetInfo_r(struct libnetapi_ctx *ctx, struct NetUserSetInfo *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -1818,7 +1787,6 @@ WERROR NetUserSetInfo_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -1877,7 +1845,7 @@ WERROR NetUserSetInfo_r(struct libnetapi_ctx *ctx, } status = set_user_info_USER_INFO_X(ctx, pipe_cli, - &cli->user_session_key, + &pipe_cli->auth->user_session_key, &user_handle, &uX); if (!NT_STATUS_IS_OK(status)) { @@ -1888,10 +1856,6 @@ WERROR NetUserSetInfo_r(struct libnetapi_ctx *ctx, werr = WERR_OK; done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&user_handle)) { rpccli_samr_Close(pipe_cli, ctx, &user_handle); } @@ -2209,7 +2173,6 @@ static NTSTATUS query_USER_MODALS_INFO_to_buffer(TALLOC_CTX *mem_ctx, WERROR NetUserModalsGet_r(struct libnetapi_ctx *ctx, struct NetUserModalsGet *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -2244,7 +2207,6 @@ WERROR NetUserModalsGet_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -2278,10 +2240,6 @@ WERROR NetUserModalsGet_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - if (ctx->disable_policy_handle_cache) { libnetapi_samr_close_domain_handle(ctx, &domain_handle); libnetapi_samr_close_connect_handle(ctx, &connect_handle); @@ -2680,7 +2638,6 @@ static NTSTATUS set_USER_MODALS_INFO_buffer(TALLOC_CTX *mem_ctx, WERROR NetUserModalsSet_r(struct libnetapi_ctx *ctx, struct NetUserModalsSet *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; NTSTATUS status; WERROR werr; @@ -2728,7 +2685,6 @@ WERROR NetUserModalsSet_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -2757,10 +2713,6 @@ WERROR NetUserModalsSet_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - if (ctx->disable_policy_handle_cache) { libnetapi_samr_close_domain_handle(ctx, &domain_handle); libnetapi_samr_close_connect_handle(ctx, &connect_handle); @@ -2829,7 +2781,6 @@ NTSTATUS add_GROUP_USERS_INFO_X_buffer(TALLOC_CTX *mem_ctx, WERROR NetUserGetGroups_r(struct libnetapi_ctx *ctx, struct NetUserGetGroups *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct policy_handle connect_handle, domain_handle, user_handle; struct lsa_String lsa_account_name; @@ -2866,7 +2817,6 @@ WERROR NetUserGetGroups_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -2957,10 +2907,6 @@ WERROR NetUserGetGroups_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - if (ctx->disable_policy_handle_cache) { libnetapi_samr_close_domain_handle(ctx, &domain_handle); libnetapi_samr_close_connect_handle(ctx, &connect_handle); @@ -2984,7 +2930,6 @@ WERROR NetUserGetGroups_l(struct libnetapi_ctx *ctx, WERROR NetUserSetGroups_r(struct libnetapi_ctx *ctx, struct NetUserSetGroups *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct policy_handle connect_handle, domain_handle, user_handle, group_handle; struct lsa_String lsa_account_name; @@ -3027,7 +2972,6 @@ WERROR NetUserSetGroups_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -3214,10 +3158,6 @@ WERROR NetUserSetGroups_r(struct libnetapi_ctx *ctx, werr = WERR_OK; done: - if (!cli) { - return werr; - } - if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } @@ -3271,7 +3211,6 @@ static NTSTATUS add_LOCALGROUP_USERS_INFO_X_buffer(TALLOC_CTX *mem_ctx, WERROR NetUserGetLocalGroups_r(struct libnetapi_ctx *ctx, struct NetUserGetLocalGroups *r) { - struct cli_state *cli = NULL; struct rpc_pipe_client *pipe_cli = NULL; struct policy_handle connect_handle, domain_handle, user_handle, builtin_handle; @@ -3314,7 +3253,6 @@ WERROR NetUserGetLocalGroups_r(struct libnetapi_ctx *ctx, werr = libnetapi_open_pipe(ctx, r->in.server_name, &ndr_table_samr.syntax_id, - &cli, &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; @@ -3472,10 +3410,6 @@ WERROR NetUserGetLocalGroups_r(struct libnetapi_ctx *ctx, } done: - if (!cli) { - return werr; - } - if (ctx->disable_policy_handle_cache) { libnetapi_samr_close_domain_handle(ctx, &domain_handle); libnetapi_samr_close_connect_handle(ctx, &connect_handle); diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 98c25c1e24..3ddc4342a7 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -978,16 +978,10 @@ struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx, struct open_socket_out_state *state; NTSTATUS status; - result = async_req_new(mem_ctx); - if (result == NULL) { + if (!async_req_setup(mem_ctx, &result, &state, + struct open_socket_out_state)) { return NULL; } - state = talloc(result, struct open_socket_out_state); - if (state == NULL) { - goto fail; - } - result->private_data = state; - state->ev = ev; state->ss = *pss; state->port = port; @@ -1170,16 +1164,10 @@ struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx, struct open_socket_out_defer_state *state; NTSTATUS status; - result = async_req_new(mem_ctx); - if (result == NULL) { + if (!async_req_setup(mem_ctx, &result, &state, + struct open_socket_out_defer_state)) { return NULL; } - state = talloc(result, struct open_socket_out_defer_state); - if (state == NULL) { - goto fail; - } - result->private_data = state; - state->ev = ev; state->ss = *pss; state->port = port; diff --git a/source3/lib/util_tdb.c b/source3/lib/util_tdb.c index 03f72dfcee..2dbdd57947 100644 --- a/source3/lib/util_tdb.c +++ b/source3/lib/util_tdb.c @@ -422,74 +422,6 @@ TDB_CONTEXT *tdb_open_log(const char *name, int hash_size, int tdb_flags, return tdb; } - -/** - * Search across the whole tdb for keys that match the given pattern - * return the result as a list of keys - * - * @param tdb pointer to opened tdb file context - * @param pattern searching pattern used by fnmatch(3) functions - * - * @return list of keys found by looking up with given pattern - **/ -TDB_LIST_NODE *tdb_search_keys(TDB_CONTEXT *tdb, const char* pattern) -{ - TDB_DATA key, next; - TDB_LIST_NODE *list = NULL; - TDB_LIST_NODE *rec = NULL; - - for (key = tdb_firstkey(tdb); key.dptr; key = next) { - /* duplicate key string to ensure null-termination */ - char *key_str = SMB_STRNDUP((const char *)key.dptr, key.dsize); - if (!key_str) { - DEBUG(0, ("tdb_search_keys: strndup() failed!\n")); - smb_panic("strndup failed!\n"); - } - - DEBUG(18, ("checking %s for match to pattern %s\n", key_str, pattern)); - - next = tdb_nextkey(tdb, key); - - /* do the pattern checking */ - if (fnmatch(pattern, key_str, 0) == 0) { - rec = SMB_MALLOC_P(TDB_LIST_NODE); - ZERO_STRUCTP(rec); - - rec->node_key = key; - - DLIST_ADD_END(list, rec, TDB_LIST_NODE *); - - DEBUG(18, ("checking %s matched pattern %s\n", key_str, pattern)); - } else { - free(key.dptr); - } - - /* free duplicated key string */ - free(key_str); - } - - return list; - -} - - -/** - * Free the list returned by tdb_search_keys - * - * @param node list of results found by tdb_search_keys - **/ -void tdb_search_list_free(TDB_LIST_NODE* node) -{ - TDB_LIST_NODE *next_node; - - while (node) { - next_node = node->next; - SAFE_FREE(node->node_key.dptr); - SAFE_FREE(node); - node = next_node; - }; -} - /**************************************************************************** tdb_store, wrapped in a transaction. This way we make sure that a process that dies within writing does not leave a corrupt tdb behind. diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index 1f5f181aa1..0e6e5d15c4 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -43,17 +43,10 @@ struct async_req *wb_req_read_send(TALLOC_CTX *mem_ctx, struct async_req *result, *subreq; struct req_read_state *state; - result = async_req_new(mem_ctx); - if (result == NULL) { + if (!async_req_setup(mem_ctx, &result, &state, + struct req_read_state)) { return NULL; } - - state = talloc(result, struct req_read_state); - if (state == NULL) { - goto nomem; - } - result->private_data = state; - state->fd = fd; state->ev = ev; state->max_extra_data = max_extra_data; @@ -205,17 +198,10 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx, struct async_req *result, *subreq; struct req_write_state *state; - result = async_req_new(mem_ctx); - if (result == NULL) { + if (!async_req_setup(mem_ctx, &result, &state, + struct req_write_state)) { return NULL; } - - state = talloc(result, struct req_write_state); - if (state == NULL) { - goto nomem; - } - result->private_data = state; - state->fd = fd; state->ev = ev; state->wb_req = wb_req; @@ -304,17 +290,10 @@ struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx, struct async_req *result, *subreq; struct resp_read_state *state; - result = async_req_new(mem_ctx); - if (result == NULL) { + if (!async_req_setup(mem_ctx, &result, &state, + struct resp_read_state)) { return NULL; } - - state = talloc(result, struct resp_read_state); - if (state == NULL) { - goto nomem; - } - result->private_data = state; - state->fd = fd; state->ev = ev; state->wb_resp = talloc(state, struct winbindd_response); @@ -458,17 +437,10 @@ struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, struct async_req *result, *subreq; struct resp_write_state *state; - result = async_req_new(mem_ctx); - if (result == NULL) { + if (!async_req_setup(mem_ctx, &result, &state, + struct resp_write_state)) { return NULL; } - - state = talloc(result, struct resp_write_state); - if (state == NULL) { - goto nomem; - } - result->private_data = state; - state->fd = fd; state->ev = ev; state->wb_resp = wb_resp; diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c index d58c934c07..ea0bcb512e 100644 --- a/source3/lib/wbclient.c +++ b/source3/lib/wbclient.c @@ -289,15 +289,10 @@ static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx, struct async_req *subreq; struct wb_int_trans_state *state; - result = async_req_new(mem_ctx); - if (result == NULL) { + if (!async_req_setup(mem_ctx, &result, &state, + struct wb_int_trans_state)) { return NULL; } - state = talloc(result, struct wb_int_trans_state); - if (state == NULL) { - goto fail; - } - result->private_data = state; if (winbind_closed_fd(fd)) { if (!async_post_status(result, ev, @@ -420,16 +415,10 @@ static struct async_req *wb_open_pipe_send(TALLOC_CTX *mem_ctx, struct async_req *subreq; struct wb_open_pipe_state *state; - result = async_req_new(mem_ctx); - if (result == NULL) { + if (!async_req_setup(mem_ctx, &result, &state, + struct wb_open_pipe_state)) { return NULL; } - state = talloc(result, struct wb_open_pipe_state); - if (state == NULL) { - goto fail; - } - result->private_data = state; - state->wb_ctx = wb_ctx; state->ev = ev; state->need_priv = need_priv; @@ -617,16 +606,10 @@ struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx, struct event_context *ev, struct async_req *result; struct wb_trans_state *state; - result = async_req_new(mem_ctx); - if (result == NULL) { + if (!async_req_setup(mem_ctx, &result, &state, + struct wb_trans_state)) { return NULL; } - state = talloc(result, struct wb_trans_state); - if (state == NULL) { - goto fail; - } - result->private_data = state; - state->wb_ctx = wb_ctx; state->ev = ev; state->wb_req = winbindd_request_copy(state, wb_req); |