diff options
author | Andrew Tridgell <tridge@samba.org> | 2002-07-15 10:35:28 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2002-07-15 10:35:28 +0000 |
commit | e90b65284812aaa5ff9e9935ce9bbad7791cbbcd (patch) | |
tree | 9e744d1dc2f93934a4b49166a37383d3cb2b2139 /source3/rpcclient/cmd_srvsvc.c | |
parent | ec167dc9cc0ec2ee461837c25a371d2981744208 (diff) | |
download | samba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.tar.gz samba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.tar.bz2 samba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.zip |
updated the 3.0 branch from the head branch - ready for alpha18
(This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce)
Diffstat (limited to 'source3/rpcclient/cmd_srvsvc.c')
-rw-r--r-- | source3/rpcclient/cmd_srvsvc.c | 131 |
1 files changed, 130 insertions, 1 deletions
diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c index 6fbd152dfb..43bfb25048 100644 --- a/source3/rpcclient/cmd_srvsvc.c +++ b/source3/rpcclient/cmd_srvsvc.c @@ -4,7 +4,7 @@ Copyright (C) Andrew Tridgell 1992-1999 Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999 - Copyright (C) Tim Potter 2000 + Copyright (C) Tim Potter 2000,2002 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 @@ -221,6 +221,132 @@ static NTSTATUS cmd_srvsvc_srv_query_info(struct cli_state *cli, return result; } +static void display_share_info_1(SRV_SHARE_INFO_1 *info1) +{ + 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(SRV_SHARE_INFO_2 *info2) +{ + 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 NTSTATUS cmd_srvsvc_net_share_enum(struct cli_state *cli, + TALLOC_CTX *mem_ctx, + int argc, char **argv) +{ + uint32 info_level = 2; + SRV_SHARE_INFO_CTR ctr; + WERROR result; + ENUM_HND hnd; + uint32 preferred_len = 0xffffffff, i; + + if (argc > 2) { + printf("Usage: %s [infolevel]\n", argv[0]); + return NT_STATUS_OK; + } + + if (argc == 2) + info_level = atoi(argv[1]); + + init_enum_hnd(&hnd, 0); + + result = cli_srvsvc_net_share_enum( + cli, mem_ctx, info_level, &ctr, preferred_len, &hnd); + + if (!W_ERROR_IS_OK(result)) + goto done; + + /* Display results */ + + switch (info_level) { + case 1: + for (i = 0; i < ctr.num_entries; i++) + display_share_info_1(&ctr.share.info1[i]); + break; + case 2: + for (i = 0; i < ctr.num_entries; i++) + display_share_info_2(&ctr.share.info2[i]); + break; + default: + printf("unsupported info level %d\n", info_level); + break; + } + + done: + return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; +} + +static NTSTATUS cmd_srvsvc_net_remote_tod(struct cli_state *cli, + TALLOC_CTX *mem_ctx, + int argc, char **argv) +{ + TIME_OF_DAY_INFO tod; + WERROR result; + + if (argc > 1) { + printf("Usage: %s\n", argv[0]); + return NT_STATUS_OK; + } + + result = cli_srvsvc_net_remote_tod( + cli, mem_ctx, cli->srv_name_slash, &tod); + + if (!W_ERROR_IS_OK(result)) + goto done; + + done: + return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; +} + +static NTSTATUS cmd_srvsvc_net_file_enum(struct cli_state *cli, + TALLOC_CTX *mem_ctx, + int argc, char **argv) +{ + uint32 info_level = 3; + SRV_FILE_INFO_CTR ctr; + WERROR result; + ENUM_HND hnd; + uint32 preferred_len = 0; + + if (argc > 2) { + printf("Usage: %s [infolevel]\n", argv[0]); + return NT_STATUS_OK; + } + + if (argc == 2) + info_level = atoi(argv[1]); + + init_enum_hnd(&hnd, 0); + + ZERO_STRUCT(ctr); + + result = cli_srvsvc_net_file_enum( + cli, mem_ctx, info_level, NULL, &ctr, preferred_len, &hnd); + + if (!W_ERROR_IS_OK(result)) + goto done; + + done: + return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; +} + /* List of commands exported by this module */ struct cmd_set srvsvc_commands[] = { @@ -228,6 +354,9 @@ struct cmd_set srvsvc_commands[] = { { "SRVSVC" }, { "srvinfo", cmd_srvsvc_srv_query_info, PIPE_SRVSVC, "Server query info", "" }, + { "netshareenum", cmd_srvsvc_net_share_enum, PIPE_SRVSVC, "Enumerate shares", "" }, + { "netfileenum", cmd_srvsvc_net_file_enum, PIPE_SRVSVC, "Enumerate open files", "" }, + { "netremotetod", cmd_srvsvc_net_remote_tod, PIPE_SRVSVC, "Fetch remote time of day", "" }, { NULL } }; |