From c6acbc16a6c6dca611a624a5e9c502dfcac92f93 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 30 Jan 2008 23:43:57 +0100 Subject: Use rpccli_netr_LogonControl() in rpcclient. Guenther (This used to be commit d54456f3c42f123af5516c6f75c87b279fdc775f) --- source3/rpcclient/cmd_netlogon.c | 56 ++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 17 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index a752003e8d..b1753575f5 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -348,30 +348,52 @@ static WERROR cmd_netlogon_dsr_getsitename(struct rpc_pipe_client *cli, return WERR_OK; } -static NTSTATUS cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, - const char **argv) +static WERROR cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) { -#if 0 - uint32 query_level = 1; -#endif - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + WERROR werr; + const char *logon_server = cli->cli->desthost; + enum netr_LogonControlCode function_code = 1; + uint32_t level = 1; + union netr_CONTROL_QUERY_INFORMATION info; + + if (argc > 4) { + fprintf(stderr, "Usage: %s " + "\n", argv[0]); + return WERR_OK; + } - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", argv[0]); - return NT_STATUS_OK; + if (argc >= 2) { + logon_server = argv[1]; } -#if 0 - result = cli_netlogon_logon_ctrl(cli, mem_ctx, query_level); - if (!NT_STATUS_IS_OK(result)) { - goto done; + if (argc >= 3) { + function_code = atoi(argv[2]); + } + + if (argc >= 4) { + level = atoi(argv[3]); + } + + status = rpccli_netr_LogonControl(cli, mem_ctx, + logon_server, + function_code, + level, + &info, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + if (!W_ERROR_IS_OK(werr)) { + return werr; } -#endif /* Display results */ - return result; + return werr; } /* Display sam synchronisation information */ @@ -852,7 +874,7 @@ struct cmd_set netlogon_commands[] = { { "dsr_getdcnameex2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcnameex2, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getsitename", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getsitename, PI_NETLOGON, NULL, "Get sitename", "" }, { "dsr_getforesttrustinfo", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getforesttrustinfo, PI_NETLOGON, NULL, "Get Forest Trust Info", "" }, - { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, NULL, "Logon Control", "" }, + { "logonctrl", RPC_RTYPE_WERROR, NULL, cmd_netlogon_logon_ctrl, 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", "" }, -- cgit From 6f05330e4a831058d02506d04f89b8cc10fa238b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 22:54:43 +0100 Subject: Fix logonctrl2 command in rpcclient. Guenther (This used to be commit c58be24cd43092e5ebf7aa84f167a5cc8344edfc) --- source3/rpcclient/cmd_netlogon.c | 70 +++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 15 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index b1753575f5..0efee845f4 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -21,27 +21,68 @@ #include "includes.h" #include "rpcclient.h" -static NTSTATUS cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, - const char **argv) +static WERROR cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) { - uint32 query_level = 1; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; + WERROR werr; + const char *logon_server = cli->cli->desthost; + enum netr_LogonControlCode function_code = NETLOGON_CONTROL_REDISCOVER; + uint32_t level = 1; + union netr_CONTROL_DATA_INFORMATION data; + union netr_CONTROL_QUERY_INFORMATION query; + const char *domain = "BER"; - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", argv[0]); - return NT_STATUS_OK; + if (argc > 5) { + fprintf(stderr, "Usage: %s " + " \n", argv[0]); + return WERR_OK; + } + + if (argc >= 2) { + logon_server = argv[1]; } - result = rpccli_netlogon_logon_ctrl2(cli, mem_ctx, query_level); + if (argc >= 3) { + function_code = atoi(argv[2]); + } - if (!NT_STATUS_IS_OK(result)) - goto done; + if (argc >= 4) { + level = atoi(argv[3]); + } + + if (argc >= 5) { + domain = argv[4]; + } + + switch (function_code) { + case NETLOGON_CONTROL_REDISCOVER: + case NETLOGON_CONTROL_TC_QUERY: + data.domain = domain; + break; + default: + break; + } + + status = rpccli_netr_LogonControl2(cli, mem_ctx, + logon_server, + function_code, + level, + &data, + &query, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + if (!W_ERROR_IS_OK(werr)) { + return werr; + } /* Display results */ - done: - return result; + return werr; } static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, @@ -859,14 +900,13 @@ static WERROR cmd_netlogon_enumtrusteddomainsex(struct rpc_pipe_client *cli, } - /* List of commands exported by this module */ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, - { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, NULL, "Logon Control 2", "" }, + { "logonctrl2", RPC_RTYPE_WERROR, NULL, cmd_netlogon_logon_ctrl2, PI_NETLOGON, NULL, "Logon Control 2", "" }, { "getanydcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getanydcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, PI_NETLOGON, NULL, "Get trusted PDC name", "" }, { "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, -- cgit From 2b84f4119d0d5dc0eac0e3596260901e3dc3eefd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:32:56 +0100 Subject: Use rpccli_lsa_EnumAccounts() in net and rpcclient. Guenther (This used to be commit bdbcfa4419a54b98ea577b0052894ddaa06890ce) --- source3/rpcclient/cmd_lsarpc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index c014dba676..6e12a90982 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -550,8 +550,7 @@ static NTSTATUS cmd_lsa_enum_sids(struct rpc_pipe_client *cli, uint32 enum_context=0; uint32 pref_max_length=0x1000; - DOM_SID *sids; - uint32 count=0; + struct lsa_SidArray sid_array; int i; if (argc > 3) { @@ -572,19 +571,22 @@ static NTSTATUS cmd_lsa_enum_sids(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = rpccli_lsa_enum_sids(cli, mem_ctx, &pol, &enum_context, pref_max_length, - &count, &sids); + result = rpccli_lsa_EnumAccounts(cli, mem_ctx, + &pol, + &enum_context, + &sid_array, + pref_max_length); if (!NT_STATUS_IS_OK(result)) goto done; /* Print results */ - printf("found %d SIDs\n\n", count); + printf("found %d SIDs\n\n", sid_array.num_sids); - for (i = 0; i < count; i++) { + for (i = 0; i < sid_array.num_sids; i++) { fstring sid_str; - sid_to_fstring(sid_str, &sids[i]); + sid_to_fstring(sid_str, sid_array.sids[i].sid); printf("%s\n", sid_str); } -- cgit From f9d992827a0935a21a1bf09a12ffd0146880fdc5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:45:07 +0100 Subject: Remove accidential commit. Guenther (This used to be commit 2ab1167e156e989f4b60fcb4dbc7d7eefc64bed0) --- source3/rpcclient/cmd_netlogon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 0efee845f4..ac27d387ce 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -32,7 +32,7 @@ static WERROR cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli, uint32_t level = 1; union netr_CONTROL_DATA_INFORMATION data; union netr_CONTROL_QUERY_INFORMATION query; - const char *domain = "BER"; + const char *domain = lp_workgroup(); if (argc > 5) { fprintf(stderr, "Usage: %s " -- cgit From eccaf125a9e3590af0a0ef84980314ea5190e586 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 12:13:13 +0100 Subject: Use rpccli_lsa_EnumPrivsAccount() in rpcclient. Guenther (This used to be commit c28b52dcfedd575f5ae4ed7942857d3853bdd051) --- source3/rpcclient/cmd_lsarpc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 6e12a90982..bd9d3c03cd 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -652,10 +652,8 @@ static NTSTATUS cmd_lsa_enum_privsaccounts(struct rpc_pipe_client *cli, POLICY_HND user_pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; uint32 access_desired = 0x000f000f; - DOM_SID sid; - uint32 count=0; - LUID_ATTR *set; + struct lsa_PrivilegeSet *privs = NULL; int i; if (argc != 2 ) { @@ -683,17 +681,22 @@ static NTSTATUS cmd_lsa_enum_privsaccounts(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = rpccli_lsa_enum_privsaccount(cli, mem_ctx, &user_pol, &count, &set); + result = rpccli_lsa_EnumPrivsAccount(cli, mem_ctx, + &user_pol, + &privs); if (!NT_STATUS_IS_OK(result)) goto done; /* Print results */ - printf("found %d privileges for SID %s\n\n", count, argv[1]); + printf("found %d privileges for SID %s\n\n", privs->count, argv[1]); printf("high\tlow\tattribute\n"); - for (i = 0; i < count; i++) { - printf("%u\t%u\t%u\n", set[i].luid.high, set[i].luid.low, set[i].attr); + for (i = 0; i < privs->count; i++) { + printf("%u\t%u\t%u\n", + privs->set[i].luid.high, + privs->set[i].luid.low, + privs->set[i].attribute); } rpccli_lsa_Close(cli, mem_ctx, &dom_pol); -- cgit From a75d6543a00fbdc52f2f783377737c4dc6f28569 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 13:29:18 +0100 Subject: Use rpccli_lsa_LookupPrivValue() in rpcclient. Guenther (This used to be commit c15243dd1faaa01cd05d6e2f6ae873cc32097397) --- source3/rpcclient/cmd_lsarpc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index bd9d3c03cd..69585eea57 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -841,7 +841,8 @@ static NTSTATUS cmd_lsa_lookup_priv_value(struct rpc_pipe_client *cli, { POLICY_HND pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - LUID luid; + struct lsa_LUID luid; + struct lsa_String name; if (argc != 2 ) { printf("Usage: %s name\n", argv[0]); @@ -855,7 +856,12 @@ static NTSTATUS cmd_lsa_lookup_priv_value(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = rpccli_lsa_lookup_priv_value(cli, mem_ctx, &pol, argv[1], &luid); + init_lsa_String(&name, argv[1]); + + result = rpccli_lsa_LookupPrivValue(cli, mem_ctx, + &pol, + &name, + &luid); if (!NT_STATUS_IS_OK(result)) goto done; -- cgit From 55e5e753bbe22c2467b5ea85abde8cee4ec838d6 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 13:46:39 +0100 Subject: Add lsaaddpriv and lsadelpriv commands to rpcclient. Guenther (This used to be commit e55bb83f84d0d459f4280c2a4bfa4cc14bd3924d) --- source3/rpcclient/cmd_lsarpc.c | 176 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 172 insertions(+), 4 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 69585eea57..120fb9b173 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -1141,6 +1141,176 @@ static NTSTATUS cmd_lsa_get_username(struct rpc_pipe_client *cli, return result; } +static NTSTATUS cmd_lsa_add_priv(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + POLICY_HND dom_pol, user_pol; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + struct lsa_PrivilegeSet privs; + struct lsa_LUIDAttribute *set = NULL; + DOM_SID sid; + int i; + + ZERO_STRUCT(privs); + + if (argc < 3 ) { + printf("Usage: %s SID [rights...]\n", argv[0]); + return NT_STATUS_OK; + } + + result = name_to_sid(cli, mem_ctx, &sid, argv[1]); + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + result = rpccli_lsa_open_policy2(cli, mem_ctx, True, + SEC_RIGHTS_MAXIMUM_ALLOWED, + &dom_pol); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + result = rpccli_lsa_OpenAccount(cli, mem_ctx, + &dom_pol, + &sid, + SEC_RIGHTS_MAXIMUM_ALLOWED, + &user_pol); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + for (i=2; i Date: Thu, 14 Feb 2008 14:34:10 +0100 Subject: Use rpccli_lsa_AddAccountRights in net and rpcclient. Guenther (This used to be commit e94ded74d6541d1d8954cfbbbd577ca0c83ecd4c) --- source3/rpcclient/cmd_lsarpc.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 120fb9b173..079a914830 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -762,8 +762,9 @@ static NTSTATUS cmd_lsa_add_acct_rights(struct rpc_pipe_client *cli, { POLICY_HND dom_pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - + struct lsa_RightSet rights; DOM_SID sid; + int i; if (argc < 3 ) { printf("Usage: %s SID [rights...]\n", argv[0]); @@ -781,8 +782,21 @@ static NTSTATUS cmd_lsa_add_acct_rights(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = rpccli_lsa_add_account_rights(cli, mem_ctx, &dom_pol, sid, - argc-2, argv+2); + rights.count = argc-2; + rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge, + rights.count); + if (!rights.names) { + return NT_STATUS_NO_MEMORY; + } + + for (i=0; i Date: Thu, 14 Feb 2008 15:09:21 +0100 Subject: Use rpccli_lsa_EnumAccountRights in net and rpcclient. Guenther (This used to be commit 6e9195329d9f2b26c959f64485902c032f140ec8) --- source3/rpcclient/cmd_lsarpc.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 079a914830..d7f5e55df4 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -713,10 +713,8 @@ static NTSTATUS cmd_lsa_enum_acct_rights(struct rpc_pipe_client *cli, { POLICY_HND dom_pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - DOM_SID sid; - uint32 count; - char **rights; + struct lsa_RightSet rights; int i; @@ -736,16 +734,19 @@ static NTSTATUS cmd_lsa_enum_acct_rights(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = rpccli_lsa_enum_account_rights(cli, mem_ctx, &dom_pol, &sid, &count, &rights); + result = rpccli_lsa_EnumAccountRights(cli, mem_ctx, + &dom_pol, + &sid, + &rights); if (!NT_STATUS_IS_OK(result)) goto done; - printf("found %d privileges for SID %s\n", count, + printf("found %d privileges for SID %s\n", rights.count, sid_string_tos(&sid)); - for (i = 0; i < count; i++) { - printf("\t%s\n", rights[i]); + for (i = 0; i < rights.count; i++) { + printf("\t%s\n", rights.names[i].string); } rpccli_lsa_Close(cli, mem_ctx, &dom_pol); -- cgit From f21cdab938a0a94405d595bb80fbda724315d984 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 15:28:26 +0100 Subject: Use rpccli_lsa_RemoveAccountRights() in net and rpcclient. Guenther (This used to be commit 78200d88924bbef3df7185fc3a0e1753160a592f) --- source3/rpcclient/cmd_lsarpc.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index d7f5e55df4..3fe8bc8e52 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -816,8 +816,9 @@ static NTSTATUS cmd_lsa_remove_acct_rights(struct rpc_pipe_client *cli, { POLICY_HND dom_pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - + struct lsa_RightSet rights; DOM_SID sid; + int i; if (argc < 3 ) { printf("Usage: %s SID [rights...]\n", argv[0]); @@ -835,8 +836,22 @@ static NTSTATUS cmd_lsa_remove_acct_rights(struct rpc_pipe_client *cli, if (!NT_STATUS_IS_OK(result)) goto done; - result = rpccli_lsa_remove_account_rights(cli, mem_ctx, &dom_pol, sid, - False, argc-2, argv+2); + rights.count = argc-2; + rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge, + rights.count); + if (!rights.names) { + return NT_STATUS_NO_MEMORY; + } + + for (i=0; i Date: Fri, 15 Feb 2008 13:55:18 +0100 Subject: Use rpccli_netr_DatabaseDeltas() in rpcclient. Guenther (This used to be commit 72ad42fee30242eb57ae0db825127fdb8f9375fd) --- source3/rpcclient/cmd_netlogon.c | 246 +++++++++++++++++++++++++-------------- 1 file changed, 159 insertions(+), 87 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index ac27d387ce..cf52da7c9f 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -439,70 +439,117 @@ static WERROR cmd_netlogon_logon_ctrl(struct rpc_pipe_client *cli, /* Display sam synchronisation information */ -static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, - SAM_DELTA_CTR *deltas) +static void display_sam_sync(struct netr_DELTA_ENUM_ARRAY *r) { - fstring name; - uint32 i, j; - - for (i = 0; i < num_deltas; i++) { - switch (hdr_deltas[i].type) { - case SAM_DELTA_DOMAIN_INFO: - unistr2_to_ascii(name, - &deltas[i].domain_info.uni_dom_name, - sizeof(name)); - printf("Domain: %s\n", name); - break; - case SAM_DELTA_GROUP_INFO: - unistr2_to_ascii(name, - &deltas[i].group_info.uni_grp_name, - sizeof(name)); - printf("Group: %s\n", name); - break; - case SAM_DELTA_ACCOUNT_INFO: - unistr2_to_ascii(name, - &deltas[i].account_info.uni_acct_name, - sizeof(name)); - printf("Account: %s\n", name); - break; - case SAM_DELTA_ALIAS_INFO: - unistr2_to_ascii(name, - &deltas[i].alias_info.uni_als_name, - sizeof(name)); - printf("Alias: %s\n", name); - break; - case SAM_DELTA_ALIAS_MEM: { - SAM_ALIAS_MEM_INFO *alias = &deltas[i].als_mem_info; - - for (j = 0; j < alias->num_members; j++) { - fstring sid_str; - - sid_to_fstring(sid_str, &alias->sids[j].sid); - - printf("%s\n", sid_str); - } - break; - } - case SAM_DELTA_GROUP_MEM: { - SAM_GROUP_MEM_INFO *group = &deltas[i].grp_mem_info; - - for (j = 0; j < group->num_members; j++) - printf("rid 0x%x, attrib 0x%08x\n", - group->rids[j], group->attribs[j]); - break; - } - case SAM_DELTA_MODIFIED_COUNT: { - SAM_DELTA_MOD_COUNT *mc = &deltas[i].mod_count; - - printf("sam sequence update: 0x%04x\n", mc->seqnum); - break; - } - default: - printf("unknown delta type 0x%02x\n", - hdr_deltas[i].type); - break; - } - } + uint32_t i, j; + + for (i=0; i < r->num_deltas; i++) { + + union netr_DELTA_UNION u = r->delta_enum[i].delta_union; + union netr_DELTA_ID_UNION id = r->delta_enum[i].delta_id_union; + + switch (r->delta_enum[i].delta_type) { + case NETR_DELTA_DOMAIN: + printf("Domain: %s\n", + u.domain->domain_name.string); + break; + case NETR_DELTA_GROUP: + printf("Group: %s\n", + u.group->group_name.string); + break; + case NETR_DELTA_DELETE_GROUP: + printf("Delete Group: %d\n", + u.delete_account.unknown); + break; + case NETR_DELTA_RENAME_GROUP: + printf("Rename Group: %s -> %s\n", + u.rename_group->OldName.string, + u.rename_group->NewName.string); + break; + case NETR_DELTA_USER: + printf("Account: %s\n", + u.user->account_name.string); + break; + case NETR_DELTA_DELETE_USER: + printf("Delete User: %d\n", + id.rid); + break; + case NETR_DELTA_RENAME_USER: + printf("Rename user: %s -> %s\n", + u.rename_user->OldName.string, + u.rename_user->NewName.string); + break; + case NETR_DELTA_GROUP_MEMBER: + for (j=0; j < u.group_member->num_rids; j++) { + printf("rid 0x%x, attrib 0x%08x\n", + u.group_member->rids[j], + u.group_member->attribs[j]); + } + break; + case NETR_DELTA_ALIAS: + printf("Alias: %s\n", + u.alias->alias_name.string); + break; + case NETR_DELTA_DELETE_ALIAS: + printf("Delete Alias: %d\n", + r->delta_enum[i].delta_id_union.rid); + break; + case NETR_DELTA_RENAME_ALIAS: + printf("Rename alias: %s -> %s\n", + u.rename_alias->OldName.string, + u.rename_alias->NewName.string); + break; + case NETR_DELTA_ALIAS_MEMBER: + for (j=0; j < u.alias_member->sids.num_sids; j++) { + fstring sid_str; + sid_to_fstring(sid_str, + u.alias_member->sids.sids[j].sid); + printf("%s\n", sid_str); + } + break; + case NETR_DELTA_POLICY: + printf("Policy\n"); + break; + case NETR_DELTA_TRUSTED_DOMAIN: + printf("Trusted Domain: %s\n", + u.trusted_domain->domain_name.string); + break; + case NETR_DELTA_DELETE_TRUST: + printf("Delete Trust: %d\n", + u.delete_trust.unknown); + break; + case NETR_DELTA_ACCOUNT: + printf("Account\n"); + break; + case NETR_DELTA_DELETE_ACCOUNT: + printf("Delete Account: %d\n", + u.delete_account.unknown); + break; + case NETR_DELTA_SECRET: + printf("Secret\n"); + break; + case NETR_DELTA_DELETE_SECRET: + printf("Delete Secret: %d\n", + u.delete_secret.unknown); + break; + case NETR_DELTA_DELETE_GROUP2: + printf("Delete Group2: %s\n", + u.delete_group->account_name); + break; + case NETR_DELTA_DELETE_USER2: + printf("Delete User2: %s\n", + u.delete_user->account_name); + break; + case NETR_DELTA_MODIFY_COUNT: + printf("sam sequence update: 0x%016llx\n", + (unsigned long long) *u.modified_count); + break; + default: + printf("unknown delta type 0x%02x\n", + r->delta_enum[i].delta_type); + break; + } + } } /* Perform sam synchronisation */ @@ -534,7 +581,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, /* Display results */ - display_sam_sync(num_deltas, hdr_deltas, deltas); +/* display_sam_sync(num_deltas, hdr_deltas, deltas); */ done: return result; @@ -542,38 +589,63 @@ static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, /* Perform sam delta synchronisation */ -static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, int argc, - const char **argv) +static NTSTATUS cmd_netlogon_sam_deltas(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - uint32 database_id, num_deltas, tmp; - SAM_DELTA_HDR *hdr_deltas; - SAM_DELTA_CTR *deltas; - uint64 seqnum; + uint32_t tmp; + const char *logon_server = cli->cli->desthost; + const char *computername = global_myname(); + struct netr_Authenticator credential; + struct netr_Authenticator return_authenticator; + enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN; + uint64_t sequence_num; + + if (argc != 3) { + fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]); + return NT_STATUS_OK; + } - if (argc != 3) { - fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]); - return NT_STATUS_OK; - } + database_id = atoi(argv[1]); + tmp = atoi(argv[2]); - database_id = atoi(argv[1]); - tmp = atoi(argv[2]); + sequence_num = tmp & 0xffff; - seqnum = tmp & 0xffff; + do { + struct netr_DELTA_ENUM_ARRAY *delta_enum_array = NULL; - result = rpccli_netlogon_sam_deltas(cli, mem_ctx, database_id, - seqnum, &num_deltas, - &hdr_deltas, &deltas); + netlogon_creds_client_step(cli->dc, &credential); - if (!NT_STATUS_IS_OK(result)) - goto done; + result = rpccli_netr_DatabaseDeltas(cli, mem_ctx, + logon_server, + computername, + &credential, + &return_authenticator, + database_id, + &sequence_num, + &delta_enum_array, + 0xffff); - /* Display results */ + /* Check returned credentials. */ + if (!netlogon_creds_client_check(cli->dc, + &return_authenticator.cred)) { + DEBUG(0,("credentials chain check failed\n")); + return NT_STATUS_ACCESS_DENIED; + } + + if (NT_STATUS_IS_ERR(result)) { + break; + } + + /* Display results */ + + display_sam_sync(delta_enum_array); + + TALLOC_FREE(delta_enum_array); + + } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); - display_sam_sync(num_deltas, hdr_deltas, deltas); - - done: return result; } -- cgit From eafec423b78f91f97793e26b6dd0c2a27c557d19 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 14:11:20 +0100 Subject: Use rpccli_netr_DatabaseSync2() in rpcclient. Guenther (This used to be commit 042173b00e023b4d4e7739524e24baa8803850bd) --- source3/rpcclient/cmd_netlogon.c | 59 ++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 15 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index cf52da7c9f..49098b12e4 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -554,37 +554,66 @@ static void display_sam_sync(struct netr_DELTA_ENUM_ARRAY *r) /* Perform sam synchronisation */ -static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, +static NTSTATUS cmd_netlogon_sam_sync(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - uint32 database_id = 0, num_deltas; - SAM_DELTA_HDR *hdr_deltas; - SAM_DELTA_CTR *deltas; + const char *logon_server = cli->cli->desthost; + const char *computername = global_myname(); + struct netr_Authenticator credential; + struct netr_Authenticator return_authenticator; + enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN; + uint16_t restart_state = 0; + uint32_t sync_context = 0; if (argc > 2) { fprintf(stderr, "Usage: %s [database_id]\n", argv[0]); return NT_STATUS_OK; } - if (argc == 2) - database_id = atoi(argv[1]); + if (argc == 2) { + database_id = atoi(argv[1]); + } + + /* Synchronise sam database */ + + do { + struct netr_DELTA_ENUM_ARRAY *delta_enum_array = NULL; - /* Synchronise sam database */ + netlogon_creds_client_step(cli->dc, &credential); - result = rpccli_netlogon_sam_sync(cli, mem_ctx, database_id, - 0, &num_deltas, &hdr_deltas, &deltas); + result = rpccli_netr_DatabaseSync2(cli, mem_ctx, + logon_server, + computername, + &credential, + &return_authenticator, + database_id, + restart_state, + &sync_context, + &delta_enum_array, + 0xffff); - if (!NT_STATUS_IS_OK(result)) - goto done; + /* Check returned credentials. */ + if (!netlogon_creds_client_check(cli->dc, + &return_authenticator.cred)) { + DEBUG(0,("credentials chain check failed\n")); + return NT_STATUS_ACCESS_DENIED; + } - /* Display results */ + if (NT_STATUS_IS_ERR(result)) { + break; + } -/* display_sam_sync(num_deltas, hdr_deltas, deltas); */ + /* Display results */ - done: - return result; + display_sam_sync(delta_enum_array); + + TALLOC_FREE(delta_enum_array); + + } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); + + return result; } /* Perform sam delta synchronisation */ -- cgit From e99f740b0ab5eef11cb3ae1f432dc9669b0a753a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:16:56 +0100 Subject: Add very basic ntsvcs client to rpcclient. Guenther (This used to be commit 0358ad7e933f6a0859000ba56e4bb88506d70610) --- source3/rpcclient/cmd_ntsvcs.c | 51 ++++++++++++++++++++++++++++++++++++++++++ source3/rpcclient/rpcclient.c | 2 ++ 2 files changed, 53 insertions(+) create mode 100644 source3/rpcclient/cmd_ntsvcs.c (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_ntsvcs.c b/source3/rpcclient/cmd_ntsvcs.c new file mode 100644 index 0000000000..a595948c35 --- /dev/null +++ b/source3/rpcclient/cmd_ntsvcs.c @@ -0,0 +1,51 @@ +/* + Unix SMB/CIFS implementation. + RPC pipe client + + Copyright (C) Günther Deschner 2008 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "includes.h" +#include "rpcclient.h" + +static WERROR cmd_ntsvcs_get_version(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + NTSTATUS status; + WERROR werr; + uint16_t version; + + status = rpccli_PNP_GetVersion(cli, mem_ctx, + &version, &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + if (W_ERROR_IS_OK(werr)) { + printf("version: %d\n", version); + } + + return werr; +} + +struct cmd_set ntsvcs_commands[] = { + + { "NTSVCS" }, + { "ntsvcs_getversion", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_version, PI_NTSVCS, NULL, "Query NTSVCS version", "" }, + { NULL } +}; diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 4a9b4acb7d..5e87058111 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -503,6 +503,7 @@ extern struct cmd_set echo_commands[]; extern struct cmd_set shutdown_commands[]; extern struct cmd_set test_commands[]; extern struct cmd_set wkssvc_commands[]; +extern struct cmd_set ntsvcs_commands[]; static struct cmd_set *rpcclient_command_list[] = { rpcclient_commands, @@ -517,6 +518,7 @@ static struct cmd_set *rpcclient_command_list[] = { shutdown_commands, test_commands, wkssvc_commands, + ntsvcs_commands, NULL }; -- cgit From 948bfd629eec03bac3715c17f9d30b3995a2e2e1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:41:31 +0100 Subject: Add ValidateDeviceInstance command to rpcclient. Guenther (This used to be commit a2e6727ff7d75b50a33c4186f48477ca35b3fbb9) --- source3/rpcclient/cmd_ntsvcs.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_ntsvcs.c b/source3/rpcclient/cmd_ntsvcs.c index a595948c35..f7648061c2 100644 --- a/source3/rpcclient/cmd_ntsvcs.c +++ b/source3/rpcclient/cmd_ntsvcs.c @@ -43,9 +43,42 @@ static WERROR cmd_ntsvcs_get_version(struct rpc_pipe_client *cli, return werr; } +static WERROR cmd_ntsvcs_validate_dev_inst(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + NTSTATUS status; + WERROR werr; + const char *devicepath = NULL; + uint32_t flags = 0; + + if (argc < 2 || argc > 3) { + printf("usage: %s [devicepath] \n", argv[0]); + return WERR_OK; + } + + devicepath = argv[1]; + + if (argc >= 3) { + flags = atoi(argv[2]); + } + + status = rpccli_PNP_ValidateDeviceInstance(cli, mem_ctx, + devicepath, + flags, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + return werr; +} + struct cmd_set ntsvcs_commands[] = { { "NTSVCS" }, { "ntsvcs_getversion", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_version, PI_NTSVCS, NULL, "Query NTSVCS version", "" }, + { "ntsvcs_validatedevinst", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_validate_dev_inst, PI_NTSVCS, NULL, "Query NTSVCS device instance", "" }, { NULL } }; -- cgit From 2e75900641b57d6a369d07efca817557650d9b8e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 00:23:25 +0100 Subject: Add ntsvcs_getdevlistsize command to rpcclient. Guenther (This used to be commit 9bc5068cc387cd02e53db6146db9b4ed0af3160d) --- source3/rpcclient/cmd_ntsvcs.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_ntsvcs.c b/source3/rpcclient/cmd_ntsvcs.c index f7648061c2..04e367abdb 100644 --- a/source3/rpcclient/cmd_ntsvcs.c +++ b/source3/rpcclient/cmd_ntsvcs.c @@ -75,10 +75,50 @@ static WERROR cmd_ntsvcs_validate_dev_inst(struct rpc_pipe_client *cli, return werr; } +static WERROR cmd_ntsvcs_get_device_list_size(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + NTSTATUS status; + WERROR werr; + const char *devicename = NULL; + uint32_t flags = 0; + uint32_t size = 0; + + if (argc < 2 || argc > 4) { + printf("usage: %s [devicename] \n", argv[0]); + return WERR_OK; + } + + devicename = argv[1]; + + if (argc >= 3) { + flags = atoi(argv[2]); + } + + status = rpccli_PNP_GetDeviceListSize(cli, mem_ctx, + devicename, + &size, + flags, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + if (W_ERROR_IS_OK(werr)) { + printf("size: %d\n", size); + } + + return werr; +} + + struct cmd_set ntsvcs_commands[] = { { "NTSVCS" }, { "ntsvcs_getversion", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_version, PI_NTSVCS, NULL, "Query NTSVCS version", "" }, { "ntsvcs_validatedevinst", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_validate_dev_inst, PI_NTSVCS, NULL, "Query NTSVCS device instance", "" }, + { "ntsvcs_getdevlistsize", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_device_list_size, PI_NTSVCS, NULL, "Query NTSVCS get device list", "" }, { NULL } }; -- cgit From 57814bccfbb936849488a0b46a7dcd65247856e1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 01:07:12 +0100 Subject: Add ntsvcs_hwprofflags command to rpcclient. Guenther (This used to be commit c184a711464d11ebb62989487d33d51d39c97092) --- source3/rpcclient/cmd_ntsvcs.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_ntsvcs.c b/source3/rpcclient/cmd_ntsvcs.c index 04e367abdb..922d03df54 100644 --- a/source3/rpcclient/cmd_ntsvcs.c +++ b/source3/rpcclient/cmd_ntsvcs.c @@ -113,6 +113,43 @@ static WERROR cmd_ntsvcs_get_device_list_size(struct rpc_pipe_client *cli, return werr; } +static WERROR cmd_ntsvcs_hw_prof_flags(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + NTSTATUS status; + WERROR werr; + const char *devicepath = NULL; + uint32_t unk3 = 0; + uint16_t unk4 = 0; + const char *unk5 = NULL; + const char *unk5a = NULL; + + if (argc < 2) { + printf("usage: %s [devicepath]\n", argv[0]); + return WERR_OK; + } + + devicepath = argv[1]; + + status = rpccli_PNP_HwProfFlags(cli, mem_ctx, + 0, + devicepath, + 0, + &unk3, + &unk4, + unk5, + &unk5a, + 0, + 0, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + return werr; +} struct cmd_set ntsvcs_commands[] = { @@ -120,5 +157,6 @@ struct cmd_set ntsvcs_commands[] = { { "ntsvcs_getversion", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_version, PI_NTSVCS, NULL, "Query NTSVCS version", "" }, { "ntsvcs_validatedevinst", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_validate_dev_inst, PI_NTSVCS, NULL, "Query NTSVCS device instance", "" }, { "ntsvcs_getdevlistsize", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_device_list_size, PI_NTSVCS, NULL, "Query NTSVCS get device list", "" }, + { "ntsvcs_hwprofflags", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_hw_prof_flags, PI_NTSVCS, NULL, "Query NTSVCS HW prof flags", "" }, { NULL } }; -- cgit From 4149868f8567a6735fde4b4fae807845e72473eb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 01:29:55 +0100 Subject: Add ntsvcs_hwprofinfo command to rpcclient. Guenther (This used to be commit 8d8cf915f793980bdd0d89fc8d53ea1c1e759065) --- source3/rpcclient/cmd_ntsvcs.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_ntsvcs.c b/source3/rpcclient/cmd_ntsvcs.c index 922d03df54..b7b37e2fa6 100644 --- a/source3/rpcclient/cmd_ntsvcs.c +++ b/source3/rpcclient/cmd_ntsvcs.c @@ -151,6 +151,32 @@ static WERROR cmd_ntsvcs_hw_prof_flags(struct rpc_pipe_client *cli, return werr; } +static WERROR cmd_ntsvcs_get_hw_prof_info(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + NTSTATUS status; + WERROR werr; + uint32_t idx = 0; + struct PNP_HwProfInfo info; + uint32_t unknown1 = 0, unknown2 = 0; + + ZERO_STRUCT(info); + + status = rpccli_PNP_GetHwProfInfo(cli, mem_ctx, + idx, + &info, + unknown1, + unknown2, + &werr); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + return werr; +} + struct cmd_set ntsvcs_commands[] = { { "NTSVCS" }, @@ -158,5 +184,6 @@ struct cmd_set ntsvcs_commands[] = { { "ntsvcs_validatedevinst", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_validate_dev_inst, PI_NTSVCS, NULL, "Query NTSVCS device instance", "" }, { "ntsvcs_getdevlistsize", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_device_list_size, PI_NTSVCS, NULL, "Query NTSVCS get device list", "" }, { "ntsvcs_hwprofflags", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_hw_prof_flags, PI_NTSVCS, NULL, "Query NTSVCS HW prof flags", "" }, + { "ntsvcs_hwprofinfo", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_hw_prof_info, PI_NTSVCS, NULL, "Query NTSVCS HW prof info", "" }, { NULL } }; -- cgit From 9053bdf57c39102f0a9ec78cbbee3f7ff45d72e1 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 18 Feb 2008 10:24:51 +1100 Subject: Fix off-by-one bugs in subcommand argument passing. (This used to be commit d85a2782a483e563a8b68924d4897a145bc25896) --- source3/rpcclient/cmd_samr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index f8b8ba893c..8b4ee47a67 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -1044,8 +1044,8 @@ static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli, return NT_STATUS_OK; } - if (argc > 2) { - sscanf(argv[2], "%x", &access_mask); + if (argc > 1) { + sscanf(argv[1], "%x", &access_mask); } /* Get sam policy handle */ @@ -1194,11 +1194,11 @@ static NTSTATUS cmd_samr_query_aliasinfo(struct rpc_pipe_client *cli, sscanf(argv[2], "%i", &alias_rid); - if (argc > 3) { + if (argc > 2) { level = atoi(argv[3]); } - if (argc > 4) { + if (argc > 3) { sscanf(argv[4], "%x", &access_mask); } -- cgit From 2d01ec2c390f8dd753600f22cefb17e7b8916ffd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 15:49:31 +0100 Subject: Use new LSA_POLICY defines in lsa rpc server code and other places. Guenther (This used to be commit 58cca9faf9db506bd2f6eab4a99ef85153797ab2) --- source3/rpcclient/cmd_lsarpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 3fe8bc8e52..512d80ae15 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -394,7 +394,7 @@ static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli, } result = rpccli_lsa_open_policy(cli, mem_ctx, True, - POLICY_VIEW_LOCAL_INFORMATION, + LSA_POLICY_VIEW_LOCAL_INFORMATION, &pol); if (!NT_STATUS_IS_OK(result)) -- cgit From 7269a504fdd06fbbe24c2df8e084b41382d71269 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 19:38:48 +0100 Subject: Add my copyright. Guenther (This used to be commit d078a8757182d84dfd3307a2e1b751cf173aaa97) --- source3/rpcclient/cmd_lsarpc.c | 1 + source3/rpcclient/cmd_netlogon.c | 1 + source3/rpcclient/cmd_samr.c | 1 + 3 files changed, 3 insertions(+) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 512d80ae15..90f8646810 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -4,6 +4,7 @@ Copyright (C) Tim Potter 2000 Copyright (C) Rafal Szczesniak 2002 + Copyright (C) Guenther Deschner 2008 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 diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 49098b12e4..95d79b5825 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -3,6 +3,7 @@ RPC pipe client Copyright (C) Tim Potter 2000 + Copyright (C) Guenther Deschner 2008 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 diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index 8b4ee47a67..2d20afeb13 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -6,6 +6,7 @@ Copyright (C) Luke Kenneth Casson Leighton 1996-2000, Copyright (C) Elrond 2000, Copyright (C) Tim Potter 2000 + Copyright (C) Guenther Deschner 2008 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 -- cgit From 640f53fe5bd989c57365e6ca85be29d2441c4b99 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 23:11:53 +0100 Subject: Use rpccli_srvsvc_NetSrvGetInfo() in rpcclient. Guenther (This used to be commit 4a74f1e8d2c45574973fc4c0ce4fbc9a843afaa0) --- source3/rpcclient/cmd_srvsvc.c | 78 ++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 40 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c index 572609981d..4b3601a5ff 100644 --- a/source3/rpcclient/cmd_srvsvc.c +++ b/source3/rpcclient/cmd_srvsvc.c @@ -130,51 +130,37 @@ static char *get_server_type_str(uint32 type) return typestr; } -static void display_server(char *sname, uint32 type, const char *comment) +static void display_server(const char *sname, uint32 type, const char *comment) { printf("\t%-15.15s%-20s %s\n", sname, get_server_type_str(type), comment); } -static void display_srv_info_101(SRV_INFO_101 *sv101) +static void display_srv_info_101(struct srvsvc_NetSrvInfo101 *r) { - fstring name; - fstring comment; + display_server(r->server_name, r->server_type, r->comment); - unistr2_to_ascii(name, &sv101->uni_name, sizeof(name)); - unistr2_to_ascii(comment, &sv101->uni_comment, sizeof(comment)); - - display_server(name, sv101->srv_type, comment); - - printf("\tplatform_id :\t%d\n", sv101->platform_id); - printf("\tos version :\t%d.%d\n", sv101->ver_major, - sv101->ver_minor); - - printf("\tserver type :\t0x%x\n", sv101->srv_type); + printf("\tplatform_id :\t%d\n", r->platform_id); + printf("\tos version :\t%d.%d\n", + r->version_major, r->version_minor); + printf("\tserver type :\t0x%x\n", r->server_type); } -static void display_srv_info_102(SRV_INFO_102 *sv102) +static void display_srv_info_102(struct srvsvc_NetSrvInfo102 *r) { - fstring name; - fstring comment; - fstring usr_path; - - unistr2_to_ascii(name, &sv102->uni_name, sizeof(name)); - unistr2_to_ascii(comment, &sv102->uni_comment, sizeof(comment)); - unistr2_to_ascii(usr_path, &sv102->uni_usr_path, sizeof(usr_path)); - - display_server(name, sv102->srv_type, comment); - - printf("\tplatform_id :\t%d\n", sv102->platform_id); - printf("\tos version :\t%d.%d\n", sv102->ver_major, - sv102->ver_minor); - - printf("\tusers :\t%x\n", sv102->users); - printf("\tdisc, hidden :\t%x, %x\n", sv102->disc, sv102->hidden); - printf("\tannounce, delta :\t%d, %d\n", sv102->announce, - sv102->ann_delta); - printf("\tlicenses :\t%d\n", sv102->licenses); - printf("\tuser path :\t%s\n", usr_path); + display_server(r->server_name, r->server_type, r->comment); + + printf("\tplatform_id :\t%d\n", r->platform_id); + printf("\tos version :\t%d.%d\n", + r->version_major, r->version_minor); + printf("\tserver type :\t0x%x\n", r->server_type); + + printf("\tusers :\t%x\n", r->users); + printf("\tdisc, hidden :\t%x, %x\n", r->disc, r->hidden); + printf("\tannounce, delta :\t%d, %d\n", r->announce, + r->anndelta); + printf("\tlicenses :\t%d\n", r->licenses); + printf("\tuser path :\t%s\n", r->userpath); } /* Server query info */ @@ -183,8 +169,10 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli, int argc, const char **argv) { uint32 info_level = 101; - SRV_INFO_CTR ctr; + union srvsvc_NetSrvInfo info; WERROR result; + NTSTATUS status; + const char *server_name; if (argc > 2) { printf("Usage: %s [infolevel]\n", argv[0]); @@ -194,8 +182,18 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli, if (argc == 2) info_level = atoi(argv[1]); - result = rpccli_srvsvc_net_srv_get_info(cli, mem_ctx, info_level, - &ctr); + server_name = talloc_asprintf_strupper_m(mem_ctx, "\\\\%s", + cli->cli->desthost); + W_ERROR_HAVE_NO_MEMORY(server_name); + + status = rpccli_srvsvc_NetSrvGetInfo(cli, mem_ctx, + server_name, + info_level, + &info, + &result); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } if (!W_ERROR_IS_OK(result)) { goto done; @@ -205,10 +203,10 @@ static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli, switch (info_level) { case 101: - display_srv_info_101(&ctr.srv.sv101); + display_srv_info_101(info.info101); break; case 102: - display_srv_info_102(&ctr.srv.sv102); + display_srv_info_102(info.info102); break; default: printf("unsupported info level %d\n", info_level); -- cgit From b0dad261add75789cbbbfed12ed1d3f25c3e2182 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 10:38:13 +0100 Subject: Use rpccli_srvsvc_NetRemoteTOD() in rpcclient. Guenther (This used to be commit 5e9d8cdc948b678e5aa6e04ee13635376b7306f5) --- source3/rpcclient/cmd_srvsvc.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c index 4b3601a5ff..2e84f0498f 100644 --- a/source3/rpcclient/cmd_srvsvc.c +++ b/source3/rpcclient/cmd_srvsvc.c @@ -402,9 +402,10 @@ 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; + struct srvsvc_NetRemoteTODInfo *tod = NULL; fstring srv_name_slash; WERROR result; + NTSTATUS status; if (argc > 1) { printf("Usage: %s\n", argv[0]); @@ -412,8 +413,14 @@ static WERROR cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *cli, } fstr_sprintf(srv_name_slash, "\\\\%s", cli->cli->desthost); - result = rpccli_srvsvc_net_remote_tod( - cli, mem_ctx, srv_name_slash, &tod); + status = rpccli_srvsvc_NetRemoteTOD(cli, mem_ctx, + srv_name_slash, + &tod, + &result); + if (!NT_STATUS_IS_OK(status)) { + result = ntstatus_to_werror(status); + goto done; + } if (!W_ERROR_IS_OK(result)) goto done; -- cgit