summaryrefslogtreecommitdiff
path: root/source3/rpcclient
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpcclient')
-rw-r--r--source3/rpcclient/cmd_dfs.c48
-rw-r--r--source3/rpcclient/cmd_lsarpc.c4
-rw-r--r--source3/rpcclient/cmd_reg.c192
-rw-r--r--source3/rpcclient/cmd_samr.c14
-rw-r--r--source3/rpcclient/cmd_spoolss.c10
-rw-r--r--source3/rpcclient/cmd_srvsvc.c4
-rw-r--r--source3/rpcclient/rpcclient.c16
7 files changed, 248 insertions, 40 deletions
diff --git a/source3/rpcclient/cmd_dfs.c b/source3/rpcclient/cmd_dfs.c
index b4914f665c..8059f42f2f 100644
--- a/source3/rpcclient/cmd_dfs.c
+++ b/source3/rpcclient/cmd_dfs.c
@@ -47,7 +47,8 @@ static uint32 cmd_dfs_exist(struct cli_state *cli, int argc, char **argv)
if (!cli_nt_session_open (cli, PIPE_NETDFS)) {
DEBUG(0, ("Could not initialize netdfs pipe!\n"));
- return NT_STATUS_UNSUCCESSFUL;
+ result = NT_STATUS_UNSUCCESSFUL;
+ goto done;
}
result = cli_dfs_exist(cli, mem_ctx, &dfs_exists);
@@ -57,6 +58,8 @@ static uint32 cmd_dfs_exist(struct cli_state *cli, int argc, char **argv)
cli_nt_session_close(cli);
+done:
+ talloc_destroy(mem_ctx);
return result;
}
@@ -87,7 +90,8 @@ static uint32 cmd_dfs_add(struct cli_state *cli, int argc, char **argv)
if (!cli_nt_session_open (cli, PIPE_NETDFS)) {
DEBUG(0, ("Could not initialize netdfs pipe!\n"));
- return NT_STATUS_UNSUCCESSFUL;
+ result = NT_STATUS_UNSUCCESSFUL;
+ goto done;
}
result = cli_dfs_add(cli, mem_ctx, entrypath, servername,
@@ -95,6 +99,8 @@ static uint32 cmd_dfs_add(struct cli_state *cli, int argc, char **argv)
cli_nt_session_close(cli);
+done:
+ talloc_destroy(mem_ctx);
return result;
}
@@ -122,7 +128,8 @@ static uint32 cmd_dfs_remove(struct cli_state *cli, int argc, char **argv)
if (!cli_nt_session_open (cli, PIPE_NETDFS)) {
DEBUG(0, ("Could not initialize netdfs pipe!\n"));
- return NT_STATUS_UNSUCCESSFUL;
+ result = NT_STATUS_UNSUCCESSFUL;
+ goto done;
}
result = cli_dfs_remove(cli, mem_ctx, entrypath, servername,
@@ -130,6 +137,8 @@ static uint32 cmd_dfs_remove(struct cli_state *cli, int argc, char **argv)
cli_nt_session_close(cli);
+done:
+ talloc_destroy(mem_ctx);
return result;
}
@@ -236,24 +245,23 @@ static uint32 cmd_dfs_enum(struct cli_state *cli, int argc, char **argv)
if (!cli_nt_session_open (cli, PIPE_NETDFS)) {
DEBUG(0, ("Could not initialize netdfs pipe!\n"));
- return NT_STATUS_UNSUCCESSFUL;
+ result = NT_STATUS_UNSUCCESSFUL;
+ goto done;
}
/* Call RPC function */
if ((result = cli_dfs_enum(cli, mem_ctx, info_level, &ctr))
- != NT_STATUS_NOPROBLEMO) {
- goto done;
+ == NT_STATUS_NOPROBLEMO) {
+
+ /* Print results */
+ display_dfs_info_ctr(&ctr);
}
- /* Print results */
-
- display_dfs_info_ctr(&ctr);
-
- done:
-
cli_nt_session_close(cli);
+done:
+ talloc_destroy(mem_ctx);
return result;
}
@@ -286,25 +294,25 @@ static uint32 cmd_dfs_getinfo(struct cli_state *cli, int argc, char **argv)
if (!cli_nt_session_open (cli, PIPE_NETDFS)) {
DEBUG(0, ("Could not initialize netdfs pipe!\n"));
- return NT_STATUS_UNSUCCESSFUL;
+ result = NT_STATUS_UNSUCCESSFUL;
+ goto done;
}
/* Call RPC function */
if ((result = cli_dfs_get_info(cli, mem_ctx, entrypath, servername,
sharename, info_level, &ctr))
- != NT_STATUS_NOPROBLEMO) {
- goto done;
- }
+ == NT_STATUS_NOPROBLEMO) {
- /* Print results */
+ /* Print results */
- display_dfs_info_ctr(&ctr);
-
- done:
+ display_dfs_info_ctr(&ctr);
+ }
cli_nt_session_close(cli);
+done:
+ talloc_destroy(mem_ctx);
return result;
}
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index 4b07333074..a34650b807 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -53,6 +53,7 @@ static uint32 cmd_lsa_query_info_policy(struct cli_state *cli, int argc, char **
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_LSARPC)) {
DEBUG(0, ("Could not initialize samr pipe!\n"));
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -117,6 +118,7 @@ static uint32 cmd_lsa_lookup_names(struct cli_state *cli, int argc, char **argv)
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_LSARPC)) {
DEBUG(0, ("Could not initialize samr pipe!\n"));
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -185,6 +187,7 @@ static uint32 cmd_lsa_lookup_sids(struct cli_state *cli, int argc, char **argv)
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_LSARPC)) {
DEBUG(0, ("Could not initialize samr pipe!\n"));
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -277,6 +280,7 @@ static uint32 cmd_lsa_enum_trust_dom(struct cli_state *cli, int argc, char **arg
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_LSARPC)) {
DEBUG(0, ("Could not initialize samr pipe!\n"));
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
diff --git a/source3/rpcclient/cmd_reg.c b/source3/rpcclient/cmd_reg.c
index 9aac99c928..41814fd41e 100644
--- a/source3/rpcclient/cmd_reg.c
+++ b/source3/rpcclient/cmd_reg.c
@@ -4,6 +4,7 @@
NT Domain Authentication SMB / MSRPC client
Copyright (C) Andrew Tridgell 1994-1997
Copyright (C) Luke Kenneth Casson Leighton 1996-1997
+ Copyright (C) Simo Sorce 2001
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
@@ -30,7 +31,6 @@
extern int DEBUGLEVEL;
-extern struct cli_state *smb_cli;
extern int smb_tidx;
extern FILE* out_hnd;
@@ -54,10 +54,12 @@ extern FILE* out_hnd;
*
*/
+#if 0 /* Simo: reg functions need to be updated to the new cmd interface */
+
/****************************************************************************
nt registry enum
****************************************************************************/
-void cmd_reg_enum(struct client_info *info)
+static void cmd_reg_enum(struct client_info *info)
{
BOOL res = True;
BOOL res1 = True;
@@ -224,7 +226,7 @@ void cmd_reg_enum(struct client_info *info)
/****************************************************************************
nt registry query key
****************************************************************************/
-void cmd_reg_query_key(struct client_info *info)
+static void cmd_reg_query_key(struct client_info *info)
{
BOOL res = True;
BOOL res1 = True;
@@ -324,7 +326,7 @@ void cmd_reg_query_key(struct client_info *info)
/****************************************************************************
nt registry create value
****************************************************************************/
-void cmd_reg_create_val(struct client_info *info)
+static void cmd_reg_create_val(struct client_info *info)
{
BOOL res = True;
BOOL res3 = True;
@@ -470,7 +472,7 @@ void cmd_reg_create_val(struct client_info *info)
/****************************************************************************
nt registry delete value
****************************************************************************/
-void cmd_reg_delete_val(struct client_info *info)
+static void cmd_reg_delete_val(struct client_info *info)
{
BOOL res = True;
BOOL res3 = True;
@@ -545,7 +547,7 @@ void cmd_reg_delete_val(struct client_info *info)
/****************************************************************************
nt registry delete key
****************************************************************************/
-void cmd_reg_delete_key(struct client_info *info)
+static void cmd_reg_delete_key(struct client_info *info)
{
BOOL res = True;
BOOL res3 = True;
@@ -623,7 +625,7 @@ void cmd_reg_delete_key(struct client_info *info)
/****************************************************************************
nt registry create key
****************************************************************************/
-void cmd_reg_create_key(struct client_info *info)
+static void cmd_reg_create_key(struct client_info *info)
{
BOOL res = True;
BOOL res3 = True;
@@ -716,7 +718,7 @@ void cmd_reg_create_key(struct client_info *info)
/****************************************************************************
nt registry security info
****************************************************************************/
-void cmd_reg_test_key_sec(struct client_info *info)
+static void cmd_reg_test_key_sec(struct client_info *info)
{
BOOL res = True;
BOOL res3 = True;
@@ -811,7 +813,7 @@ void cmd_reg_test_key_sec(struct client_info *info)
/****************************************************************************
nt registry security info
****************************************************************************/
-void cmd_reg_get_key_sec(struct client_info *info)
+static void cmd_reg_get_key_sec(struct client_info *info)
{
BOOL res = True;
BOOL res3 = True;
@@ -898,3 +900,175 @@ void cmd_reg_get_key_sec(struct client_info *info)
DEBUG(5,("cmd_reg_get_key_sec: query failed\n"));
}
}
+
+#endif /* 0 */
+
+/****************************************************************************
+nt registry shutdown
+****************************************************************************/
+static uint32 cmd_reg_shutdown(struct cli_state *cli, int argc, char **argv)
+{
+ uint32 result = NT_STATUS_UNSUCCESSFUL;
+ fstring msg;
+ uint32 timeout = 20;
+ uint16 flgs = 0;
+ int opt;
+ int ret;
+ char *srv_name;
+ TALLOC_CTX *mem_ctx;
+
+ ret = asprintf (&srv_name, "\\\\%s", cli->desthost);
+ if (ret < 0) {
+ DEBUG(0,("cmd_reg_shutdown: Not enough memory!\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ strupper(srv_name);
+
+ if (!(mem_ctx=talloc_init()))
+ {
+ DEBUG(0,("cmd_spoolss_getprinter: talloc_init returned NULL!\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ /* Initialise RPC connection */
+ if (!cli_nt_session_open (cli, PIPE_WINREG)) {
+ fprintf (stderr, "Could not initialize winreg pipe!\n");
+ goto done;
+ }
+
+ *msg = 0;
+ optind = 0; /* TODO: test if this hack works on other systems too --simo */
+
+ while ((opt = getopt(argc, argv, "m:t:rf")) != EOF)
+ {
+ fprintf (stderr, "[%s]\n", argv[argc-1]);
+
+ switch (opt)
+ {
+ case 'm':
+ {
+ safe_strcpy(msg, optarg, sizeof(msg)-1);
+ fprintf (stderr, "[%s|%s]\n", optarg, msg);
+ break;
+ }
+ case 't':
+ {
+ timeout = atoi(optarg);
+ fprintf (stderr, "[%s|%d]\n", optarg, timeout);
+ break;
+ }
+ case 'r':
+ {
+ flgs |= 0x100;
+ break;
+ }
+ case 'f':
+ {
+ flgs |= 0x001;
+ break;
+ }
+ }
+ }
+
+ /* create an entry */
+ result = cli_reg_shutdown(cli, mem_ctx, srv_name, msg, timeout, flgs);
+
+ if (result == NT_STATUS_NOPROBLEMO)
+ DEBUG(5,("cmd_reg_shutdown: query succeeded\n"));
+ else
+ DEBUG(5,("cmd_reg_shutdown: query failed\n"));
+
+ cli_nt_session_close(cli);
+
+done:
+ talloc_destroy(mem_ctx);
+
+ return result;
+}
+
+/****************************************************************************
+abort a shutdown
+****************************************************************************/
+static uint32 cmd_reg_abort_shutdown(struct cli_state *cli, int argc, char **argv)
+{
+ uint32 result = NT_STATUS_UNSUCCESSFUL;
+ int ret;
+ char *srv_name;
+ TALLOC_CTX *mem_ctx;
+
+ ret = asprintf(&srv_name, "\\\\%s", cli->desthost);
+ if (ret < 0) {
+ DEBUG(0,("cmd_reg_shutdown: Not enough memory!\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ strupper(srv_name);
+
+ if (!(mem_ctx=talloc_init()))
+ {
+ DEBUG(0,("cmd_spoolss_getprinter: talloc_init returned NULL!\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ /* Initialise RPC connection */
+ if (!cli_nt_session_open (cli, PIPE_WINREG)) {
+ fprintf (stderr, "Could not initialize winreg pipe!\n");
+ goto done;
+ }
+
+ result = cli_reg_abort_shutdown(cli, mem_ctx, srv_name);
+
+ if (result == NT_STATUS_NOPROBLEMO)
+ DEBUG(5,("cmd_reg_abort_shutdown: query succeeded\n"));
+ else
+ DEBUG(5,("cmd_reg_abort_shutdown: query failed\n"));
+
+ cli_nt_session_close(cli);
+
+done:
+ talloc_destroy(mem_ctx);
+
+ return result;
+}
+
+
+/* List of commands exported by this module */
+struct cmd_set reg_commands[] = {
+
+ { "REG" },
+
+ { "shutdown", cmd_reg_shutdown, "Remote Shutdown",
+ "[-m message] [-t timeout] [-r] [-f] (-r == reboot, -f == force)" },
+
+ { "abortshutdown", cmd_reg_abort_shutdown, "Abort Shutdown",
+ "" },
+/*
+ { "regenum", cmd_reg_enum, "Registry Enumeration",
+ "<keyname>" },
+
+ { "regdeletekey", cmd_reg_delete_key, "Registry Key Delete",
+ "<keyname>" },
+
+ { "regcreatekey", cmd_reg_create_key, "Registry Key Create",
+ "<keyname> [keyclass]" },
+
+ { "regqueryval", cmd_reg_query_info, "Registry Value Query",
+ "<valname>" },
+
+ { "regquerykey", cmd_reg_query_key, "Registry Key Query",
+ "<keyname>" },
+
+ { "regdeleteval", cmd_reg_delete_val, "Registry Value Delete",
+ "<valname>" },
+
+ { "regcreateval", cmd_reg_create_val, "Registry Key Create",
+ "<valname> <valtype> <value>" },
+
+ { "reggetsec", cmd_reg_get_key_sec, "Registry Key Security",
+ "<keyname>" },
+
+ { "regtestsec", cmd_reg_test_key_sec, "Test Registry Key Security",
+ "<keyname>" },
+*/
+ { NULL }
+};
+
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index dee466ffea..6e8aa23a08 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -170,6 +170,7 @@ static uint32 cmd_samr_query_user(struct cli_state *cli, int argc, char **argv)
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -297,6 +298,7 @@ static uint32 cmd_samr_query_group(struct cli_state *cli, int argc, char **argv)
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -386,6 +388,7 @@ static uint32 cmd_samr_query_usergroups(struct cli_state *cli, int argc, char **
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -472,6 +475,7 @@ static uint32 cmd_samr_query_groupmem(struct cli_state *cli, int argc, char **ar
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -556,6 +560,7 @@ static uint32 cmd_samr_enum_dom_groups(struct cli_state *cli, int argc,
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -634,6 +639,7 @@ static uint32 cmd_samr_query_aliasmem(struct cli_state *cli, int argc,
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -724,6 +730,7 @@ static uint32 cmd_samr_query_dispinfo(struct cli_state *cli, int argc,
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -790,7 +797,7 @@ static uint32 cmd_samr_query_dominfo(struct cli_state *cli, int argc,
SAM_UNK_CTR ctr;
if (argc > 2) {
- printf("Usage: %s [infolevel\n", argv[0]);
+ printf("Usage: %s [infolevel]\n", argv[0]);
return 0;
}
@@ -809,6 +816,7 @@ static uint32 cmd_samr_query_dominfo(struct cli_state *cli, int argc,
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -896,6 +904,7 @@ static uint32 cmd_samr_create_dom_user(struct cli_state *cli, int argc,
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -975,6 +984,7 @@ static uint32 cmd_samr_lookup_names(struct cli_state *cli, int argc,
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -1058,6 +1068,7 @@ static uint32 cmd_samr_lookup_rids(struct cli_state *cli, int argc,
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -1135,6 +1146,7 @@ static uint32 cmd_samr_delete_dom_user(struct cli_state *cli, int argc,
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
DEBUG(0, ("cmd_samr_delete_dom_user: could not open samr pipe!\n"));
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index c7d49dedaa..70552c9c72 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -174,6 +174,7 @@ static uint32 cmd_spoolss_open_printer_ex(struct cli_state *cli, int argc, char
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_SPOOLSS)) {
fprintf (stderr, "Could not initialize spoolss pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -360,6 +361,7 @@ static uint32 cmd_spoolss_enum_printers(struct cli_state *cli, int argc, char **
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_SPOOLSS)) {
fprintf (stderr, "Could not initialize spoolss pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -467,6 +469,7 @@ static uint32 cmd_spoolss_enum_ports(struct cli_state *cli, int argc, char **arg
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_SPOOLSS)) {
fprintf (stderr, "Could not initialize spoolss pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -529,6 +532,7 @@ static uint32 cmd_spoolss_getprinter(struct cli_state *cli, int argc, char **arg
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_SPOOLSS)) {
fprintf (stderr, "Could not initialize spoolss pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -729,6 +733,7 @@ static uint32 cmd_spoolss_getdriver(struct cli_state *cli, int argc, char **argv
if (!cli_nt_session_open (cli, PIPE_SPOOLSS))
{
fprintf (stderr, "Could not initialize spoolss pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -835,6 +840,7 @@ static uint32 cmd_spoolss_enum_drivers(struct cli_state *cli, int argc, char **a
if (!cli_nt_session_open (cli, PIPE_SPOOLSS))
{
fprintf (stderr, "Could not initialize spoolss pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -1107,6 +1113,7 @@ static uint32 cmd_spoolss_addprinterdriver (struct cli_state *cli, int argc, cha
if (!cli_nt_session_open (cli, PIPE_SPOOLSS))
{
fprintf (stderr, "Could not initialize spoolss pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -1177,6 +1184,7 @@ static uint32 cmd_spoolss_addprinterex (struct cli_state *cli, int argc, char **
if (!cli_nt_session_open (cli, PIPE_SPOOLSS))
{
fprintf (stderr, "Could not initialize spoolss pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -1262,6 +1270,7 @@ static uint32 cmd_spoolss_setdriver (struct cli_state *cli, int argc, char **arg
if (!cli_nt_session_open (cli, PIPE_SPOOLSS))
{
fprintf (stderr, "Could not initialize spoolss pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -1333,6 +1342,7 @@ static uint32 cmd_spoolss_deletedriver (struct cli_state *cli, int argc, char **
if (!cli_nt_session_open (cli, PIPE_SPOOLSS))
{
fprintf (stderr, "Could not initialize spoolss pipe!\n");
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
}
diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c
index c097f5325d..b74dc5a833 100644
--- a/source3/rpcclient/cmd_srvsvc.c
+++ b/source3/rpcclient/cmd_srvsvc.c
@@ -200,7 +200,7 @@ static uint32 cmd_srvsvc_srv_query_info(struct cli_state *cli, int argc,
if (!(mem_ctx = talloc_init())) {
DEBUG(0,("cmd_srvsvc_srv_query_info: talloc_init failed\n"));
- goto done;
+ return result;
}
/* Initialise RPC connection */
@@ -231,6 +231,8 @@ static uint32 cmd_srvsvc_srv_query_info(struct cli_state *cli, int argc,
}
done:
+ talloc_destroy(mem_ctx);
+
return result;
}
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index ee860798f6..d833043401 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -374,6 +374,7 @@ extern struct cmd_set spoolss_commands[];
extern struct cmd_set netlogon_commands[];
extern struct cmd_set srvsvc_commands[];
extern struct cmd_set dfs_commands[];
+extern struct cmd_set reg_commands[];
static struct cmd_set *rpcclient_command_list[] = {
rpcclient_commands,
@@ -383,6 +384,7 @@ static struct cmd_set *rpcclient_command_list[] = {
netlogon_commands,
srvsvc_commands,
dfs_commands,
+ reg_commands,
NULL
};
@@ -406,15 +408,13 @@ static uint32 do_cmd(struct cli_state *cli, struct cmd_set *cmd_entry, char *cmd
char *p = cmd, **argv = NULL;
uint32 result;
pstring buf;
- int argc = 1, i;
-
- next_token_nr(&p, buf, " ", sizeof(buf));
+ int argc = 0, i;
/* Count number of arguments first time through the loop then
allocate memory and strdup them. */
again:
- while(next_token_nr(NULL, buf, " ", sizeof(buf))) {
+ while(next_token(&p, buf, " ", sizeof(buf))) {
if (argv) {
argv[argc] = strdup(buf);
}
@@ -429,14 +429,12 @@ static uint32 do_cmd(struct cli_state *cli, struct cmd_set *cmd_entry, char *cmd
argv = (char **)malloc(sizeof(char *) * argc);
if (!argv) {
- fprintf(stderr, "out of memoryx\n");
+ fprintf(stderr, "out of memory\n");
return 0;
}
p = cmd;
- next_token_nr(&p, buf, " ", sizeof(buf));
- argv[0] = strdup(buf);
- argc = 1;
+ argc = 0;
goto again;
}
@@ -475,7 +473,7 @@ static uint32 process_cmd(struct cli_state *cli, char *cmd)
if (cmd[strlen(cmd) - 1] == '\n')
cmd[strlen(cmd) - 1] = '\0';
- if (!next_token_nr(&p, buf, " ", sizeof(buf))) {
+ if (!next_token(&p, buf, " ", sizeof(buf))) {
return 0;
}