From 90de1431b91231c2ef0013fb3cfac537ca9830f1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 7 Dec 2018 10:32:08 +0100 Subject: [PATCH] rpcclient: Use dom_sid_str_buf Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Sat Dec 8 02:43:48 CET 2018 on sn-devel-144 --- source3/rpcclient/cmd_lsarpc.c | 61 ++++++++++++++++++---------------- source3/rpcclient/cmd_samr.c | 12 +++---- 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 462ed06e007..d2479821bee 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -252,10 +252,12 @@ static NTSTATUS cmd_lsa_lookup_names(struct rpc_pipe_client *cli, /* Print results */ for (i = 0; i < (argc - 1); i++) { - fstring sid_str; - sid_to_fstring(sid_str, &sids[i]); - printf("%s %s (%s: %d)\n", argv[i + 1], sid_str, - sid_type_lookup(types[i]), types[i]); + struct dom_sid_buf sid_str; + printf("%s %s (%s: %d)\n", + argv[i + 1], + dom_sid_str_buf(&sids[i], &sid_str), + sid_type_lookup(types[i]), + types[i]); } dcerpc_lsa_Close(b, mem_ctx, &pol, &result); @@ -305,10 +307,12 @@ static NTSTATUS cmd_lsa_lookup_names_level(struct rpc_pipe_client *cli, /* Print results */ for (i = 0; i < (argc - 2); i++) { - fstring sid_str; - sid_to_fstring(sid_str, &sids[i]); - printf("%s %s (%s: %d)\n", argv[i + 2], sid_str, - sid_type_lookup(types[i]), types[i]); + struct dom_sid_buf sid_str; + printf("%s %s (%s: %d)\n", + argv[i + 2], + dom_sid_str_buf(&sids[i], &sid_str), + sid_type_lookup(types[i]), + types[i]); } dcerpc_lsa_Close(b, mem_ctx, &pol, &result); @@ -368,9 +372,10 @@ static NTSTATUS cmd_lsa_lookup_names4(struct rpc_pipe_client *cli, } for (i = 0; i < sids.count; i++) { - fstring sid_str; - sid_to_fstring(sid_str, sids.sids[i].sid); - printf("%s %s (%s: %d)\n", argv[i+1], sid_str, + struct dom_sid_buf sid_str; + printf("%s %s (%s: %d)\n", + argv[i+1], + dom_sid_str_buf(sids.sids[i].sid, &sid_str), sid_type_lookup(sids.sids[i].sid_type), sids.sids[i].sid_type); } @@ -433,15 +438,15 @@ static NTSTATUS cmd_lsa_lookup_sids(struct rpc_pipe_client *cli, TALLOC_CTX *mem /* Print results */ for (i = 0; i < (argc - 1); i++) { - fstring sid_str; + struct dom_sid_buf sid_str; - sid_to_fstring(sid_str, &sids[i]); + dom_sid_str_buf(&sids[i], &sid_str); if (types[i] == SID_NAME_DOMAIN) { - printf("%s %s (%d)\n", sid_str, + printf("%s %s (%d)\n", sid_str.buf, domains[i] ? domains[i] : "*unknown*", types[i]); } else { - printf("%s %s\\%s (%d)\n", sid_str, + printf("%s %s\\%s (%d)\n", sid_str.buf, domains[i] ? domains[i] : "*unknown*", names[i] ? names[i] : "*unknown*", types[i]); @@ -525,15 +530,15 @@ static NTSTATUS cmd_lsa_lookup_sids_level(struct rpc_pipe_client *cli, /* Print results */ for (i = 0; i < (argc - 2); i++) { - fstring sid_str; + struct dom_sid_buf sid_str; - sid_to_fstring(sid_str, &sids[i]); + dom_sid_str_buf(&sids[i], &sid_str); if (types[i] == SID_NAME_DOMAIN) { - printf("%s %s (%d)\n", sid_str, + printf("%s %s (%d)\n", sid_str.buf, domains[i] ? domains[i] : "*unknown*", types[i]); } else { - printf("%s %s\\%s (%d)\n", sid_str, + printf("%s %s\\%s (%d)\n", sid_str.buf, domains[i] ? domains[i] : "*unknown*", names[i] ? names[i] : "*unknown*", types[i]); @@ -612,13 +617,13 @@ static NTSTATUS cmd_lsa_lookup_sids3(struct rpc_pipe_client *cli, /* Print results */ for (i = 0; i < names.count; i++) { - fstring sid_str; + struct dom_sid_buf sid_str; if (i >= sids.num_sids) { break; } - sid_to_fstring(sid_str, sids.sids[i].sid); - printf("%s %s (%d)\n", sid_str, + printf("%s %s (%d)\n", + dom_sid_str_buf(sids.sids[i].sid, &sid_str), names.names[i].name.string, names.names[i].sid_type); } @@ -685,13 +690,13 @@ static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli, /* Print results: list of names and sids returned in this * response. */ for (i = 0; i < domain_list.count; i++) { - fstring sid_str; + struct dom_sid_buf sid_str; - sid_to_fstring(sid_str, domain_list.domains[i].sid); printf("%s %s\n", domain_list.domains[i].name.string ? domain_list.domains[i].name.string : "*unknown*", - sid_str); + dom_sid_str_buf(domain_list.domains[i].sid, + &sid_str)); } } @@ -866,10 +871,10 @@ static NTSTATUS cmd_lsa_enum_sids(struct rpc_pipe_client *cli, printf("found %d SIDs\n\n", sid_array.num_sids); for (i = 0; i < sid_array.num_sids; i++) { - fstring sid_str; + struct dom_sid_buf sid_str; - sid_to_fstring(sid_str, sid_array.sids[i].sid); - printf("%s\n", sid_str); + printf("%s\n", + dom_sid_str_buf(sid_array.sids[i].sid, &sid_str)); } dcerpc_lsa_Close(b, mem_ctx, &pol, &result); diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index 19ae0aa30ea..d55d1648c91 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -1279,10 +1279,10 @@ static NTSTATUS cmd_samr_query_aliasmem(struct rpc_pipe_client *cli, } for (i = 0; i < sid_array.num_sids; i++) { - fstring sid_str; + struct dom_sid_buf sid_str; - sid_to_fstring(sid_str, sid_array.sids[i].sid); - printf("\tsid:[%s]\n", sid_str); + printf("\tsid:[%s]\n", + dom_sid_str_buf(sid_array.sids[i].sid, &sid_str)); } dcerpc_samr_Close(b, mem_ctx, &alias_pol, &result); @@ -2690,7 +2690,6 @@ static NTSTATUS cmd_samr_lookup_domain(struct rpc_pipe_client *cli, struct policy_handle connect_pol, domain_pol; NTSTATUS status, result; uint32_t access_mask = MAXIMUM_ALLOWED_ACCESS; - fstring sid_string; struct lsa_String domain_name; struct dom_sid *sid = NULL; struct dcerpc_binding_handle *b = cli->binding_handle; @@ -2737,9 +2736,10 @@ static NTSTATUS cmd_samr_lookup_domain(struct rpc_pipe_client *cli, } if (NT_STATUS_IS_OK(result)) { - sid_to_fstring(sid_string, sid); + struct dom_sid_buf sid_str; printf("SAMR_LOOKUP_DOMAIN: Domain Name: %s Domain SID: %s\n", - argv[1], sid_string); + argv[1], + dom_sid_str_buf(sid, &sid_str)); } dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);