summaryrefslogtreecommitdiff
path: root/source3/rpcclient/cmd_reg.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2001-10-12 05:56:23 +0000
committerTim Potter <tpot@samba.org>2001-10-12 05:56:23 +0000
commit439c7e0ca2ceb866cac4f0fbed65e157aa12482d (patch)
tree485198a7c227c05736986cdcaf82e42ec016e296 /source3/rpcclient/cmd_reg.c
parentd726eb216ad431d2bbd4ee07f4098b72446cdca2 (diff)
downloadsamba-439c7e0ca2ceb866cac4f0fbed65e157aa12482d.tar.gz
samba-439c7e0ca2ceb866cac4f0fbed65e157aa12482d.tar.bz2
samba-439c7e0ca2ceb866cac4f0fbed65e157aa12482d.zip
Some old stuff hanging around since the CIFS conference. Big cleanup of
rpcclient code. Refactored cmd_* functions to move common mem_ctx and pipe opening stuff up one level. Moved rpcclient.h into rpcclient directory and out of includes/smb.h (This used to be commit a40facba9651f9fb1dcc9e143f92ca298a324312)
Diffstat (limited to 'source3/rpcclient/cmd_reg.c')
-rw-r--r--source3/rpcclient/cmd_reg.c56
1 files changed, 8 insertions, 48 deletions
diff --git a/source3/rpcclient/cmd_reg.c b/source3/rpcclient/cmd_reg.c
index 28cd83ef58..991d76b3a3 100644
--- a/source3/rpcclient/cmd_reg.c
+++ b/source3/rpcclient/cmd_reg.c
@@ -21,15 +21,8 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef SYSLOG
-#undef SYSLOG
-#endif
-
#include "includes.h"
-
-extern int smb_tidx;
-
-extern FILE* out_hnd;
+#include "rpcclient.h"
/*
* keys. of the form:
@@ -902,7 +895,8 @@ static void cmd_reg_get_key_sec(struct client_info *info)
/****************************************************************************
nt registry shutdown
****************************************************************************/
-static NTSTATUS cmd_reg_shutdown(struct cli_state *cli, int argc, char **argv)
+static NTSTATUS cmd_reg_shutdown(struct cli_state *cli, TALLOC_CTX *mem_ctx,
+ int argc, char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
fstring msg;
@@ -911,7 +905,6 @@ static NTSTATUS cmd_reg_shutdown(struct cli_state *cli, int argc, char **argv)
int opt;
int ret;
char *srv_name;
- TALLOC_CTX *mem_ctx;
ret = asprintf (&srv_name, "\\\\%s", cli->desthost);
if (ret < 0) {
@@ -920,18 +913,6 @@ static NTSTATUS cmd_reg_shutdown(struct cli_state *cli, int argc, char **argv)
}
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 */
@@ -974,23 +955,19 @@ static NTSTATUS cmd_reg_shutdown(struct cli_state *cli, int argc, char **argv)
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 NTSTATUS cmd_reg_abort_shutdown(struct cli_state *cli, int argc, char **argv)
+static NTSTATUS cmd_reg_abort_shutdown(struct cli_state *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
int ret;
char *srv_name;
- TALLOC_CTX *mem_ctx;
ret = asprintf(&srv_name, "\\\\%s", cli->desthost);
if (ret < 0) {
@@ -999,18 +976,6 @@ static NTSTATUS cmd_reg_abort_shutdown(struct cli_state *cli, int argc, char **a
}
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 (NT_STATUS_IS_OK(result))
@@ -1018,11 +983,6 @@ static NTSTATUS cmd_reg_abort_shutdown(struct cli_state *cli, int argc, char **a
else
DEBUG(5,("cmd_reg_abort_shutdown: query failed\n"));
- cli_nt_session_close(cli);
-
-done:
- talloc_destroy(mem_ctx);
-
return result;
}
@@ -1032,10 +992,10 @@ struct cmd_set reg_commands[] = {
{ "REG" },
- { "shutdown", cmd_reg_shutdown, "Remote Shutdown",
+ { "shutdown", cmd_reg_shutdown, PIPE_WINREG, "Remote Shutdown",
"[-m message] [-t timeout] [-r] [-f] (-r == reboot, -f == force)" },
- { "abortshutdown", cmd_reg_abort_shutdown, "Abort Shutdown",
+ { "abortshutdown", cmd_reg_abort_shutdown, PIPE_WINREG, "Abort Shutdown",
"" },
/*
{ "regenum", cmd_reg_enum, "Registry Enumeration",