From 0a362a94c8f720ad0805c0789433d3e70b86d1c3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 16 Apr 2008 02:16:08 +0200 Subject: net/libnetapi: Include netapi headers early and free on exit. Guenther (This used to be commit 020b1e6431601fadf44dbfe8393908c096ecfa4c) --- source3/utils/net.c | 7 +++++++ source3/utils/net.h | 2 ++ source3/utils/net_dom.c | 3 --- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net.c b/source3/utils/net.c index 5706e336de..f6851f69da 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -1169,6 +1169,13 @@ static struct functable net_func[] = { rc = net_run_function(argc_new-1, argv_new+1, net_func, net_help); DEBUG(2,("return code = %d\n", rc)); + + { + struct libnetapi_ctx *ctx = NULL; + libnetapi_getctx(&ctx); + libnetapi_free(ctx); + } + TALLOC_FREE(frame); return rc; } diff --git a/source3/utils/net.h b/source3/utils/net.h index 3a4b1da7b0..00a818a606 100644 --- a/source3/utils/net.h +++ b/source3/utils/net.h @@ -22,6 +22,8 @@ * include */ +#include "lib/netapi/netapi.h" + typedef NTSTATUS (*rpc_command_fn)(const DOM_SID *, const char *, struct cli_state *cli, diff --git a/source3/utils/net_dom.c b/source3/utils/net_dom.c index e88bbdb276..6e4bf14c84 100644 --- a/source3/utils/net_dom.c +++ b/source3/utils/net_dom.c @@ -19,7 +19,6 @@ #include "includes.h" #include "utils/net.h" -#include "lib/netapi/netapi.h" static int net_dom_usage(int argc, const char **argv) { @@ -130,7 +129,6 @@ static int net_dom_unjoin(int argc, const char **argv) cli_shutdown(cli); } - /* libnetapi_free(ctx); */ return ret; } @@ -244,7 +242,6 @@ static int net_dom_join(int argc, const char **argv) cli_shutdown(cli); } - /* libnetapi_free(ctx); */ return ret; } -- cgit From cd87be5ba22e711e16d7f1feb5be753807efdc05 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 16 Apr 2008 02:39:41 +0200 Subject: net: use NetUserDel for "net rpc user delete". Guenther (This used to be commit 0105770c1598e6fcbcaa29e17f3b7fd33114a333) --- source3/utils/net_rpc.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 5663680eb7..3cd72fa3d8 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -987,8 +987,26 @@ static int rpc_user_rename(int argc, const char **argv) static int rpc_user_delete(int argc, const char **argv) { - return run_rpc_command(NULL, PI_SAMR, 0, rpc_user_del_internals, - argc, argv); + NET_API_STATUS status; + + if (argc < 1) { + d_printf("User must be specified\n"); + rpc_user_usage(argc, argv); + return 0; + } + + status = NetUserDel(opt_host, argv[0]); + + if (status != 0) { + d_fprintf(stderr, "Failed to delete user '%s' with: %s.\n", + argv[0], + libnetapi_get_error_string(NULL, status)); + return -1; + } else { + d_printf("Deleted user '%s'.\n", argv[0]); + } + + return 0; } /** @@ -1360,6 +1378,9 @@ static NTSTATUS rpc_user_list_internals(const DOM_SID *domain_sid, int net_rpc_user(int argc, const char **argv) { + struct libnetapi_ctx *ctx = NULL; + NET_API_STATUS status; + struct functable func[] = { {"add", rpc_user_add}, {"info", rpc_user_info}, @@ -1368,7 +1389,14 @@ int net_rpc_user(int argc, const char **argv) {"rename", rpc_user_rename}, {NULL, NULL} }; - + + status = libnetapi_init(&ctx); + if (status != 0) { + return -1; + } + libnetapi_set_username(ctx, opt_user_name); + libnetapi_set_password(ctx, opt_password); + if (argc == 0) { return run_rpc_command(NULL,PI_SAMR, 0, rpc_user_list_internals, -- cgit From 004c2beef4e4b89cb361cbd4cf71ef7635121fd5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 16 Apr 2008 02:41:52 +0200 Subject: net: Use NetUserAdd for "net rpc user add". Guenther (This used to be commit 4868b4ea1a18d4218330c49bf57818c4b5117d1d) --- source3/utils/net_rpc.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 3cd72fa3d8..d0e0487372 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -730,8 +730,34 @@ static NTSTATUS rpc_user_add_internals(const DOM_SID *domain_sid, static int rpc_user_add(int argc, const char **argv) { - return run_rpc_command(NULL, PI_SAMR, 0, rpc_user_add_internals, - argc, argv); + NET_API_STATUS status; + struct USER_INFO_1 info1; + uint32_t parm_error = 0; + + if (argc < 1) { + d_printf("User must be specified\n"); + rpc_user_usage(argc, argv); + return 0; + } + + ZERO_STRUCT(info1); + + info1.usri1_name = argv[0]; + if (argc == 2) { + info1.usri1_password = argv[1]; + } + + status = NetUserAdd(opt_host, 1, (uint8_t *)&info1, &parm_error); + + if (status != 0) { + d_fprintf(stderr, "Failed to add user '%s' with: %s.\n", + argv[0], libnetapi_get_error_string(NULL, status)); + return -1; + } else { + d_printf("Added user '%s'.\n", argv[0]); + } + + return 0; } /** -- cgit From 409e093334c4399e87a0a06114fd4ac37bd8f3e8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 16 Apr 2008 02:45:00 +0200 Subject: net: Remove unused rpc_user_add/del_internals code. Guenther (This used to be commit e68daef0ee051515c8f489820fde9110747e8aa6) --- source3/utils/net_rpc.c | 257 ------------------------------------------------ 1 file changed, 257 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index d0e0487372..93947791f3 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -568,156 +568,6 @@ static int rpc_user_usage(int argc, const char **argv) return net_help_user(argc, argv); } -/** - * Add a new user to a remote RPC server - * - * All parameters are provided by the run_rpc_command function, except for - * argc, argv which are passes through. - * - * @param domain_sid The domain sid acquired from the remote server - * @param cli A cli_state connected to the server. - * @param mem_ctx Talloc context, destoyed on completion of the function. - * @param argc Standard main() style argc - * @param argv Standard main() style argv. Initial components are already - * stripped - * - * @return Normal NTSTATUS return. - **/ - -static NTSTATUS rpc_user_add_internals(const DOM_SID *domain_sid, - const char *domain_name, - struct cli_state *cli, - struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, - int argc, const char **argv) -{ - - POLICY_HND connect_pol, domain_pol, user_pol; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - const char *acct_name; - struct lsa_String lsa_acct_name; - uint32 acb_info; - uint32 acct_flags, user_rid; - uint32_t access_granted = 0; - struct samr_Ids user_rids, name_types; - - if (argc < 1) { - d_printf("User must be specified\n"); - rpc_user_usage(argc, argv); - return NT_STATUS_OK; - } - - acct_name = argv[0]; - init_lsa_String(&lsa_acct_name, acct_name); - - /* Get sam policy handle */ - - result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, - MAXIMUM_ALLOWED_ACCESS, - &connect_pol); - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - /* Get domain policy handle */ - - result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx, - &connect_pol, - MAXIMUM_ALLOWED_ACCESS, - CONST_DISCARD(struct dom_sid2 *, domain_sid), - &domain_pol); - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - /* Create domain user */ - - acb_info = ACB_NORMAL; - acct_flags = SEC_GENERIC_READ | SEC_GENERIC_WRITE | SEC_GENERIC_EXECUTE | - SEC_STD_WRITE_DAC | SEC_STD_DELETE | - SAMR_USER_ACCESS_SET_PASSWORD | - SAMR_USER_ACCESS_GET_ATTRIBUTES | - SAMR_USER_ACCESS_SET_ATTRIBUTES; - - result = rpccli_samr_CreateUser2(pipe_hnd, mem_ctx, - &domain_pol, - &lsa_acct_name, - acb_info, - acct_flags, - &user_pol, - &access_granted, - &user_rid); - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - if (argc == 2) { - - union samr_UserInfo info; - uchar pwbuf[516]; - - result = rpccli_samr_LookupNames(pipe_hnd, mem_ctx, - &domain_pol, - 1, - &lsa_acct_name, - &user_rids, - &name_types); - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx, - &domain_pol, - MAXIMUM_ALLOWED_ACCESS, - user_rids.ids[0], - &user_pol); - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - /* Set password on account */ - - encode_pw_buffer(pwbuf, argv[1], STR_UNICODE); - - init_samr_user_info24(&info.info24, pwbuf, 24); - - SamOEMhashBlob(info.info24.password.data, 516, - &cli->user_session_key); - - result = rpccli_samr_SetUserInfo2(pipe_hnd, mem_ctx, - &user_pol, - 24, - &info); - - if (!NT_STATUS_IS_OK(result)) { - d_fprintf(stderr, "Failed to set password for user %s - %s\n", - acct_name, nt_errstr(result)); - - result = rpccli_samr_DeleteUser(pipe_hnd, mem_ctx, - &user_pol); - - if (!NT_STATUS_IS_OK(result)) { - d_fprintf(stderr, "Failed to delete user %s - %s\n", - acct_name, nt_errstr(result)); - return result; - } - } - - } - done: - if (!NT_STATUS_IS_OK(result)) { - d_fprintf(stderr, "Failed to add user '%s' with %s.\n", - acct_name, nt_errstr(result)); - } else { - d_printf("Added user '%s'.\n", acct_name); - } - return result; -} - /** * Add a new user to a remote RPC server * @@ -760,113 +610,6 @@ static int rpc_user_add(int argc, const char **argv) return 0; } -/** - * Delete a user from a remote RPC server - * - * All parameters are provided by the run_rpc_command function, except for - * argc, argv which are passes through. - * - * @param domain_sid The domain sid acquired from the remote server - * @param cli A cli_state connected to the server. - * @param mem_ctx Talloc context, destoyed on completion of the function. - * @param argc Standard main() style argc - * @param argv Standard main() style argv. Initial components are already - * stripped - * - * @return Normal NTSTATUS return. - **/ - -static NTSTATUS rpc_user_del_internals(const DOM_SID *domain_sid, - const char *domain_name, - struct cli_state *cli, - struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, - int argc, - const char **argv) -{ - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - POLICY_HND connect_pol, domain_pol, user_pol; - const char *acct_name; - - if (argc < 1) { - d_printf("User must be specified\n"); - rpc_user_usage(argc, argv); - return NT_STATUS_OK; - } - - acct_name = argv[0]; - - /* Get sam policy and domain handles */ - - result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, - MAXIMUM_ALLOWED_ACCESS, - &connect_pol); - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - result = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx, - &connect_pol, - MAXIMUM_ALLOWED_ACCESS, - CONST_DISCARD(struct dom_sid2 *, domain_sid), - &domain_pol); - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - /* Get handle on user */ - - { - struct samr_Ids user_rids, name_types; - struct lsa_String lsa_acct_name; - - init_lsa_String(&lsa_acct_name, acct_name); - - result = rpccli_samr_LookupNames(pipe_hnd, mem_ctx, - &domain_pol, - 1, - &lsa_acct_name, - &user_rids, - &name_types); - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - result = rpccli_samr_OpenUser(pipe_hnd, mem_ctx, - &domain_pol, - MAXIMUM_ALLOWED_ACCESS, - user_rids.ids[0], - &user_pol); - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - } - - /* Delete user */ - - result = rpccli_samr_DeleteUser(pipe_hnd, mem_ctx, - &user_pol); - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - done: - if (!NT_STATUS_IS_OK(result)) { - d_fprintf(stderr, "Failed to delete user '%s' with %s.\n", - acct_name, nt_errstr(result)); - } else { - d_printf("Deleted user '%s'.\n", acct_name); - } - - return result; -} - /** * Rename a user on a remote RPC server * -- cgit From 6f4b7fcf9777aa72ad587b8664b078c5dcb8d11f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 17 Apr 2008 00:06:00 +0200 Subject: net: Be more tolerant while joining. Guenther (This used to be commit 70b7b331d9e2d915e6209fca5900f41fae4866fd) --- source3/utils/net_ads.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 88051ec4a1..c8bfc2630c 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -1199,7 +1199,7 @@ int net_ads_join(int argc, const char **argv) /* Check the short name of the domain */ - if (!strequal(lp_workgroup(), r->out.netbios_domain_name)) { + if (!modify_config && !strequal(lp_workgroup(), r->out.netbios_domain_name)) { d_printf("The workgroup in %s does not match the short\n", get_dyn_CONFIGFILE()); d_printf("domain name obtained from the server.\n"); d_printf("Using the name [%s] from the server.\n", r->out.netbios_domain_name); @@ -1209,11 +1209,16 @@ int net_ads_join(int argc, const char **argv) d_printf("Using short domain name -- %s\n", r->out.netbios_domain_name); - d_printf("Joined '%s' to realm '%s'\n", r->in.machine_name, - r->out.dns_domain_name); + if (r->out.dns_domain_name) { + d_printf("Joined '%s' to realm '%s'\n", r->in.machine_name, + r->out.dns_domain_name); + } else { + d_printf("Joined '%s' to domain '%s'\n", r->in.machine_name, + r->out.netbios_domain_name); + } #if defined(WITH_DNS_UPDATES) - { + if (r->out.domain_is_ad) { /* We enter this block with user creds */ ADS_STRUCT *ads_dns = NULL; -- cgit From 1c8553783515fa29b3af8499d9a36f92bdcf32cd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 17 Apr 2008 08:02:46 -0700 Subject: Fix gcc uninitialized variable used warning. Jeremy. (This used to be commit b95f2adeb5e2f7ce71e46e6a6165159483c9a702) --- source3/utils/net_rpc_samsync.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index 986499731a..06cde2a3fd 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -1028,7 +1028,6 @@ static NTSTATUS fetch_domain_info(uint32_t rid, struct netr_DELTA_DOMAIN *r) { time_t u_max_age, u_min_age, u_logout; - time_t u_lockoutreset, u_lockouttime; NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; const char *domname; struct netr_AcctLockStr *lockstr = NULL; @@ -1046,11 +1045,6 @@ static NTSTATUS fetch_domain_info(uint32_t rid, u_min_age = uint64s_nt_time_to_unix_abs((uint64 *)&r->min_password_age); u_logout = uint64s_nt_time_to_unix_abs((uint64 *)&r->force_logoff_time); - if (lockstr) { - u_lockoutreset = uint64s_nt_time_to_unix_abs(&lockstr->reset_count); - u_lockouttime = uint64s_nt_time_to_unix_abs((uint64_t *)&lockstr->lockout_duration); - } - domname = r->domain_name.string; if (!domname) { return NT_STATUS_NO_MEMORY; @@ -1081,6 +1075,11 @@ static NTSTATUS fetch_domain_info(uint32_t rid, return nt_status; if (lockstr) { + time_t u_lockoutreset, u_lockouttime; + + u_lockoutreset = uint64s_nt_time_to_unix_abs(&lockstr->reset_count); + u_lockouttime = uint64s_nt_time_to_unix_abs((uint64_t *)&lockstr->lockout_duration); + if (!pdb_set_account_policy(AP_BAD_ATTEMPT_LOCKOUT, lockstr->bad_attempt_lockout)) return nt_status; -- cgit From 2a2188591b5ed922d09dc723adcf10f8b8f5e5a0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Apr 2008 21:56:43 +0200 Subject: Add "desthost" to rpc_pipe_client This reduces the dependency on cli_state (This used to be commit 783afab9c891dd7bcb78895b2a639b6f3a0edf5b) --- source3/utils/net_rpc.c | 64 ++++++++++++++++++++--------------------- source3/utils/net_rpc_join.c | 2 +- source3/utils/net_rpc_printer.c | 3 +- source3/utils/net_rpc_samsync.c | 6 ++-- source3/utils/net_rpc_sh_acct.c | 2 +- source3/utils/smbtree.c | 2 +- 6 files changed, 40 insertions(+), 39 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 93947791f3..330317b0fd 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -451,7 +451,7 @@ NTSTATUS rpc_info_internals(const DOM_SID *domain_sid, /* Get sam policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); if (!NT_STATUS_IS_OK(result)) { @@ -654,7 +654,7 @@ static NTSTATUS rpc_user_rename_internals(const DOM_SID *domain_sid, /* Get sam policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); @@ -829,7 +829,7 @@ static NTSTATUS rpc_user_password_internals(const DOM_SID *domain_sid, /* Get sam policy and domain handles */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); @@ -960,7 +960,7 @@ static NTSTATUS rpc_user_info_internals(const DOM_SID *domain_sid, /* Get sam policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); if (!NT_STATUS_IS_OK(result)) goto done; @@ -1078,7 +1078,7 @@ static NTSTATUS rpc_user_list_internals(const DOM_SID *domain_sid, /* Get sam policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); if (!NT_STATUS_IS_OK(result)) { @@ -1243,7 +1243,7 @@ static NTSTATUS rpc_sh_handle_user(TALLOC_CTX *mem_ctx, } result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); if (!NT_STATUS_IS_OK(result)) { @@ -1611,7 +1611,7 @@ static NTSTATUS rpc_group_delete_internals(const DOM_SID *domain_sid, } result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); @@ -1809,7 +1809,7 @@ static NTSTATUS rpc_group_add_internals(const DOM_SID *domain_sid, /* Get sam policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); if (!NT_STATUS_IS_OK(result)) goto done; @@ -1879,7 +1879,7 @@ static NTSTATUS rpc_alias_add_internals(const DOM_SID *domain_sid, /* Get sam policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); if (!NT_STATUS_IS_OK(result)) goto done; @@ -2015,7 +2015,7 @@ static NTSTATUS rpc_add_groupmem(struct rpc_pipe_client *pipe_hnd, /* Get sam policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); if (!NT_STATUS_IS_OK(result)) { @@ -2097,7 +2097,7 @@ static NTSTATUS rpc_add_aliasmem(struct rpc_pipe_client *pipe_hnd, /* Get sam policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); if (!NT_STATUS_IS_OK(result)) { @@ -2216,7 +2216,7 @@ static NTSTATUS rpc_del_groupmem(struct rpc_pipe_client *pipe_hnd, /* Get sam policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); if (!NT_STATUS_IS_OK(result)) @@ -2292,7 +2292,7 @@ static NTSTATUS rpc_del_aliasmem(struct rpc_pipe_client *pipe_hnd, /* Get sam policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); if (!NT_STATUS_IS_OK(result)) { @@ -2439,7 +2439,7 @@ static NTSTATUS rpc_group_list_internals(const DOM_SID *domain_sid, /* Get sam policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); if (!NT_STATUS_IS_OK(result)) { @@ -2810,7 +2810,7 @@ static NTSTATUS rpc_group_members_internals(const DOM_SID *domain_sid, /* Get sam policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); @@ -2923,7 +2923,7 @@ static NTSTATUS rpc_group_rename_internals(const DOM_SID *domain_sid, /* Get sam policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); @@ -3084,7 +3084,7 @@ static NTSTATUS rpc_share_add_internals(const DOM_SID *domain_sid, info.info2 = &info2; status = rpccli_srvsvc_NetShareAdd(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, level, &info, &parm_error, @@ -3129,7 +3129,7 @@ static NTSTATUS rpc_share_del_internals(const DOM_SID *domain_sid, WERROR result; return rpccli_srvsvc_NetShareDel(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, argv[0], 0, &result); @@ -3195,7 +3195,7 @@ static WERROR get_share_info(struct rpc_pipe_client *pipe_hnd, info_ctr->level = level; status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, info_ctr, preferred_len, &total_entries, @@ -3206,7 +3206,7 @@ static WERROR get_share_info(struct rpc_pipe_client *pipe_hnd, /* request just one share */ status = rpccli_srvsvc_NetShareGetInfo(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, argv[0], level, &info, @@ -3425,7 +3425,7 @@ static NTSTATUS rpc_share_migrate_shares_internals(const DOM_SID *domain_sid, info.info502 = &info502; nt_status = rpccli_srvsvc_NetShareAdd(srvsvc_pipe, mem_ctx, - srvsvc_pipe->cli->desthost, + srvsvc_pipe->desthost, 502, &info, &parm_error, @@ -3848,7 +3848,7 @@ static NTSTATUS rpc_share_migrate_security_internals(const DOM_SID *domain_sid, /* finally modify the share on the dst server */ nt_status = rpccli_srvsvc_NetShareSetInfo(srvsvc_pipe, mem_ctx, - srvsvc_pipe->cli->desthost, + srvsvc_pipe->desthost, info502.name, level, &info, @@ -4141,7 +4141,7 @@ static NTSTATUS rpc_aliaslist_internals(const DOM_SID *domain_sid, POLICY_HND connect_pol; result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); @@ -4488,7 +4488,7 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd, uint16 cnum; status = rpccli_srvsvc_NetShareGetInfo(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, netname, 502, &info, @@ -4807,7 +4807,7 @@ static NTSTATUS rpc_sh_share_add(TALLOC_CTX *mem_ctx, info.info2 = &info2; status = rpccli_srvsvc_NetShareAdd(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, 2, &info, &parm_err, @@ -4830,7 +4830,7 @@ static NTSTATUS rpc_sh_share_delete(TALLOC_CTX *mem_ctx, } status = rpccli_srvsvc_NetShareDel(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, argv[0], 0, &result); @@ -4853,7 +4853,7 @@ static NTSTATUS rpc_sh_share_info(TALLOC_CTX *mem_ctx, } status = rpccli_srvsvc_NetShareGetInfo(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, argv[0], 2, &info, @@ -4925,7 +4925,7 @@ static NTSTATUS rpc_file_close_internals(const DOM_SID *domain_sid, const char **argv) { return rpccli_srvsvc_NetFileClose(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, atoi(argv[0]), NULL); } @@ -5006,7 +5006,7 @@ static NTSTATUS rpc_file_list_internals(const DOM_SID *domain_sid, info_ctr.ctr.ctr3 = &ctr3; status = rpccli_srvsvc_NetFileEnum(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, NULL, username, &info_ctr, @@ -5371,7 +5371,7 @@ static NTSTATUS rpc_trustdom_add_internals(const DOM_SID *domain_sid, /* Get samr policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); if (!NT_STATUS_IS_OK(result)) { @@ -5527,7 +5527,7 @@ static NTSTATUS rpc_trustdom_del_internals(const DOM_SID *domain_sid, /* Get samr policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); if (!NT_STATUS_IS_OK(result)) { @@ -6269,7 +6269,7 @@ static int rpc_trustdom_list(int argc, const char **argv) /* SamrConnect2 */ nt_status = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, SA_RIGHT_SAM_OPEN_DOMAIN, &connect_hnd); if (!NT_STATUS_IS_OK(nt_status)) { diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c index ea3bb10c22..b868ea824f 100644 --- a/source3/utils/net_rpc_join.c +++ b/source3/utils/net_rpc_join.c @@ -238,7 +238,7 @@ int net_rpc_join_newstyle(int argc, const char **argv) } CHECK_RPC_ERR(rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, SEC_RIGHTS_MAXIMUM_ALLOWED, &sam_pol), "could not connect to SAM database"); diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index bcfb37713c..80140792a3 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -721,7 +721,8 @@ static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd, WERROR result; fstring servername, printername2; - slprintf(servername, sizeof(servername)-1, "\\\\%s", pipe_hnd->cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", + pipe_hnd->desthost); fstrcpy(printername2, servername); fstrcat(printername2, "\\"); diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index 06cde2a3fd..6ea0a2dcfc 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -330,7 +330,7 @@ static void dump_database(struct rpc_pipe_client *pipe_hnd, NTSTATUS result; int i; TALLOC_CTX *mem_ctx; - const char *logon_server = pipe_hnd->cli->desthost; + const char *logon_server = pipe_hnd->desthost; const char *computername = global_myname(); struct netr_Authenticator credential; struct netr_Authenticator return_authenticator; @@ -1190,7 +1190,7 @@ static NTSTATUS fetch_database(struct rpc_pipe_client *pipe_hnd, uint32 db_type, NTSTATUS result; int i; TALLOC_CTX *mem_ctx; - const char *logon_server = pipe_hnd->cli->desthost; + const char *logon_server = pipe_hnd->desthost; const char *computername = global_myname(); struct netr_Authenticator credential; struct netr_Authenticator return_authenticator; @@ -2011,7 +2011,7 @@ static NTSTATUS fetch_database_to_ldif(struct rpc_pipe_client *pipe_hnd, uint32 num_deltas; FILE *add_file = NULL, *mod_file = NULL, *ldif_file = NULL; int num_alloced = 0, g_index = 0, a_index = 0; - const char *logon_server = pipe_hnd->cli->desthost; + const char *logon_server = pipe_hnd->desthost; const char *computername = global_myname(); struct netr_Authenticator credential; struct netr_Authenticator return_authenticator; diff --git a/source3/utils/net_rpc_sh_acct.c b/source3/utils/net_rpc_sh_acct.c index 57640ca3a8..00a7967f07 100644 --- a/source3/utils/net_rpc_sh_acct.c +++ b/source3/utils/net_rpc_sh_acct.c @@ -49,7 +49,7 @@ static NTSTATUS rpc_sh_acct_do(TALLOC_CTX *mem_ctx, /* Get sam policy handle */ result = rpccli_samr_Connect2(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, MAXIMUM_ALLOWED_ACCESS, &connect_pol); if (!NT_STATUS_IS_OK(result)) { diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c index 48eae5ac5c..d2dd1b49d3 100644 --- a/source3/utils/smbtree.c +++ b/source3/utils/smbtree.c @@ -179,7 +179,7 @@ static bool get_rpc_shares(struct cli_state *cli, info_ctr.ctr.ctr1 = &ctr1; status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, mem_ctx, - pipe_hnd->cli->desthost, + pipe_hnd->desthost, &info_ctr, 0xffffffff, &total_entries, -- cgit From 9048cafbeaf82d1916de6538024fd660612dd25f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Apr 2008 23:03:16 +0200 Subject: Move srv_name_slash from cli_state to rpc_pipe_client (This used to be commit a9061e52e1ff8e31aa480f4a30cda64c9d93214e) --- source3/utils/net_rpc_service.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net_rpc_service.c b/source3/utils/net_rpc_service.c index 1b12bd3114..b886283adc 100644 --- a/source3/utils/net_rpc_service.c +++ b/source3/utils/net_rpc_service.c @@ -213,7 +213,7 @@ static NTSTATUS rpc_service_list_internal(const DOM_SID *domain_sid, } status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, - pipe_hnd->cli->srv_name_slash, + pipe_hnd->srv_name_slash, NULL, SC_RIGHT_MGR_ENUMERATE_SERVICE, &hSCM, @@ -272,7 +272,7 @@ static NTSTATUS rpc_service_status_internal(const DOM_SID *domain_sid, /* Open the Service Control Manager */ status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, - pipe_hnd->cli->srv_name_slash, + pipe_hnd->srv_name_slash, NULL, SC_RIGHT_MGR_ENUMERATE_SERVICE, &hSCM, @@ -384,7 +384,7 @@ static NTSTATUS rpc_service_stop_internal(const DOM_SID *domain_sid, /* Open the Service Control Manager */ status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, - pipe_hnd->cli->srv_name_slash, + pipe_hnd->srv_name_slash, NULL, SC_RIGHT_MGR_ENUMERATE_SERVICE, &hSCM, @@ -427,7 +427,7 @@ static NTSTATUS rpc_service_pause_internal(const DOM_SID *domain_sid, /* Open the Service Control Manager */ status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, - pipe_hnd->cli->srv_name_slash, + pipe_hnd->srv_name_slash, NULL, SC_RIGHT_MGR_ENUMERATE_SERVICE, &hSCM, @@ -470,7 +470,7 @@ static NTSTATUS rpc_service_resume_internal(const DOM_SID *domain_sid, /* Open the Service Control Manager */ status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, - pipe_hnd->cli->srv_name_slash, + pipe_hnd->srv_name_slash, NULL, SC_RIGHT_MGR_ENUMERATE_SERVICE, &hSCM, @@ -511,7 +511,7 @@ static NTSTATUS rpc_service_start_internal(const DOM_SID *domain_sid, /* Open the Service Control Manager */ status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, - pipe_hnd->cli->srv_name_slash, + pipe_hnd->srv_name_slash, NULL, SC_RIGHT_MGR_ENUMERATE_SERVICE, &hSCM, -- cgit From cf2442bdcb68d75582da98ba15da8928c37fb058 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Apr 2008 00:01:52 +0200 Subject: Use rpc_pipe_client->user_name instead of rpc_pipe_client->cli->user_name Also make sure that rpc_pipe_client->user_name is always talloced. (This used to be commit 3f6c5b99664a75a6f490ee3b6980b89cacf7f579) --- source3/utils/net_rpc_printer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index 80140792a3..9dc409123e 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -994,7 +994,7 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd, /* argument given, get a single printer by name */ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, argv[0], - MAXIMUM_ALLOWED_ACCESS, pipe_hnd->cli->user_name, &hnd)) + MAXIMUM_ALLOWED_ACCESS, pipe_hnd->user_name, &hnd)) return False; if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, ctr)) { @@ -1190,7 +1190,7 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_ /* open printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename, - PRINTER_ALL_ACCESS, pipe_hnd->cli->user_name, &hnd)) + PRINTER_ALL_ACCESS, pipe_hnd->user_name, &hnd)) goto done; got_hnd = True; @@ -1838,7 +1838,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid, /* open src printer handle */ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename, - MAXIMUM_ALLOWED_ACCESS, pipe_hnd->cli->user_name, &hnd_src)) + MAXIMUM_ALLOWED_ACCESS, pipe_hnd->user_name, &hnd_src)) goto done; got_hnd_src = True; -- cgit From e73e8297f5484b6c7f525917679414c09a145cf0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Apr 2008 13:51:46 +0200 Subject: Replace cli_rpc_pipe_close by a talloc destructor on rpc_pipe_struct (This used to be commit 99fc3283c4ecc791f5a242bd1983b4352ce3e6cf) --- source3/utils/net_rpc.c | 18 +++++++++--------- source3/utils/net_rpc_join.c | 8 ++++---- source3/utils/net_rpc_shell.c | 2 +- source3/utils/net_util.c | 2 +- source3/utils/smbcacls.c | 8 ++------ source3/utils/smbtree.c | 4 ++-- 6 files changed, 19 insertions(+), 23 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index 330317b0fd..f6f0c4054c 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -88,7 +88,7 @@ NTSTATUS net_get_remote_domain_sid(struct cli_state *cli, TALLOC_CTX *mem_ctx, *domain_sid = info->account_domain.sid; rpccli_lsa_Close(lsa_pipe, mem_ctx, &pol); - cli_rpc_pipe_close(lsa_pipe); + TALLOC_FREE(lsa_pipe); return NT_STATUS_OK; } @@ -185,7 +185,7 @@ int run_rpc_command(struct cli_state *cli_arg, if (!(conn_flags & NET_FLAGS_NO_PIPE)) { if (pipe_hnd) { - cli_rpc_pipe_close(pipe_hnd); + TALLOC_FREE(pipe_hnd); } } @@ -1973,7 +1973,7 @@ static NTSTATUS get_sid_from_name(struct cli_state *cli, done: if (pipe_hnd) { - cli_rpc_pipe_close(pipe_hnd); + TALLOC_FREE(pipe_hnd); } if (!NT_STATUS_IS_OK(result) && (StrnCaseCmp(name, "S-", 2) == 0)) { @@ -2748,14 +2748,14 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd, if (!NT_STATUS_IS_OK(result)) { d_fprintf(stderr, "Couldn't open LSA policy handle\n"); - cli_rpc_pipe_close(lsa_pipe); + TALLOC_FREE(lsa_pipe); return result; } alias_sids = TALLOC_ZERO_ARRAY(mem_ctx, DOM_SID, num_members); if (!alias_sids) { d_fprintf(stderr, "Out of memory\n"); - cli_rpc_pipe_close(lsa_pipe); + TALLOC_FREE(lsa_pipe); return NT_STATUS_NO_MEMORY; } @@ -2770,7 +2770,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd, if (!NT_STATUS_IS_OK(result) && !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED)) { d_fprintf(stderr, "Couldn't lookup SIDs\n"); - cli_rpc_pipe_close(lsa_pipe); + TALLOC_FREE(lsa_pipe); return result; } @@ -2790,7 +2790,7 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd, } } - cli_rpc_pipe_close(lsa_pipe); + TALLOC_FREE(lsa_pipe); return NT_STATUS_OK; } @@ -5652,7 +5652,7 @@ static NTSTATUS rpc_trustdom_get_pdc(struct cli_state *cli, domain_name, &buffer, NULL); - cli_rpc_pipe_close(netr); + TALLOC_FREE(netr); if (NT_STATUS_IS_OK(status)) { return status; @@ -6248,7 +6248,7 @@ static int rpc_trustdom_list(int argc, const char **argv) return -1; }; - cli_rpc_pipe_close(pipe_hnd); + TALLOC_FREE(pipe_hnd); /* * Listing trusting domains (stored in passdb backend, if local) diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c index b868ea824f..c94e9d1a40 100644 --- a/source3/utils/net_rpc_join.c +++ b/source3/utils/net_rpc_join.c @@ -221,7 +221,7 @@ int net_rpc_join_newstyle(int argc, const char **argv) domain_sid = info->account_domain.sid; rpccli_lsa_Close(pipe_hnd, mem_ctx, &lsa_pol); - cli_rpc_pipe_close(pipe_hnd); /* Done with this pipe */ + TALLOC_FREE(pipe_hnd); /* Done with this pipe */ /* Bail out if domain didn't get set. */ if (!domain) { @@ -368,7 +368,7 @@ int net_rpc_join_newstyle(int argc, const char **argv) &set_info); rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol); - cli_rpc_pipe_close(pipe_hnd); /* Done with this pipe */ + TALLOC_FREE(pipe_hnd); /* Done with this pipe */ /* Now check the whole process from top-to-bottom */ @@ -429,10 +429,10 @@ int net_rpc_join_newstyle(int argc, const char **argv) goto done; } - cli_rpc_pipe_close(netlogon_schannel_pipe); + TALLOC_FREE(netlogon_schannel_pipe); } - cli_rpc_pipe_close(pipe_hnd); + TALLOC_FREE(pipe_hnd); /* Now store the secret in the secrets database */ diff --git a/source3/utils/net_rpc_shell.c b/source3/utils/net_rpc_shell.c index e6302b652e..7bd726e614 100644 --- a/source3/utils/net_rpc_shell.c +++ b/source3/utils/net_rpc_shell.c @@ -85,7 +85,7 @@ static NTSTATUS net_sh_run(struct rpc_sh_ctx *ctx, struct rpc_sh_cmd *cmd, status = cmd->fn(mem_ctx, ctx, pipe_hnd, argc, argv); - cli_rpc_pipe_close(pipe_hnd); + TALLOC_FREE(pipe_hnd); talloc_destroy(mem_ctx); diff --git a/source3/utils/net_util.c b/source3/utils/net_util.c index f844992d56..576c2191b3 100644 --- a/source3/utils/net_util.c +++ b/source3/utils/net_util.c @@ -75,7 +75,7 @@ NTSTATUS net_rpc_lookup_name(TALLOC_CTX *mem_ctx, struct cli_state *cli, if (is_valid_policy_hnd(&pol)) { rpccli_lsa_Close(lsa_pipe, mem_ctx, &pol); } - cli_rpc_pipe_close(lsa_pipe); + TALLOC_FREE(lsa_pipe); return result; } diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index 134f561760..af14c622dc 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -103,9 +103,7 @@ static NTSTATUS cli_lsa_lookup_sid(struct cli_state *cli, status = NT_STATUS_OK; fail: - if (p != NULL) { - cli_rpc_pipe_close(p); - } + TALLOC_FREE(p); cli_tdis(cli); cli->cnum = orig_cnum; TALLOC_FREE(frame); @@ -151,9 +149,7 @@ static NTSTATUS cli_lsa_lookup_name(struct cli_state *cli, status = NT_STATUS_OK; fail: - if (p != NULL) { - cli_rpc_pipe_close(p); - } + TALLOC_FREE(p); cli_tdis(cli); cli->cnum = orig_cnum; TALLOC_FREE(frame); diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c index d2dd1b49d3..c2b364d1e9 100644 --- a/source3/utils/smbtree.c +++ b/source3/utils/smbtree.c @@ -188,7 +188,7 @@ static bool get_rpc_shares(struct cli_state *cli, if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(werr)) { TALLOC_FREE(mem_ctx); - cli_rpc_pipe_close(pipe_hnd); + TALLOC_FREE(pipe_hnd); return False; } @@ -198,7 +198,7 @@ static bool get_rpc_shares(struct cli_state *cli, } TALLOC_FREE(mem_ctx); - cli_rpc_pipe_close(pipe_hnd); + TALLOC_FREE(pipe_hnd); return True; } -- cgit From b9cc05506273e5ce3398a5912b9c9e5989717480 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Apr 2008 14:05:25 +0200 Subject: Introduce rpc_pipe_np_smb_conn() This abstracts away all references to rpc_pipe_client->cli, the only reference is now in cli_pipe.c. (This used to be commit c56e1c08cef107ff33a34346ceeca3475a102b19) --- source3/utils/net_rpc.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index f6f0c4054c..924398fc33 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -1221,8 +1221,8 @@ static NTSTATUS rpc_sh_handle_user(TALLOC_CTX *mem_ctx, ZERO_STRUCT(domain_pol); ZERO_STRUCT(user_pol); - result = net_rpc_lookup_name(mem_ctx, pipe_hnd->cli, argv[0], - NULL, NULL, &sid, &type); + result = net_rpc_lookup_name(mem_ctx, rpc_pipe_np_smb_conn(pipe_hnd), + argv[0], NULL, NULL, &sid, &type); if (!NT_STATUS_IS_OK(result)) { d_fprintf(stderr, "Could not lookup %s: %s\n", argv[0], nt_errstr(result)); @@ -2087,8 +2087,8 @@ static NTSTATUS rpc_add_aliasmem(struct rpc_pipe_client *pipe_hnd, return NT_STATUS_UNSUCCESSFUL; } - result = get_sid_from_name(pipe_hnd->cli, mem_ctx, member, - &member_sid, &member_type); + result = get_sid_from_name(rpc_pipe_np_smb_conn(pipe_hnd), mem_ctx, + member, &member_sid, &member_type); if (!NT_STATUS_IS_OK(result)) { d_fprintf(stderr, "Could not lookup up group member %s\n", member); @@ -2282,8 +2282,8 @@ static NTSTATUS rpc_del_aliasmem(struct rpc_pipe_client *pipe_hnd, if (!sid_split_rid(&sid, &alias_rid)) return NT_STATUS_UNSUCCESSFUL; - result = get_sid_from_name(pipe_hnd->cli, mem_ctx, member, - &member_sid, &member_type); + result = get_sid_from_name(rpc_pipe_np_smb_conn(pipe_hnd), mem_ctx, + member, &member_sid, &member_type); if (!NT_STATUS_IS_OK(result)) { d_fprintf(stderr, "Could not lookup up group member %s\n", member); @@ -2736,7 +2736,8 @@ static NTSTATUS rpc_list_alias_members(struct rpc_pipe_client *pipe_hnd, return NT_STATUS_OK; } - lsa_pipe = cli_rpc_pipe_open_noauth(pipe_hnd->cli, PI_LSARPC, &result); + lsa_pipe = cli_rpc_pipe_open_noauth(rpc_pipe_np_smb_conn(pipe_hnd), + PI_LSARPC, &result); if (!lsa_pipe) { d_fprintf(stderr, "Couldn't open LSA pipe. Error was %s\n", nt_errstr(result) ); @@ -4480,7 +4481,7 @@ static void show_userlist(struct rpc_pipe_client *pipe_hnd, int fnum; SEC_DESC *share_sd = NULL; SEC_DESC *root_sd = NULL; - struct cli_state *cli = pipe_hnd->cli; + struct cli_state *cli = rpc_pipe_np_smb_conn(pipe_hnd); int i; union srvsvc_NetShareInfo info; WERROR result; @@ -5945,8 +5946,8 @@ static NTSTATUS vampire_trusted_domain(struct rpc_pipe_client *pipe_hnd, data = data_blob(info->password.password->data, info->password.password->length); - cleartextpwd = decrypt_trustdom_secret(pipe_hnd->cli->pwd.password, - &data); + cleartextpwd = decrypt_trustdom_secret( + rpc_pipe_np_smb_conn(pipe_hnd)->pwd.password, &data); if (cleartextpwd == NULL) { DEBUG(0,("retrieved NULL password\n")); -- cgit