diff options
author | Gerald Carter <jerry@samba.org> | 2005-09-30 17:13:37 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:04:48 -0500 |
commit | 54abd2aa66069e6baf7769c496f46d9dba18db39 (patch) | |
tree | 9cf8e88168011797319ba9e9866749201b1eac1e /source3/rpcclient | |
parent | 4a2cc231d22a82ed21771a72508f15d21ed63227 (diff) | |
download | samba-54abd2aa66069e6baf7769c496f46d9dba18db39.tar.gz samba-54abd2aa66069e6baf7769c496f46d9dba18db39.tar.bz2 samba-54abd2aa66069e6baf7769c496f46d9dba18db39.zip |
r10656: BIG merge from trunk. Features not copied over
* \PIPE\unixinfo
* winbindd's {group,alias}membership new functions
* winbindd's lookupsids() functionality
* swat (trunk changes to be reverted as per discussion with Deryck)
(This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r-- | source3/rpcclient/cmd_dfs.c | 30 | ||||
-rw-r--r-- | source3/rpcclient/cmd_ds.c | 14 | ||||
-rw-r--r-- | source3/rpcclient/cmd_echo.c | 24 | ||||
-rw-r--r-- | source3/rpcclient/cmd_lsarpc.c | 177 | ||||
-rw-r--r-- | source3/rpcclient/cmd_netlogon.c | 52 | ||||
-rw-r--r-- | source3/rpcclient/cmd_samr.c | 257 | ||||
-rw-r--r-- | source3/rpcclient/cmd_spoolss.c | 502 | ||||
-rw-r--r-- | source3/rpcclient/cmd_srvsvc.c | 44 | ||||
-rw-r--r-- | source3/rpcclient/cmd_test.c | 68 | ||||
-rw-r--r-- | source3/rpcclient/cmd_wkssvc.c | 2 | ||||
-rw-r--r-- | source3/rpcclient/rpcclient.c | 333 | ||||
-rw-r--r-- | source3/rpcclient/rpcclient.h | 11 |
12 files changed, 931 insertions, 583 deletions
diff --git a/source3/rpcclient/cmd_dfs.c b/source3/rpcclient/cmd_dfs.c index 44e97f9881..956dbfa402 100644 --- a/source3/rpcclient/cmd_dfs.c +++ b/source3/rpcclient/cmd_dfs.c @@ -24,7 +24,7 @@ /* Check DFS is supported by the remote server */ -static NTSTATUS cmd_dfs_exist(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_dfs_exist(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { BOOL dfs_exists; @@ -35,7 +35,7 @@ static NTSTATUS cmd_dfs_exist(struct cli_state *cli, TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } - result = cli_dfs_exist(cli, mem_ctx, &dfs_exists); + result = rpccli_dfs_exist(cli, mem_ctx, &dfs_exists); if (NT_STATUS_IS_OK(result)) printf("dfs is %spresent\n", dfs_exists ? "" : "not "); @@ -43,7 +43,7 @@ static NTSTATUS cmd_dfs_exist(struct cli_state *cli, TALLOC_CTX *mem_ctx, return result; } -static NTSTATUS cmd_dfs_add(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_dfs_add(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { NTSTATUS result; @@ -61,13 +61,13 @@ static NTSTATUS cmd_dfs_add(struct cli_state *cli, TALLOC_CTX *mem_ctx, sharename = argv[3]; comment = argv[4]; - result = cli_dfs_add(cli, mem_ctx, entrypath, servername, + result = rpccli_dfs_add(cli, mem_ctx, entrypath, servername, sharename, comment, flags); return result; } -static NTSTATUS cmd_dfs_remove(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_dfs_remove(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { NTSTATUS result; @@ -82,7 +82,7 @@ static NTSTATUS cmd_dfs_remove(struct cli_state *cli, TALLOC_CTX *mem_ctx, servername = argv[2]; sharename = argv[3]; - result = cli_dfs_remove(cli, mem_ctx, entrypath, servername, + result = rpccli_dfs_remove(cli, mem_ctx, entrypath, servername, sharename); return result; @@ -168,7 +168,7 @@ static void display_dfs_info_ctr(DFS_INFO_CTR *ctr) /* Enumerate dfs shares */ -static NTSTATUS cmd_dfs_enum(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_dfs_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { DFS_INFO_CTR ctr; @@ -183,7 +183,7 @@ static NTSTATUS cmd_dfs_enum(struct cli_state *cli, TALLOC_CTX *mem_ctx, if (argc == 2) info_level = atoi(argv[1]); - result = cli_dfs_enum(cli, mem_ctx, info_level, &ctr); + result = rpccli_dfs_enum(cli, mem_ctx, info_level, &ctr); if (NT_STATUS_IS_OK(result)) display_dfs_info_ctr(&ctr); @@ -191,7 +191,7 @@ static NTSTATUS cmd_dfs_enum(struct cli_state *cli, TALLOC_CTX *mem_ctx, return result; } -static NTSTATUS cmd_dfs_getinfo(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_dfs_getinfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { NTSTATUS result; @@ -212,7 +212,7 @@ static NTSTATUS cmd_dfs_getinfo(struct cli_state *cli, TALLOC_CTX *mem_ctx, if (argc == 5) info_level = atoi(argv[4]); - result = cli_dfs_get_info(cli, mem_ctx, entrypath, servername, + result = rpccli_dfs_get_info(cli, mem_ctx, entrypath, servername, sharename, info_level, &ctr); if (NT_STATUS_IS_OK(result)) @@ -227,11 +227,11 @@ struct cmd_set dfs_commands[] = { { "DFS" }, - { "dfsexist", RPC_RTYPE_NTSTATUS, cmd_dfs_exist, NULL, PI_NETDFS, "Query DFS support", "" }, - { "dfsadd", RPC_RTYPE_NTSTATUS, cmd_dfs_add, NULL, PI_NETDFS, "Add a DFS share", "" }, - { "dfsremove", RPC_RTYPE_NTSTATUS, cmd_dfs_remove, NULL, PI_NETDFS, "Remove a DFS share", "" }, - { "dfsgetinfo",RPC_RTYPE_NTSTATUS, cmd_dfs_getinfo, NULL, PI_NETDFS, "Query DFS share info", "" }, - { "dfsenum", RPC_RTYPE_NTSTATUS, cmd_dfs_enum, NULL, PI_NETDFS, "Enumerate dfs shares", "" }, + { "dfsexist", RPC_RTYPE_NTSTATUS, cmd_dfs_exist, NULL, PI_NETDFS, NULL, "Query DFS support", "" }, + { "dfsadd", RPC_RTYPE_NTSTATUS, cmd_dfs_add, NULL, PI_NETDFS, NULL, "Add a DFS share", "" }, + { "dfsremove", RPC_RTYPE_NTSTATUS, cmd_dfs_remove, NULL, PI_NETDFS, NULL, "Remove a DFS share", "" }, + { "dfsgetinfo",RPC_RTYPE_NTSTATUS, cmd_dfs_getinfo, NULL, PI_NETDFS, NULL, "Query DFS share info", "" }, + { "dfsenum", RPC_RTYPE_NTSTATUS, cmd_dfs_enum, NULL, PI_NETDFS, NULL, "Enumerate dfs shares", "" }, { NULL } }; diff --git a/source3/rpcclient/cmd_ds.c b/source3/rpcclient/cmd_ds.c index 0a1fd7e012..951d18a710 100644 --- a/source3/rpcclient/cmd_ds.c +++ b/source3/rpcclient/cmd_ds.c @@ -24,14 +24,14 @@ /* Look up domain related information on a remote host */ -static NTSTATUS cmd_ds_dsrole_getprimarydominfo(struct cli_state *cli, +static NTSTATUS cmd_ds_dsrole_getprimarydominfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { NTSTATUS result; DS_DOMINFO_CTR ctr; - result = cli_ds_getprimarydominfo( cli, mem_ctx, DsRolePrimaryDomainInfoBasic, &ctr ); + result = rpccli_ds_getprimarydominfo( cli, mem_ctx, DsRolePrimaryDomainInfoBasic, &ctr ); if ( NT_STATUS_IS_OK(result) ) { printf ("Machine Role = [%d]\n", ctr.basic->machine_role); @@ -47,7 +47,7 @@ static NTSTATUS cmd_ds_dsrole_getprimarydominfo(struct cli_state *cli, return result; } -static NTSTATUS cmd_ds_enum_domain_trusts(struct cli_state *cli, +static NTSTATUS cmd_ds_enum_domain_trusts(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -57,7 +57,7 @@ static NTSTATUS cmd_ds_enum_domain_trusts(struct cli_state *cli, unsigned int num_domains = 0; int i; - result = cli_ds_enum_domain_trusts( cli, mem_ctx, cli->desthost, flags, + result = rpccli_ds_enum_domain_trusts( cli, mem_ctx, cli->cli->desthost, flags, &trusts, &num_domains ); printf( "%d domains returned\n", num_domains ); @@ -74,8 +74,8 @@ struct cmd_set ds_commands[] = { { "LSARPC-DS" }, - { "dsroledominfo", RPC_RTYPE_NTSTATUS, cmd_ds_dsrole_getprimarydominfo, NULL, PI_LSARPC_DS, "Get Primary Domain Information", "" }, - { "dsenumdomtrusts", RPC_RTYPE_NTSTATUS, cmd_ds_enum_domain_trusts, NULL, PI_NETLOGON, "Enumerate all trusted domains in an AD forest", "" }, + { "dsroledominfo", RPC_RTYPE_NTSTATUS, cmd_ds_dsrole_getprimarydominfo, NULL, PI_LSARPC_DS, NULL, "Get Primary Domain Information", "" }, + { "dsenumdomtrusts", RPC_RTYPE_NTSTATUS, cmd_ds_enum_domain_trusts, NULL, PI_NETLOGON, NULL, "Enumerate all trusted domains in an AD forest", "" }, - { NULL } +{ NULL } }; diff --git a/source3/rpcclient/cmd_echo.c b/source3/rpcclient/cmd_echo.c index fce8e4c7b8..6d608ebaf1 100644 --- a/source3/rpcclient/cmd_echo.c +++ b/source3/rpcclient/cmd_echo.c @@ -22,7 +22,7 @@ #include "includes.h" #include "rpcclient.h" -static NTSTATUS cmd_echo_add_one(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_echo_add_one(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { uint32 request = 1, response; @@ -36,7 +36,7 @@ static NTSTATUS cmd_echo_add_one(struct cli_state *cli, TALLOC_CTX *mem_ctx, if (argc == 2) request = atoi(argv[1]); - result = cli_echo_add_one(cli, mem_ctx, request, &response); + result = rpccli_echo_add_one(cli, mem_ctx, request, &response); if (!NT_STATUS_IS_OK(result)) goto done; @@ -47,7 +47,7 @@ done: return result; } -static NTSTATUS cmd_echo_data(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_echo_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { uint32 size, i; @@ -65,7 +65,7 @@ static NTSTATUS cmd_echo_data(struct cli_state *cli, TALLOC_CTX *mem_ctx, for (i = 0; i < size; i++) in_data[i] = i & 0xff; - result = cli_echo_data(cli, mem_ctx, size, in_data, &out_data); + result = rpccli_echo_data(cli, mem_ctx, size, in_data, &out_data); if (!NT_STATUS_IS_OK(result)) goto done; @@ -84,7 +84,7 @@ done: return result; } -static NTSTATUS cmd_echo_source_data(struct cli_state *cli, +static NTSTATUS cmd_echo_source_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -99,7 +99,7 @@ static NTSTATUS cmd_echo_source_data(struct cli_state *cli, size = atoi(argv[1]); - result = cli_echo_source_data(cli, mem_ctx, size, &out_data); + result = rpccli_echo_source_data(cli, mem_ctx, size, &out_data); if (!NT_STATUS_IS_OK(result)) goto done; @@ -116,7 +116,7 @@ done: return result; } -static NTSTATUS cmd_echo_sink_data(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_echo_sink_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { uint32 size, i; @@ -134,7 +134,7 @@ static NTSTATUS cmd_echo_sink_data(struct cli_state *cli, TALLOC_CTX *mem_ctx, for (i = 0; i < size; i++) in_data[i] = i & 0xff; - result = cli_echo_sink_data(cli, mem_ctx, size, in_data); + result = rpccli_echo_sink_data(cli, mem_ctx, size, in_data); if (!NT_STATUS_IS_OK(result)) goto done; @@ -151,9 +151,9 @@ struct cmd_set echo_commands[] = { { "ECHO" }, - { "echoaddone", RPC_RTYPE_NTSTATUS, cmd_echo_add_one, NULL, PI_ECHO, "Add one to a number", "" }, - { "echodata", RPC_RTYPE_NTSTATUS, cmd_echo_data, NULL, PI_ECHO, "Echo data", "" }, - { "sinkdata", RPC_RTYPE_NTSTATUS, cmd_echo_sink_data, NULL, PI_ECHO, "Sink data", "" }, - { "sourcedata", RPC_RTYPE_NTSTATUS, cmd_echo_source_data, NULL, PI_ECHO, "Source data", "" }, + { "echoaddone", RPC_RTYPE_NTSTATUS, cmd_echo_add_one, NULL, PI_ECHO, NULL, "Add one to a number", "" }, + { "echodata", RPC_RTYPE_NTSTATUS, cmd_echo_data, NULL, PI_ECHO, NULL, "Echo data", "" }, + { "sinkdata", RPC_RTYPE_NTSTATUS, cmd_echo_sink_data, NULL, PI_ECHO, NULL, "Sink data", "" }, + { "sourcedata", RPC_RTYPE_NTSTATUS, cmd_echo_source_data, NULL, PI_ECHO, NULL, "Source data", "" }, { NULL } }; diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index b01f639247..00ed515245 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -26,7 +26,7 @@ /* useful function to allow entering a name instead of a SID and * looking it up automatically */ -static NTSTATUS name_to_sid(struct cli_state *cli, +static NTSTATUS name_to_sid(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, DOM_SID *sid, const char *name) { @@ -41,17 +41,17 @@ static NTSTATUS name_to_sid(struct cli_state *cli, return NT_STATUS_OK; } - result = cli_lsa_open_policy(cli, mem_ctx, True, + result = rpccli_lsa_open_policy(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_lookup_names(cli, mem_ctx, &pol, 1, &name, &sids, &sid_types); + result = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, 1, &name, &sids, &sid_types); if (!NT_STATUS_IS_OK(result)) goto done; - cli_lsa_close(cli, mem_ctx, &pol); + rpccli_lsa_close(cli, mem_ctx, &pol); *sid = sids[0]; @@ -62,7 +62,7 @@ done: /* Look up domain related information on a remote host */ -static NTSTATUS cmd_lsa_query_info_policy(struct cli_state *cli, +static NTSTATUS cmd_lsa_query_info_policy(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -88,25 +88,25 @@ static NTSTATUS cmd_lsa_query_info_policy(struct cli_state *cli, /* Lookup info policy */ switch (info_class) { case 12: - result = cli_lsa_open_policy2(cli, mem_ctx, True, + result = rpccli_lsa_open_policy2(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_query_info_policy2(cli, mem_ctx, &pol, + result = rpccli_lsa_query_info_policy2(cli, mem_ctx, &pol, info_class, &domain_name, &dns_name, &forest_name, &dom_guid, &dom_sid); break; default: - result = cli_lsa_open_policy(cli, mem_ctx, True, + result = rpccli_lsa_open_policy(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_query_info_policy(cli, mem_ctx, &pol, + result = rpccli_lsa_query_info_policy(cli, mem_ctx, &pol, info_class, &domain_name, &dom_sid); } @@ -130,13 +130,16 @@ static NTSTATUS cmd_lsa_query_info_policy(struct cli_state *cli, printf("domain GUID is "); smb_uuid_string_static(*dom_guid); } + + rpccli_lsa_close(cli, mem_ctx, &pol); + done: return result; } /* Resolve a list of names to a list of sids */ -static NTSTATUS cmd_lsa_lookup_names(struct cli_state *cli, +static NTSTATUS cmd_lsa_lookup_names(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -151,14 +154,14 @@ static NTSTATUS cmd_lsa_lookup_names(struct cli_state *cli, return NT_STATUS_OK; } - result = cli_lsa_open_policy(cli, mem_ctx, True, + result = rpccli_lsa_open_policy(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1, + result = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1, (const char**)(argv + 1), &sids, &types); if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) != @@ -176,7 +179,7 @@ static NTSTATUS cmd_lsa_lookup_names(struct cli_state *cli, sid_type_lookup(types[i]), types[i]); } - cli_lsa_close(cli, mem_ctx, &pol); + rpccli_lsa_close(cli, mem_ctx, &pol); done: return result; @@ -184,7 +187,7 @@ static NTSTATUS cmd_lsa_lookup_names(struct cli_state *cli, /* Resolve a list of SIDs to a list of names */ -static NTSTATUS cmd_lsa_lookup_sids(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_lsa_lookup_sids(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { POLICY_HND pol; @@ -200,7 +203,7 @@ static NTSTATUS cmd_lsa_lookup_sids(struct cli_state *cli, TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } - result = cli_lsa_open_policy(cli, mem_ctx, True, + result = rpccli_lsa_open_policy(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); @@ -224,7 +227,7 @@ static NTSTATUS cmd_lsa_lookup_sids(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Lookup the SIDs */ - result = cli_lsa_lookup_sids(cli, mem_ctx, &pol, argc - 1, sids, + result = rpccli_lsa_lookup_sids(cli, mem_ctx, &pol, argc - 1, sids, &domains, &names, &types); if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) != @@ -244,7 +247,7 @@ static NTSTATUS cmd_lsa_lookup_sids(struct cli_state *cli, TALLOC_CTX *mem_ctx, names[i] ? names[i] : "*unknown*", types[i]); } - cli_lsa_close(cli, mem_ctx, &pol); + rpccli_lsa_close(cli, mem_ctx, &pol); done: return result; @@ -252,7 +255,7 @@ static NTSTATUS cmd_lsa_lookup_sids(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Enumerate list of trusted domains */ -static NTSTATUS cmd_lsa_enum_trust_dom(struct cli_state *cli, +static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -275,7 +278,7 @@ static NTSTATUS cmd_lsa_enum_trust_dom(struct cli_state *cli, enum_ctx = atoi(argv[2]); } - result = cli_lsa_open_policy(cli, mem_ctx, True, + result = rpccli_lsa_open_policy(cli, mem_ctx, True, POLICY_VIEW_LOCAL_INFORMATION, &pol); @@ -288,7 +291,7 @@ static NTSTATUS cmd_lsa_enum_trust_dom(struct cli_state *cli, /* Lookup list of trusted domains */ - result = cli_lsa_enum_trust_dom(cli, mem_ctx, &pol, &enum_ctx, + result = rpccli_lsa_enum_trust_dom(cli, mem_ctx, &pol, &enum_ctx, &num_domains, &domain_names, &domain_sids); if (!NT_STATUS_IS_OK(result) && @@ -307,13 +310,14 @@ static NTSTATUS cmd_lsa_enum_trust_dom(struct cli_state *cli, } } + rpccli_lsa_close(cli, mem_ctx, &pol); done: return result; } /* Enumerates privileges */ -static NTSTATUS cmd_lsa_enum_privilege(struct cli_state *cli, +static NTSTATUS cmd_lsa_enum_privilege(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -339,14 +343,14 @@ static NTSTATUS cmd_lsa_enum_privilege(struct cli_state *cli, if (argc==3) pref_max_length=atoi(argv[2]); - result = cli_lsa_open_policy(cli, mem_ctx, True, + result = rpccli_lsa_open_policy(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_enum_privilege(cli, mem_ctx, &pol, &enum_context, pref_max_length, + result = rpccli_lsa_enum_privilege(cli, mem_ctx, &pol, &enum_context, pref_max_length, &count, &privs_name, &privs_high, &privs_low); if (!NT_STATUS_IS_OK(result)) @@ -360,13 +364,14 @@ static NTSTATUS cmd_lsa_enum_privilege(struct cli_state *cli, privs_high[i], privs_low[i], privs_high[i], privs_low[i]); } + rpccli_lsa_close(cli, mem_ctx, &pol); done: return result; } /* Get privilege name */ -static NTSTATUS cmd_lsa_get_dispname(struct cli_state *cli, +static NTSTATUS cmd_lsa_get_dispname(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -383,14 +388,14 @@ static NTSTATUS cmd_lsa_get_dispname(struct cli_state *cli, return NT_STATUS_OK; } - result = cli_lsa_open_policy(cli, mem_ctx, True, + result = rpccli_lsa_open_policy(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_get_dispname(cli, mem_ctx, &pol, argv[1], lang_id, lang_id_sys, description, &lang_id_desc); + result = rpccli_lsa_get_dispname(cli, mem_ctx, &pol, argv[1], lang_id, lang_id_sys, description, &lang_id_desc); if (!NT_STATUS_IS_OK(result)) goto done; @@ -398,13 +403,14 @@ static NTSTATUS cmd_lsa_get_dispname(struct cli_state *cli, /* Print results */ printf("%s -> %s (language: 0x%x)\n", argv[1], description, lang_id_desc); + rpccli_lsa_close(cli, mem_ctx, &pol); done: return result; } /* Enumerate the LSA SIDS */ -static NTSTATUS cmd_lsa_enum_sids(struct cli_state *cli, +static NTSTATUS cmd_lsa_enum_sids(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -428,14 +434,14 @@ static NTSTATUS cmd_lsa_enum_sids(struct cli_state *cli, if (argc==3) pref_max_length=atoi(argv[2]); - result = cli_lsa_open_policy(cli, mem_ctx, True, + result = rpccli_lsa_open_policy(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_enum_sids(cli, mem_ctx, &pol, &enum_context, pref_max_length, + result = rpccli_lsa_enum_sids(cli, mem_ctx, &pol, &enum_context, pref_max_length, &count, &sids); if (!NT_STATUS_IS_OK(result)) @@ -451,13 +457,14 @@ static NTSTATUS cmd_lsa_enum_sids(struct cli_state *cli, printf("%s\n", sid_str); } + rpccli_lsa_close(cli, mem_ctx, &pol); done: return result; } /* Create a new account */ -static NTSTATUS cmd_lsa_create_account(struct cli_state *cli, +static NTSTATUS cmd_lsa_create_account(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -477,14 +484,14 @@ static NTSTATUS cmd_lsa_create_account(struct cli_state *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_open_policy2(cli, mem_ctx, True, + result = rpccli_lsa_open_policy2(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &dom_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_create_account(cli, mem_ctx, &dom_pol, &sid, des_access, &user_pol); + result = rpccli_lsa_create_account(cli, mem_ctx, &dom_pol, &sid, des_access, &user_pol); if (!NT_STATUS_IS_OK(result)) goto done; @@ -492,6 +499,7 @@ static NTSTATUS cmd_lsa_create_account(struct cli_state *cli, printf("Account for SID %s successfully created\n\n", argv[1]); result = NT_STATUS_OK; + rpccli_lsa_close(cli, mem_ctx, &dom_pol); done: return result; } @@ -499,7 +507,7 @@ static NTSTATUS cmd_lsa_create_account(struct cli_state *cli, /* Enumerate the privileges of an SID */ -static NTSTATUS cmd_lsa_enum_privsaccounts(struct cli_state *cli, +static NTSTATUS cmd_lsa_enum_privsaccounts(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -522,19 +530,19 @@ static NTSTATUS cmd_lsa_enum_privsaccounts(struct cli_state *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_open_policy2(cli, mem_ctx, True, + result = rpccli_lsa_open_policy2(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &dom_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_open_account(cli, mem_ctx, &dom_pol, &sid, access_desired, &user_pol); + result = rpccli_lsa_open_account(cli, mem_ctx, &dom_pol, &sid, access_desired, &user_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_enum_privsaccount(cli, mem_ctx, &user_pol, &count, &set); + result = rpccli_lsa_enum_privsaccount(cli, mem_ctx, &user_pol, &count, &set); if (!NT_STATUS_IS_OK(result)) goto done; @@ -547,6 +555,7 @@ static NTSTATUS cmd_lsa_enum_privsaccounts(struct cli_state *cli, printf("%u\t%u\t%u\n", set[i].luid.high, set[i].luid.low, set[i].attr); } + rpccli_lsa_close(cli, mem_ctx, &dom_pol); done: return result; } @@ -554,7 +563,7 @@ static NTSTATUS cmd_lsa_enum_privsaccounts(struct cli_state *cli, /* Enumerate the privileges of an SID via LsaEnumerateAccountRights */ -static NTSTATUS cmd_lsa_enum_acct_rights(struct cli_state *cli, +static NTSTATUS cmd_lsa_enum_acct_rights(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -576,14 +585,14 @@ static NTSTATUS cmd_lsa_enum_acct_rights(struct cli_state *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_open_policy2(cli, mem_ctx, True, + result = rpccli_lsa_open_policy2(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &dom_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_enum_account_rights(cli, mem_ctx, &dom_pol, &sid, &count, &rights); + result = rpccli_lsa_enum_account_rights(cli, mem_ctx, &dom_pol, &sid, &count, &rights); if (!NT_STATUS_IS_OK(result)) goto done; @@ -594,6 +603,7 @@ static NTSTATUS cmd_lsa_enum_acct_rights(struct cli_state *cli, printf("\t%s\n", rights[i]); } + rpccli_lsa_close(cli, mem_ctx, &dom_pol); done: return result; } @@ -601,7 +611,7 @@ static NTSTATUS cmd_lsa_enum_acct_rights(struct cli_state *cli, /* add some privileges to a SID via LsaAddAccountRights */ -static NTSTATUS cmd_lsa_add_acct_rights(struct cli_state *cli, +static NTSTATUS cmd_lsa_add_acct_rights(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -619,19 +629,20 @@ static NTSTATUS cmd_lsa_add_acct_rights(struct cli_state *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_open_policy2(cli, mem_ctx, True, + result = rpccli_lsa_open_policy2(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &dom_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_add_account_rights(cli, mem_ctx, &dom_pol, sid, + result = rpccli_lsa_add_account_rights(cli, mem_ctx, &dom_pol, sid, argc-2, argv+2); if (!NT_STATUS_IS_OK(result)) goto done; + rpccli_lsa_close(cli, mem_ctx, &dom_pol); done: return result; } @@ -639,7 +650,7 @@ static NTSTATUS cmd_lsa_add_acct_rights(struct cli_state *cli, /* remove some privileges to a SID via LsaRemoveAccountRights */ -static NTSTATUS cmd_lsa_remove_acct_rights(struct cli_state *cli, +static NTSTATUS cmd_lsa_remove_acct_rights(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -657,19 +668,21 @@ static NTSTATUS cmd_lsa_remove_acct_rights(struct cli_state *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_open_policy2(cli, mem_ctx, True, + result = rpccli_lsa_open_policy2(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &dom_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_remove_account_rights(cli, mem_ctx, &dom_pol, sid, + result = rpccli_lsa_remove_account_rights(cli, mem_ctx, &dom_pol, sid, False, argc-2, argv+2); if (!NT_STATUS_IS_OK(result)) goto done; + rpccli_lsa_close(cli, mem_ctx, &dom_pol); + done: return result; } @@ -677,7 +690,7 @@ static NTSTATUS cmd_lsa_remove_acct_rights(struct cli_state *cli, /* Get a privilege value given its name */ -static NTSTATUS cmd_lsa_lookup_priv_value(struct cli_state *cli, +static NTSTATUS cmd_lsa_lookup_priv_value(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -690,14 +703,14 @@ static NTSTATUS cmd_lsa_lookup_priv_value(struct cli_state *cli, return NT_STATUS_OK; } - result = cli_lsa_open_policy2(cli, mem_ctx, True, + result = rpccli_lsa_open_policy2(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_lookup_priv_value(cli, mem_ctx, &pol, argv[1], &luid); + result = rpccli_lsa_lookup_priv_value(cli, mem_ctx, &pol, argv[1], &luid); if (!NT_STATUS_IS_OK(result)) goto done; @@ -706,13 +719,14 @@ static NTSTATUS cmd_lsa_lookup_priv_value(struct cli_state *cli, printf("%u:%u (0x%x:0x%x)\n", luid.high, luid.low, luid.high, luid.low); + rpccli_lsa_close(cli, mem_ctx, &pol); done: return result; } /* Query LSA security object */ -static NTSTATUS cmd_lsa_query_secobj(struct cli_state *cli, +static NTSTATUS cmd_lsa_query_secobj(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -726,14 +740,14 @@ static NTSTATUS cmd_lsa_query_secobj(struct cli_state *cli, return NT_STATUS_OK; } - result = cli_lsa_open_policy2(cli, mem_ctx, True, + result = rpccli_lsa_open_policy2(cli, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_query_secobj(cli, mem_ctx, &pol, sec_info, &sdb); + result = rpccli_lsa_query_secobj(cli, mem_ctx, &pol, sec_info, &sdb); if (!NT_STATUS_IS_OK(result)) goto done; @@ -742,6 +756,7 @@ static NTSTATUS cmd_lsa_query_secobj(struct cli_state *cli, display_sec_desc(sdb->sec); + rpccli_lsa_close(cli, mem_ctx, &pol); done: return result; } @@ -800,7 +815,7 @@ static void display_trust_dom_info(LSA_TRUSTED_DOMAIN_INFO *info, uint32 info_cl } } -static NTSTATUS cmd_lsa_query_trustdominfobysid(struct cli_state *cli, +static NTSTATUS cmd_lsa_query_trustdominfobysid(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -823,12 +838,12 @@ static NTSTATUS cmd_lsa_query_trustdominfobysid(struct cli_state *cli, if (argc == 3) info_class = atoi(argv[2]); - result = cli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol); + result = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_query_trusted_domain_info_by_sid(cli, mem_ctx, &pol, + result = rpccli_lsa_query_trusted_domain_info_by_sid(cli, mem_ctx, &pol, info_class, &dom_sid, &info); if (!NT_STATUS_IS_OK(result)) @@ -838,12 +853,12 @@ static NTSTATUS cmd_lsa_query_trustdominfobysid(struct cli_state *cli, done: if (&pol) - cli_lsa_close(cli, mem_ctx, &pol); + rpccli_lsa_close(cli, mem_ctx, &pol); return result; } -static NTSTATUS cmd_lsa_query_trustdominfobyname(struct cli_state *cli, +static NTSTATUS cmd_lsa_query_trustdominfobyname(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -861,12 +876,12 @@ static NTSTATUS cmd_lsa_query_trustdominfobyname(struct cli_state *cli, if (argc == 3) info_class = atoi(argv[2]); - result = cli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol); + result = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_query_trusted_domain_info_by_name(cli, mem_ctx, &pol, + result = rpccli_lsa_query_trusted_domain_info_by_name(cli, mem_ctx, &pol, info_class, argv[1], &info); if (!NT_STATUS_IS_OK(result)) @@ -876,12 +891,12 @@ static NTSTATUS cmd_lsa_query_trustdominfobyname(struct cli_state *cli, done: if (&pol) - cli_lsa_close(cli, mem_ctx, &pol); + rpccli_lsa_close(cli, mem_ctx, &pol); return result; } -static NTSTATUS cmd_lsa_query_trustdominfo(struct cli_state *cli, +static NTSTATUS cmd_lsa_query_trustdominfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -904,18 +919,18 @@ static NTSTATUS cmd_lsa_query_trustdominfo(struct cli_state *cli, if (argc == 3) info_class = atoi(argv[2]); - result = cli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol); + result = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_open_trusted_domain(cli, mem_ctx, &pol, + result = rpccli_lsa_open_trusted_domain(cli, mem_ctx, &pol, &dom_sid, access_mask, &trustdom_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_lsa_query_trusted_domain_info(cli, mem_ctx, &trustdom_pol, + result = rpccli_lsa_query_trusted_domain_info(cli, mem_ctx, &trustdom_pol, info_class, &dom_sid, &info); if (!NT_STATUS_IS_OK(result)) @@ -925,7 +940,7 @@ static NTSTATUS cmd_lsa_query_trustdominfo(struct cli_state *cli, done: if (&pol) - cli_lsa_close(cli, mem_ctx, &pol); + rpccli_lsa_close(cli, mem_ctx, &pol); return result; } @@ -938,27 +953,27 @@ struct cmd_set lsarpc_commands[] = { { "LSARPC" }, - { "lsaquery", RPC_RTYPE_NTSTATUS, cmd_lsa_query_info_policy, NULL, PI_LSARPC, "Query info policy", "" }, - { "lookupsids", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_sids, NULL, PI_LSARPC, "Convert SIDs to names", "" }, - { "lookupnames", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_names, NULL, PI_LSARPC, "Convert names to SIDs", "" }, - { "enumtrust", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_trust_dom, NULL, PI_LSARPC, "Enumerate trusted domains", "Usage: [preferred max number] [enum context (0)]" }, - { "enumprivs", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_privilege, NULL, PI_LSARPC, "Enumerate privileges", "" }, - { "getdispname", RPC_RTYPE_NTSTATUS, cmd_lsa_get_dispname, NULL, PI_LSARPC, "Get the privilege name", "" }, - { "lsaenumsid", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_sids, NULL, PI_LSARPC, "Enumerate the LSA SIDS", "" }, - { "lsacreateaccount", RPC_RTYPE_NTSTATUS, cmd_lsa_create_account, NULL, PI_LSARPC, "Create a new lsa account", "" }, - { "lsaenumprivsaccount", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_privsaccounts, NULL, PI_LSARPC, "Enumerate the privileges of an SID", "" }, - { "lsaenumacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_acct_rights, NULL, PI_LSARPC, "Enumerate the rights of an SID", "" }, + { "lsaquery", RPC_RTYPE_NTSTATUS, cmd_lsa_query_info_policy, NULL, PI_LSARPC, NULL, "Query info policy", "" }, + { "lookupsids", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_sids, NULL, PI_LSARPC, NULL, "Convert SIDs to names", "" }, + { "lookupnames", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_names, NULL, PI_LSARPC, NULL, "Convert names to SIDs", "" }, + { "enumtrust", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_trust_dom, NULL, PI_LSARPC, NULL, "Enumerate trusted domains", "Usage: [preferred max number] [enum context (0)]" }, + { "enumprivs", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_privilege, NULL, PI_LSARPC, NULL, "Enumerate privileges", "" }, + { "getdispname", RPC_RTYPE_NTSTATUS, cmd_lsa_get_dispname, NULL, PI_LSARPC, NULL, "Get the privilege name", "" }, + { "lsaenumsid", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_sids, NULL, PI_LSARPC, NULL, "Enumerate the LSA SIDS", "" }, + { "lsacreateaccount", RPC_RTYPE_NTSTATUS, cmd_lsa_create_account, NULL, PI_LSARPC, NULL, "Create a new lsa account", "" }, + { "lsaenumprivsaccount", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_privsaccounts, NULL, PI_LSARPC, NULL, "Enumerate the privileges of an SID", "" }, + { "lsaenumacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_acct_rights, NULL, PI_LSARPC, NULL, "Enumerate the rights of an SID", "" }, #if 0 { "lsaaddpriv", RPC_RTYPE_NTSTATUS, cmd_lsa_add_priv, NULL, PI_LSARPC, "Assign a privilege to a SID", "" }, { "lsadelpriv", RPC_RTYPE_NTSTATUS, cmd_lsa_del_priv, NULL, PI_LSARPC, "Revoke a privilege from a SID", "" }, #endif - { "lsaaddacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_add_acct_rights, NULL, PI_LSARPC, "Add rights to an account", "" }, - { "lsaremoveacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_remove_acct_rights, NULL, PI_LSARPC, "Remove rights from an account", "" }, - { "lsalookupprivvalue", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_priv_value, NULL, PI_LSARPC, "Get a privilege value given its name", "" }, - { "lsaquerysecobj", RPC_RTYPE_NTSTATUS, cmd_lsa_query_secobj, NULL, PI_LSARPC, "Query LSA security object", "" }, - { "lsaquerytrustdominfo",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfo, NULL, PI_LSARPC, "Query LSA trusted domains info (given a SID)", "" }, - { "lsaquerytrustdominfobyname",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfobyname, NULL, PI_LSARPC, "Query LSA trusted domains info (given a name), only works for Windows > 2k", "" }, - { "lsaquerytrustdominfobysid",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfobysid, NULL, PI_LSARPC, "Query LSA trusted domains info (given a SID)", "" }, + { "lsaaddacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_add_acct_rights, NULL, PI_LSARPC, NULL, "Add rights to an account", "" }, + { "lsaremoveacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_remove_acct_rights, NULL, PI_LSARPC, NULL, "Remove rights from an account", "" }, + { "lsalookupprivvalue", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_priv_value, NULL, PI_LSARPC, NULL, "Get a privilege value given its name", "" }, + { "lsaquerysecobj", RPC_RTYPE_NTSTATUS, cmd_lsa_query_secobj, NULL, PI_LSARPC, NULL, "Query LSA security object", "" }, + { "lsaquerytrustdominfo",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfo, NULL, PI_LSARPC, NULL, "Query LSA trusted domains info (given a SID)", "" }, + { "lsaquerytrustdominfobyname",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfobyname, NULL, PI_LSARPC, NULL, "Query LSA trusted domains info (given a name), only works for Windows > 2k", "" }, + { "lsaquerytrustdominfobysid",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfobysid, NULL, PI_LSARPC, NULL, "Query LSA trusted domains info (given a SID)", "" }, { NULL } }; diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index b55306ddc8..153daa5cf2 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -22,7 +22,7 @@ #include "includes.h" #include "rpcclient.h" -static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli, +static NTSTATUS cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -34,7 +34,7 @@ static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli, return NT_STATUS_OK; } - result = cli_netlogon_logon_ctrl2(cli, mem_ctx, query_level); + result = rpccli_netlogon_logon_ctrl2(cli, mem_ctx, query_level); if (!NT_STATUS_IS_OK(result)) goto done; @@ -45,7 +45,7 @@ static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli, return result; } -static NTSTATUS cmd_netlogon_getdcname(struct cli_state *cli, +static NTSTATUS cmd_netlogon_getdcname(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -57,7 +57,7 @@ static NTSTATUS cmd_netlogon_getdcname(struct cli_state *cli, return NT_STATUS_OK; } - result = cli_netlogon_getdcname(cli, mem_ctx, argv[1], dcname); + result = rpccli_netlogon_getdcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); if (!NT_STATUS_IS_OK(result)) goto done; @@ -70,7 +70,7 @@ static NTSTATUS cmd_netlogon_getdcname(struct cli_state *cli, return result; } -static NTSTATUS cmd_netlogon_logon_ctrl(struct cli_state *cli, +static NTSTATUS cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -166,7 +166,7 @@ static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, /* Perform sam synchronisation */ -static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, +static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -174,7 +174,6 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, uint32 database_id = 0, num_deltas; SAM_DELTA_HDR *hdr_deltas; SAM_DELTA_CTR *deltas; - DOM_CRED ret_creds; if (argc > 2) { fprintf(stderr, "Usage: %s [database_id]\n", argv[0]); @@ -184,12 +183,9 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, if (argc == 2) database_id = atoi(argv[1]); - /* on first call the returnAuthenticator is empty */ - memset(&ret_creds, 0, sizeof(ret_creds)); - /* Synchronise sam database */ - result = cli_netlogon_sam_sync(cli, mem_ctx, &ret_creds, database_id, + result = rpccli_netlogon_sam_sync(cli, mem_ctx, database_id, 0, &num_deltas, &hdr_deltas, &deltas); if (!NT_STATUS_IS_OK(result)) @@ -205,7 +201,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, /* Perform sam delta synchronisation */ -static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, +static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -226,7 +222,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, seqnum.low = tmp & 0xffff; seqnum.high = 0; - result = cli_netlogon_sam_deltas(cli, mem_ctx, database_id, + result = rpccli_netlogon_sam_deltas(cli, mem_ctx, database_id, seqnum, &num_deltas, &hdr_deltas, &deltas); @@ -243,7 +239,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, /* Log on a domain user */ -static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, +static NTSTATUS cmd_netlogon_sam_logon(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -252,7 +248,6 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, const char *username, *password; uint32 neg_flags = 0x000001ff; int auth_level = 2; - DOM_CRED ret_creds; /* Check arguments */ @@ -277,12 +272,8 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, /* Perform the sam logon */ - ZERO_STRUCT(ret_creds); + result = rpccli_netlogon_sam_logon(cli, mem_ctx, lp_workgroup(), username, password, logon_type); - result = cli_netlogon_sam_logon(cli, mem_ctx, &ret_creds, username, password, logon_type); - - clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), &ret_creds); - if (!NT_STATUS_IS_OK(result)) goto done; @@ -292,12 +283,11 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, /* Change the trust account password */ -static NTSTATUS cmd_netlogon_change_trust_pw(struct cli_state *cli, +static NTSTATUS cmd_netlogon_change_trust_pw(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - DOM_CRED ret_creds; /* Check arguments */ @@ -308,13 +298,9 @@ static NTSTATUS cmd_netlogon_change_trust_pw(struct cli_state *cli, /* Perform the sam logon */ - ZERO_STRUCT(ret_creds); - result = trust_pw_find_change_and_store_it(cli, mem_ctx, lp_workgroup()); - clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), &ret_creds); - if (!NT_STATUS_IS_OK(result)) goto done; @@ -329,13 +315,13 @@ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, - { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, "Logon Control 2", "" }, - { "getdcname", RPC_RTYPE_NTSTATUS, cmd_netlogon_getdcname, NULL, PI_NETLOGON, "Get trusted DC name", "" }, - { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, "Logon Control", "" }, - { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, "Sam Synchronisation", "" }, - { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, "Query Sam Deltas", "" }, - { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, "Sam Logon", "" }, - { "change_trust_pw", RPC_RTYPE_NTSTATUS, cmd_netlogon_change_trust_pw, NULL, PI_NETLOGON, "Change Trust Account Password", "" }, + { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, NULL, "Logon Control 2", "" }, + { "getdcname", RPC_RTYPE_NTSTATUS, cmd_netlogon_getdcname, NULL, PI_NETLOGON, NULL, "Get trusted DC name", "" }, + { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, NULL, "Logon Control", "" }, + { "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, NULL, "Sam Synchronisation", "" }, + { "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, NULL, "Query Sam Deltas", "" }, + { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, NULL, "Sam Logon", "" }, + { "change_trust_pw", RPC_RTYPE_NTSTATUS, cmd_netlogon_change_trust_pw, NULL, PI_NETLOGON, NULL, "Change Trust Account Password", "" }, { NULL } }; diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index acb3927105..a05c2c8a0b 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -300,14 +300,14 @@ static void display_sam_info_5(SAM_ENTRY5 *e5, SAM_STR5 *s5) /**************************************************************************** Try samr_connect4 first, then samr_conenct if it fails ****************************************************************************/ -static NTSTATUS try_samr_connects(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS try_samr_connects(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint32 access_mask, POLICY_HND *connect_pol) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - result = cli_samr_connect4(cli, mem_ctx, access_mask, connect_pol); + result = rpccli_samr_connect4(cli, mem_ctx, access_mask, connect_pol); if (!NT_STATUS_IS_OK(result)) { - result = cli_samr_connect(cli, mem_ctx, access_mask, + result = rpccli_samr_connect(cli, mem_ctx, access_mask, connect_pol); } return result; @@ -316,7 +316,7 @@ static NTSTATUS try_samr_connects(struct cli_state *cli, TALLOC_CTX *mem_ctx, /********************************************************************** * Query user information */ -static NTSTATUS cmd_samr_query_user(struct cli_state *cli, +static NTSTATUS cmd_samr_query_user(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -342,7 +342,7 @@ static NTSTATUS cmd_samr_query_user(struct cli_state *cli, sscanf(argv[3], "%x", &access_mask); - slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost); + slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost); strupper_m(server); result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS, @@ -351,14 +351,14 @@ static NTSTATUS cmd_samr_query_user(struct cli_state *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, MAXIMUM_ALLOWED_ACCESS, &domain_sid, &domain_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_open_user(cli, mem_ctx, &domain_pol, + result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol, access_mask, user_rid, &user_pol); @@ -367,7 +367,7 @@ static NTSTATUS cmd_samr_query_user(struct cli_state *cli, ZERO_STRUCT(user_ctr); - result = cli_samr_query_userinfo(cli, mem_ctx, &user_pol, + result = rpccli_samr_query_userinfo(cli, mem_ctx, &user_pol, info_level, &user_ctr); if (!NT_STATUS_IS_OK(result)) @@ -385,6 +385,10 @@ static NTSTATUS cmd_samr_query_user(struct cli_state *cli, break; } + rpccli_samr_close(cli, mem_ctx, &user_pol); + rpccli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); + done: return result; } @@ -435,7 +439,7 @@ static void display_group_info_ctr(GROUP_INFO_CTR *ctr) /*********************************************************************** * Query group information */ -static NTSTATUS cmd_samr_query_group(struct cli_state *cli, +static NTSTATUS cmd_samr_query_group(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -460,7 +464,7 @@ static NTSTATUS cmd_samr_query_group(struct cli_state *cli, if (argc > 3) sscanf(argv[3], "%x", &access_mask); - slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost); + slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost); strupper_m(server); result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS, @@ -469,21 +473,21 @@ static NTSTATUS cmd_samr_query_group(struct cli_state *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, MAXIMUM_ALLOWED_ACCESS, &domain_sid, &domain_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_open_group(cli, mem_ctx, &domain_pol, + result = rpccli_samr_open_group(cli, mem_ctx, &domain_pol, access_mask, group_rid, &group_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_query_groupinfo(cli, mem_ctx, &group_pol, + result = rpccli_samr_query_groupinfo(cli, mem_ctx, &group_pol, info_level, &group_ctr); if (!NT_STATUS_IS_OK(result)) { goto done; @@ -491,13 +495,16 @@ static NTSTATUS cmd_samr_query_group(struct cli_state *cli, display_group_info_ctr(group_ctr); + rpccli_samr_close(cli, mem_ctx, &group_pol); + rpccli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); done: return result; } /* Query groups a user is a member of */ -static NTSTATUS cmd_samr_query_usergroups(struct cli_state *cli, +static NTSTATUS cmd_samr_query_usergroups(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -522,7 +529,7 @@ static NTSTATUS cmd_samr_query_usergroups(struct cli_state *cli, if (argc > 2) sscanf(argv[2], "%x", &access_mask); - slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost); + slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost); strupper_m(server); result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS, @@ -531,21 +538,21 @@ static NTSTATUS cmd_samr_query_usergroups(struct cli_state *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, MAXIMUM_ALLOWED_ACCESS, &domain_sid, &domain_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_open_user(cli, mem_ctx, &domain_pol, + result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol, access_mask, user_rid, &user_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_query_usergroups(cli, mem_ctx, &user_pol, + result = rpccli_samr_query_usergroups(cli, mem_ctx, &user_pol, &num_groups, &user_gids); if (!NT_STATUS_IS_OK(result)) @@ -556,13 +563,16 @@ static NTSTATUS cmd_samr_query_usergroups(struct cli_state *cli, user_gids[i].g_rid, user_gids[i].attr); } + rpccli_samr_close(cli, mem_ctx, &user_pol); + rpccli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); done: return result; } /* Query aliases a user is a member of */ -static NTSTATUS cmd_samr_query_useraliases(struct cli_state *cli, +static NTSTATUS cmd_samr_query_useraliases(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -602,7 +612,7 @@ static NTSTATUS cmd_samr_query_useraliases(struct cli_state *cli, sid2[i].num_auths = sid2[i].sid.num_auths; } - slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost); + slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost); strupper_m(server); result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS, @@ -612,11 +622,11 @@ static NTSTATUS cmd_samr_query_useraliases(struct cli_state *cli, goto done; if (StrCaseCmp(argv[1], "domain")==0) - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, access_mask, &domain_sid, &domain_pol); else if (StrCaseCmp(argv[1], "builtin")==0) - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, access_mask, &global_sid_Builtin, &domain_pol); @@ -628,7 +638,7 @@ static NTSTATUS cmd_samr_query_useraliases(struct cli_state *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_query_useraliases(cli, mem_ctx, &domain_pol, + result = rpccli_samr_query_useraliases(cli, mem_ctx, &domain_pol, num_sids, sid2, &num_aliases, &alias_rids); @@ -639,13 +649,15 @@ static NTSTATUS cmd_samr_query_useraliases(struct cli_state *cli, printf("\tgroup rid:[0x%x]\n", alias_rids[i]); } + rpccli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); done: return result; } /* Query members of a group */ -static NTSTATUS cmd_samr_query_groupmem(struct cli_state *cli, +static NTSTATUS cmd_samr_query_groupmem(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -666,7 +678,7 @@ static NTSTATUS cmd_samr_query_groupmem(struct cli_state *cli, if (argc > 2) sscanf(argv[2], "%x", &access_mask); - slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost); + slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost); strupper_m(server); result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS, @@ -675,21 +687,21 @@ static NTSTATUS cmd_samr_query_groupmem(struct cli_state *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, MAXIMUM_ALLOWED_ACCESS, &domain_sid, &domain_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_open_group(cli, mem_ctx, &domain_pol, + result = rpccli_samr_open_group(cli, mem_ctx, &domain_pol, access_mask, group_rid, &group_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_query_groupmem(cli, mem_ctx, &group_pol, + result = rpccli_samr_query_groupmem(cli, mem_ctx, &group_pol, &num_members, &group_rids, &group_attrs); @@ -701,13 +713,16 @@ static NTSTATUS cmd_samr_query_groupmem(struct cli_state *cli, group_attrs[i]); } + rpccli_samr_close(cli, mem_ctx, &group_pol); + rpccli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); done: return result; } /* Enumerate domain users */ -static NTSTATUS cmd_samr_enum_dom_users(struct cli_state *cli, +static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -743,7 +758,7 @@ static NTSTATUS cmd_samr_enum_dom_users(struct cli_state *cli, /* Get domain policy handle */ - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, access_mask, &domain_sid, &domain_pol); @@ -758,7 +773,7 @@ static NTSTATUS cmd_samr_enum_dom_users(struct cli_state *cli, size = 0xffff; do { - result = cli_samr_enum_dom_users( + result = rpccli_samr_enum_dom_users( cli, mem_ctx, &domain_pol, &start_idx, acb_mask, size, &dom_users, &dom_rids, &num_dom_users); @@ -774,17 +789,17 @@ static NTSTATUS cmd_samr_enum_dom_users(struct cli_state *cli, done: if (got_domain_pol) - cli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &domain_pol); if (got_connect_pol) - cli_samr_close(cli, mem_ctx, &connect_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); return result; } /* Enumerate domain groups */ -static NTSTATUS cmd_samr_enum_dom_groups(struct cli_state *cli, +static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -815,7 +830,7 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct cli_state *cli, /* Get domain policy handle */ - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, access_mask, &domain_sid, &domain_pol); @@ -830,7 +845,7 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct cli_state *cli, size = 0xffff; do { - result = cli_samr_enum_dom_groups( + result = rpccli_samr_enum_dom_groups( cli, mem_ctx, &domain_pol, &start_idx, size, &dom_groups, &num_dom_groups); @@ -847,17 +862,17 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct cli_state *cli, done: if (got_domain_pol) - cli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &domain_pol); if (got_connect_pol) - cli_samr_close(cli, mem_ctx, &connect_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); return result; } /* Enumerate alias groups */ -static NTSTATUS cmd_samr_enum_als_groups(struct cli_state *cli, +static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -889,11 +904,11 @@ static NTSTATUS cmd_samr_enum_als_groups(struct cli_state *cli, /* Get domain policy handle */ if (StrCaseCmp(argv[1], "domain")==0) - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, access_mask, &domain_sid, &domain_pol); else if (StrCaseCmp(argv[1], "builtin")==0) - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, access_mask, &global_sid_Builtin, &domain_pol); else @@ -910,7 +925,7 @@ static NTSTATUS cmd_samr_enum_als_groups(struct cli_state *cli, size = 0xffff; /* Number of groups to retrieve */ do { - result = cli_samr_enum_als_groups( + result = rpccli_samr_enum_als_groups( cli, mem_ctx, &domain_pol, &start_idx, size, &als_groups, &num_als_groups); @@ -926,17 +941,17 @@ static NTSTATUS cmd_samr_enum_als_groups(struct cli_state *cli, done: if (got_domain_pol) - cli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &domain_pol); if (got_connect_pol) - cli_samr_close(cli, mem_ctx, &connect_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); return result; } /* Query alias membership */ -static NTSTATUS cmd_samr_query_aliasmem(struct cli_state *cli, +static NTSTATUS cmd_samr_query_aliasmem(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -967,11 +982,11 @@ static NTSTATUS cmd_samr_query_aliasmem(struct cli_state *cli, /* Open handle on domain */ if (StrCaseCmp(argv[1], "domain")==0) - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, MAXIMUM_ALLOWED_ACCESS, &domain_sid, &domain_pol); else if (StrCaseCmp(argv[1], "builtin")==0) - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, MAXIMUM_ALLOWED_ACCESS, &global_sid_Builtin, &domain_pol); else @@ -982,13 +997,13 @@ static NTSTATUS cmd_samr_query_aliasmem(struct cli_state *cli, /* Open handle on alias */ - result = cli_samr_open_alias(cli, mem_ctx, &domain_pol, + result = rpccli_samr_open_alias(cli, mem_ctx, &domain_pol, access_mask, alias_rid, &alias_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_query_aliasmem(cli, mem_ctx, &alias_pol, + result = rpccli_samr_query_aliasmem(cli, mem_ctx, &alias_pol, &num_members, &alias_sids); if (!NT_STATUS_IS_OK(result)) @@ -1001,13 +1016,16 @@ static NTSTATUS cmd_samr_query_aliasmem(struct cli_state *cli, printf("\tsid:[%s]\n", sid_str); } + rpccli_samr_close(cli, mem_ctx, &alias_pol); + rpccli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); done: return result; } /* Query display info */ -static NTSTATUS cmd_samr_query_dispinfo(struct cli_state *cli, +static NTSTATUS cmd_samr_query_dispinfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1059,7 +1077,7 @@ static NTSTATUS cmd_samr_query_dispinfo(struct cli_state *cli, /* Get domain policy handle */ - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, access_mask, &domain_sid, &domain_pol); @@ -1101,7 +1119,7 @@ static NTSTATUS cmd_samr_query_dispinfo(struct cli_state *cli, get_query_dispinfo_params( loop_count, &max_entries, &max_size); - result = cli_samr_query_dispinfo(cli, mem_ctx, &domain_pol, + result = rpccli_samr_query_dispinfo(cli, mem_ctx, &domain_pol, &start_idx, info_level, &num_entries, max_entries, max_size, &ctr); @@ -1135,13 +1153,15 @@ static NTSTATUS cmd_samr_query_dispinfo(struct cli_state *cli, } } while ( NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); + rpccli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); done: return result; } /* Query domain info */ -static NTSTATUS cmd_samr_query_dominfo(struct cli_state *cli, +static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1172,7 +1192,7 @@ static NTSTATUS cmd_samr_query_dominfo(struct cli_state *cli, /* Get domain policy handle */ - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, access_mask, &domain_sid, &domain_pol); @@ -1181,7 +1201,7 @@ static NTSTATUS cmd_samr_query_dominfo(struct cli_state *cli, /* Query domain info */ - result = cli_samr_query_dom_info(cli, mem_ctx, &domain_pol, + result = rpccli_samr_query_dom_info(cli, mem_ctx, &domain_pol, switch_level, &ctr); if (!NT_STATUS_IS_OK(result)) @@ -1213,14 +1233,14 @@ static NTSTATUS cmd_samr_query_dominfo(struct cli_state *cli, done: - cli_samr_close(cli, mem_ctx, &domain_pol); - cli_samr_close(cli, mem_ctx, &connect_pol); + rpccli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); return result; } /* Create domain user */ -static NTSTATUS cmd_samr_create_dom_user(struct cli_state *cli, +static NTSTATUS cmd_samr_create_dom_user(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1251,7 +1271,7 @@ static NTSTATUS cmd_samr_create_dom_user(struct cli_state *cli, /* Get domain policy handle */ - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, access_mask, &domain_sid, &domain_pol); @@ -1263,20 +1283,20 @@ static NTSTATUS cmd_samr_create_dom_user(struct cli_state *cli, acb_info = ACB_NORMAL; unknown = 0xe005000b; /* No idea what this is - a permission mask? */ - result = cli_samr_create_dom_user(cli, mem_ctx, &domain_pol, + result = rpccli_samr_create_dom_user(cli, mem_ctx, &domain_pol, acct_name, acb_info, unknown, &user_pol, &user_rid); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_close(cli, mem_ctx, &user_pol); + result = rpccli_samr_close(cli, mem_ctx, &user_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_close(cli, mem_ctx, &domain_pol); + result = rpccli_samr_close(cli, mem_ctx, &domain_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_close(cli, mem_ctx, &connect_pol); + result = rpccli_samr_close(cli, mem_ctx, &connect_pol); if (!NT_STATUS_IS_OK(result)) goto done; done: @@ -1285,7 +1305,7 @@ static NTSTATUS cmd_samr_create_dom_user(struct cli_state *cli, /* Create domain group */ -static NTSTATUS cmd_samr_create_dom_group(struct cli_state *cli, +static NTSTATUS cmd_samr_create_dom_group(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1314,7 +1334,7 @@ static NTSTATUS cmd_samr_create_dom_group(struct cli_state *cli, /* Get domain policy handle */ - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, access_mask, &domain_sid, &domain_pol); @@ -1323,20 +1343,20 @@ static NTSTATUS cmd_samr_create_dom_group(struct cli_state *cli, /* Create domain user */ - result = cli_samr_create_dom_group(cli, mem_ctx, &domain_pol, + result = rpccli_samr_create_dom_group(cli, mem_ctx, &domain_pol, grp_name, MAXIMUM_ALLOWED_ACCESS, &group_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_close(cli, mem_ctx, &group_pol); + result = rpccli_samr_close(cli, mem_ctx, &group_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_close(cli, mem_ctx, &domain_pol); + result = rpccli_samr_close(cli, mem_ctx, &domain_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_close(cli, mem_ctx, &connect_pol); + result = rpccli_samr_close(cli, mem_ctx, &connect_pol); if (!NT_STATUS_IS_OK(result)) goto done; done: @@ -1345,7 +1365,7 @@ static NTSTATUS cmd_samr_create_dom_group(struct cli_state *cli, /* Lookup sam names */ -static NTSTATUS cmd_samr_lookup_names(struct cli_state *cli, +static NTSTATUS cmd_samr_lookup_names(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1372,11 +1392,11 @@ static NTSTATUS cmd_samr_lookup_names(struct cli_state *cli, goto done; if (StrCaseCmp(argv[1], "domain")==0) - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, MAXIMUM_ALLOWED_ACCESS, &domain_sid, &domain_pol); else if (StrCaseCmp(argv[1], "builtin")==0) - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, MAXIMUM_ALLOWED_ACCESS, &global_sid_Builtin, &domain_pol); else @@ -1393,7 +1413,7 @@ static NTSTATUS cmd_samr_lookup_names(struct cli_state *cli, for (i = 0; i < argc - 2; i++) names[i] = argv[i + 2]; - result = cli_samr_lookup_names(cli, mem_ctx, &domain_pol, + result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol, flags, num_names, names, &num_rids, &rids, &name_types); @@ -1406,13 +1426,15 @@ static NTSTATUS cmd_samr_lookup_names(struct cli_state *cli, printf("name %s: 0x%x (%d)\n", names[i], rids[i], name_types[i]); + rpccli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); done: return result; } /* Lookup sam rids */ -static NTSTATUS cmd_samr_lookup_rids(struct cli_state *cli, +static NTSTATUS cmd_samr_lookup_rids(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1435,7 +1457,7 @@ static NTSTATUS cmd_samr_lookup_rids(struct cli_state *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, MAXIMUM_ALLOWED_ACCESS, &domain_sid, &domain_pol); @@ -1450,7 +1472,7 @@ static NTSTATUS cmd_samr_lookup_rids(struct cli_state *cli, for (i = 0; i < argc - 1; i++) sscanf(argv[i + 1], "%i", &rids[i]); - result = cli_samr_lookup_rids(cli, mem_ctx, &domain_pol, num_rids, rids, + result = rpccli_samr_lookup_rids(cli, mem_ctx, &domain_pol, num_rids, rids, &num_names, &names, &name_types); if (!NT_STATUS_IS_OK(result) && @@ -1462,13 +1484,15 @@ static NTSTATUS cmd_samr_lookup_rids(struct cli_state *cli, for (i = 0; i < num_names; i++) printf("rid 0x%x: %s (%d)\n", rids[i], names[i], name_types[i]); + rpccli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); done: return result; } /* Delete domain user */ -static NTSTATUS cmd_samr_delete_dom_user(struct cli_state *cli, +static NTSTATUS cmd_samr_delete_dom_user(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1492,7 +1516,7 @@ static NTSTATUS cmd_samr_delete_dom_user(struct cli_state *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, MAXIMUM_ALLOWED_ACCESS, &domain_sid, &domain_pol); @@ -1505,7 +1529,7 @@ static NTSTATUS cmd_samr_delete_dom_user(struct cli_state *cli, uint32 *user_rids, num_rids, *name_types; uint32 flags = 0x000003e8; /* Unknown */ - result = cli_samr_lookup_names(cli, mem_ctx, &domain_pol, + result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol, flags, 1, (const char **)&argv[1], &num_rids, &user_rids, &name_types); @@ -1513,7 +1537,7 @@ static NTSTATUS cmd_samr_delete_dom_user(struct cli_state *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_open_user(cli, mem_ctx, &domain_pol, + result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol, access_mask, user_rids[0], &user_pol); @@ -1523,13 +1547,17 @@ static NTSTATUS cmd_samr_delete_dom_user(struct cli_state *cli, /* Delete user */ - result = cli_samr_delete_dom_user(cli, mem_ctx, &user_pol); + result = rpccli_samr_delete_dom_user(cli, mem_ctx, &user_pol); if (!NT_STATUS_IS_OK(result)) goto done; /* Display results */ + rpccli_samr_close(cli, mem_ctx, &user_pol); + rpccli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); + done: return result; } @@ -1537,7 +1565,7 @@ static NTSTATUS cmd_samr_delete_dom_user(struct cli_state *cli, /********************************************************************** * Query user security object */ -static NTSTATUS cmd_samr_query_sec_obj(struct cli_state *cli, +static NTSTATUS cmd_samr_query_sec_obj(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1565,7 +1593,7 @@ static NTSTATUS cmd_samr_query_sec_obj(struct cli_state *cli, sscanf(argv[1], "%i", &user_rid); } - slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost); + slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost); strupper_m(server); result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS, &connect_pol); @@ -1574,7 +1602,7 @@ static NTSTATUS cmd_samr_query_sec_obj(struct cli_state *cli, goto done; if (domain || user_rid) - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, MAXIMUM_ALLOWED_ACCESS, &domain_sid, &domain_pol); @@ -1582,7 +1610,7 @@ static NTSTATUS cmd_samr_query_sec_obj(struct cli_state *cli, goto done; if (user_rid) - result = cli_samr_open_user(cli, mem_ctx, &domain_pol, + result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol, MAXIMUM_ALLOWED_ACCESS, user_rid, &user_pol); @@ -1601,7 +1629,7 @@ static NTSTATUS cmd_samr_query_sec_obj(struct cli_state *cli, /* Query SAM security object */ - result = cli_samr_query_sec_obj(cli, mem_ctx, pol, info_level, ctx, + result = rpccli_samr_query_sec_obj(cli, mem_ctx, pol, info_level, ctx, &sec_desc_buf); if (!NT_STATUS_IS_OK(result)) @@ -1609,12 +1637,15 @@ static NTSTATUS cmd_samr_query_sec_obj(struct cli_state *cli, display_sec_desc(sec_desc_buf->sec); + rpccli_samr_close(cli, mem_ctx, &user_pol); + rpccli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); done: talloc_destroy(ctx); return result; } -static NTSTATUS cmd_samr_get_dom_pwinfo(struct cli_state *cli, +static NTSTATUS cmd_samr_get_dom_pwinfo(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1626,7 +1657,7 @@ static NTSTATUS cmd_samr_get_dom_pwinfo(struct cli_state *cli, return NT_STATUS_OK; } - result = cli_samr_get_dom_pwinfo(cli, mem_ctx, &unk_0, &unk_1) ; + result = rpccli_samr_get_dom_pwinfo(cli, mem_ctx, &unk_0, &unk_1) ; if (NT_STATUS_IS_OK(result)) { printf("unk_0 = 0x%08x\n", unk_0); @@ -1638,7 +1669,7 @@ static NTSTATUS cmd_samr_get_dom_pwinfo(struct cli_state *cli, /* Look up domain name */ -static NTSTATUS cmd_samr_lookup_domain(struct cli_state *cli, +static NTSTATUS cmd_samr_lookup_domain(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1660,13 +1691,13 @@ static NTSTATUS cmd_samr_lookup_domain(struct cli_state *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_open_domain(cli, mem_ctx, &connect_pol, + result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, access_mask, &domain_sid, &domain_pol); if (!NT_STATUS_IS_OK(result)) goto done; - result = cli_samr_lookup_domain( + result = rpccli_samr_lookup_domain( cli, mem_ctx, &connect_pol, domain_name, &sid); sid_to_string(sid_string,&sid); @@ -1675,6 +1706,8 @@ static NTSTATUS cmd_samr_lookup_domain(struct cli_state *cli, printf("SAMR_LOOKUP_DOMAIN: Domain Name: %s Domain SID: %s\n", domain_name,sid_string); + rpccli_samr_close(cli, mem_ctx, &domain_pol); + rpccli_samr_close(cli, mem_ctx, &connect_pol); done: return result; } @@ -1686,26 +1719,26 @@ struct cmd_set samr_commands[] = { { "SAMR" }, - { "queryuser", RPC_RTYPE_NTSTATUS, cmd_samr_query_user, NULL, PI_SAMR, "Query user info", "" }, - { "querygroup", RPC_RTYPE_NTSTATUS, cmd_samr_query_group, NULL, PI_SAMR, "Query group info", "" }, - { "queryusergroups", RPC_RTYPE_NTSTATUS, cmd_samr_query_usergroups, NULL, PI_SAMR, "Query user groups", "" }, - { "queryuseraliases", RPC_RTYPE_NTSTATUS, cmd_samr_query_useraliases, NULL, PI_SAMR, "Query user aliases", "" }, - { "querygroupmem", RPC_RTYPE_NTSTATUS, cmd_samr_query_groupmem, NULL, PI_SAMR, "Query group membership", "" }, - { "queryaliasmem", RPC_RTYPE_NTSTATUS, cmd_samr_query_aliasmem, NULL, PI_SAMR, "Query alias membership", "" }, - { "querydispinfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo, NULL, PI_SAMR, "Query display info", "" }, - { "querydominfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_dominfo, NULL, PI_SAMR, "Query domain info", "" }, - { "enumdomusers", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_users, NULL, PI_SAMR, "Enumerate domain users", "" }, - { "enumdomgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_groups, NULL, PI_SAMR, "Enumerate domain groups", "" }, - { "enumalsgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_als_groups, NULL, PI_SAMR, "Enumerate alias groups", "" }, - - { "createdomuser", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_user, NULL, PI_SAMR, "Create domain user", "" }, - { "createdomgroup", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_group, NULL, PI_SAMR, "Create domain group", "" }, - { "samlookupnames", RPC_RTYPE_NTSTATUS, cmd_samr_lookup_names, NULL, PI_SAMR, "Look up names", "" }, - { "samlookuprids", RPC_RTYPE_NTSTATUS, cmd_samr_lookup_rids, NULL, PI_SAMR, "Look up names", "" }, - { "deletedomuser", RPC_RTYPE_NTSTATUS, cmd_samr_delete_dom_user, NULL, PI_SAMR, "Delete domain user", "" }, - { "samquerysecobj", RPC_RTYPE_NTSTATUS, cmd_samr_query_sec_obj, NULL, PI_SAMR, "Query SAMR security object", "" }, - { "getdompwinfo", RPC_RTYPE_NTSTATUS, cmd_samr_get_dom_pwinfo, NULL, PI_SAMR, "Retrieve domain password info", "" }, - - { "lookupdomain", RPC_RTYPE_NTSTATUS, cmd_samr_lookup_domain, NULL, PI_SAMR, "Lookup Domain Name", "" }, + { "queryuser", RPC_RTYPE_NTSTATUS, cmd_samr_query_user, NULL, PI_SAMR, NULL, "Query user info", "" }, + { "querygroup", RPC_RTYPE_NTSTATUS, cmd_samr_query_group, NULL, PI_SAMR, NULL, "Query group info", "" }, + { "queryusergroups", RPC_RTYPE_NTSTATUS, cmd_samr_query_usergroups, NULL, PI_SAMR, NULL, "Query user groups", "" }, + { "queryuseraliases", RPC_RTYPE_NTSTATUS, cmd_samr_query_useraliases, NULL, PI_SAMR, NULL, "Query user aliases", "" }, + { "querygroupmem", RPC_RTYPE_NTSTATUS, cmd_samr_query_groupmem, NULL, PI_SAMR, NULL, "Query group membership", "" }, + { "queryaliasmem", RPC_RTYPE_NTSTATUS, cmd_samr_query_aliasmem, NULL, PI_SAMR, NULL, "Query alias membership", "" }, + { "querydispinfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo, NULL, PI_SAMR, NULL, "Query display info", "" }, + { "querydominfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_dominfo, NULL, PI_SAMR, NULL, "Query domain info", "" }, + { "enumdomusers", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_users, NULL, PI_SAMR, NULL, "Enumerate domain users", "" }, + { "enumdomgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_groups, NULL, PI_SAMR, NULL, "Enumerate domain groups", "" }, + { "enumalsgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_als_groups, NULL, PI_SAMR, NULL, "Enumerate alias groups", "" }, + + { "createdomuser", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_user, NULL, PI_SAMR, NULL, "Create domain user", "" }, + { "createdomgroup", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_group, NULL, PI_SAMR, NULL, "Create domain group", "" }, + { "samlookupnames", RPC_RTYPE_NTSTATUS, cmd_samr_lookup_names, NULL, PI_SAMR, NULL, "Look up names", "" }, + { "samlookuprids", RPC_RTYPE_NTSTATUS, cmd_samr_lookup_rids, NULL, PI_SAMR, NULL, "Look up names", "" }, + { "deletedomuser", RPC_RTYPE_NTSTATUS, cmd_samr_delete_dom_user, NULL, PI_SAMR, NULL, "Delete domain user", "" }, + { "samquerysecobj", RPC_RTYPE_NTSTATUS, cmd_samr_query_sec_obj, NULL, PI_SAMR, NULL, "Query SAMR security object", "" }, + { "getdompwinfo", RPC_RTYPE_NTSTATUS, cmd_samr_get_dom_pwinfo, NULL, PI_SAMR, NULL, "Retrieve domain password info", "" }, + + { "lookupdomain", RPC_RTYPE_NTSTATUS, cmd_samr_lookup_domain, NULL, PI_SAMR, NULL, "Lookup Domain Name", "" }, { NULL } }; diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 1b3d3b7e0c..0ae16e8f1a 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -93,7 +93,7 @@ static const char *cmd_spoolss_get_short_archi(const char *long_archi) /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_open_printer_ex(struct cli_state *cli, +static WERROR cmd_spoolss_open_printer_ex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -110,20 +110,20 @@ static WERROR cmd_spoolss_open_printer_ex(struct cli_state *cli, if (!cli) return WERR_GENERAL_FAILURE; - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); fstrcpy(user, cli->user_name); fstrcpy(printername, argv[1]); /* Open the printer handle */ - werror = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, + werror = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", PRINTER_ALL_ACCESS, servername, user, &hnd); if (W_ERROR_IS_OK(werror)) { printf("Printer %s opened successfully\n", printername); - werror = cli_spoolss_close_printer(cli, mem_ctx, &hnd); + werror = rpccli_spoolss_close_printer(cli, mem_ctx, &hnd); if (!W_ERROR_IS_OK(werror)) { printf("Error closing printer handle! (%s)\n", @@ -298,7 +298,7 @@ static void display_print_info_7(PRINTER_INFO_7 *i7) /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_enum_printers(struct cli_state *cli, +static WERROR cmd_spoolss_enum_printers(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -320,13 +320,13 @@ static WERROR cmd_spoolss_enum_printers(struct cli_state *cli, if (argc == 3) fstrcpy(name, argv[2]); else { - slprintf(name, sizeof(name)-1, "\\\\%s", cli->desthost); + slprintf(name, sizeof(name)-1, "\\\\%s", cli->cli->desthost); strupper_m(name); } ZERO_STRUCT(ctr); - result = cli_spoolss_enum_printers(cli, mem_ctx, name, PRINTER_ENUM_LOCAL, + result = rpccli_spoolss_enum_printers(cli, mem_ctx, name, PRINTER_ENUM_LOCAL, info_level, &num_printers, &ctr); if (W_ERROR_IS_OK(result)) { @@ -419,7 +419,7 @@ static void display_port_info_2(PORT_INFO_2 *i2) /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_enum_ports(struct cli_state *cli, +static WERROR cmd_spoolss_enum_ports(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -440,7 +440,7 @@ static WERROR cmd_spoolss_enum_ports(struct cli_state *cli, ZERO_STRUCT(ctr); - result = cli_spoolss_enum_ports(cli, mem_ctx, info_level, &returned, &ctr); + result = rpccli_spoolss_enum_ports(cli, mem_ctx, info_level, &returned, &ctr); if (W_ERROR_IS_OK(result)) { int i; @@ -466,7 +466,7 @@ static WERROR cmd_spoolss_enum_ports(struct cli_state *cli, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_setprinter(struct cli_state *cli, +static WERROR cmd_spoolss_setprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -491,13 +491,13 @@ static WERROR cmd_spoolss_setprinter(struct cli_state *cli, fstrcpy(comment, argv[2]); } - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); slprintf(printername, sizeof(servername)-1, "%s\\%s", servername, argv[1]); fstrcpy(user, cli->user_name); /* get a printer handle */ - result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", + result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", PRINTER_ALL_ACCESS, servername, user, &pol); @@ -507,7 +507,7 @@ static WERROR cmd_spoolss_setprinter(struct cli_state *cli, opened_hnd = True; /* Get printer info */ - result = cli_spoolss_getprinter(cli, mem_ctx, &pol, info_level, &ctr); + result = rpccli_spoolss_getprinter(cli, mem_ctx, &pol, info_level, &ctr); if (!W_ERROR_IS_OK(result)) goto done; @@ -518,13 +518,13 @@ static WERROR cmd_spoolss_setprinter(struct cli_state *cli, ctr.printers_2->devmode = NULL; ctr.printers_2->secdesc = NULL; - result = cli_spoolss_setprinter(cli, mem_ctx, &pol, info_level, &ctr, 0); + result = rpccli_spoolss_setprinter(cli, mem_ctx, &pol, info_level, &ctr, 0); if (W_ERROR_IS_OK(result)) printf("Success in setting comment.\n"); done: if (opened_hnd) - cli_spoolss_close_printer(cli, mem_ctx, &pol); + rpccli_spoolss_close_printer(cli, mem_ctx, &pol); return result; } @@ -532,7 +532,7 @@ static WERROR cmd_spoolss_setprinter(struct cli_state *cli, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_setprintername(struct cli_state *cli, +static WERROR cmd_spoolss_setprintername(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -557,13 +557,13 @@ static WERROR cmd_spoolss_setprintername(struct cli_state *cli, fstrcpy(new_printername, argv[2]); } - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); slprintf(printername, sizeof(printername)-1, "%s\\%s", servername, argv[1]); fstrcpy(user, cli->user_name); /* get a printer handle */ - result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", + result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", PRINTER_ALL_ACCESS, servername, user, &pol); @@ -573,7 +573,7 @@ static WERROR cmd_spoolss_setprintername(struct cli_state *cli, opened_hnd = True; /* Get printer info */ - result = cli_spoolss_getprinter(cli, mem_ctx, &pol, info_level, &ctr); + result = rpccli_spoolss_getprinter(cli, mem_ctx, &pol, info_level, &ctr); if (!W_ERROR_IS_OK(result)) goto done; @@ -583,13 +583,13 @@ static WERROR cmd_spoolss_setprintername(struct cli_state *cli, ctr.printers_2->devmode = NULL; ctr.printers_2->secdesc = NULL; - result = cli_spoolss_setprinter(cli, mem_ctx, &pol, info_level, &ctr, 0); + result = rpccli_spoolss_setprinter(cli, mem_ctx, &pol, info_level, &ctr, 0); if (W_ERROR_IS_OK(result)) printf("Success in setting printername.\n"); done: if (opened_hnd) - cli_spoolss_close_printer(cli, mem_ctx, &pol); + rpccli_spoolss_close_printer(cli, mem_ctx, &pol); return result; } @@ -597,7 +597,7 @@ static WERROR cmd_spoolss_setprintername(struct cli_state *cli, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_getprinter(struct cli_state *cli, +static WERROR cmd_spoolss_getprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -620,14 +620,14 @@ static WERROR cmd_spoolss_getprinter(struct cli_state *cli, info_level = atoi(argv[2]); } - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); slprintf(printername, sizeof(printername)-1, "%s\\%s", servername, argv[1]); fstrcpy(user, cli->user_name); /* get a printer handle */ - result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, + result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, servername, user, &pol); @@ -638,7 +638,7 @@ static WERROR cmd_spoolss_getprinter(struct cli_state *cli, /* Get printer info */ - result = cli_spoolss_getprinter(cli, mem_ctx, &pol, info_level, &ctr); + result = rpccli_spoolss_getprinter(cli, mem_ctx, &pol, info_level, &ctr); if (!W_ERROR_IS_OK(result)) goto done; @@ -668,7 +668,7 @@ static WERROR cmd_spoolss_getprinter(struct cli_state *cli, done: if (opened_hnd) - cli_spoolss_close_printer(cli, mem_ctx, &pol); + rpccli_spoolss_close_printer(cli, mem_ctx, &pol); return result; } @@ -729,7 +729,7 @@ static void display_reg_value(REGISTRY_VALUE value) /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_getprinterdata(struct cli_state *cli, +static WERROR cmd_spoolss_getprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -751,7 +751,7 @@ static WERROR cmd_spoolss_getprinterdata(struct cli_state *cli, /* Open a printer handle */ - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); if (strncmp(argv[1], ".", sizeof(".")) == 0) fstrcpy(printername, servername); @@ -762,7 +762,7 @@ static WERROR cmd_spoolss_getprinterdata(struct cli_state *cli, /* get a printer handle */ - result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, + result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, servername, user, &pol); @@ -773,7 +773,7 @@ static WERROR cmd_spoolss_getprinterdata(struct cli_state *cli, /* Get printer info */ - result = cli_spoolss_getprinterdata(cli, mem_ctx, &pol, valuename, &value); + result = rpccli_spoolss_getprinterdata(cli, mem_ctx, &pol, valuename, &value); if (!W_ERROR_IS_OK(result)) goto done; @@ -786,7 +786,7 @@ static WERROR cmd_spoolss_getprinterdata(struct cli_state *cli, done: if (opened_hnd) - cli_spoolss_close_printer(cli, mem_ctx, &pol); + rpccli_spoolss_close_printer(cli, mem_ctx, &pol); return result; } @@ -794,7 +794,7 @@ static WERROR cmd_spoolss_getprinterdata(struct cli_state *cli, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_getprinterdataex(struct cli_state *cli, +static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -818,7 +818,7 @@ static WERROR cmd_spoolss_getprinterdataex(struct cli_state *cli, /* Open a printer handle */ - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); if (strncmp(argv[1], ".", sizeof(".")) == 0) fstrcpy(printername, servername); @@ -829,7 +829,7 @@ static WERROR cmd_spoolss_getprinterdataex(struct cli_state *cli, /* get a printer handle */ - result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, + result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, servername, user, &pol); @@ -840,7 +840,7 @@ static WERROR cmd_spoolss_getprinterdataex(struct cli_state *cli, /* Get printer info */ - result = cli_spoolss_getprinterdataex(cli, mem_ctx, &pol, keyname, + result = rpccli_spoolss_getprinterdataex(cli, mem_ctx, &pol, keyname, valuename, &value); if (!W_ERROR_IS_OK(result)) @@ -854,7 +854,7 @@ static WERROR cmd_spoolss_getprinterdataex(struct cli_state *cli, done: if (opened_hnd) - cli_spoolss_close_printer(cli, mem_ctx, &pol); + rpccli_spoolss_close_printer(cli, mem_ctx, &pol); return result; } @@ -972,7 +972,7 @@ static void display_print_driver_3(DRIVER_INFO_3 *i1) /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_getdriver(struct cli_state *cli, +static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -994,7 +994,7 @@ static WERROR cmd_spoolss_getdriver(struct cli_state *cli, } /* get the arguments need to open the printer handle */ - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); fstrcpy(user, cli->user_name); slprintf(printername, sizeof(servername)-1, "%s\\%s", servername, argv[1]); @@ -1003,7 +1003,7 @@ static WERROR cmd_spoolss_getdriver(struct cli_state *cli, /* Open a printer handle */ - werror = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", + werror = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", PRINTER_ACCESS_USE, servername, user, &pol); @@ -1018,7 +1018,7 @@ static WERROR cmd_spoolss_getdriver(struct cli_state *cli, for (i=0; archi_table[i].long_archi!=NULL; i++) { - werror = cli_spoolss_getprinterdriver( cli, mem_ctx, &pol, info_level, + werror = rpccli_spoolss_getprinterdriver( cli, mem_ctx, &pol, info_level, archi_table[i].long_archi, archi_table[i].version, &ctr); @@ -1050,7 +1050,7 @@ static WERROR cmd_spoolss_getdriver(struct cli_state *cli, /* Cleanup */ if (opened_hnd) - cli_spoolss_close_printer (cli, mem_ctx, &pol); + rpccli_spoolss_close_printer (cli, mem_ctx, &pol); if ( success ) werror = WERR_OK; @@ -1061,7 +1061,7 @@ static WERROR cmd_spoolss_getdriver(struct cli_state *cli, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_enum_drivers(struct cli_state *cli, +static WERROR cmd_spoolss_enum_drivers(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1089,7 +1089,7 @@ static WERROR cmd_spoolss_enum_drivers(struct cli_state *cli, if ( i>0 && strequal(archi_table[i].long_archi, archi_table[i-1].long_archi) ) continue; - werror = cli_spoolss_enumprinterdrivers( + werror = rpccli_spoolss_enumprinterdrivers( cli, mem_ctx, info_level, archi_table[i].long_archi, &returned, &ctr); @@ -1154,7 +1154,7 @@ static void display_printdriverdir_1(DRIVER_DIRECTORY_1 *i1) /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_getdriverdir(struct cli_state *cli, +static WERROR cmd_spoolss_getdriverdir(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1176,7 +1176,7 @@ static WERROR cmd_spoolss_getdriverdir(struct cli_state *cli, /* Get the directory. Only use Info level 1 */ - result = cli_spoolss_getprinterdriverdir(cli, mem_ctx, 1, env, &ctr); + result = rpccli_spoolss_getprinterdriverdir(cli, mem_ctx, 1, env, &ctr); if (W_ERROR_IS_OK(result)) display_printdriverdir_1(ctr.info1); @@ -1293,7 +1293,7 @@ static BOOL init_drv_info_3_members ( TALLOC_CTX *mem_ctx, DRIVER_INFO_3 *info, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_addprinterdriver(struct cli_state *cli, +static WERROR cmd_spoolss_addprinterdriver(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1344,7 +1344,7 @@ static WERROR cmd_spoolss_addprinterdriver(struct cli_state *cli, ctr.info3 = &info3; - result = cli_spoolss_addprinterdriver (cli, mem_ctx, level, &ctr); + result = rpccli_spoolss_addprinterdriver (cli, mem_ctx, level, &ctr); if (W_ERROR_IS_OK(result)) { rpcstr_pull(driver_name, info3.name.buffer, @@ -1360,7 +1360,7 @@ static WERROR cmd_spoolss_addprinterdriver(struct cli_state *cli, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_addprinterex(struct cli_state *cli, +static WERROR cmd_spoolss_addprinterex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1377,7 +1377,7 @@ static WERROR cmd_spoolss_addprinterex(struct cli_state *cli, return WERR_OK; } - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); /* Fill in the DRIVER_INFO_2 struct */ @@ -1407,7 +1407,7 @@ static WERROR cmd_spoolss_addprinterex(struct cli_state *cli, */ ctr.printers_2 = &info2; - result = cli_spoolss_addprinterex (cli, mem_ctx, level, &ctr); + result = rpccli_spoolss_addprinterex (cli, mem_ctx, level, &ctr); if (W_ERROR_IS_OK(result)) printf ("Printer %s successfully installed.\n", argv[1]); @@ -1418,7 +1418,7 @@ static WERROR cmd_spoolss_addprinterex(struct cli_state *cli, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_setdriver(struct cli_state *cli, +static WERROR cmd_spoolss_setdriver(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1439,14 +1439,14 @@ static WERROR cmd_spoolss_setdriver(struct cli_state *cli, return WERR_OK; } - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); slprintf(printername, sizeof(printername)-1, "%s\\%s", servername, argv[1]); fstrcpy(user, cli->user_name); /* Get a printer handle */ - result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", + result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", PRINTER_ALL_ACCESS, servername, user, &pol); @@ -1460,7 +1460,7 @@ static WERROR cmd_spoolss_setdriver(struct cli_state *cli, ZERO_STRUCT (info2); ctr.printers_2 = &info2; - result = cli_spoolss_getprinter(cli, mem_ctx, &pol, level, &ctr); + result = rpccli_spoolss_getprinter(cli, mem_ctx, &pol, level, &ctr); if (!W_ERROR_IS_OK(result)) { printf ("Unable to retrieve printer information!\n"); @@ -1471,7 +1471,7 @@ static WERROR cmd_spoolss_setdriver(struct cli_state *cli, init_unistr(&ctr.printers_2->drivername, argv[2]); - result = cli_spoolss_setprinter(cli, mem_ctx, &pol, level, &ctr, 0); + result = rpccli_spoolss_setprinter(cli, mem_ctx, &pol, level, &ctr, 0); if (!W_ERROR_IS_OK(result)) { printf("SetPrinter call failed!\n"); @@ -1484,7 +1484,7 @@ done: /* Cleanup */ if (opened_hnd) - cli_spoolss_close_printer(cli, mem_ctx, &pol); + rpccli_spoolss_close_printer(cli, mem_ctx, &pol); return result; } @@ -1493,7 +1493,7 @@ done: /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_deletedriverex(struct cli_state *cli, +static WERROR cmd_spoolss_deletedriverex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1526,7 +1526,7 @@ static WERROR cmd_spoolss_deletedriverex(struct cli_state *cli, continue; /* make the call to remove the driver */ - result = cli_spoolss_deleteprinterdriverex( + result = rpccli_spoolss_deleteprinterdriverex( cli, mem_ctx, archi_table[i].long_archi, argv[1], archi_table[i].version); if ( !W_ERROR_IS_OK(result) ) @@ -1551,7 +1551,7 @@ static WERROR cmd_spoolss_deletedriverex(struct cli_state *cli, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_deletedriver(struct cli_state *cli, +static WERROR cmd_spoolss_deletedriver(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1566,14 +1566,14 @@ static WERROR cmd_spoolss_deletedriver(struct cli_state *cli, return WERR_OK; } - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); /* delete the driver for all architectures */ for (i=0; archi_table[i].long_archi; i++) { /* make the call to remove the driver */ - result = cli_spoolss_deleteprinterdriver( + result = rpccli_spoolss_deleteprinterdriver( cli, mem_ctx, archi_table[i].long_archi, argv[1]); if ( !W_ERROR_IS_OK(result) ) { @@ -1596,7 +1596,7 @@ static WERROR cmd_spoolss_deletedriver(struct cli_state *cli, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_getprintprocdir(struct cli_state *cli, +static WERROR cmd_spoolss_getprintprocdir(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1610,7 +1610,7 @@ static WERROR cmd_spoolss_getprintprocdir(struct cli_state *cli, return WERR_OK; } - if (asprintf(&servername, "\\\\%s", cli->desthost) < 0) + if (asprintf(&servername, "\\\\%s", cli->cli->desthost) < 0) return WERR_NOMEM; strupper_m(servername); @@ -1620,7 +1620,7 @@ static WERROR cmd_spoolss_getprintprocdir(struct cli_state *cli, return WERR_NOMEM; } - result = cli_spoolss_getprintprocessordirectory( + result = rpccli_spoolss_getprintprocessordirectory( cli, mem_ctx, servername, environment, procdir); if (W_ERROR_IS_OK(result)) @@ -1635,7 +1635,7 @@ static WERROR cmd_spoolss_getprintprocdir(struct cli_state *cli, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_addform(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { POLICY_HND handle; @@ -1653,11 +1653,11 @@ static WERROR cmd_spoolss_addform(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Get a printer handle */ - asprintf(&servername, "\\\\%s", cli->desthost); + asprintf(&servername, "\\\\%s", cli->cli->desthost); strupper_m(servername); asprintf(&printername, "%s\\%s", servername, argv[1]); - werror = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", + werror = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", PRINTER_ALL_ACCESS, servername, cli->user_name, &handle); @@ -1680,11 +1680,11 @@ static WERROR cmd_spoolss_addform(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Add the form */ - werror = cli_spoolss_addform(cli, mem_ctx, &handle, 1, &form); + werror = rpccli_spoolss_addform(cli, mem_ctx, &handle, 1, &form); done: if (got_handle) - cli_spoolss_close_printer(cli, mem_ctx, &handle); + rpccli_spoolss_close_printer(cli, mem_ctx, &handle); SAFE_FREE(servername); SAFE_FREE(printername); @@ -1695,7 +1695,7 @@ static WERROR cmd_spoolss_addform(struct cli_state *cli, TALLOC_CTX *mem_ctx, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_setform(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { POLICY_HND handle; @@ -1713,11 +1713,11 @@ static WERROR cmd_spoolss_setform(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Get a printer handle */ - asprintf(&servername, "\\\\%s", cli->desthost); + asprintf(&servername, "\\\\%s", cli->cli->desthost); strupper_m(servername); asprintf(&printername, "%s\\%s", servername, argv[1]); - werror = cli_spoolss_open_printer_ex( + werror = rpccli_spoolss_open_printer_ex( cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, servername, cli->user_name, &handle); @@ -1739,11 +1739,11 @@ static WERROR cmd_spoolss_setform(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Set the form */ - werror = cli_spoolss_setform(cli, mem_ctx, &handle, 1, argv[2], &form); + werror = rpccli_spoolss_setform(cli, mem_ctx, &handle, 1, argv[2], &form); done: if (got_handle) - cli_spoolss_close_printer(cli, mem_ctx, &handle); + rpccli_spoolss_close_printer(cli, mem_ctx, &handle); SAFE_FREE(servername); SAFE_FREE(printername); @@ -1792,7 +1792,7 @@ static void display_form(FORM_1 *form) /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_getform(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { POLICY_HND handle; @@ -1810,11 +1810,11 @@ static WERROR cmd_spoolss_getform(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Get a printer handle */ - asprintf(&servername, "\\\\%s", cli->desthost); + asprintf(&servername, "\\\\%s", cli->cli->desthost); strupper_m(servername); asprintf(&printername, "%s\\%s", servername, argv[1]); - werror = cli_spoolss_open_printer_ex( + werror = rpccli_spoolss_open_printer_ex( cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, servername, cli->user_name, &handle); @@ -1825,7 +1825,7 @@ static WERROR cmd_spoolss_getform(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Get the form */ - werror = cli_spoolss_getform(cli, mem_ctx, &handle, argv[2], 1, &form); + werror = rpccli_spoolss_getform(cli, mem_ctx, &handle, argv[2], 1, &form); if (!W_ERROR_IS_OK(werror)) goto done; @@ -1834,7 +1834,7 @@ static WERROR cmd_spoolss_getform(struct cli_state *cli, TALLOC_CTX *mem_ctx, done: if (got_handle) - cli_spoolss_close_printer(cli, mem_ctx, &handle); + rpccli_spoolss_close_printer(cli, mem_ctx, &handle); SAFE_FREE(servername); SAFE_FREE(printername); @@ -1845,7 +1845,7 @@ static WERROR cmd_spoolss_getform(struct cli_state *cli, TALLOC_CTX *mem_ctx, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_deleteform(struct cli_state *cli, +static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1863,11 +1863,11 @@ static WERROR cmd_spoolss_deleteform(struct cli_state *cli, /* Get a printer handle */ - asprintf(&servername, "\\\\%s", cli->desthost); + asprintf(&servername, "\\\\%s", cli->cli->desthost); strupper_m(servername); asprintf(&printername, "%s\\%s", servername, argv[1]); - werror = cli_spoolss_open_printer_ex( + werror = rpccli_spoolss_open_printer_ex( cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, servername, cli->user_name, &handle); @@ -1878,11 +1878,11 @@ static WERROR cmd_spoolss_deleteform(struct cli_state *cli, /* Delete the form */ - werror = cli_spoolss_deleteform(cli, mem_ctx, &handle, argv[2]); + werror = rpccli_spoolss_deleteform(cli, mem_ctx, &handle, argv[2]); done: if (got_handle) - cli_spoolss_close_printer(cli, mem_ctx, &handle); + rpccli_spoolss_close_printer(cli, mem_ctx, &handle); SAFE_FREE(servername); SAFE_FREE(printername); @@ -1893,7 +1893,7 @@ static WERROR cmd_spoolss_deleteform(struct cli_state *cli, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_enum_forms(struct cli_state *cli, +static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1913,11 +1913,11 @@ static WERROR cmd_spoolss_enum_forms(struct cli_state *cli, /* Get a printer handle */ - asprintf(&servername, "\\\\%s", cli->desthost); + asprintf(&servername, "\\\\%s", cli->cli->desthost); strupper_m(servername); asprintf(&printername, "%s\\%s", servername, argv[1]); - werror = cli_spoolss_open_printer_ex( + werror = rpccli_spoolss_open_printer_ex( cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, servername, cli->user_name, &handle); @@ -1929,7 +1929,7 @@ static WERROR cmd_spoolss_enum_forms(struct cli_state *cli, /* Enumerate forms */ offered = needed = 0; - werror = cli_spoolss_enumforms(cli, mem_ctx, &handle, level, &num_forms, &forms); + werror = rpccli_spoolss_enumforms(cli, mem_ctx, &handle, level, &num_forms, &forms); if (!W_ERROR_IS_OK(werror)) goto done; @@ -1944,7 +1944,7 @@ static WERROR cmd_spoolss_enum_forms(struct cli_state *cli, done: if (got_handle) - cli_spoolss_close_printer(cli, mem_ctx, &handle); + rpccli_spoolss_close_printer(cli, mem_ctx, &handle); SAFE_FREE(servername); SAFE_FREE(printername); @@ -1955,7 +1955,7 @@ static WERROR cmd_spoolss_enum_forms(struct cli_state *cli, /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_setprinterdata(struct cli_state *cli, +static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -1975,7 +1975,7 @@ static WERROR cmd_spoolss_setprinterdata(struct cli_state *cli, return WERR_INVALID_PARAM; } - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); slprintf(printername, sizeof(servername)-1, "%s\\%s", servername, argv[1]); fstrcpy(user, cli->user_name); @@ -2004,7 +2004,7 @@ static WERROR cmd_spoolss_setprinterdata(struct cli_state *cli, } /* get a printer handle */ - result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", + result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, servername, user, &pol); if (!W_ERROR_IS_OK(result)) @@ -2014,7 +2014,7 @@ static WERROR cmd_spoolss_setprinterdata(struct cli_state *cli, ctr.printers_0 = &info; - result = cli_spoolss_getprinter(cli, mem_ctx, &pol, 0, &ctr); + result = rpccli_spoolss_getprinter(cli, mem_ctx, &pol, 0, &ctr); if (!W_ERROR_IS_OK(result)) goto done; @@ -2082,7 +2082,7 @@ static WERROR cmd_spoolss_setprinterdata(struct cli_state *cli, goto done; } - result = cli_spoolss_setprinterdata(cli, mem_ctx, &pol, &value); + result = rpccli_spoolss_setprinterdata(cli, mem_ctx, &pol, &value); if (!W_ERROR_IS_OK(result)) { printf ("Unable to set [%s=%s]!\n", argv[3], argv[4]); @@ -2090,7 +2090,7 @@ static WERROR cmd_spoolss_setprinterdata(struct cli_state *cli, } printf("\tSetPrinterData succeeded [%s: %s]\n", argv[3], argv[4]); - result = cli_spoolss_getprinter(cli, mem_ctx, &pol, 0, &ctr); + result = rpccli_spoolss_getprinter(cli, mem_ctx, &pol, 0, &ctr); if (!W_ERROR_IS_OK(result)) goto done; @@ -2101,7 +2101,7 @@ static WERROR cmd_spoolss_setprinterdata(struct cli_state *cli, done: /* cleanup */ if (opened_hnd) - cli_spoolss_close_printer(cli, mem_ctx, &pol); + rpccli_spoolss_close_printer(cli, mem_ctx, &pol); return result; } @@ -2151,7 +2151,7 @@ static void display_job_info_2(JOB_INFO_2 *job) /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_enum_jobs(struct cli_state *cli, +static WERROR cmd_spoolss_enum_jobs(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -2173,14 +2173,14 @@ static WERROR cmd_spoolss_enum_jobs(struct cli_state *cli, /* Open printer handle */ - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); fstrcpy(user, cli->user_name); - slprintf(printername, sizeof(servername)-1, "\\\\%s\\", cli->desthost); + slprintf(printername, sizeof(servername)-1, "\\\\%s\\", cli->cli->desthost); strupper_m(printername); pstrcat(printername, argv[1]); - result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, + result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, servername, user, &hnd); @@ -2192,7 +2192,7 @@ static WERROR cmd_spoolss_enum_jobs(struct cli_state *cli, /* Enumerate ports */ offered = needed = 0; - result = cli_spoolss_enumjobs(cli, mem_ctx, &hnd, level, 0, 1000, + result = rpccli_spoolss_enumjobs(cli, mem_ctx, &hnd, level, 0, 1000, &num_jobs, &ctr); if (!W_ERROR_IS_OK(result)) @@ -2214,7 +2214,7 @@ static WERROR cmd_spoolss_enum_jobs(struct cli_state *cli, done: if (got_hnd) - cli_spoolss_close_printer(cli, mem_ctx, &hnd); + rpccli_spoolss_close_printer(cli, mem_ctx, &hnd); return result; } @@ -2222,7 +2222,7 @@ done: /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_enum_data( struct cli_state *cli, +static WERROR cmd_spoolss_enum_data( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -2240,14 +2240,14 @@ static WERROR cmd_spoolss_enum_data( struct cli_state *cli, /* Open printer handle */ - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); fstrcpy(user, cli->user_name); - slprintf(printername, sizeof(printername)-1, "\\\\%s\\", cli->desthost); + slprintf(printername, sizeof(printername)-1, "\\\\%s\\", cli->cli->desthost); strupper_m(printername); pstrcat(printername, argv[1]); - result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, + result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, servername, user, &hnd); @@ -2258,12 +2258,12 @@ static WERROR cmd_spoolss_enum_data( struct cli_state *cli, /* Enumerate data */ - result = cli_spoolss_enumprinterdata(cli, mem_ctx, &hnd, i, 0, 0, + result = rpccli_spoolss_enumprinterdata(cli, mem_ctx, &hnd, i, 0, 0, &val_needed, &data_needed, NULL); while (W_ERROR_IS_OK(result)) { REGISTRY_VALUE value; - result = cli_spoolss_enumprinterdata( + result = rpccli_spoolss_enumprinterdata( cli, mem_ctx, &hnd, i++, val_needed, data_needed, 0, 0, &value); if (W_ERROR_IS_OK(result)) @@ -2274,7 +2274,7 @@ static WERROR cmd_spoolss_enum_data( struct cli_state *cli, done: if (got_hnd) - cli_spoolss_close_printer(cli, mem_ctx, &hnd); + rpccli_spoolss_close_printer(cli, mem_ctx, &hnd); return result; } @@ -2282,7 +2282,7 @@ done: /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_enum_data_ex( struct cli_state *cli, +static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -2304,14 +2304,14 @@ static WERROR cmd_spoolss_enum_data_ex( struct cli_state *cli, /* Open printer handle */ - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); fstrcpy(user, cli->user_name); - slprintf(printername, sizeof(printername)-1, "\\\\%s\\", cli->desthost); + slprintf(printername, sizeof(printername)-1, "\\\\%s\\", cli->cli->desthost); strupper_m(printername); pstrcat(printername, argv[1]); - result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, + result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, servername, user, &hnd); @@ -2325,7 +2325,7 @@ static WERROR cmd_spoolss_enum_data_ex( struct cli_state *cli, if ( !(ctr = TALLOC_ZERO_P( mem_ctx, REGVAL_CTR )) ) return WERR_NOMEM; - result = cli_spoolss_enumprinterdataex(cli, mem_ctx, &hnd, keyname, ctr); + result = rpccli_spoolss_enumprinterdataex(cli, mem_ctx, &hnd, keyname, ctr); if (!W_ERROR_IS_OK(result)) goto done; @@ -2338,7 +2338,7 @@ static WERROR cmd_spoolss_enum_data_ex( struct cli_state *cli, done: if (got_hnd) - cli_spoolss_close_printer(cli, mem_ctx, &hnd); + rpccli_spoolss_close_printer(cli, mem_ctx, &hnd); return result; } @@ -2346,7 +2346,7 @@ done: /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_enum_printerkey( struct cli_state *cli, +static WERROR cmd_spoolss_enum_printerkey( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -2370,14 +2370,14 @@ static WERROR cmd_spoolss_enum_printerkey( struct cli_state *cli, /* Open printer handle */ - slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost); strupper_m(servername); fstrcpy(user, cli->user_name); - slprintf(printername, sizeof(printername)-1, "\\\\%s\\", cli->desthost); + slprintf(printername, sizeof(printername)-1, "\\\\%s\\", cli->cli->desthost); strupper_m(printername); pstrcat(printername, argv[1]); - result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, + result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, servername, user, &hnd); @@ -2388,7 +2388,7 @@ static WERROR cmd_spoolss_enum_printerkey( struct cli_state *cli, /* Enumerate subkeys */ - result = cli_spoolss_enumprinterkey(cli, mem_ctx, &hnd, keyname, &keylist, NULL); + result = rpccli_spoolss_enumprinterkey(cli, mem_ctx, &hnd, keyname, &keylist, NULL); if (!W_ERROR_IS_OK(result)) goto done; @@ -2406,7 +2406,7 @@ static WERROR cmd_spoolss_enum_printerkey( struct cli_state *cli, done: if (got_hnd) - cli_spoolss_close_printer(cli, mem_ctx, &hnd); + rpccli_spoolss_close_printer(cli, mem_ctx, &hnd); return result; } @@ -2414,7 +2414,7 @@ done: /**************************************************************************** ****************************************************************************/ -static WERROR cmd_spoolss_rffpcnex(struct cli_state *cli, +static WERROR cmd_spoolss_rffpcnex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -2432,14 +2432,14 @@ static WERROR cmd_spoolss_rffpcnex(struct cli_state *cli, /* Open printer */ - slprintf(servername, sizeof(servername) - 1, "\\\\%s", cli->desthost); + slprintf(servername, sizeof(servername) - 1, "\\\\%s", cli->cli->desthost); strupper_m(servername); - slprintf(printername, sizeof(printername) - 1, "\\\\%s\\%s", cli->desthost, + slprintf(printername, sizeof(printername) - 1, "\\\\%s\\%s", cli->cli->desthost, argv[1]); strupper_m(printername); - result = cli_spoolss_open_printer_ex( + result = rpccli_spoolss_open_printer_ex( cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, servername, cli->user_name, &hnd); @@ -2477,7 +2477,7 @@ static WERROR cmd_spoolss_rffpcnex(struct cli_state *cli, slprintf(servername, sizeof(servername) - 1, "\\\\%s", myhostname()); strupper_m(servername); - result = cli_spoolss_rffpcnex( + result = rpccli_spoolss_rffpcnex( cli, mem_ctx, &hnd, 0, 0, servername, 123, &option); if (!W_ERROR_IS_OK(result)) { @@ -2487,44 +2487,236 @@ static WERROR cmd_spoolss_rffpcnex(struct cli_state *cli, done: if (got_hnd) - cli_spoolss_close_printer(cli, mem_ctx, &hnd); + rpccli_spoolss_close_printer(cli, mem_ctx, &hnd); return result; } +/**************************************************************************** +****************************************************************************/ + +static BOOL compare_printer( struct rpc_pipe_client *cli1, POLICY_HND *hnd1, + struct rpc_pipe_client *cli2, POLICY_HND *hnd2 ) +{ + PRINTER_INFO_CTR ctr1, ctr2; + WERROR werror; + TALLOC_CTX *mem_ctx = talloc_init("compare_printer"); + + printf("Retrieving printer propertiesfor %s...", cli1->cli->desthost); + werror = rpccli_spoolss_getprinter( cli1, mem_ctx, hnd1, 2, &ctr1); + if ( !W_ERROR_IS_OK(werror) ) { + printf("failed (%s)\n", dos_errstr(werror)); + talloc_destroy(mem_ctx); + return False; + } + printf("ok\n"); + + printf("Retrieving printer properties for %s...", cli2->cli->desthost); + werror = rpccli_spoolss_getprinter( cli2, mem_ctx, hnd2, 2, &ctr2); + if ( !W_ERROR_IS_OK(werror) ) { + printf("failed (%s)\n", dos_errstr(werror)); + talloc_destroy(mem_ctx); + return False; + } + printf("ok\n"); + + talloc_destroy(mem_ctx); + + return True; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL compare_printer_secdesc( struct rpc_pipe_client *cli1, POLICY_HND *hnd1, + struct rpc_pipe_client *cli2, POLICY_HND *hnd2 ) +{ + PRINTER_INFO_CTR ctr1, ctr2; + WERROR werror; + TALLOC_CTX *mem_ctx = talloc_init("compare_printer_secdesc"); + SEC_DESC *sd1, *sd2; + BOOL result = True; + + + printf("Retreiving printer security for %s...", cli1->cli->desthost); + werror = rpccli_spoolss_getprinter( cli1, mem_ctx, hnd1, 3, &ctr1); + if ( !W_ERROR_IS_OK(werror) ) { + printf("failed (%s)\n", dos_errstr(werror)); + result = False; + goto done; + } + printf("ok\n"); + + printf("Retrieving printer security for %s...", cli2->cli->desthost); + werror = rpccli_spoolss_getprinter( cli2, mem_ctx, hnd2, 3, &ctr2); + if ( !W_ERROR_IS_OK(werror) ) { + printf("failed (%s)\n", dos_errstr(werror)); + result = False; + goto done; + } + printf("ok\n"); + + + printf("++ "); + + if ( (ctr1.printers_3 != ctr2.printers_3) && (!ctr1.printers_3 || !ctr2.printers_3) ) { + printf("NULL PRINTER_INFO_3!\n"); + result = False; + goto done; + } + + sd1 = ctr1.printers_3->secdesc; + sd2 = ctr2.printers_3->secdesc; + + if ( (sd1 != sd2) && ( !sd1 || !sd2 ) ) { + printf("NULL secdesc!\n"); + result = False; + goto done; + } + + if ( (ctr1.printers_3->flags != ctr1.printers_3->flags ) || !sec_desc_equal( sd1, sd2 ) ) { + printf("Security Descriptors *not* equal!\n"); + result = False; + goto done; + } + + printf("Security descriptors match\n"); + +done: + talloc_destroy(mem_ctx); + return result; +} + + +/**************************************************************************** +****************************************************************************/ + +static WERROR cmd_spoolss_printercmp(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + fstring printername, servername1, servername2; + pstring printername_path; + struct cli_state *cli_server1 = cli->cli; + struct cli_state *cli_server2 = NULL; + struct rpc_pipe_client *cli2 = NULL; + POLICY_HND hPrinter1, hPrinter2; + NTSTATUS nt_status; + WERROR werror; + + if ( argc != 3 ) { + printf("Usage: %s <printer> <server>\n", argv[0]); + return WERR_OK; + } + + fstrcpy( printername, argv[1] ); + + fstr_sprintf( servername1, cli->cli->desthost ); + fstrcpy( servername2, argv[2] ); + strupper_m( servername1 ); + strupper_m( servername2 ); + + + /* first get the connection to the remote server */ + + nt_status = cli_full_connection(&cli_server2, global_myname(), servername2, + NULL, 0, + "IPC$", "IPC", + cmdline_auth_info.username, + lp_workgroup(), + cmdline_auth_info.password, + cmdline_auth_info.use_kerberos ? CLI_FULL_CONNECTION_USE_KERBEROS : 0, + cmdline_auth_info.signing_state, NULL); + + if ( !NT_STATUS_IS_OK(nt_status) ) + return WERR_GENERAL_FAILURE; + + cli2 = cli_rpc_pipe_open_noauth(cli_server2, PI_SPOOLSS, &nt_status); + if (!cli2) { + printf("failed to open spoolss pipe on server %s (%s)\n", + servername2, nt_errstr(nt_status)); + return WERR_GENERAL_FAILURE; + } + + /* now open up both printers */ + + pstr_sprintf( printername_path, "\\\\%s\\%s", servername1, printername ); + printf("Opening %s...", printername_path); + werror = rpccli_spoolss_open_printer_ex( cli, mem_ctx, printername_path, + "", PRINTER_ALL_ACCESS, servername1, cli_server1->user_name, &hPrinter1); + if ( !W_ERROR_IS_OK(werror) ) { + printf("failed (%s)\n", dos_errstr(werror)); + goto done; + } + printf("ok\n"); + + pstr_sprintf( printername_path, "\\\\%s\\%s", servername2, printername ); + printf("Opening %s...", printername_path); + werror = rpccli_spoolss_open_printer_ex( cli2, mem_ctx, printername_path, + "", PRINTER_ALL_ACCESS, servername2, cli_server2->user_name, &hPrinter2 ); + if ( !W_ERROR_IS_OK(werror) ) { + printf("failed (%s)\n", dos_errstr(werror)); + goto done; + } + printf("ok\n"); + + + compare_printer( cli, &hPrinter1, cli2, &hPrinter2 ); + compare_printer_secdesc( cli, &hPrinter1, cli2, &hPrinter2 ); +#if 0 + compare_printerdata( cli_server1, &hPrinter1, cli_server2, &hPrinter2 ); +#endif + + +done: + /* cleanup */ + + printf("Closing printers..."); + rpccli_spoolss_close_printer( cli, mem_ctx, &hPrinter1 ); + rpccli_spoolss_close_printer( cli2, mem_ctx, &hPrinter2 ); + printf("ok\n"); + + /* close the second remote connection */ + + cli_shutdown( cli_server2 ); + + return WERR_OK; +} + /* List of commands exported by this module */ struct cmd_set spoolss_commands[] = { { "SPOOLSS" }, - { "adddriver", RPC_RTYPE_WERROR, NULL, cmd_spoolss_addprinterdriver, PI_SPOOLSS, "Add a print driver", "" }, - { "addprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_addprinterex, PI_SPOOLSS, "Add a printer", "" }, - { "deldriver", RPC_RTYPE_WERROR, NULL, cmd_spoolss_deletedriver, PI_SPOOLSS, "Delete a printer driver", "" }, - { "deldriverex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_deletedriverex, PI_SPOOLSS, "Delete a printer driver with files", "" }, - { "enumdata", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_data, PI_SPOOLSS, "Enumerate printer data", "" }, - { "enumdataex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_data_ex, PI_SPOOLSS, "Enumerate printer data for a key", "" }, - { "enumkey", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_printerkey, PI_SPOOLSS, "Enumerate printer keys", "" }, - { "enumjobs", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_jobs, PI_SPOOLSS, "Enumerate print jobs", "" }, - { "enumports", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_ports, PI_SPOOLSS, "Enumerate printer ports", "" }, - { "enumdrivers", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_drivers, PI_SPOOLSS, "Enumerate installed printer drivers", "" }, - { "enumprinters", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_printers, PI_SPOOLSS, "Enumerate printers", "" }, - { "getdata", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprinterdata, PI_SPOOLSS, "Get print driver data", "" }, - { "getdataex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprinterdataex, PI_SPOOLSS, "Get printer driver data with keyname", ""}, - { "getdriver", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getdriver, PI_SPOOLSS, "Get print driver information", "" }, - { "getdriverdir", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getdriverdir, PI_SPOOLSS, "Get print driver upload directory", "" }, - { "getprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprinter, PI_SPOOLSS, "Get printer info", "" }, - { "openprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_open_printer_ex, PI_SPOOLSS, "Open printer handle", "" }, - { "setdriver", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setdriver, PI_SPOOLSS, "Set printer driver", "" }, - { "getprintprocdir", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprintprocdir, PI_SPOOLSS, "Get print processor directory", "" }, - { "addform", RPC_RTYPE_WERROR, NULL, cmd_spoolss_addform, PI_SPOOLSS, "Add form", "" }, - { "setform", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setform, PI_SPOOLSS, "Set form", "" }, - { "getform", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getform, PI_SPOOLSS, "Get form", "" }, - { "deleteform", RPC_RTYPE_WERROR, NULL, cmd_spoolss_deleteform, PI_SPOOLSS, "Delete form", "" }, - { "enumforms", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_forms, PI_SPOOLSS, "Enumerate forms", "" }, - { "setprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setprinter, PI_SPOOLSS, "Set printer comment", "" }, - { "setprintername", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setprintername, PI_SPOOLSS, "Set printername", "" }, - { "setprinterdata", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setprinterdata, PI_SPOOLSS, "Set REG_SZ printer data", "" }, - { "rffpcnex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_rffpcnex, PI_SPOOLSS, "Rffpcnex test", "" }, + { "adddriver", RPC_RTYPE_WERROR, NULL, cmd_spoolss_addprinterdriver, PI_SPOOLSS, NULL, "Add a print driver", "" }, + { "addprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_addprinterex, PI_SPOOLSS, NULL, "Add a printer", "" }, + { "deldriver", RPC_RTYPE_WERROR, NULL, cmd_spoolss_deletedriver, PI_SPOOLSS, NULL, "Delete a printer driver", "" }, + { "deldriverex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_deletedriverex, PI_SPOOLSS, NULL, "Delete a printer driver with files", "" }, + { "enumdata", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_data, PI_SPOOLSS, NULL, "Enumerate printer data", "" }, + { "enumdataex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_data_ex, PI_SPOOLSS, NULL, "Enumerate printer data for a key", "" }, + { "enumkey", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_printerkey, PI_SPOOLSS, NULL, "Enumerate printer keys", "" }, + { "enumjobs", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_jobs, PI_SPOOLSS, NULL, "Enumerate print jobs", "" }, + { "enumports", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_ports, PI_SPOOLSS, NULL, "Enumerate printer ports", "" }, + { "enumdrivers", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_drivers, PI_SPOOLSS, NULL, "Enumerate installed printer drivers", "" }, + { "enumprinters", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_printers, PI_SPOOLSS, NULL, "Enumerate printers", "" }, + { "getdata", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprinterdata, PI_SPOOLSS, NULL, "Get print driver data", "" }, + { "getdataex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprinterdataex, PI_SPOOLSS, NULL, "Get printer driver data with keyname", ""}, + { "getdriver", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getdriver, PI_SPOOLSS, NULL, "Get print driver information", "" }, + { "getdriverdir", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getdriverdir, PI_SPOOLSS, NULL, "Get print driver upload directory", "" }, + { "getprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprinter, PI_SPOOLSS, NULL, "Get printer info", "" }, + { "openprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_open_printer_ex, PI_SPOOLSS, NULL, "Open printer handle", "" }, + { "setdriver", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setdriver, PI_SPOOLSS, NULL, "Set printer driver", "" }, + { "getprintprocdir", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprintprocdir, PI_SPOOLSS, NULL, "Get print processor directory", "" }, + { "addform", RPC_RTYPE_WERROR, NULL, cmd_spoolss_addform, PI_SPOOLSS, NULL, "Add form", "" }, + { "setform", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setform, PI_SPOOLSS, NULL, "Set form", "" }, + { "getform", RPC_RTYPE_WERROR, NULL, cmd_spoolss_getform, PI_SPOOLSS, NULL, "Get form", "" }, + { "deleteform", RPC_RTYPE_WERROR, NULL, cmd_spoolss_deleteform, PI_SPOOLSS, NULL, "Delete form", "" }, + { "enumforms", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_forms, PI_SPOOLSS, NULL, "Enumerate forms", "" }, + { "setprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setprinter, PI_SPOOLSS, NULL, "Set printer comment", "" }, + { "setprintername", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setprintername, PI_SPOOLSS, NULL, "Set printername", "" }, + { "setprinterdata", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setprinterdata, PI_SPOOLSS, NULL, "Set REG_SZ printer data", "" }, + { "rffpcnex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_rffpcnex, PI_SPOOLSS, NULL, "Rffpcnex test", "" }, + { "printercmp", RPC_RTYPE_WERROR, NULL, cmd_spoolss_printercmp, PI_SPOOLSS, NULL, "Printer comparison test", "" }, { NULL } }; diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c index 1d173ffdff..da81a82c8d 100644 --- a/source3/rpcclient/cmd_srvsvc.c +++ b/source3/rpcclient/cmd_srvsvc.c @@ -179,7 +179,7 @@ static void display_srv_info_102(SRV_INFO_102 *sv102) } /* Server query info */ -static WERROR cmd_srvsvc_srv_query_info(struct cli_state *cli, +static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -195,7 +195,7 @@ static WERROR cmd_srvsvc_srv_query_info(struct cli_state *cli, if (argc == 2) info_level = atoi(argv[1]); - result = cli_srvsvc_net_srv_get_info(cli, mem_ctx, info_level, + result = rpccli_srvsvc_net_srv_get_info(cli, mem_ctx, info_level, &ctr); if (!W_ERROR_IS_OK(result)) { @@ -270,7 +270,7 @@ static void display_share_info_502(SRV_SHARE_INFO_502 *info502) } -static WERROR cmd_srvsvc_net_share_enum(struct cli_state *cli, +static WERROR cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -290,7 +290,7 @@ static WERROR cmd_srvsvc_net_share_enum(struct cli_state *cli, init_enum_hnd(&hnd, 0); - result = cli_srvsvc_net_share_enum( + result = rpccli_srvsvc_net_share_enum( cli, mem_ctx, info_level, &ctr, preferred_len, &hnd); if (!W_ERROR_IS_OK(result) || !ctr.num_entries) @@ -320,7 +320,7 @@ static WERROR cmd_srvsvc_net_share_enum(struct cli_state *cli, return result; } -static WERROR cmd_srvsvc_net_share_get_info(struct cli_state *cli, +static WERROR cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -336,7 +336,7 @@ static WERROR cmd_srvsvc_net_share_get_info(struct cli_state *cli, if (argc == 3) info_level = atoi(argv[2]); - result = cli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info); + result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info); if (!W_ERROR_IS_OK(result)) goto done; @@ -362,7 +362,7 @@ static WERROR cmd_srvsvc_net_share_get_info(struct cli_state *cli, return result; } -static WERROR cmd_srvsvc_net_share_set_info(struct cli_state *cli, +static WERROR cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -376,7 +376,7 @@ static WERROR cmd_srvsvc_net_share_set_info(struct cli_state *cli, } /* retrieve share info */ - result = cli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info_get); + result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info_get); if (!W_ERROR_IS_OK(result)) goto done; @@ -385,13 +385,13 @@ static WERROR cmd_srvsvc_net_share_set_info(struct cli_state *cli, init_unistr2(&(info_get.share.info502.info_502_str.uni_remark), argv[2], UNI_STR_TERMINATE); /* set share info */ - result = cli_srvsvc_net_share_set_info(cli, mem_ctx, argv[1], info_level, &info_get); + result = rpccli_srvsvc_net_share_set_info(cli, mem_ctx, argv[1], info_level, &info_get); if (!W_ERROR_IS_OK(result)) goto done; /* re-retrieve share info and display */ - result = cli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info_get); + result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info_get); if (!W_ERROR_IS_OK(result)) goto done; @@ -401,11 +401,12 @@ static WERROR cmd_srvsvc_net_share_set_info(struct cli_state *cli, return result; } -static WERROR cmd_srvsvc_net_remote_tod(struct cli_state *cli, +static WERROR cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { TIME_OF_DAY_INFO tod; + fstring srv_name_slash; WERROR result; if (argc > 1) { @@ -413,8 +414,9 @@ static WERROR cmd_srvsvc_net_remote_tod(struct cli_state *cli, return WERR_OK; } - result = cli_srvsvc_net_remote_tod( - cli, mem_ctx, cli->srv_name_slash, &tod); + fstr_sprintf(srv_name_slash, "\\\\%s", cli->cli->desthost); + result = rpccli_srvsvc_net_remote_tod( + cli, mem_ctx, srv_name_slash, &tod); if (!W_ERROR_IS_OK(result)) goto done; @@ -423,7 +425,7 @@ static WERROR cmd_srvsvc_net_remote_tod(struct cli_state *cli, return result; } -static WERROR cmd_srvsvc_net_file_enum(struct cli_state *cli, +static WERROR cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -445,7 +447,7 @@ static WERROR cmd_srvsvc_net_file_enum(struct cli_state *cli, ZERO_STRUCT(ctr); - result = cli_srvsvc_net_file_enum( + result = rpccli_srvsvc_net_file_enum( cli, mem_ctx, info_level, NULL, &ctr, preferred_len, &hnd); if (!W_ERROR_IS_OK(result)) @@ -461,12 +463,12 @@ struct cmd_set srvsvc_commands[] = { { "SRVSVC" }, - { "srvinfo", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_srv_query_info, PI_SRVSVC, "Server query info", "" }, - { "netshareenum",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_enum, PI_SRVSVC, "Enumerate shares", "" }, - { "netsharegetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_get_info, PI_SRVSVC, "Get Share Info", "" }, - { "netsharesetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_set_info, PI_SRVSVC, "Set Share Info", "" }, - { "netfileenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_file_enum, PI_SRVSVC, "Enumerate open files", "" }, - { "netremotetod",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_remote_tod, PI_SRVSVC, "Fetch remote time of day", "" }, + { "srvinfo", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_srv_query_info, PI_SRVSVC, NULL, "Server query info", "" }, + { "netshareenum",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_enum, PI_SRVSVC, NULL, "Enumerate shares", "" }, + { "netsharegetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_get_info, PI_SRVSVC, NULL, "Get Share Info", "" }, + { "netsharesetinfo",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_share_set_info, PI_SRVSVC, NULL, "Set Share Info", "" }, + { "netfileenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_file_enum, PI_SRVSVC, NULL, "Enumerate open files", "" }, + { "netremotetod",RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_remote_tod, PI_SRVSVC, NULL, "Fetch remote time of day", "" }, { NULL } }; diff --git a/source3/rpcclient/cmd_test.c b/source3/rpcclient/cmd_test.c new file mode 100644 index 0000000000..94545dc74e --- /dev/null +++ b/source3/rpcclient/cmd_test.c @@ -0,0 +1,68 @@ +/* + Unix SMB/CIFS implementation. + RPC pipe client + + Copyright (C) Volker Lendecke 2005 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "rpcclient.h" + +static NTSTATUS cmd_testme(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + int argc, const char **argv) +{ + struct rpc_pipe_client *lsa_pipe = NULL, *samr_pipe = NULL; + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + POLICY_HND pol; + + d_printf("testme\n"); + + lsa_pipe = cli_rpc_pipe_open_noauth(cli->cli, PI_LSARPC, &status); + if (lsa_pipe == NULL) goto done; + + samr_pipe = cli_rpc_pipe_open_noauth(cli->cli, PI_SAMR, &status); + if (samr_pipe == NULL) goto done; + + status = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, False, + SEC_RIGHTS_QUERY_VALUE, &pol); + + if (!NT_STATUS_IS_OK(status)) + goto done; + + status = rpccli_lsa_close(lsa_pipe, mem_ctx, &pol); + + if (!NT_STATUS_IS_OK(status)) + goto done; + + done: + if (lsa_pipe != NULL) cli_rpc_pipe_close(lsa_pipe); + if (samr_pipe != NULL) cli_rpc_pipe_close(samr_pipe); + + return status; +} + +/* List of commands exported by this module */ + +struct cmd_set test_commands[] = { + + { "TESTING" }, + + { "testme", RPC_RTYPE_NTSTATUS, cmd_testme, NULL, + -1, NULL, "Sample test", "testme" }, + + { NULL } +}; diff --git a/source3/rpcclient/cmd_wkssvc.c b/source3/rpcclient/cmd_wkssvc.c index 137ff3bdae..a65cd1f799 100644 --- a/source3/rpcclient/cmd_wkssvc.c +++ b/source3/rpcclient/cmd_wkssvc.c @@ -19,6 +19,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +THIS IS NO LONGER USED - NEEDS REMOVAL. + #include "includes.h" #define DEBUG_TESTING diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 34e81cafe6..630add0e9b 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -25,6 +25,8 @@ DOM_SID domain_sid; +static enum pipe_auth_type pipe_default_auth_type = PIPE_AUTH_TYPE_NONE; +static enum pipe_auth_level pipe_default_auth_level = PIPE_AUTH_LEVEL_NONE; /* List to hold groups of commands. * @@ -128,29 +130,28 @@ static void fetch_machine_sid(struct cli_state *cli) static BOOL got_domain_sid; TALLOC_CTX *mem_ctx; DOM_SID *dom_sid = NULL; + struct rpc_pipe_client *lsapipe = NULL; if (got_domain_sid) return; - if (!(mem_ctx=talloc_init("fetch_machine_sid"))) - { + if (!(mem_ctx=talloc_init("fetch_machine_sid"))) { DEBUG(0,("fetch_machine_sid: talloc_init returned NULL!\n")); goto error; } - - if (!cli_nt_session_open (cli, PI_LSARPC)) { - fprintf(stderr, "could not initialise lsa pipe\n"); + if ((lsapipe = cli_rpc_pipe_open_noauth(cli, PI_LSARPC, &result)) == NULL) { + fprintf(stderr, "could not initialise lsa pipe. Error was %s\n", nt_errstr(result) ); goto error; } - result = cli_lsa_open_policy(cli, mem_ctx, True, + result = rpccli_lsa_open_policy(lsapipe, mem_ctx, True, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); if (!NT_STATUS_IS_OK(result)) { goto error; } - result = cli_lsa_query_info_policy(cli, mem_ctx, &pol, info_class, + result = rpccli_lsa_query_info_policy(lsapipe, mem_ctx, &pol, info_class, &domain_name, &dom_sid); if (!NT_STATUS_IS_OK(result)) { goto error; @@ -159,13 +160,18 @@ static void fetch_machine_sid(struct cli_state *cli) got_domain_sid = True; sid_copy( &domain_sid, dom_sid ); - cli_lsa_close(cli, mem_ctx, &pol); - cli_nt_session_close(cli); + rpccli_lsa_close(lsapipe, mem_ctx, &pol); + cli_rpc_pipe_close(lsapipe); talloc_destroy(mem_ctx); return; error: + + if (lsapipe) { + cli_rpc_pipe_close(lsapipe); + } + fprintf(stderr, "could not obtain sid for domain %s\n", cli->domain); if (!NT_STATUS_IS_OK(result)) { @@ -177,7 +183,7 @@ static void fetch_machine_sid(struct cli_state *cli) /* List the available commands on a given pipe */ -static NTSTATUS cmd_listcommands(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_listcommands(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { struct cmd_list *tmp; @@ -222,7 +228,7 @@ static NTSTATUS cmd_listcommands(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Display help on commands */ -static NTSTATUS cmd_help(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_help(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { struct cmd_list *tmp; @@ -282,7 +288,7 @@ static NTSTATUS cmd_help(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Change the debug level */ -static NTSTATUS cmd_debuglevel(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_debuglevel(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { if (argc > 2) { @@ -299,114 +305,118 @@ static NTSTATUS cmd_debuglevel(struct cli_state *cli, TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } -static NTSTATUS cmd_quit(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_quit(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { exit(0); return NT_STATUS_OK; /* NOTREACHED */ } -static NTSTATUS cmd_sign(struct cli_state *cli, TALLOC_CTX *mem_ctx, - int argc, const char **argv) +static NTSTATUS cmd_set_ss_level(void) { - if (cli->pipe_auth_flags == (AUTH_PIPE_NTLMSSP|AUTH_PIPE_SIGN)) { - return NT_STATUS_OK; - } else { - /* still have session, just need to use it again */ - cli->pipe_auth_flags = AUTH_PIPE_NTLMSSP; - cli->pipe_auth_flags |= AUTH_PIPE_SIGN; - if (cli->pipes[cli->pipe_idx].fnum != 0) - cli_nt_session_close(cli); - } + struct cmd_list *tmp; - return NT_STATUS_OK; -} + /* Close any existing connections not at this level. */ -static NTSTATUS cmd_seal(struct cli_state *cli, TALLOC_CTX *mem_ctx, - int argc, const char **argv) -{ - if (cli->pipe_auth_flags == (AUTH_PIPE_NTLMSSP|AUTH_PIPE_SIGN|AUTH_PIPE_SEAL)) { - return NT_STATUS_OK; - } else { - /* still have session, just need to use it again */ - cli->pipe_auth_flags = AUTH_PIPE_NTLMSSP; - cli->pipe_auth_flags |= AUTH_PIPE_SIGN; - cli->pipe_auth_flags |= AUTH_PIPE_SEAL; - if (cli->pipes[cli->pipe_idx].fnum != 0) - cli_nt_session_close(cli); - } - return NT_STATUS_OK; + for (tmp = cmd_list; tmp; tmp = tmp->next) { + struct cmd_set *tmp_set; + + for (tmp_set = tmp->cmd_set; tmp_set->name; tmp_set++) { + if (tmp_set->rpc_pipe == NULL) { + continue; + } + + if (tmp_set->rpc_pipe->auth.auth_type != pipe_default_auth_type || + tmp_set->rpc_pipe->auth.auth_level != pipe_default_auth_level) { + cli_rpc_pipe_close(tmp_set->rpc_pipe); + tmp_set->rpc_pipe = NULL; + } + } + } + return NT_STATUS_OK; } -static NTSTATUS cmd_none(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_sign(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { - if (cli->pipe_auth_flags == 0) { + pipe_default_auth_level = PIPE_AUTH_LEVEL_INTEGRITY; + pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP; + + if (argc > 2) { + printf("Usage: %s [NTLMSSP|NTLMSSP_SPNEGO|SCHANNEL]\n", argv[0]); return NT_STATUS_OK; - } else { - /* still have session, just need to use it again */ - cli->pipe_auth_flags = 0; - if (cli->pipes[cli->pipe_idx].fnum != 0) - cli_nt_session_close(cli); } - cli->pipe_auth_flags = 0; - return NT_STATUS_OK; -} - -static NTSTATUS setup_schannel(struct cli_state *cli, int pipe_auth_flags, - int argc, const char **argv) -{ - NTSTATUS ret; - static uchar zeros[16]; - uchar trust_password[16]; - uint32 sec_channel_type; if (argc == 2) { - strhex_to_str(cli->sess_key, strlen(argv[1]), argv[1]); - cli->pipe_auth_flags = pipe_auth_flags; - return NT_STATUS_OK; + if (strequal(argv[1], "NTLMSSP")) { + pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP; + } else if (strequal(argv[1], "NTLMSSP_SPNEGO")) { + pipe_default_auth_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP; + } else if (strequal(argv[1], "SCHANNEL")) { + pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL; + } else { + printf("unknown type %s\n", argv[1]); + return NT_STATUS_INVALID_LEVEL; + } } - /* Cleanup */ + printf("debuglevel is %d\n", DEBUGLEVEL); + return cmd_set_ss_level(); +} - if ((memcmp(cli->sess_key, zeros, sizeof(cli->sess_key)) != 0) && - (cli->pipe_auth_flags == pipe_auth_flags)) { - /* already in this mode nothing to do */ - return NT_STATUS_OK; - } - - if (!secrets_fetch_trust_account_password(lp_workgroup(), - trust_password, - NULL, &sec_channel_type)) { - return NT_STATUS_UNSUCCESSFUL; +static NTSTATUS cmd_seal(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + int argc, const char **argv) +{ + pipe_default_auth_level = PIPE_AUTH_LEVEL_PRIVACY; + pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP; + + if (argc > 2) { + printf("Usage: %s [NTLMSSP|NTLMSSP_SPNEGO|SCHANNEL]\n", argv[0]); + return NT_STATUS_OK; } - ret = cli_nt_setup_netsec(cli, sec_channel_type, pipe_auth_flags, trust_password); - if (NT_STATUS_IS_OK(ret)) { - char *hex_session_key; - hex_session_key = hex_encode(NULL, cli->pipes[cli->pipe_idx].auth_info.sess_key, - sizeof(cli->pipes[cli->pipe_idx].auth_info.sess_key)); - printf("Got Session key: %s\n", hex_session_key); - talloc_free(hex_session_key); + if (argc == 2) { + if (strequal(argv[1], "NTLMSSP")) { + pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP; + } else if (strequal(argv[1], "NTLMSSP_SPNEGO")) { + pipe_default_auth_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP; + } else if (strequal(argv[1], "SCHANNEL")) { + pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL; + } else { + printf("unknown type %s\n", argv[1]); + return NT_STATUS_INVALID_LEVEL; + } } - return ret; + return cmd_set_ss_level(); } +static NTSTATUS cmd_none(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, + int argc, const char **argv) +{ + pipe_default_auth_level = PIPE_AUTH_LEVEL_NONE; + pipe_default_auth_type = PIPE_AUTH_TYPE_NONE; + + return cmd_set_ss_level(); +} -static NTSTATUS cmd_schannel(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_schannel(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { d_printf("Setting schannel - sign and seal\n"); - return setup_schannel(cli, AUTH_PIPE_NETSEC | AUTH_PIPE_SIGN | AUTH_PIPE_SEAL, - argc, argv); + pipe_default_auth_level = PIPE_AUTH_LEVEL_PRIVACY; + pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL; + + return cmd_set_ss_level(); } -static NTSTATUS cmd_schannel_sign(struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS cmd_schannel_sign(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { d_printf("Setting schannel - sign only\n"); - return setup_schannel(cli, AUTH_PIPE_NETSEC | AUTH_PIPE_SIGN, - argc, argv); + pipe_default_auth_level = PIPE_AUTH_LEVEL_INTEGRITY; + pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL; + + return cmd_set_ss_level(); } @@ -416,23 +426,23 @@ static struct cmd_set rpcclient_commands[] = { { "GENERAL OPTIONS" }, - { "help", RPC_RTYPE_NTSTATUS, cmd_help, NULL, -1, "Get help on commands", "[command]" }, - { "?", RPC_RTYPE_NTSTATUS, cmd_help, NULL, -1, "Get help on commands", "[command]" }, - { "debuglevel", RPC_RTYPE_NTSTATUS, cmd_debuglevel, NULL, -1, "Set debug level", "level" }, - { "list", RPC_RTYPE_NTSTATUS, cmd_listcommands, NULL, -1, "List available commands on <pipe>", "pipe" }, - { "exit", RPC_RTYPE_NTSTATUS, cmd_quit, NULL, -1, "Exit program", "" }, - { "quit", RPC_RTYPE_NTSTATUS, cmd_quit, NULL, -1, "Exit program", "" }, - { "sign", RPC_RTYPE_NTSTATUS, cmd_sign, NULL, -1, "Force RPC pipe connections to be signed", "" }, - { "seal", RPC_RTYPE_NTSTATUS, cmd_seal, NULL, -1, "Force RPC pipe connections to be sealed", "" }, - { "schannel", RPC_RTYPE_NTSTATUS, cmd_schannel, NULL, -1, "Force RPC pipe connections to be sealed with 'schannel' (NETSEC). Assumes valid machine account to this domain controller.", "" }, - { "schannelsign", RPC_RTYPE_NTSTATUS, cmd_schannel_sign, NULL, -1, "Force RPC pipe connections to be signed (not sealed) with 'schannel' (NETSEC). Assumes valid machine account to this domain controller.", "" }, - { "none", RPC_RTYPE_NTSTATUS, cmd_none, NULL, -1, "Force RPC pipe connections to have no special properties", "" }, + { "help", RPC_RTYPE_NTSTATUS, cmd_help, NULL, -1, NULL, "Get help on commands", "[command]" }, + { "?", RPC_RTYPE_NTSTATUS, cmd_help, NULL, -1, NULL, "Get help on commands", "[command]" }, + { "debuglevel", RPC_RTYPE_NTSTATUS, cmd_debuglevel, NULL, -1, NULL, "Set debug level", "level" }, + { "list", RPC_RTYPE_NTSTATUS, cmd_listcommands, NULL, -1, NULL, "List available commands on <pipe>", "pipe" }, + { "exit", RPC_RTYPE_NTSTATUS, cmd_quit, NULL, -1, NULL, "Exit program", "" }, + { "quit", RPC_RTYPE_NTSTATUS, cmd_quit, NULL, -1, NULL, "Exit program", "" }, + { "sign", RPC_RTYPE_NTSTATUS, cmd_sign, NULL, -1, NULL, "Force RPC pipe connections to be signed", "" }, + { "seal", RPC_RTYPE_NTSTATUS, cmd_seal, NULL, -1, NULL, "Force RPC pipe connections to be sealed", "" }, + { "schannel", RPC_RTYPE_NTSTATUS, cmd_schannel, NULL, -1, NULL, "Force RPC pipe connections to be sealed with 'schannel'. Assumes valid machine account to this domain controller.", "" }, + { "schannelsign", RPC_RTYPE_NTSTATUS, cmd_schannel_sign, NULL, -1, NULL, "Force RPC pipe connections to be signed (not sealed) with 'schannel'. Assumes valid machine account to this domain controller.", "" }, + { "none", RPC_RTYPE_NTSTATUS, cmd_none, NULL, -1, NULL, "Force RPC pipe connections to have no special properties", "" }, { NULL } }; static struct cmd_set separator_command[] = { - { "---------------", MAX_RPC_RETURN_TYPE, NULL, NULL, -1, "----------------------" }, + { "---------------", MAX_RPC_RETURN_TYPE, NULL, NULL, -1, NULL, "----------------------" }, { NULL } }; @@ -449,6 +459,7 @@ extern struct cmd_set reg_commands[]; extern struct cmd_set ds_commands[]; extern struct cmd_set echo_commands[]; extern struct cmd_set shutdown_commands[]; +extern struct cmd_set test_commands[]; static struct cmd_set *rpcclient_command_list[] = { rpcclient_commands, @@ -462,6 +473,7 @@ static struct cmd_set *rpcclient_command_list[] = { reg_commands, echo_commands, shutdown_commands, + test_commands, NULL }; @@ -492,7 +504,6 @@ static NTSTATUS do_cmd(struct cli_state *cli, { NTSTATUS ntresult; WERROR wresult; - uchar trust_password[16]; TALLOC_CTX *mem_ctx; @@ -505,57 +516,93 @@ static NTSTATUS do_cmd(struct cli_state *cli, /* Open pipe */ - if (cmd_entry->pipe_idx != -1 - && cmd_entry->pipe_idx != cli->pipe_idx) { - if (cli->pipes[cli->pipe_idx].fnum != 0) - cli_nt_session_close(cli); - - if (!cli_nt_session_open(cli, cmd_entry->pipe_idx)) { - DEBUG(0, ("Could not initialise %s\n", - get_pipe_name_from_index(cmd_entry->pipe_idx))); - return NT_STATUS_UNSUCCESSFUL; + if (cmd_entry->pipe_idx != -1 && cmd_entry->rpc_pipe == NULL) { + switch (pipe_default_auth_type) { + case PIPE_AUTH_TYPE_NONE: + cmd_entry->rpc_pipe = cli_rpc_pipe_open_noauth(cli, + cmd_entry->pipe_idx, + &ntresult); + break; + case PIPE_AUTH_TYPE_SPNEGO_NTLMSSP: + cmd_entry->rpc_pipe = cli_rpc_pipe_open_spnego_ntlmssp(cli, + cmd_entry->pipe_idx, + pipe_default_auth_level, + lp_workgroup(), + cmdline_auth_info.username, + cmdline_auth_info.password, + &ntresult); + break; + case PIPE_AUTH_TYPE_NTLMSSP: + cmd_entry->rpc_pipe = cli_rpc_pipe_open_ntlmssp(cli, + cmd_entry->pipe_idx, + pipe_default_auth_level, + lp_workgroup(), + cmdline_auth_info.username, + cmdline_auth_info.password, + &ntresult); + break; + case PIPE_AUTH_TYPE_SCHANNEL: + cmd_entry->rpc_pipe = cli_rpc_pipe_open_schannel(cli, + cmd_entry->pipe_idx, + pipe_default_auth_level, + lp_workgroup(), + &ntresult); + break; + default: + DEBUG(0, ("Could not initialise %s. Invalid auth type %u\n", + cli_get_pipe_name(cmd_entry->pipe_idx), + pipe_default_auth_type )); + return NT_STATUS_UNSUCCESSFUL; + } + if (!cmd_entry->rpc_pipe) { + DEBUG(0, ("Could not initialise %s. Error was %s\n", + cli_get_pipe_name(cmd_entry->pipe_idx), + nt_errstr(ntresult) )); + return ntresult; } - } - - /* some of the DsXXX commands use the netlogon pipe */ - if (lp_client_schannel() && (cmd_entry->pipe_idx == PI_NETLOGON) && !(cli->pipe_auth_flags & AUTH_PIPE_NETSEC)) { - uint32 neg_flags = NETLOGON_NEG_AUTH2_FLAGS; - uint32 sec_channel_type; + if (cmd_entry->pipe_idx == PI_NETLOGON) { + uint32 neg_flags = NETLOGON_NEG_AUTH2_FLAGS; + uint32 sec_channel_type; + uchar trust_password[16]; - if (!secrets_fetch_trust_account_password(lp_workgroup(), - trust_password, - NULL, &sec_channel_type)) { - return NT_STATUS_UNSUCCESSFUL; - } + if (!secrets_fetch_trust_account_password(lp_workgroup(), + trust_password, + NULL, &sec_channel_type)) { + return NT_STATUS_UNSUCCESSFUL; + } - ntresult = cli_nt_setup_creds(cli, sec_channel_type, - trust_password, - &neg_flags, 2); - if (!NT_STATUS_IS_OK(ntresult)) { - ZERO_STRUCT(cli->pipes[cli->pipe_idx].auth_info.sess_key); - printf("nt_setup_creds failed with %s\n", nt_errstr(ntresult)); - return ntresult; + ntresult = rpccli_netlogon_setup_creds(cmd_entry->rpc_pipe, + cli->desthost, + lp_workgroup(), + global_myname(), + trust_password, + sec_channel_type, + &neg_flags); + + if (!NT_STATUS_IS_OK(ntresult)) { + DEBUG(0, ("Could not initialise credentials for %s.\n", + cli_get_pipe_name(cmd_entry->pipe_idx))); + return ntresult; + } } - } - /* Run command */ + /* Run command */ - if ( cmd_entry->returntype == RPC_RTYPE_NTSTATUS ) { - ntresult = cmd_entry->ntfn(cli, mem_ctx, argc, (const char **) argv); - if (!NT_STATUS_IS_OK(ntresult)) { - printf("result was %s\n", nt_errstr(ntresult)); - } - } else { - wresult = cmd_entry->wfn( cli, mem_ctx, argc, (const char **) argv); - /* print out the DOS error */ - if (!W_ERROR_IS_OK(wresult)) { - printf( "result was %s\n", dos_errstr(wresult)); - } - ntresult = W_ERROR_IS_OK(wresult)?NT_STATUS_OK:NT_STATUS_UNSUCCESSFUL; - } - + if ( cmd_entry->returntype == RPC_RTYPE_NTSTATUS ) { + ntresult = cmd_entry->ntfn(cmd_entry->rpc_pipe, mem_ctx, argc, (const char **) argv); + if (!NT_STATUS_IS_OK(ntresult)) { + printf("result was %s\n", nt_errstr(ntresult)); + } + } else { + wresult = cmd_entry->wfn(cmd_entry->rpc_pipe, mem_ctx, argc, (const char **) argv); + /* print out the DOS error */ + if (!W_ERROR_IS_OK(wresult)) { + printf( "result was %s\n", dos_errstr(wresult)); + } + ntresult = W_ERROR_IS_OK(wresult)?NT_STATUS_OK:NT_STATUS_UNSUCCESSFUL; + } /* Cleanup */ @@ -736,7 +783,9 @@ out_free: return 1; } +#if 0 /* COMMENT OUT FOR TESTING */ memset(cmdline_auth_info.password,'X',sizeof(cmdline_auth_info.password)); +#endif /* Load command lists */ diff --git a/source3/rpcclient/rpcclient.h b/source3/rpcclient/rpcclient.h index e1e61dc43d..3c86c0be62 100644 --- a/source3/rpcclient/rpcclient.h +++ b/source3/rpcclient/rpcclient.h @@ -30,11 +30,12 @@ typedef enum { struct cmd_set { const char *name; - RPC_RETURN_TYPE returntype; - NTSTATUS (*ntfn)(struct cli_state *cli, TALLOC_CTX *mem_ctx, int argc, - const char **argv); - WERROR (*wfn)(struct cli_state *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv); - int pipe_idx; + RPC_RETURN_TYPE returntype; + NTSTATUS (*ntfn)(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, + const char **argv); + WERROR (*wfn)(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv); + int pipe_idx; + struct rpc_pipe_client *rpc_pipe; const char *description; const char *usage; }; |