diff options
Diffstat (limited to 'source3/rpcclient')
-rw-r--r-- | source3/rpcclient/cmd_lsarpc.c | 9 | ||||
-rw-r--r-- | source3/rpcclient/cmd_samr.c | 152 | ||||
-rw-r--r-- | source3/rpcclient/cmd_srvsvc.c | 261 | ||||
-rw-r--r-- | source3/rpcclient/cmd_unixinfo.c | 201 | ||||
-rw-r--r-- | source3/rpcclient/rpcclient.c | 2 |
5 files changed, 148 insertions, 477 deletions
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 020f4acf4d..31a8e2bdfd 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -993,7 +993,8 @@ static NTSTATUS cmd_lsa_query_trustdominfobysid(struct rpc_pipe_client *cli, display_trust_dom_info(info, info_class, cli->pwd.password); done: - rpccli_lsa_Close(cli, mem_ctx, &pol); + if (&pol) + rpccli_lsa_Close(cli, mem_ctx, &pol); return result; } @@ -1030,7 +1031,8 @@ static NTSTATUS cmd_lsa_query_trustdominfobyname(struct rpc_pipe_client *cli, display_trust_dom_info(info, info_class, cli->pwd.password); done: - rpccli_lsa_Close(cli, mem_ctx, &pol); + if (&pol) + rpccli_lsa_Close(cli, mem_ctx, &pol); return result; } @@ -1078,7 +1080,8 @@ static NTSTATUS cmd_lsa_query_trustdominfo(struct rpc_pipe_client *cli, display_trust_dom_info(info, info_class, cli->pwd.password); done: - rpccli_lsa_Close(cli, mem_ctx, &pol); + if (&pol) + rpccli_lsa_Close(cli, mem_ctx, &pol); return result; } diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index b4cfb1eb29..3cef720ac5 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -1207,14 +1207,13 @@ static NTSTATUS cmd_samr_delete_alias(struct rpc_pipe_client *cli, /* Query display info */ -static NTSTATUS cmd_samr_query_dispinfo_int(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - int argc, const char **argv, - int opcode) +static NTSTATUS cmd_samr_query_dispinfo(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + int argc, const char **argv) { POLICY_HND connect_pol, domain_pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - uint32 start_idx=0, max_entries=250, max_size = (uint32) -1, num_entries, i; + uint32 start_idx=0, max_entries=250, max_size = 0xffff, num_entries, i; uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; uint32 info_level = 1; SAM_DISPINFO_CTR ctr; @@ -1250,7 +1249,6 @@ static NTSTATUS cmd_samr_query_dispinfo_int(struct rpc_pipe_client *cli, if (argc >= 6) sscanf(argv[5], "%x", &access_mask); - /* Get sam policy handle */ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS, @@ -1302,31 +1300,11 @@ static NTSTATUS cmd_samr_query_dispinfo_int(struct rpc_pipe_client *cli, if (!got_params) get_query_dispinfo_params( loop_count, &max_entries, &max_size); - - switch (opcode) { - case SAMR_QUERY_DISPINFO: - result = rpccli_samr_query_dispinfo(cli, mem_ctx, &domain_pol, - &start_idx, info_level, - &num_entries, max_entries, - max_size, &ctr); - break; - case SAMR_QUERY_DISPINFO2: - result = rpccli_samr_query_dispinfo2(cli, mem_ctx, &domain_pol, - &start_idx, info_level, - &num_entries, max_entries, - max_size, &ctr); - break; - case SAMR_QUERY_DISPINFO3: - result = rpccli_samr_query_dispinfo3(cli, mem_ctx, &domain_pol, - &start_idx, info_level, - &num_entries, max_entries, - max_size, &ctr); - break; - default: - printf("unknown opcode: %d\n", opcode); - return NT_STATUS_INVALID_PARAMETER; - break; - } + + result = rpccli_samr_query_dispinfo(cli, mem_ctx, &domain_pol, + &start_idx, info_level, + &num_entries, max_entries, + max_size, &ctr); loop_count++; @@ -1363,114 +1341,6 @@ static NTSTATUS cmd_samr_query_dispinfo_int(struct rpc_pipe_client *cli, return result; } -static NTSTATUS cmd_samr_query_dispinfo(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - int argc, const char **argv) -{ - return cmd_samr_query_dispinfo_int(cli, mem_ctx, argc, argv, SAMR_QUERY_DISPINFO); -} - -static NTSTATUS cmd_samr_query_dispinfo2(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - int argc, const char **argv) -{ - return cmd_samr_query_dispinfo_int(cli, mem_ctx, argc, argv, SAMR_QUERY_DISPINFO2); -} - -static NTSTATUS cmd_samr_query_dispinfo3(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - int argc, const char **argv) -{ - return cmd_samr_query_dispinfo_int(cli, mem_ctx, argc, argv, SAMR_QUERY_DISPINFO3); -} - -/* Query display info index */ - -static NTSTATUS cmd_samr_get_dispenum_index_int(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - int argc, const char **argv, - int opcode) -{ - POLICY_HND connect_pol, domain_pol; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - uint32 access_mask = MAXIMUM_ALLOWED_ACCESS; - uint16 info_level = 1; - uint32 idx; - - if (argc < 2 || argc > 3) { - printf("Usage: %s name [info level]\n", argv[0]); - return NT_STATUS_OK; - } - - if (argc >= 3) { - sscanf(argv[2], "%hd", &info_level); - } - - /* Get sam policy handle */ - - result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS, - &connect_pol); - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - /* Get domain policy handle */ - - result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol, - access_mask, - &domain_sid, &domain_pol); - - if (!NT_STATUS_IS_OK(result)) { - goto done; - } - - /* Query display info index */ - - switch (opcode) { - case SAMR_GET_DISPENUM_INDEX: - result = rpccli_samr_get_dispenum_index(cli, mem_ctx, &domain_pol, - info_level, argv[1], &idx); - break; - case SAMR_GET_DISPENUM_INDEX2: - result = rpccli_samr_get_dispenum_index2(cli, mem_ctx, &domain_pol, - info_level, argv[1], &idx); - break; - default: - printf("unknown opcode\n"); - return NT_STATUS_INVALID_PARAMETER; - } - - if (NT_STATUS_IS_ERR(result)) { - goto done; - }; - - printf("idx is: %d (0x%08x)\n", idx, idx); - - rpccli_samr_close(cli, mem_ctx, &domain_pol); - rpccli_samr_close(cli, mem_ctx, &connect_pol); - done: - return result; -} - -/* Query display info index */ - -static NTSTATUS cmd_samr_get_dispenum_index(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - int argc, const char **argv) -{ - return cmd_samr_get_dispenum_index_int(cli, mem_ctx, argc, argv, SAMR_GET_DISPENUM_INDEX); -} - -/* Query display info index2 */ - -static NTSTATUS cmd_samr_get_dispenum_index2(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - int argc, const char **argv) -{ - return cmd_samr_get_dispenum_index_int(cli, mem_ctx, argc, argv, SAMR_GET_DISPENUM_INDEX2); -} - /* Query domain info */ static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli, @@ -2402,10 +2272,6 @@ struct cmd_set samr_commands[] = { { "queryaliasmem", RPC_RTYPE_NTSTATUS, cmd_samr_query_aliasmem, NULL, PI_SAMR, NULL, "Query alias membership", "" }, { "deletealias", RPC_RTYPE_NTSTATUS, cmd_samr_delete_alias, NULL, PI_SAMR, NULL, "Delete an alias", "" }, { "querydispinfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo, NULL, PI_SAMR, NULL, "Query display info", "" }, - { "querydispinfo2", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo2, NULL, PI_SAMR, NULL, "Query display info 2", "" }, - { "querydispinfo3", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo3, NULL, PI_SAMR, NULL, "Query display info 3", "" }, - { "getdispenumindex", RPC_RTYPE_NTSTATUS, cmd_samr_get_dispenum_index, NULL, PI_SAMR, NULL, "Query display info index", "" }, - { "getdispenumindex2", RPC_RTYPE_NTSTATUS, cmd_samr_get_dispenum_index2, NULL, PI_SAMR, NULL, "Query display info index", "" }, { "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", "" }, diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c index b1cefb5f21..572609981d 100644 --- a/source3/rpcclient/cmd_srvsvc.c +++ b/source3/rpcclient/cmd_srvsvc.c @@ -130,61 +130,74 @@ static char *get_server_type_str(uint32 type) return typestr; } -static void display_server(const char *sname, uint32 type, const char *comment) +static void display_server(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(struct srvsvc_NetSrvInfo101 *sv101) +static void display_srv_info_101(SRV_INFO_101 *sv101) { - display_server(sv101->server_name, sv101->server_type, sv101->comment); + fstring name; + fstring 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->version_major, - sv101->version_minor); + printf("\tos version :\t%d.%d\n", sv101->ver_major, + sv101->ver_minor); - printf("\tserver type :\t0x%x\n", sv101->server_type); + printf("\tserver type :\t0x%x\n", sv101->srv_type); } -static void display_srv_info_102(struct srvsvc_NetSrvInfo102 *sv102) +static void display_srv_info_102(SRV_INFO_102 *sv102) { - display_server(sv102->server_name, sv102->server_type, - sv102->comment); + 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->version_major, - sv102->version_minor); + 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->anndelta); + sv102->ann_delta); printf("\tlicenses :\t%d\n", sv102->licenses); - printf("\tuser path :\t%s\n", sv102->userpath); + printf("\tuser path :\t%s\n", usr_path); } /* Server query info */ -static NTSTATUS cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli, +static WERROR cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { uint32 info_level = 101; - union srvsvc_NetSrvInfo ctr; - NTSTATUS result; + SRV_INFO_CTR ctr; + WERROR result; if (argc > 2) { printf("Usage: %s [infolevel]\n", argv[0]); - return NT_STATUS_OK; + return WERR_OK; } if (argc == 2) info_level = atoi(argv[1]); - result = rpccli_srvsvc_NetSrvGetInfo(cli, mem_ctx, NULL, info_level, + result = rpccli_srvsvc_net_srv_get_info(cli, mem_ctx, info_level, &ctr); - if (!NT_STATUS_IS_OK(result)) { + if (!W_ERROR_IS_OK(result)) { goto done; } @@ -192,10 +205,10 @@ static NTSTATUS cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli, switch (info_level) { case 101: - display_srv_info_101(ctr.info101); + display_srv_info_101(&ctr.srv.sv101); break; case 102: - display_srv_info_102(ctr.info102); + display_srv_info_102(&ctr.srv.sv102); break; default: printf("unsupported info level %d\n", info_level); @@ -206,106 +219,96 @@ static NTSTATUS cmd_srvsvc_srv_query_info(struct rpc_pipe_client *cli, return result; } -static void display_share_info_1(struct srvsvc_NetShareInfo1 *info1) +static void display_share_info_1(SRV_SHARE_INFO_1 *info1) { - printf("netname: %s\n", info1->name); - printf("\tremark:\t%s\n", info1->comment); + fstring netname = "", remark = ""; + + rpcstr_pull_unistr2_fstring(netname, &info1->info_1_str.uni_netname); + rpcstr_pull_unistr2_fstring(remark, &info1->info_1_str.uni_remark); + + printf("netname: %s\n", netname); + printf("\tremark:\t%s\n", remark); } -static void display_share_info_2(struct srvsvc_NetShareInfo2 *info2) +static void display_share_info_2(SRV_SHARE_INFO_2 *info2) { - printf("netname: %s\n", info2->name); - printf("\tremark:\t%s\n", info2->comment); - printf("\tpath:\t%s\n", info2->path); - printf("\tpassword:\t%s\n", info2->password); + fstring netname = "", remark = "", path = "", passwd = ""; + + rpcstr_pull_unistr2_fstring(netname, &info2->info_2_str.uni_netname); + rpcstr_pull_unistr2_fstring(remark, &info2->info_2_str.uni_remark); + rpcstr_pull_unistr2_fstring(path, &info2->info_2_str.uni_path); + rpcstr_pull_unistr2_fstring(passwd, &info2->info_2_str.uni_passwd); + + printf("netname: %s\n", netname); + printf("\tremark:\t%s\n", remark); + printf("\tpath:\t%s\n", path); + printf("\tpassword:\t%s\n", passwd); } -static void display_share_info_502(struct srvsvc_NetShareInfo502 *info502) +static void display_share_info_502(SRV_SHARE_INFO_502 *info502) { - printf("netname: %s\n", info502->name); - printf("\tremark:\t%s\n", info502->comment); - printf("\tpath:\t%s\n", info502->path); - printf("\tpassword:\t%s\n", info502->password); - - printf("\ttype:\t0x%x\n", info502->type); - printf("\tperms:\t%d\n", info502->permissions); - printf("\tmax_uses:\t%d\n", info502->max_users); - printf("\tnum_uses:\t%d\n", info502->current_users); + fstring netname = "", remark = "", path = "", passwd = ""; + + rpcstr_pull_unistr2_fstring(netname, &info502->info_502_str.uni_netname); + rpcstr_pull_unistr2_fstring(remark, &info502->info_502_str.uni_remark); + rpcstr_pull_unistr2_fstring(path, &info502->info_502_str.uni_path); + rpcstr_pull_unistr2_fstring(passwd, &info502->info_502_str.uni_passwd); + + printf("netname: %s\n", netname); + printf("\tremark:\t%s\n", remark); + printf("\tpath:\t%s\n", path); + printf("\tpassword:\t%s\n", passwd); + + printf("\ttype:\t0x%x\n", info502->info_502.type); + printf("\tperms:\t%d\n", info502->info_502.perms); + printf("\tmax_uses:\t%d\n", info502->info_502.max_uses); + printf("\tnum_uses:\t%d\n", info502->info_502.num_uses); - if (info502->sd) - display_sec_desc(info502->sd); + if (info502->info_502_str.sd) + display_sec_desc(info502->info_502_str.sd); } -static NTSTATUS cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli, +static WERROR cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { uint32 info_level = 2; - struct srvsvc_NetShareCtr1 ctr1; - struct srvsvc_NetShareCtr2 ctr2; - struct srvsvc_NetShareCtr502 ctr502; - union srvsvc_NetShareCtr ctr; - NTSTATUS result; - uint32 hnd; + SRV_SHARE_INFO_CTR ctr; + WERROR result; + ENUM_HND hnd; uint32 preferred_len = 0xffffffff, i; - uint32 numentries; - - ZERO_STRUCT(ctr); if (argc > 2) { printf("Usage: %s [infolevel]\n", argv[0]); - return NT_STATUS_OK; + return WERR_OK; } if (argc == 2) info_level = atoi(argv[1]); - hnd = 0; - - switch (info_level) { - case 1: { - ZERO_STRUCT(ctr1); - ctr.ctr1 = &ctr1; - } - break; - - case 2: { - ZERO_STRUCT(ctr2); - ctr.ctr2 = &ctr2; - } - break; - case 502: { - ZERO_STRUCT(ctr502); - ctr.ctr502 = &ctr502; - } - break; - - default: - break; - } + init_enum_hnd(&hnd, 0); - result = rpccli_srvsvc_NetShareEnum( - cli, mem_ctx, cli->cli->desthost, &info_level, &ctr, preferred_len, &numentries, - &hnd); + result = rpccli_srvsvc_net_share_enum( + cli, mem_ctx, info_level, &ctr, preferred_len, &hnd); - if (!NT_STATUS_IS_OK(result) || !numentries) + if (!W_ERROR_IS_OK(result) || !ctr.num_entries) goto done; /* Display results */ switch (info_level) { case 1: - for (i = 0; i < numentries; i++) - display_share_info_1(&ctr.ctr1->array[i]); + for (i = 0; i < ctr.num_entries; i++) + display_share_info_1(&ctr.share.info1[i]); break; case 2: - for (i = 0; i < numentries; i++) - display_share_info_2(&ctr.ctr2->array[i]); + for (i = 0; i < ctr.num_entries; i++) + display_share_info_2(&ctr.share.info2[i]); break; case 502: - for (i = 0; i < numentries; i++) - display_share_info_502(&ctr.ctr502->array[i]); + for (i = 0; i < ctr.num_entries; i++) + display_share_info_502(&ctr.share.info502[i]); break; default: printf("unsupported info level %d\n", info_level); @@ -316,38 +319,38 @@ static NTSTATUS cmd_srvsvc_net_share_enum(struct rpc_pipe_client *cli, return result; } -static NTSTATUS cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli, +static WERROR cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { uint32 info_level = 502; - union srvsvc_NetShareInfo info; - NTSTATUS result; + SRV_SHARE_INFO info; + WERROR result; if (argc > 3) { printf("Usage: %s [sharename] [infolevel]\n", argv[0]); - return NT_STATUS_OK; + return WERR_OK; } if (argc == 3) info_level = atoi(argv[2]); - result = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx, NULL, argv[1], info_level, &info); + result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info); - if (!NT_STATUS_IS_OK(result)) + if (!W_ERROR_IS_OK(result)) goto done; /* Display results */ switch (info_level) { case 1: - display_share_info_1(info.info1); + display_share_info_1(&info.share.info1); break; case 2: - display_share_info_2(info.info2); + display_share_info_2(&info.share.info2); break; case 502: - display_share_info_502(info.info502); + display_share_info_502(&info.share.info502); break; default: printf("unsupported info level %d\n", info_level); @@ -358,93 +361,95 @@ static NTSTATUS cmd_srvsvc_net_share_get_info(struct rpc_pipe_client *cli, return result; } -static NTSTATUS cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli, +static WERROR cmd_srvsvc_net_share_set_info(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { uint32 info_level = 502; - union srvsvc_NetShareInfo info_get; - NTSTATUS result; - uint32 parm_error = 0; + SRV_SHARE_INFO info_get; + WERROR result; if (argc > 3) { printf("Usage: %s [sharename] [comment]\n", argv[0]); - return NT_STATUS_OK; + return WERR_OK; } /* retrieve share info */ - result = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx, NULL, argv[1], info_level, &info_get); - if (!NT_STATUS_IS_OK(result)) + result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info_get); + if (!W_ERROR_IS_OK(result)) goto done; + info_get.switch_value = info_level; + info_get.ptr_share_ctr = 1; + init_unistr2(&(info_get.share.info502.info_502_str.uni_remark), argv[2], UNI_STR_TERMINATE); + /* set share info */ - result = rpccli_srvsvc_NetShareSetInfo(cli, mem_ctx, NULL, argv[1], info_level, info_get, &parm_error); + result = rpccli_srvsvc_net_share_set_info(cli, mem_ctx, argv[1], info_level, &info_get); - if (!NT_STATUS_IS_OK(result)) + if (!W_ERROR_IS_OK(result)) goto done; /* re-retrieve share info and display */ - result = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx, NULL, argv[1], info_level, &info_get); - if (!NT_STATUS_IS_OK(result)) + result = rpccli_srvsvc_net_share_get_info(cli, mem_ctx, argv[1], info_level, &info_get); + if (!W_ERROR_IS_OK(result)) goto done; - display_share_info_502(info_get.info502); + display_share_info_502(&info_get.share.info502); done: return result; } -static NTSTATUS cmd_srvsvc_net_remote_tod(struct rpc_pipe_client *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; - NTSTATUS result; - struct srvsvc_NetRemoteTODInfo tod; + WERROR result; if (argc > 1) { printf("Usage: %s\n", argv[0]); - return NT_STATUS_OK; + return WERR_OK; } fstr_sprintf(srv_name_slash, "\\\\%s", cli->cli->desthost); - result = rpccli_srvsvc_NetRemoteTOD( + result = rpccli_srvsvc_net_remote_tod( cli, mem_ctx, srv_name_slash, &tod); - if (!NT_STATUS_IS_OK(result)) + if (!W_ERROR_IS_OK(result)) goto done; done: return result; } -static NTSTATUS cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli, +static WERROR cmd_srvsvc_net_file_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { uint32 info_level = 3; - union srvsvc_NetFileCtr ctr; - NTSTATUS result; - uint32 hnd; + SRV_FILE_INFO_CTR ctr; + WERROR result; + ENUM_HND hnd; uint32 preferred_len = 0xffff; - uint32 numentries; if (argc > 2) { printf("Usage: %s [infolevel]\n", argv[0]); - return NT_STATUS_OK; + return WERR_OK; } if (argc == 2) info_level = atoi(argv[1]); - hnd = 0; + init_enum_hnd(&hnd, 0); ZERO_STRUCT(ctr); - result = rpccli_srvsvc_NetFileEnum( - cli, mem_ctx, NULL, NULL, NULL, &info_level, &ctr, preferred_len, &numentries, &hnd); + result = rpccli_srvsvc_net_file_enum( + cli, mem_ctx, info_level, NULL, &ctr, preferred_len, &hnd); - if (!NT_STATUS_IS_OK(result)) + if (!W_ERROR_IS_OK(result)) goto done; done: @@ -457,12 +462,12 @@ struct cmd_set srvsvc_commands[] = { { "SRVSVC" }, - { "srvinfo", RPC_RTYPE_NTSTATUS, cmd_srvsvc_srv_query_info, NULL, PI_SRVSVC, NULL, "Server query info", "" }, - { "netshareenum",RPC_RTYPE_NTSTATUS, cmd_srvsvc_net_share_enum, NULL, PI_SRVSVC, NULL, "Enumerate shares", "" }, - { "netsharegetinfo",RPC_RTYPE_NTSTATUS, cmd_srvsvc_net_share_get_info, NULL, PI_SRVSVC, NULL, "Get Share Info", "" }, - { "netsharesetinfo",RPC_RTYPE_NTSTATUS, cmd_srvsvc_net_share_set_info, NULL, PI_SRVSVC, NULL, "Set Share Info", "" }, - { "netfileenum", RPC_RTYPE_NTSTATUS, cmd_srvsvc_net_file_enum, NULL, PI_SRVSVC, NULL, "Enumerate open files", "" }, - { "netremotetod",RPC_RTYPE_NTSTATUS, cmd_srvsvc_net_remote_tod, NULL, PI_SRVSVC, NULL, "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_unixinfo.c b/source3/rpcclient/cmd_unixinfo.c deleted file mode 100644 index e6f1e04a45..0000000000 --- a/source3/rpcclient/cmd_unixinfo.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - 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 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include "includes.h" -#include "rpcclient.h" - -static NTSTATUS cmd_unixinfo_uid2sid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - int argc, const char **argv) -{ - uid_t uid; - DOM_SID sid; - NTSTATUS result; - - if (argc != 2) { - printf("Usage: %s uid\n", argv[0]); - return NT_STATUS_INVALID_PARAMETER; - } - - uid = atoi(argv[1]); - result = rpccli_unixinfo_UidToSid(cli, mem_ctx, uid, &sid); - - if (!NT_STATUS_IS_OK(result)) - goto done; - - printf("%s\n", sid_string_static(&sid)); - -done: - return result; -} - -static NTSTATUS cmd_unixinfo_sid2uid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - int argc, const char **argv) -{ - uint64_t uid; - DOM_SID sid; - NTSTATUS result; - - if (argc != 2) { - printf("Usage: %s sid\n", argv[0]); - return NT_STATUS_INVALID_PARAMETER; - } - - if (!string_to_sid(&sid, argv[1])) { - result = NT_STATUS_INVALID_SID; - goto done; - } - - result = rpccli_unixinfo_SidToUid(cli, mem_ctx, sid, &uid); - - if (!NT_STATUS_IS_OK(result)) - goto done; - - printf("%llu\n", (unsigned long long)uid); - -done: - return result; -} - -static NTSTATUS cmd_unixinfo_gid2sid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - int argc, const char **argv) -{ - gid_t gid; - DOM_SID sid; - NTSTATUS result; - - if (argc != 2) { - printf("Usage: %s gid\n", argv[0]); - return NT_STATUS_INVALID_PARAMETER; - } - - gid = atoi(argv[1]); - - result = rpccli_unixinfo_GidToSid(cli, mem_ctx, gid, &sid); - - if (!NT_STATUS_IS_OK(result)) - goto done; - - printf("%s\n", sid_string_static(&sid)); - -done: - return result; -} - -static NTSTATUS cmd_unixinfo_sid2gid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - int argc, const char **argv) -{ - uint64_t gid; - DOM_SID sid; - NTSTATUS result; - - if (argc != 2) { - printf("Usage: %s sid\n", argv[0]); - return NT_STATUS_INVALID_PARAMETER; - } - - if (!string_to_sid(&sid, argv[1])) { - result = NT_STATUS_INVALID_SID; - goto done; - } - - result = rpccli_unixinfo_SidToGid(cli, mem_ctx, sid, &gid); - - if (!NT_STATUS_IS_OK(result)) - goto done; - - printf("%llu\n", (unsigned long long)gid); - -done: - return result; -} - -static NTSTATUS cmd_unixinfo_getpwuid(struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, - int argc, const char **argv) -{ - uint64_t *uids; - unsigned int i, num_uids; - struct unixinfo_GetPWUidInfo *info; - NTSTATUS result; - - if (argc < 2) { - printf("Usage: %s uid [uid2 uid3 ...]\n", argv[0]); - return NT_STATUS_INVALID_PARAMETER; - } - - num_uids = argc-1; - uids = TALLOC_ARRAY(mem_ctx, uint64_t, num_uids); - - if (uids == NULL) { - return NT_STATUS_NO_MEMORY; - } - - for (i=0; i<num_uids; i++) { - uids[i] = atoi(argv[i+1]); - } - - info = TALLOC_ARRAY(mem_ctx, struct unixinfo_GetPWUidInfo, num_uids); - if (info == NULL) { - return NT_STATUS_NO_MEMORY; - } - - - result = rpccli_unixinfo_GetPWUid(cli, mem_ctx, &num_uids, uids, - info); - - if (!NT_STATUS_IS_OK(result)) { - return result; - } - - for (i=0; i<num_uids; i++) { - if (NT_STATUS_IS_OK(info[i].status)) { - printf("%llu:%s:%s\n", (unsigned long long)uids[i], - info[i].homedir, info[i].shell); - } else { - printf("%llu:%s\n", (unsigned long long)uids[i], - nt_errstr(info[i].status)); - } - } - - return NT_STATUS_OK; -} - -/* List of commands exported by this module */ - -struct cmd_set unixinfo_commands[] = { - - { "UNIXINFO" }, - - { "uid2sid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_uid2sid, NULL, - PI_UNIXINFO, NULL, "Convert a uid to a sid", "" }, - { "sid2uid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_sid2uid, NULL, - PI_UNIXINFO, NULL, "Convert a sid to a uid", "" }, - { "gid2sid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_gid2sid, NULL, - PI_UNIXINFO, NULL, "Convert a gid to a sid", "" }, - { "sid2gid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_sid2gid, NULL, - PI_UNIXINFO, NULL, "Convert a sid to a gid", "" }, - { "getpwuid", RPC_RTYPE_NTSTATUS, cmd_unixinfo_getpwuid, NULL, - PI_UNIXINFO, NULL, "Get passwd info", "" }, - { NULL } -}; diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index b43ce09f46..7a7b463b71 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -492,7 +492,6 @@ static struct cmd_set separator_command[] = { /* Various pipe commands */ -extern struct cmd_set unixinfo_commands[]; extern struct cmd_set lsarpc_commands[]; extern struct cmd_set samr_commands[]; extern struct cmd_set spoolss_commands[]; @@ -506,7 +505,6 @@ extern struct cmd_set test_commands[]; static struct cmd_set *rpcclient_command_list[] = { rpcclient_commands, - unixinfo_commands, lsarpc_commands, ds_commands, samr_commands, |