summaryrefslogtreecommitdiff
path: root/source3/rpcclient/cmd_srvsvc.c
diff options
context:
space:
mode:
authorGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:34:30 -0500
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:34:30 -0500
commite5a951325a6cac8567af3a66de6d2df577508ae4 (patch)
tree34da9fe59f3c2d7f8edb072144443a9704197831 /source3/rpcclient/cmd_srvsvc.c
parent57482469b32645250e92a7ffd003aeeb4a42235e (diff)
downloadsamba-e5a951325a6cac8567af3a66de6d2df577508ae4.tar.gz
samba-e5a951325a6cac8567af3a66de6d2df577508ae4.tar.bz2
samba-e5a951325a6cac8567af3a66de6d2df577508ae4.zip
[GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch.
(This used to be commit 5c6c8e1fe93f340005110a7833946191659d88ab)
Diffstat (limited to 'source3/rpcclient/cmd_srvsvc.c')
-rw-r--r--source3/rpcclient/cmd_srvsvc.c261
1 files changed, 133 insertions, 128 deletions
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 }
};