summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/Makefile.in5
-rw-r--r--source3/include/rpc_reg.h174
-rw-r--r--source3/include/util_getent.h5
-rw-r--r--source3/libsmb/cli_reg.c116
-rw-r--r--source3/param/loadparm.c20
-rw-r--r--source3/rpc_parse/parse_reg.c217
-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
13 files changed, 713 insertions, 112 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index a809ee11bb..63a2543e44 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -121,7 +121,7 @@ READLINE_OBJ = lib/readline.o
UBIQX_OBJ = ubiqx/ubi_BinTree.o ubiqx/ubi_Cache.o ubiqx/ubi_SplayTree.o \
ubiqx/ubi_dLinkList.o ubiqx/ubi_sLinkList.o ubiqx/debugparse.o
-PARAM_OBJ = param/loadparm.o param/params.o
+PARAM_OBJ = param/loadparm.o param/params.o
LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
libsmb/clirap.o libsmb/clierror.o libsmb/climessage.o \
@@ -135,6 +135,7 @@ LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
LIBMSRPC_OBJ = libsmb/cli_lsarpc.o libsmb/cli_samr.o libsmb/cli_spoolss.o \
libsmb/cli_netlogon.o libsmb/cli_srvsvc.o libsmb/cli_dfs.o \
+ libsmb/cli_reg.o \
rpc_client/cli_pipe.o nsswitch/winbindd_glue.o \
libsmb/cli_pipe_util.o
@@ -270,7 +271,7 @@ SMBGROUPEDIT_OBJ = utils/smbgroupedit.o $(GROUPDB_OBJ) $(PARAM_OBJ) \
RPCCLIENT_OBJ1 = rpcclient/rpcclient.o rpcclient/cmd_lsarpc.o \
rpcclient/cmd_samr.o rpcclient/cmd_spoolss.o \
rpcclient/cmd_netlogon.o rpcclient/cmd_srvsvc.o \
- rpcclient/cmd_dfs.o
+ rpcclient/cmd_dfs.o rpcclient/cmd_reg.o
RPCCLIENT_OBJ = $(RPCCLIENT_OBJ1) \
$(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) \
diff --git a/source3/include/rpc_reg.h b/source3/include/rpc_reg.h
index 103a7492cd..f65d8d7cc3 100644
--- a/source3/include/rpc_reg.h
+++ b/source3/include/rpc_reg.h
@@ -26,47 +26,81 @@
/* winreg pipe defines */
-#define REG_OPEN_HKLM 0x02
-#define REG_OPEN_HKU 0x04
-#define REG_FLUSH_KEY 0x0B
-#define REG_UNK_1A 0x1a
-#define REG_QUERY_KEY 0x10
-#define REG_ENUM_KEY 0x09
-#define REG_CREATE_KEY 0x06
-#define REG_DELETE_KEY 0x07
-#define REG_DELETE_VALUE 0x08
-#define REG_CREATE_VALUE 0x16
-#define REG_GET_KEY_SEC 0x0c
-#define REG_SET_KEY_SEC 0x15
-#define REG_ENUM_VALUE 0x0a
-#define REG_OPEN_ENTRY 0x0f
-#define REG_INFO 0x11
-#define REG_CLOSE 0x05
-
-#define HKEY_LOCAL_MACHINE 0x80000000
-#define HKEY_USERS 0x80000003
-
-/* REG_Q_OPEN_HKLM */
-typedef struct q_reg_open_policy_info
+#define REG_OPEN_HKCR 0x00
+#define _REG_UNK_01 0x01
+#define REG_OPEN_HKLM 0x02
+#define _REG_UNK_03 0x03
+#define REG_OPEN_HKU 0x04
+#define REG_CLOSE 0x05
+#define REG_CREATE_KEY 0x06
+#define REG_DELETE_KEY 0x07
+#define REG_DELETE_VALUE 0x08
+#define REG_ENUM_KEY 0x09
+#define REG_ENUM_VALUE 0x0a
+#define REG_FLUSH_KEY 0x0b
+#define REG_GET_KEY_SEC 0x0c
+#define _REG_UNK_0D 0x0d
+#define _REG_UNK_0E 0x0e
+#define REG_OPEN_ENTRY 0x0f
+#define REG_QUERY_KEY 0x10
+#define REG_INFO 0x11
+#define _REG_UNK_12 0x12
+#define _REG_UNK_13 0x13
+#define _REG_UNK_14 0x14
+#define REG_SET_KEY_SEC 0x15
+#define REG_CREATE_VALUE 0x16
+#define _REG_UNK_17 0x17
+#define REG_SHUTDOWN 0x18
+#define REG_ABORT_SHUTDOWN 0x19
+#define REG_UNK_1A 0x1a
+
+#define HKEY_CLASSES_ROOT 0x80000000
+#define HKEY_CURRENT_USER 0x80000001
+#define HKEY_LOCAL_MACHINE 0x80000002
+#define HKEY_USERS 0x80000003
+
+/* REG_Q_OPEN_HKCR */
+typedef struct q_reg_open_hkcr_info
{
uint32 ptr;
- uint16 unknown_0; /* 0xE084 - 16 bit unknown */
+ uint16 unknown_0; /* 0x5428 - 16 bit unknown */
uint16 unknown_1; /* random. changes */
uint32 level; /* 0x0000 0002 - 32 bit unknown */
-} REG_Q_OPEN_HKLM ;
+} REG_Q_OPEN_HKCR ;
-/* REG_R_OPEN_HKLM */
-typedef struct r_reg_open_policy_info
+/* REG_R_OPEN_HKCR */
+typedef struct r_reg_open_hkcr_info
{
POLICY_HND pol; /* policy handle */
uint32 status; /* return status */
-} REG_R_OPEN_HKLM;
+} REG_R_OPEN_HKCR;
+
+
+/* REG_Q_OPEN_HKLM */
+typedef struct q_reg_open_hklm_info
+{
+ uint32 ptr;
+ uint16 unknown_0; /* 0xE084 - 16 bit unknown */
+ uint16 unknown_1; /* random. changes */
+ uint32 access_mask; /* 0x0000 0002 - 32 bit unknown */
+
+}
+REG_Q_OPEN_HKLM;
+
+/* REG_R_OPEN_HKLM */
+typedef struct r_reg_open_hklm_info
+{
+ POLICY_HND pol; /* policy handle */
+ uint32 status; /* return status */
+
+}
+REG_R_OPEN_HKLM;
/* REG_Q_OPEN_HKU */
-typedef struct q_reg_open_unk4_info
+typedef struct q_reg_open_hku_info
{
uint32 ptr;
uint16 unknown_0; /* 0xE084 - 16 bit unknown */
@@ -76,7 +110,7 @@ typedef struct q_reg_open_unk4_info
} REG_Q_OPEN_HKU;
/* REG_R_OPEN_HKU */
-typedef struct r_reg_open_unk4_info
+typedef struct r_reg_open_hku_info
{
POLICY_HND pol; /* policy handle */
uint32 status; /* return status */
@@ -396,43 +430,43 @@ typedef struct r_reg_enum_key_info
/* REG_Q_INFO */
typedef struct q_reg_info_info
{
- POLICY_HND pol; /* policy handle */
+ POLICY_HND pol; /* policy handle */
- UNIHDR hdr_type; /* unicode product type header */
- UNISTR2 uni_type; /* unicode product type - "ProductType" */
+ UNIHDR hdr_type; /* unicode product type header */
+ UNISTR2 uni_type; /* unicode product type - "ProductType" */
- uint32 ptr_reserved;
+ uint32 ptr_reserved; /* pointer */
- uint32 ptr_buf; /* the next three fields follow if ptr_buf != 0 */
- uint32 ptr_bufsize;
- uint32 bufsize;
- uint32 buf_unk;
-
- uint32 unk1;
- uint32 ptr_buflen;
- uint32 buflen;
+ uint32 ptr_buf; /* the next three fields follow if ptr_buf != 0 */
+ uint32 ptr_bufsize;
+ uint32 bufsize;
+ uint32 buf_unk;
+
+ uint32 unk1;
+ uint32 ptr_buflen;
+ uint32 buflen;
- uint32 ptr_buflen2;
- uint32 buflen2;
+ uint32 ptr_buflen2;
+ uint32 buflen2;
} REG_Q_INFO;
/* REG_R_INFO */
typedef struct r_reg_info_info
{
- uint32 ptr_type; /* keyvalue pointer */
- uint32 type; /* keyvalue datatype */
-
- uint32 ptr_uni_val; /* pointer to o/s type */
- BUFFER2 *uni_val; /* unicode string o/s type - "LanmanNT" */
+ uint32 ptr_type; /* key type pointer */
+ uint32 type; /* key datatype */
- uint32 ptr_max_len; /* pointer to unknown_0 */
- uint32 buf_max_len; /* 0x12 */
+ uint32 ptr_uni_val; /* key value pointer */
+ BUFFER2 *uni_val; /* key value */
- uint32 ptr_len; /* pointer to unknown_1 */
- uint32 buf_len; /* 0x12 */
+ uint32 ptr_max_len;
+ uint32 buf_max_len;
- uint32 status; /* return status */
+ uint32 ptr_len;
+ uint32 buf_len;
+
+ uint32 status; /* return status */
} REG_R_INFO;
@@ -460,6 +494,40 @@ typedef struct r_reg_open_entry_info
} REG_R_OPEN_ENTRY;
+/* REG_Q_SHUTDOWN */
+typedef struct q_reg_shutdown_info
+{
+ uint32 ptr_0;
+ uint32 ptr_1;
+ uint32 ptr_2;
+ UNIHDR hdr_msg; /* shutdown message */
+ UNISTR2 uni_msg; /* seconds */
+ uint32 timeout; /* seconds */
+ uint16 flags;
+
+} REG_Q_SHUTDOWN;
+
+/* REG_R_SHUTDOWN */
+typedef struct r_reg_shutdown_info
+{
+ uint32 status; /* return status */
+
+} REG_R_SHUTDOWN;
+
+/* REG_Q_ABORT_SHUTDOWN */
+typedef struct q_reg_abort_shutdown_info
+{
+ uint32 ptr_server;
+ uint16 server;
+
+} REG_Q_ABORT_SHUTDOWN;
+
+/* REG_R_ABORT_SHUTDOWN */
+typedef struct r_reg_abort_shutdown_info
+{
+ uint32 status; /* return status */
+
+} REG_R_ABORT_SHUTDOWN;
#endif /* _RPC_REG_H */
diff --git a/source3/include/util_getent.h b/source3/include/util_getent.h
index 11926b8964..877d272ceb 100644
--- a/source3/include/util_getent.h
+++ b/source3/include/util_getent.h
@@ -19,6 +19,9 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#ifndef _UTIL_GETENT_H
+#define _UTIL_GETENT_H
+
/* element for a single linked list of group entries */
/* replace the use of struct group in some cases */
/* used by getgrent_list() */
@@ -43,3 +46,5 @@ struct sys_pwent {
char *pw_shell;
struct sys_pwent *next;
};
+
+#endif /* _UTIL_GETENT_H */
diff --git a/source3/libsmb/cli_reg.c b/source3/libsmb/cli_reg.c
new file mode 100644
index 0000000000..42fea91874
--- /dev/null
+++ b/source3/libsmb/cli_reg.c
@@ -0,0 +1,116 @@
+
+/*
+ Unix SMB/Netbios implementation.
+ Version 2.2
+ RPC Pipe client
+
+ Copyright (C) Andrew Tridgell 1992-1998,
+ Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
+ Copyright (C) Paul Ashton 1997-1998.
+ Copyright (C) Jeremy Allison 1999.
+ Copyright (C) Simo Sorce 2000
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+/* Opens a SMB connection to the WINREG pipe */
+struct cli_state *cli_winreg_initialise(struct cli_state *cli,
+ char *system_name,
+ struct ntuser_creds *creds)
+{
+ return cli_pipe_initialise(cli, system_name, PIPE_WINREG, creds);
+}
+
+/* Shutdown a server */
+
+uint32 cli_reg_shutdown(struct cli_state * cli, TALLOC_CTX *mem_ctx,
+ const char *srv_name, const char *msg,
+ uint32 timeout, uint16 flags)
+{
+ prs_struct qbuf;
+ prs_struct rbuf;
+ REG_Q_SHUTDOWN q_s;
+ REG_R_SHUTDOWN r_s;
+ uint32 result = NT_STATUS_UNSUCCESSFUL;
+
+ if (msg == NULL) return False;
+
+ ZERO_STRUCT (q_s);
+ ZERO_STRUCT (r_s);
+
+ prs_init(&qbuf , MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
+
+ /* Marshall data and send request */
+
+ init_reg_q_shutdown(&q_s, msg, timeout, flags);
+
+ if (!reg_io_q_shutdown("", &q_s, &qbuf, 0) ||
+ !rpc_api_pipe_req(cli, REG_SHUTDOWN, &qbuf, &rbuf))
+ goto done;
+
+ /* Unmarshall response */
+
+ if(reg_io_r_shutdown("", &r_s, &rbuf, 0))
+ result = r_s.status;
+
+done:
+ prs_mem_free(&rbuf);
+ prs_mem_free(&qbuf);
+
+ return result;
+}
+
+
+/* Abort a server shutdown */
+
+uint32 cli_reg_abort_shutdown(struct cli_state * cli,
+ TALLOC_CTX *mem_ctx,
+ const char *srv_name)
+{
+ prs_struct rbuf;
+ prs_struct qbuf;
+ REG_Q_ABORT_SHUTDOWN q_s;
+ REG_R_ABORT_SHUTDOWN r_s;
+ uint32 result = NT_STATUS_UNSUCCESSFUL;
+
+ ZERO_STRUCT (q_s);
+ ZERO_STRUCT (r_s);
+
+ prs_init(&qbuf , MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
+
+ /* Marshall data and send request */
+
+ init_reg_q_abort_shutdown(&q_s);
+
+ if (!reg_io_q_abort_shutdown("", &q_s, &qbuf, 0) ||
+ !rpc_api_pipe_req(cli, REG_ABORT_SHUTDOWN, &qbuf, &rbuf))
+ goto done;
+
+ /* Unmarshall response */
+
+ if (reg_io_r_abort_shutdown("", &r_s, &rbuf, 0))
+ result = r_s.status;
+
+done:
+ prs_mem_free(&rbuf);
+ prs_mem_free(&qbuf );
+
+ return result;
+}
+
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index c110139e21..cb7f9f35c3 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3580,8 +3580,8 @@ char **lp_list_make(char *string)
if (!string || !*string) return NULL;
s = strdup(string);
- if (!s || !*s) {
- DEBUG(0,("ERROR: Unable to allocate memory"));
+ if (!s) {
+ DEBUG(0,("lp_list_make: Unable to allocate memory"));
return NULL;
}
@@ -3589,15 +3589,13 @@ char **lp_list_make(char *string)
list = NULL;
str = s;
- while (*str)
- {
- if (!next_token(&str, tok, LIST_SEP, sizeof(pstring))) continue;
-
+ while (next_token(&str, tok, LIST_SEP, sizeof(pstring)))
+ {
if (num == lsize) {
lsize += P_LIST_ABS;
rlist = (char **)Realloc(list, ((sizeof(char **)) * (lsize +1)));
if (!rlist) {
- DEBUG(0,("ERROR: Unable to allocate memory"));
+ DEBUG(0,("lp_list_make: Unable to allocate memory"));
lp_list_free (&list);
free (s);
return NULL;
@@ -3608,7 +3606,7 @@ char **lp_list_make(char *string)
list[num] = strdup(tok);
if (!list[num]) {
- DEBUG(0,("ERROR: Unable to allocate memory"));
+ DEBUG(0,("lp_list_make: Unable to allocate memory"));
lp_list_free (&list);
free (s);
return NULL;
@@ -3638,7 +3636,7 @@ BOOL lp_list_copy(char ***dest, char **src)
lsize += P_LIST_ABS;
rlist = (char **)Realloc(list, ((sizeof(char **)) * (lsize +1)));
if (!rlist) {
- DEBUG(0,("ERROR: Unable to allocate memory"));
+ DEBUG(0,("lp_list_copy: Unable to allocate memory"));
lp_list_free (&list);
return False;
}
@@ -3648,7 +3646,7 @@ BOOL lp_list_copy(char ***dest, char **src)
list[num] = strdup(src[num]);
if (!list[num]) {
- DEBUG(0,("ERROR: Unable to allocate memory"));
+ DEBUG(0,("lp_list_copy: Unable to allocate memory"));
lp_list_free (&list);
return False;
}
@@ -3713,7 +3711,7 @@ BOOL lp_list_substitute(char **list, const char *pattern, const char *insert)
{
t = (char *) malloc(ls +ld +1);
if (!t) {
- DEBUG(0,("ERROR: Unable to allocate memory"));
+ DEBUG(0,("lp_list_substitute: Unable to allocate memory"));
return False;
}
memcpy(t, *list, d);
diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c
index a7602434e5..23d47cf9b5 100644
--- a/source3/rpc_parse/parse_reg.c
+++ b/source3/rpc_parse/parse_reg.c
@@ -5,7 +5,8 @@
* Copyright (C) Andrew Tridgell 1992-1997,
* Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
* Copyright (C) Paul Ashton 1997.
- * Copyright (C) Marc Jacobsen 1999.
+ * Copyright (C) Marc Jacobsen 1999.
+ * Copyright (C) Simo Sorce 2000.
*
* 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
@@ -32,7 +33,7 @@ extern int DEBUGLEVEL;
Inits a structure.
********************************************************************/
-void init_reg_q_open_hklm(REG_Q_OPEN_HKLM *q_o,
+void init_reg_q_open_hkcr(REG_Q_OPEN_HKCR *q_o,
uint16 unknown_0, uint32 level)
{
q_o->ptr = 1;
@@ -45,12 +46,12 @@ void init_reg_q_open_hklm(REG_Q_OPEN_HKLM *q_o,
reads or writes a structure.
********************************************************************/
-BOOL reg_io_q_open_hklm(char *desc, REG_Q_OPEN_HKLM *r_q, prs_struct *ps, int depth)
+BOOL reg_io_q_open_hkcr(char *desc, REG_Q_OPEN_HKCR *r_q, prs_struct *ps, int depth)
{
if (r_q == NULL)
return False;
- prs_debug(ps, depth, desc, "reg_io_q_open_hklm");
+ prs_debug(ps, depth, desc, "reg_io_q_open_hkcr");
depth++;
if(!prs_align(ps))
@@ -76,12 +77,12 @@ BOOL reg_io_q_open_hklm(char *desc, REG_Q_OPEN_HKLM *r_q, prs_struct *ps, int d
reads or writes a structure.
********************************************************************/
-BOOL reg_io_r_open_hklm(char *desc, REG_R_OPEN_HKLM *r_r, prs_struct *ps, int depth)
+BOOL reg_io_r_open_hkcr(char *desc, REG_R_OPEN_HKCR *r_r, prs_struct *ps, int depth)
{
if (r_r == NULL)
return False;
- prs_debug(ps, depth, desc, "reg_io_r_open_hklm");
+ prs_debug(ps, depth, desc, "reg_io_r_open_hkcr");
depth++;
if(!prs_align(ps))
@@ -96,6 +97,75 @@ BOOL reg_io_r_open_hklm(char *desc, REG_R_OPEN_HKLM *r_r, prs_struct *ps, int d
return True;
}
+/*******************************************************************
+ Inits a structure.
+********************************************************************/
+
+void init_reg_q_open_hklm(REG_Q_OPEN_HKLM * q_o,
+ uint16 unknown_0, uint32 access_mask)
+{
+ q_o->ptr = 1;
+ q_o->unknown_0 = unknown_0;
+ q_o->unknown_1 = 0x0; /* random - changes */
+ q_o->access_mask = access_mask;
+
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+BOOL reg_io_q_open_hklm(char *desc, REG_Q_OPEN_HKLM * r_q, prs_struct *ps,
+ int depth)
+{
+ if (r_q == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "reg_io_q_open_hklm");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("ptr ", ps, depth, &(r_q->ptr)))
+ return False;
+ if (r_q->ptr != 0)
+ {
+ if (!prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0)))
+ return False;
+ if (!prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1)))
+ return False;
+ if (!prs_uint32("access_mask", ps, depth, &(r_q->access_mask)))
+ return False;
+ }
+
+ return True;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+BOOL reg_io_r_open_hklm(char *desc, REG_R_OPEN_HKLM * r_r, prs_struct *ps,
+ int depth)
+{
+ if (r_r == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "reg_io_r_open_hklm");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!smb_io_pol_hnd("", &(r_r->pol), ps, depth))
+ return False;
+
+ if (!prs_uint32("status", ps, depth, &(r_r->status)))
+ return False;
+
+ return True;
+}
+
/*******************************************************************
Inits a structure.
@@ -1478,3 +1548,138 @@ BOOL reg_io_r_open_entry(char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int
return True;
}
+
+/*******************************************************************
+Inits a structure.
+********************************************************************/
+void init_reg_q_shutdown(REG_Q_SHUTDOWN * q_s,
+ const char *msg, uint32 timeout, uint16 flags)
+{
+ int msg_len;
+ msg_len = strlen(msg);
+
+ q_s->ptr_0 = 1;
+ q_s->ptr_1 = 1;
+ q_s->ptr_2 = 1;
+
+ init_uni_hdr(&(q_s->hdr_msg), msg_len);
+ init_unistr2(&(q_s->uni_msg), msg, msg_len);
+
+ q_s->timeout = timeout;
+ q_s->flags = flags;
+
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+BOOL reg_io_q_shutdown(char *desc, REG_Q_SHUTDOWN * q_s, prs_struct *ps,
+ int depth)
+{
+ if (q_s == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "reg_io_q_shutdown");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("ptr_0", ps, depth, &(q_s->ptr_0)))
+ return False;
+ if (!prs_uint32("ptr_1", ps, depth, &(q_s->ptr_1)))
+ return False;
+ if (!prs_uint32("ptr_2", ps, depth, &(q_s->ptr_2)))
+ return False;
+
+ if (!smb_io_unihdr("hdr_msg", &(q_s->hdr_msg), ps, depth))
+ return False;
+ if (!smb_io_unistr2("uni_msg", &(q_s->uni_msg), q_s->hdr_msg.buffer, ps, depth))
+ return False;
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("timeout", ps, depth, &(q_s->timeout)))
+ return False;
+ if (!prs_uint16("flags ", ps, depth, &(q_s->flags)))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+BOOL reg_io_r_shutdown(char *desc, REG_R_SHUTDOWN * r_s, prs_struct *ps,
+ int depth)
+{
+ if (r_s == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "reg_io_r_shutdown");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("status", ps, depth, &(r_s->status)))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+Inits a structure.
+********************************************************************/
+void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN * q_s)
+{
+
+ q_s->ptr_server = 0;
+
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+BOOL reg_io_q_abort_shutdown(char *desc, REG_Q_ABORT_SHUTDOWN * q_s,
+ prs_struct *ps, int depth)
+{
+ if (q_s == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "reg_io_q_abort_shutdown");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server)))
+ return False;
+ if (q_s->ptr_server != 0)
+ if (!prs_uint16("server", ps, depth, &(q_s->server)))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+BOOL reg_io_r_abort_shutdown(char *desc, REG_R_ABORT_SHUTDOWN * r_s,
+ prs_struct *ps, int depth)
+{
+ if (r_s == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "reg_io_r_abort_shutdown");
+ depth++;
+
+ if (!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("status", ps, depth, &(r_s->status)))
+ return False;
+
+ return True;
+}
+
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;
}