summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h47
-rw-r--r--source3/rpc_client/cli_reg.c202
-rw-r--r--source3/rpc_parse/parse_reg.c2
-rw-r--r--source3/rpcclient/cmd_reg.c265
-rw-r--r--source3/rpcclient/rpcclient.c7
5 files changed, 324 insertions, 199 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index f986cc7c2d..f23106ed18 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1909,55 +1909,58 @@ void cli_nt_session_close(struct cli_state *cli, uint16 fnum);
/*The following definitions come from rpc_client/cli_reg.c */
-BOOL do_reg_connect(struct cli_state *cli, uint16 fnum,
+BOOL reg_connect( const char* srv_name,
const char *full_keyname,
char *key_name,
POLICY_HND *reg_hnd);
-BOOL do_reg_open_hkcr(struct cli_state *cli, uint16 fnum, uint16 unknown_0, uint32 level,
+BOOL reg_open_hkcr( struct cli_state *cli, uint16 fnum,
+ uint16 unknown_0, uint32 level,
POLICY_HND *hnd);
-BOOL do_reg_open_hklm(struct cli_state *cli, uint16 fnum, uint16 unknown_0, uint32 level,
+BOOL reg_open_hklm( struct cli_state *cli, uint16 fnum,
+ uint16 unknown_0, uint32 level,
POLICY_HND *hnd);
-BOOL do_reg_open_hku(struct cli_state *cli, uint16 fnum, uint16 unknown_0, uint32 level,
+BOOL reg_open_hku( struct cli_state *cli, uint16 fnum,
+ uint16 unknown_0, uint32 level,
POLICY_HND *hnd);
-BOOL do_reg_flush_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd);
-BOOL do_reg_query_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_flush_key( POLICY_HND *hnd);
+BOOL reg_query_key( POLICY_HND *hnd,
char *key_class, uint32 *class_len,
uint32 *num_subkeys, uint32 *max_subkeylen,
uint32 *max_subkeysize, uint32 *num_values,
uint32 *max_valnamelen, uint32 *max_valbufsize,
uint32 *sec_desc, NTTIME *mod_time);
-BOOL do_reg_unknown_1a(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, uint32 *unk);
-BOOL do_reg_query_info(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_unknown_1a( POLICY_HND *hnd, uint32 *unk);
+BOOL reg_query_info( POLICY_HND *hnd,
const char* val_name,
uint32 *type, BUFFER2 *buffer);
-BOOL do_reg_set_key_sec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_set_key_sec( POLICY_HND *hnd,
uint32 sec_info,
uint32 sec_buf_size, SEC_DESC *sec_buf);
-BOOL do_reg_get_key_sec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_get_key_sec( POLICY_HND *hnd,
uint32 sec_info,
uint32 *sec_buf_size, SEC_DESC_BUF *sec_buf);
-BOOL do_reg_delete_val(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, char *val_name);
-BOOL do_reg_delete_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, char *key_name);
-BOOL do_reg_create_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_delete_val( POLICY_HND *hnd, char *val_name);
+BOOL reg_delete_key( POLICY_HND *hnd, char *key_name);
+BOOL reg_create_key( POLICY_HND *hnd,
char *key_name, char *key_class,
SEC_ACCESS *sam_access,
POLICY_HND *key);
-BOOL do_reg_enum_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_enum_key( POLICY_HND *hnd,
int key_index, char *key_name,
uint32 *unk_1, uint32 *unk_2,
time_t *mod_time);
-BOOL do_reg_create_val(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_create_val( POLICY_HND *hnd,
char *val_name, uint32 type, BUFFER3 *data);
-BOOL do_reg_enum_val(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_enum_val( POLICY_HND *hnd,
int val_index, int max_valnamelen, int max_valbufsize,
fstring val_name,
uint32 *val_type, BUFFER2 *value);
-BOOL do_reg_open_entry(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_open_entry( POLICY_HND *hnd,
char *key_name, uint32 unk_0,
POLICY_HND *key_hnd);
-BOOL do_reg_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd);
-BOOL do_reg_shutdown(struct cli_state *cli, uint16 fnum,
- char *msg, uint32 timeout, uint16 flags);
+BOOL reg_close( POLICY_HND *hnd);
+BOOL reg_shutdown(const char *srv_name,
+ const char *msg, uint32 timeout, uint16 flags);
/*The following definitions come from rpc_client/cli_samr.c */
@@ -2709,7 +2712,7 @@ BOOL make_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r,
POLICY_HND *pol, uint32 status);
BOOL reg_io_r_open_entry(char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth);
BOOL make_reg_q_shutdown(REG_Q_SHUTDOWN *q_i,
- char *msg, uint32 timeout, uint16 flags);
+ const char *msg, uint32 timeout, uint16 flags);
BOOL reg_io_q_shutdown(char *desc, REG_Q_SHUTDOWN *q_q, prs_struct *ps, int depth);
BOOL reg_io_r_shutdown(char *desc, REG_R_SHUTDOWN *r_q, prs_struct *ps, int depth);
@@ -3602,7 +3605,7 @@ void cmd_sam_sync(struct client_info *info, int argc, char *argv[]);
/*The following definitions come from rpcclient/cmd_reg.c */
-BOOL msrpc_reg_enum_key(struct cli_state *cli, const char* full_keyname,
+BOOL msrpc_reg_enum_key(const char* srv_name, const char* full_keyname,
REG_FN(reg_fn),
REG_KEY_FN(reg_key_fn),
REG_VAL_FN(reg_val_fn));
diff --git a/source3/rpc_client/cli_reg.c b/source3/rpc_client/cli_reg.c
index 1bad3e16a4..46ab55dcab 100644
--- a/source3/rpc_client/cli_reg.c
+++ b/source3/rpc_client/cli_reg.c
@@ -34,7 +34,7 @@ extern int DEBUGLEVEL;
/****************************************************************************
do a REG Open Policy
****************************************************************************/
-BOOL do_reg_connect(struct cli_state *cli, uint16 fnum,
+BOOL reg_connect( const char* srv_name,
const char *full_keyname,
char *key_name,
POLICY_HND *reg_hnd)
@@ -42,20 +42,29 @@ BOOL do_reg_connect(struct cli_state *cli, uint16 fnum,
BOOL res = True;
uint32 reg_type = 0;
- if (full_keyname == NULL)
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_init(srv_name, PIPE_WINREG, &cli, &fnum))
{
return False;
}
ZERO_STRUCTP(reg_hnd);
+ if (full_keyname == NULL)
+ {
+ return False;
+ }
+
/*
* open registry receive a policy handle
*/
if (!reg_split_key(full_keyname, &reg_type, key_name))
{
- DEBUG(0,("do_reg_connect: unrecognised key name %s\n", full_keyname));
+ DEBUG(0,("reg_connect: unrecognised key name %s\n",
+ full_keyname));
return False;
}
@@ -63,7 +72,7 @@ BOOL do_reg_connect(struct cli_state *cli, uint16 fnum,
{
case HKEY_CLASSES_ROOT:
{
- res = res ? do_reg_open_hkcr(cli, fnum,
+ res = res ? reg_open_hkcr(cli, fnum,
0x5428, 0x02000000,
reg_hnd) : False;
break;
@@ -71,7 +80,7 @@ BOOL do_reg_connect(struct cli_state *cli, uint16 fnum,
case HKEY_LOCAL_MACHINE:
{
- res = res ? do_reg_open_hklm(cli, fnum,
+ res = res ? reg_open_hklm(cli, fnum,
0x84E0, 0x02000000,
reg_hnd) : False;
break;
@@ -79,14 +88,25 @@ BOOL do_reg_connect(struct cli_state *cli, uint16 fnum,
case HKEY_USERS:
{
- res = res ? do_reg_open_hku(cli, fnum,
+ res = res ? reg_open_hku(cli, fnum,
0x84E0, 0x02000000,
reg_hnd) : False;
break;
}
default:
{
- DEBUG(0,("do_reg_connect: unrecognised hive key\n"));
+ DEBUG(0,("reg_connect: unrecognised hive key\n"));
+ return False;
+ }
+ }
+
+ if (res)
+ {
+ if (!register_policy_hnd(reg_hnd) ||
+ !set_policy_cli_state(reg_hnd, cli, fnum,
+ cli_state_free))
+ {
+ cli_state_free(cli, fnum);
return False;
}
}
@@ -97,7 +117,8 @@ BOOL do_reg_connect(struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a REG Open Policy
****************************************************************************/
-BOOL do_reg_open_hkcr(struct cli_state *cli, uint16 fnum, uint16 unknown_0, uint32 level,
+BOOL reg_open_hkcr( struct cli_state *cli, uint16 fnum,
+ uint16 unknown_0, uint32 level,
POLICY_HND *hnd)
{
prs_struct rbuf;
@@ -154,7 +175,8 @@ BOOL do_reg_open_hkcr(struct cli_state *cli, uint16 fnum, uint16 unknown_0, uint
/****************************************************************************
do a REG Open Policy
****************************************************************************/
-BOOL do_reg_open_hklm(struct cli_state *cli, uint16 fnum, uint16 unknown_0, uint32 level,
+BOOL reg_open_hklm( struct cli_state *cli, uint16 fnum,
+ uint16 unknown_0, uint32 level,
POLICY_HND *hnd)
{
prs_struct rbuf;
@@ -211,7 +233,8 @@ BOOL do_reg_open_hklm(struct cli_state *cli, uint16 fnum, uint16 unknown_0, uint
/****************************************************************************
do a REG Open HKU
****************************************************************************/
-BOOL do_reg_open_hku(struct cli_state *cli, uint16 fnum, uint16 unknown_0, uint32 level,
+BOOL reg_open_hku( struct cli_state *cli, uint16 fnum,
+ uint16 unknown_0, uint32 level,
POLICY_HND *hnd)
{
prs_struct rbuf;
@@ -270,13 +293,21 @@ do a REG Unknown 0xB command. sent after a create key or create value.
this might be some sort of "sync" or "refresh" command, sent after
modification of the registry...
****************************************************************************/
-BOOL do_reg_flush_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd)
+BOOL reg_flush_key( POLICY_HND *hnd)
{
prs_struct rbuf;
prs_struct buf;
REG_Q_FLUSH_KEY q_o;
BOOL valid_query = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -324,7 +355,7 @@ BOOL do_reg_flush_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd)
/****************************************************************************
do a REG Query Key
****************************************************************************/
-BOOL do_reg_query_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_query_key( POLICY_HND *hnd,
char *key_class, uint32 *class_len,
uint32 *num_subkeys, uint32 *max_subkeylen,
uint32 *max_subkeysize, uint32 *num_values,
@@ -336,6 +367,14 @@ BOOL do_reg_query_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
REG_Q_QUERY_KEY q_o;
BOOL valid_query = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -394,13 +433,21 @@ BOOL do_reg_query_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
/****************************************************************************
do a REG Unknown 1A
****************************************************************************/
-BOOL do_reg_unknown_1a(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, uint32 *unk)
+BOOL reg_unknown_1a( POLICY_HND *hnd, uint32 *unk)
{
prs_struct rbuf;
prs_struct buf;
REG_Q_UNK_1A q_o;
BOOL valid_query = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -449,7 +496,7 @@ BOOL do_reg_unknown_1a(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, uint
/****************************************************************************
do a REG Query Info
****************************************************************************/
-BOOL do_reg_query_info(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_query_info( POLICY_HND *hnd,
const char* val_name,
uint32 *type, BUFFER2 *buffer)
{
@@ -458,6 +505,14 @@ BOOL do_reg_query_info(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
REG_Q_INFO q_o;
BOOL valid_query = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -508,7 +563,7 @@ BOOL do_reg_query_info(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
/****************************************************************************
do a REG Set Key Security
****************************************************************************/
-BOOL do_reg_set_key_sec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_set_key_sec( POLICY_HND *hnd,
uint32 sec_info,
uint32 sec_buf_size, SEC_DESC *sec_buf)
{
@@ -517,6 +572,14 @@ BOOL do_reg_set_key_sec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
REG_Q_SET_KEY_SEC q_o;
BOOL valid_query = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -558,7 +621,7 @@ BOOL do_reg_set_key_sec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
/****************************************************************************
do a REG Query Key Security
****************************************************************************/
-BOOL do_reg_get_key_sec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_get_key_sec( POLICY_HND *hnd,
uint32 sec_info,
uint32 *sec_buf_size, SEC_DESC_BUF *sec_buf)
{
@@ -567,6 +630,14 @@ BOOL do_reg_get_key_sec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
REG_Q_GET_KEY_SEC q_o;
BOOL valid_query = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -628,13 +699,21 @@ BOOL do_reg_get_key_sec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
/****************************************************************************
do a REG Delete Value
****************************************************************************/
-BOOL do_reg_delete_val(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, char *val_name)
+BOOL reg_delete_val( POLICY_HND *hnd, char *val_name)
{
prs_struct rbuf;
prs_struct buf;
REG_Q_DELETE_VALUE q_o;
BOOL valid_delete = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -682,13 +761,21 @@ BOOL do_reg_delete_val(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, char
/****************************************************************************
do a REG Delete Key
****************************************************************************/
-BOOL do_reg_delete_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, char *key_name)
+BOOL reg_delete_key( POLICY_HND *hnd, char *key_name)
{
prs_struct rbuf;
prs_struct buf;
REG_Q_DELETE_KEY q_o;
BOOL valid_delete = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -736,7 +823,7 @@ BOOL do_reg_delete_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, char
/****************************************************************************
do a REG Create Key
****************************************************************************/
-BOOL do_reg_create_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_create_key( POLICY_HND *hnd,
char *key_name, char *key_class,
SEC_ACCESS *sam_access,
POLICY_HND *key)
@@ -749,6 +836,14 @@ BOOL do_reg_create_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
SEC_DESC_BUF sec_buf;
int sec_len;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
ZERO_STRUCT(sec);
ZERO_STRUCT(sec_buf);
ZERO_STRUCT(q_o);
@@ -810,7 +905,7 @@ BOOL do_reg_create_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
/****************************************************************************
do a REG Enum Key
****************************************************************************/
-BOOL do_reg_enum_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_enum_key( POLICY_HND *hnd,
int key_index, char *key_name,
uint32 *unk_1, uint32 *unk_2,
time_t *mod_time)
@@ -820,6 +915,14 @@ BOOL do_reg_enum_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
REG_Q_ENUM_KEY q_o;
BOOL valid_query = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -872,7 +975,7 @@ BOOL do_reg_enum_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
/****************************************************************************
do a REG Create Value
****************************************************************************/
-BOOL do_reg_create_val(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_create_val( POLICY_HND *hnd,
char *val_name, uint32 type, BUFFER3 *data)
{
prs_struct rbuf;
@@ -880,6 +983,14 @@ BOOL do_reg_create_val(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
REG_Q_CREATE_VALUE q_o;
BOOL valid_create = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -927,7 +1038,7 @@ BOOL do_reg_create_val(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
/****************************************************************************
do a REG Enum Value
****************************************************************************/
-BOOL do_reg_enum_val(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_enum_val( POLICY_HND *hnd,
int val_index, int max_valnamelen, int max_valbufsize,
fstring val_name,
uint32 *val_type, BUFFER2 *value)
@@ -937,6 +1048,14 @@ BOOL do_reg_enum_val(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
REG_Q_ENUM_VALUE q_o;
BOOL valid_query = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -987,7 +1106,7 @@ BOOL do_reg_enum_val(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
/****************************************************************************
do a REG Open Key
****************************************************************************/
-BOOL do_reg_open_entry(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
+BOOL reg_open_entry( POLICY_HND *hnd,
char *key_name, uint32 unk_0,
POLICY_HND *key_hnd)
{
@@ -996,6 +1115,14 @@ BOOL do_reg_open_entry(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
REG_Q_OPEN_ENTRY q_o;
BOOL valid_pol = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -1030,8 +1157,9 @@ BOOL do_reg_open_entry(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
if (p)
{
- valid_pol = True;
memcpy(key_hnd, r_o.pol.data, sizeof(key_hnd->data));
+ valid_pol = register_policy_hnd(key_hnd) &&
+ set_policy_cli_state(key_hnd, cli, fnum, NULL);
}
}
@@ -1044,13 +1172,21 @@ BOOL do_reg_open_entry(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
/****************************************************************************
do a REG Close
****************************************************************************/
-BOOL do_reg_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd)
+BOOL reg_close( POLICY_HND *hnd)
{
prs_struct rbuf;
prs_struct buf;
REG_Q_CLOSE q_c;
BOOL valid_close = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_get(hnd, &cli, &fnum))
+ {
+ return False;
+ }
+
if (hnd == NULL) return False;
/* create and send a MSRPC command with api REG_CLOSE */
@@ -1108,20 +1244,30 @@ BOOL do_reg_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd)
prs_mem_free(&rbuf);
prs_mem_free(&buf );
+ close_policy_hnd(hnd);
+
return valid_close;
}
/****************************************************************************
do a REG Shutdown Server
****************************************************************************/
-BOOL do_reg_shutdown(struct cli_state *cli, uint16 fnum,
- char *msg, uint32 timeout, uint16 flags)
+BOOL reg_shutdown(const char *srv_name,
+ const char *msg, uint32 timeout, uint16 flags)
{
prs_struct rbuf;
prs_struct buf;
REG_Q_SHUTDOWN q_o;
BOOL valid_shutdown = False;
+ struct cli_state *cli = NULL;
+ uint16 fnum = 0xffff;
+
+ if (!cli_state_init(srv_name, PIPE_WINREG, &cli, &fnum))
+ {
+ return False;
+ }
+
if (msg == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -1163,6 +1309,8 @@ BOOL do_reg_shutdown(struct cli_state *cli, uint16 fnum,
prs_mem_free(&rbuf);
prs_mem_free(&buf );
+ cli_state_free(cli, fnum);
+
return valid_shutdown;
}
diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c
index 5e7e950ae4..9f446cc86a 100644
--- a/source3/rpc_parse/parse_reg.c
+++ b/source3/rpc_parse/parse_reg.c
@@ -1350,7 +1350,7 @@ BOOL reg_io_r_open_entry(char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int
makes a structure.
********************************************************************/
BOOL make_reg_q_shutdown(REG_Q_SHUTDOWN *q_i,
- char *msg, uint32 timeout, uint16 flags)
+ const char *msg, uint32 timeout, uint16 flags)
{
int len = strlen(msg) + 1;
diff --git a/source3/rpcclient/cmd_reg.c b/source3/rpcclient/cmd_reg.c
index 9911bc49c0..cae24faf9f 100644
--- a/source3/rpcclient/cmd_reg.c
+++ b/source3/rpcclient/cmd_reg.c
@@ -31,9 +31,6 @@
extern int DEBUGLEVEL;
-extern struct cli_state *smb_cli;
-extern int smb_tidx;
-
extern FILE* out_hnd;
/*
@@ -45,7 +42,7 @@ extern FILE* out_hnd;
* reg_getsubkey() splits this down into:
* [HKLM]|[HKU]\[parent_keyname_components] and [subkey]|[value]
*
- * do_reg_connect() splits the left side down further into:
+ * reg_connect() splits the left side down further into:
* [HKLM]|[HKU] and [parent_keyname_components].
*
* HKLM is short for HKEY_LOCAL_MACHINE
@@ -101,12 +98,11 @@ static void reg_display_key(int val, const char *full_keyname, int num)
/****************************************************************************
nt registry enum
****************************************************************************/
-BOOL msrpc_reg_enum_key(struct cli_state *cli, const char* full_keyname,
+BOOL msrpc_reg_enum_key(const char* srv_name, const char* full_keyname,
REG_FN(reg_fn),
REG_KEY_FN(reg_key_fn),
REG_VAL_FN(reg_val_fn))
{
- uint16 fnum;
BOOL res = True;
BOOL res1 = True;
BOOL res2 = True;
@@ -139,17 +135,14 @@ BOOL msrpc_reg_enum_key(struct cli_state *cli, const char* full_keyname,
DEBUG(5, ("reg_enum_key: %s\n", full_keyname));
- /* open WINREG session. */
- res = res ? cli_nt_session_open(cli, PIPE_WINREG, &fnum) : False;
-
/* open registry receive a policy handle */
- res = res ? do_reg_connect(cli, fnum, full_keyname, key_name,
+ res = res ? reg_connect(srv_name, full_keyname, key_name,
&pol_con) : False;
if ((*key_name) != 0)
{
/* open an entry */
- res1 = res ? do_reg_open_entry(cli, fnum, &pol_con,
+ res1 = res ? reg_open_entry(&pol_con,
key_name, 0x02000000, &key_pol) : False;
}
else
@@ -157,7 +150,7 @@ BOOL msrpc_reg_enum_key(struct cli_state *cli, const char* full_keyname,
memcpy(&key_pol, &pol_con, sizeof(key_pol));
}
- res1 = res1 ? do_reg_query_key(cli, fnum,
+ res1 = res1 ? reg_query_key(
&key_pol,
key_class, &max_class_len,
&num_subkeys, &max_subkeylen, &max_subkeysize,
@@ -182,7 +175,7 @@ BOOL msrpc_reg_enum_key(struct cli_state *cli, const char* full_keyname,
time_t key_mod_time;
/* unknown 1a it */
- res2 = res1 ? do_reg_unknown_1a(cli, fnum, &key_pol,
+ res2 = res1 ? reg_unknown_1a(&key_pol,
&unk_1a_response) : False;
if (res2 && unk_1a_response != 5)
@@ -191,7 +184,7 @@ BOOL msrpc_reg_enum_key(struct cli_state *cli, const char* full_keyname,
}
/* enum key */
- res2 = res2 ? do_reg_enum_key(cli, fnum, &key_pol,
+ res2 = res2 ? reg_enum_key(&key_pol,
i, enum_name,
&enum_unk1, &enum_unk2,
&key_mod_time) : False;
@@ -219,7 +212,7 @@ BOOL msrpc_reg_enum_key(struct cli_state *cli, const char* full_keyname,
fstring val_name;
/* unknown 1a it */
- res2 = res1 ? do_reg_unknown_1a(cli, fnum, &key_pol,
+ res2 = res1 ? reg_unknown_1a(&key_pol,
&unk_1a_response) : False;
if (res2 && unk_1a_response != 5)
@@ -228,7 +221,7 @@ BOOL msrpc_reg_enum_key(struct cli_state *cli, const char* full_keyname,
}
/* enum key */
- res2 = res2 ? do_reg_enum_val(cli, fnum, &key_pol,
+ res2 = res2 ? reg_enum_val(&key_pol,
i, max_valnamelen, max_valbufsize,
val_name, &val_type, &value) : False;
@@ -246,12 +239,9 @@ BOOL msrpc_reg_enum_key(struct cli_state *cli, const char* full_keyname,
/* close the handles */
if ((*key_name) != 0)
{
- res1 = res1 ? do_reg_close(cli, fnum, &key_pol) : False;
+ res1 = res1 ? reg_close(&key_pol) : False;
}
- res = res ? do_reg_close(cli, fnum, &pol_con) : False;
-
- /* close the session */
- cli_nt_session_close(cli, fnum);
+ res = res ? reg_close(&pol_con) : False;
if (res && res1 && res2)
{
@@ -290,6 +280,12 @@ void cmd_reg_enum(struct client_info *info, int argc, char *argv[])
{
char *full_keyname;
+ fstring srv_name;
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
+
if (argc < 2)
{
report(out_hnd, "regenum <key_name>\n");
@@ -298,7 +294,7 @@ void cmd_reg_enum(struct client_info *info, int argc, char *argv[])
full_keyname = argv[1];
- if (msrpc_reg_enum_key(smb_cli, full_keyname,
+ if (msrpc_reg_enum_key(srv_name, full_keyname,
reg_display_key,
reg_display_key_info,
reg_display_val_info))
@@ -312,7 +308,6 @@ nt registry query value info
****************************************************************************/
void cmd_reg_query_info(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
BOOL res1 = True;
@@ -330,7 +325,11 @@ void cmd_reg_query_info(struct client_info *info, int argc, char *argv[])
BUFFER2 buf;
uint32 type;
- DEBUG(5, ("cmd_reg_enum: smb_cli->fd:%d\n", smb_cli->fd));
+ fstring srv_name;
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
if (argc < 2)
{
@@ -348,17 +347,14 @@ void cmd_reg_query_info(struct client_info *info, int argc, char *argv[])
return;
}
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG, &fnum) : False;
-
/* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, fnum, keyname, key_name,
+ res = res ? reg_connect(srv_name, keyname, key_name,
&pol_con) : False;
if ((*key_name) != 0)
{
/* open an entry */
- res1 = res ? do_reg_open_entry(smb_cli, fnum, &pol_con,
+ res1 = res ? reg_open_entry(&pol_con,
key_name, 0x02000000, &key_pol) : False;
}
else
@@ -367,7 +363,7 @@ void cmd_reg_query_info(struct client_info *info, int argc, char *argv[])
}
/* query it */
- res1 = res1 ? do_reg_query_info(smb_cli, fnum, &key_pol,
+ res1 = res1 ? reg_query_info(&key_pol,
val_name, &type, &buf) : False;
if (res1)
@@ -378,12 +374,9 @@ void cmd_reg_query_info(struct client_info *info, int argc, char *argv[])
/* close the handles */
if ((*key_name) != 0)
{
- res1 = res1 ? do_reg_close(smb_cli, fnum, &key_pol) : False;
+ res1 = res1 ? reg_close(&key_pol) : False;
}
- res = res ? do_reg_close(smb_cli, fnum, &pol_con) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, fnum);
+ res = res ? reg_close(&pol_con) : False;
if (res && res1)
{
@@ -400,7 +393,6 @@ nt registry query key
****************************************************************************/
void cmd_reg_query_key(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
BOOL res1 = True;
@@ -424,7 +416,11 @@ void cmd_reg_query_key(struct client_info *info, int argc, char *argv[])
uint32 sec_desc;
NTTIME mod_time;
- DEBUG(5, ("cmd_reg_enum: smb_cli->fd:%d\n", smb_cli->fd));
+ fstring srv_name;
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
if (argc < 2)
{
@@ -434,17 +430,14 @@ void cmd_reg_query_key(struct client_info *info, int argc, char *argv[])
full_keyname = argv[1];
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG, &fnum) : False;
-
/* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, fnum, full_keyname, key_name,
+ res = res ? reg_connect(srv_name, full_keyname, key_name,
&pol_con) : False;
if ((*key_name) != 0)
{
/* open an entry */
- res1 = res ? do_reg_open_entry(smb_cli, fnum, &pol_con,
+ res1 = res ? reg_open_entry(&pol_con,
key_name, 0x02000000, &key_pol) : False;
}
else
@@ -452,7 +445,7 @@ void cmd_reg_query_key(struct client_info *info, int argc, char *argv[])
memcpy(&key_pol, &pol_con, sizeof(key_pol));
}
- res1 = res1 ? do_reg_query_key(smb_cli, fnum,
+ res1 = res1 ? reg_query_key(
&key_pol,
key_class, &key_class_len,
&num_subkeys, &max_subkeylen, &max_subkeysize,
@@ -461,7 +454,7 @@ void cmd_reg_query_key(struct client_info *info, int argc, char *argv[])
if (res1 && key_class_len != 0)
{
- res1 = res1 ? do_reg_query_key(smb_cli, fnum,
+ res1 = res1 ? reg_query_key(
&key_pol,
key_class, &key_class_len,
&num_subkeys, &max_subkeylen, &max_subkeysize,
@@ -482,12 +475,9 @@ void cmd_reg_query_key(struct client_info *info, int argc, char *argv[])
/* close the handles */
if ((*key_name) != 0)
{
- res1 = res1 ? do_reg_close(smb_cli, fnum, &key_pol) : False;
+ res1 = res1 ? reg_close(&key_pol) : False;
}
- res = res ? do_reg_close(smb_cli, fnum, &pol_con) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, fnum);
+ res = res ? reg_close(&pol_con) : False;
if (res && res1)
{
@@ -504,7 +494,6 @@ nt registry create value
****************************************************************************/
void cmd_reg_create_val(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
BOOL res3 = True;
BOOL res4 = True;
@@ -522,11 +511,15 @@ void cmd_reg_create_val(struct client_info *info, int argc, char *argv[])
uint32 unk_0;
uint32 unk_1;
/* query it */
- res1 = res1 ? do_reg_query_info(smb_cli, fnum, &val_pol,
+ res1 = res1 ? reg_query_info(&val_pol,
type, &unk_0, &unk_1) : False;
#endif
- DEBUG(5, ("cmd_reg_create_val: smb_cli->fd:%d\n", smb_cli->fd));
+ fstring srv_name;
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
if (argc < 4)
{
@@ -594,17 +587,14 @@ void cmd_reg_create_val(struct client_info *info, int argc, char *argv[])
DEBUG(10,("key data:\n"));
dump_data(10, (char *)value.buffer, value.buf_len);
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG, &fnum) : False;
-
/* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, fnum, keyname, parent_name,
+ res = res ? reg_connect(srv_name, keyname, parent_name,
&pol_con) : False;
if ((*val_name) != 0)
{
/* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, fnum, &pol_con,
+ res3 = res ? reg_open_entry(&pol_con,
parent_name, 0x02000000, &parent_pol) : False;
}
else
@@ -613,23 +603,20 @@ void cmd_reg_create_val(struct client_info *info, int argc, char *argv[])
}
/* create an entry */
- res4 = res3 ? do_reg_create_val(smb_cli, fnum, &parent_pol,
+ res4 = res3 ? reg_create_val(&parent_pol,
val_name, val_type, &value) : False;
/* flush the modified key */
- res4 = res4 ? do_reg_flush_key(smb_cli, fnum, &parent_pol) : False;
+ res4 = res4 ? reg_flush_key(&parent_pol) : False;
/* close the val handle */
if ((*val_name) != 0)
{
- res3 = res3 ? do_reg_close(smb_cli, fnum, &parent_pol) : False;
+ res3 = res3 ? reg_close(&parent_pol) : False;
}
/* close the registry handles */
- res = res ? do_reg_close(smb_cli, fnum, &pol_con) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, fnum);
+ res = res ? reg_close(&pol_con) : False;
if (res && res3 && res4)
{
@@ -647,7 +634,6 @@ nt registry delete value
****************************************************************************/
void cmd_reg_delete_val(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
BOOL res3 = True;
BOOL res4 = True;
@@ -659,7 +645,11 @@ void cmd_reg_delete_val(struct client_info *info, int argc, char *argv[])
fstring parent_name;
fstring val_name;
- DEBUG(5, ("cmd_reg_delete_val: smb_cli->fd:%d\n", smb_cli->fd));
+ fstring srv_name;
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
if (argc < 2)
{
@@ -677,17 +667,14 @@ void cmd_reg_delete_val(struct client_info *info, int argc, char *argv[])
return;
}
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG, &fnum) : False;
-
/* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, fnum, keyname, parent_name,
+ res = res ? reg_connect(srv_name, keyname, parent_name,
&pol_con) : False;
if ((*val_name) != 0)
{
/* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, fnum, &pol_con,
+ res3 = res ? reg_open_entry(&pol_con,
parent_name, 0x02000000, &parent_pol) : False;
}
else
@@ -696,19 +683,16 @@ void cmd_reg_delete_val(struct client_info *info, int argc, char *argv[])
}
/* delete an entry */
- res4 = res3 ? do_reg_delete_val(smb_cli, fnum, &parent_pol, val_name) : False;
+ res4 = res3 ? reg_delete_val(&parent_pol, val_name) : False;
/* flush the modified key */
- res4 = res4 ? do_reg_flush_key(smb_cli, fnum, &parent_pol) : False;
+ res4 = res4 ? reg_flush_key(&parent_pol) : False;
/* close the key handle */
- res3 = res3 ? do_reg_close(smb_cli, fnum, &parent_pol) : False;
+ res3 = res3 ? reg_close(&parent_pol) : False;
/* close the registry handles */
- res = res ? do_reg_close(smb_cli, fnum, &pol_con) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, fnum);
+ res = res ? reg_close(&pol_con) : False;
if (res && res3 && res4)
{
@@ -726,7 +710,6 @@ nt registry delete key
****************************************************************************/
void cmd_reg_delete_key(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
BOOL res3 = True;
BOOL res4 = True;
@@ -738,7 +721,11 @@ void cmd_reg_delete_key(struct client_info *info, int argc, char *argv[])
fstring key_name;
fstring subkey_name;
- DEBUG(5, ("cmd_reg_delete_key: smb_cli->fd:%d\n", smb_cli->fd));
+ fstring srv_name;
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
if (argc < 2)
{
@@ -756,17 +743,14 @@ void cmd_reg_delete_key(struct client_info *info, int argc, char *argv[])
return;
}
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG, &fnum) : False;
-
/* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, fnum, parent_name, key_name,
+ res = res ? reg_connect(srv_name, parent_name, key_name,
&pol_con) : False;
if ((*key_name) != 0)
{
/* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, fnum, &pol_con,
+ res3 = res ? reg_open_entry(&pol_con,
key_name, 0x02000000, &parent_pol) : False;
}
else
@@ -775,22 +759,19 @@ void cmd_reg_delete_key(struct client_info *info, int argc, char *argv[])
}
/* create an entry */
- res4 = res3 ? do_reg_delete_key(smb_cli, fnum, &parent_pol, subkey_name) : False;
+ res4 = res3 ? reg_delete_key(&parent_pol, subkey_name) : False;
/* flush the modified key */
- res4 = res4 ? do_reg_flush_key(smb_cli, fnum, &parent_pol) : False;
+ res4 = res4 ? reg_flush_key(&parent_pol) : False;
/* close the key handle */
if ((*key_name) != 0)
{
- res3 = res3 ? do_reg_close(smb_cli, fnum, &parent_pol) : False;
+ res3 = res3 ? reg_close(&parent_pol) : False;
}
/* close the registry handles */
- res = res ? do_reg_close(smb_cli, fnum, &pol_con) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, fnum);
+ res = res ? reg_close(&pol_con) : False;
if (res && res3 && res4)
{
@@ -808,7 +789,6 @@ nt registry create key
****************************************************************************/
void cmd_reg_create_key(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
BOOL res3 = True;
BOOL res4 = True;
@@ -823,7 +803,11 @@ void cmd_reg_create_key(struct client_info *info, int argc, char *argv[])
fstring key_class;
SEC_ACCESS sam_access;
- DEBUG(5, ("cmd_reg_create_key: smb_cli->fd:%d\n", smb_cli->fd));
+ fstring srv_name;
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
if (argc < 2)
{
@@ -841,7 +825,7 @@ void cmd_reg_create_key(struct client_info *info, int argc, char *argv[])
return;
}
- if (argc < 3)
+ if (argc > 2)
{
fstrcpy(key_class, argv[2]);
}
@@ -853,17 +837,14 @@ void cmd_reg_create_key(struct client_info *info, int argc, char *argv[])
/* set access permissions */
sam_access.mask = SEC_RIGHTS_READ;
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG, &fnum) : False;
-
/* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, fnum, parent_key, parent_name,
+ res = res ? reg_connect(srv_name, parent_key, parent_name,
&pol_con) : False;
if ((*parent_name) != 0)
{
/* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, fnum, &pol_con,
+ res3 = res ? reg_open_entry(&pol_con,
parent_name, 0x02000000, &parent_pol) : False;
}
else
@@ -872,26 +853,23 @@ void cmd_reg_create_key(struct client_info *info, int argc, char *argv[])
}
/* create an entry */
- res4 = res3 ? do_reg_create_key(smb_cli, fnum, &parent_pol,
+ res4 = res3 ? reg_create_key(&parent_pol,
key_name, key_class, &sam_access, &key_pol) : False;
/* flush the modified key */
- res4 = res4 ? do_reg_flush_key(smb_cli, fnum, &parent_pol) : False;
+ res4 = res4 ? reg_flush_key(&parent_pol) : False;
/* close the key handle */
- res4 = res4 ? do_reg_close(smb_cli, fnum, &key_pol) : False;
+ res4 = res4 ? reg_close(&key_pol) : False;
/* close the key handle */
if ((*parent_name) != 0)
{
- res3 = res3 ? do_reg_close(smb_cli, fnum, &parent_pol) : False;
+ res3 = res3 ? reg_close(&parent_pol) : False;
}
/* close the registry handles */
- res = res ? do_reg_close(smb_cli, fnum, &pol_con) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, fnum);
+ res = res ? reg_close(&pol_con) : False;
if (res && res3 && res4)
{
@@ -909,7 +887,6 @@ nt registry security info
****************************************************************************/
void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
BOOL res3 = True;
BOOL res4 = True;
@@ -927,7 +904,11 @@ void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[])
SEC_DESC_BUF sec_buf;
uint32 sec_info = 0x7;
- DEBUG(5, ("cmd_reg_get_key_sec: smb_cli->fd:%d\n", smb_cli->fd));
+ fstring srv_name;
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
if (argc < 2)
{
@@ -937,17 +918,14 @@ void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[])
full_keyname = argv[1];
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG, &fnum) : False;
-
/* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, fnum, full_keyname, key_name,
+ res = res ? reg_connect(srv_name, full_keyname, key_name,
&pol_con) : False;
if ((*key_name) != 0)
{
/* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, fnum, &pol_con,
+ res3 = res ? reg_open_entry(&pol_con,
key_name, 0x02000000, &key_pol) : False;
}
else
@@ -956,14 +934,14 @@ void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[])
}
/* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, fnum, &pol_con,
+ res3 = res ? reg_open_entry(&pol_con,
key_name, 0x02000000, &key_pol) : False;
/* query key sec info. first call sets sec_buf_size. */
sec_buf_size = 0;
ZERO_STRUCT(sec_buf);
- res4 = res3 ? do_reg_get_key_sec(smb_cli, fnum, &key_pol,
+ res4 = res3 ? reg_get_key_sec(&key_pol,
sec_info,
&sec_buf_size, &sec_buf) : False;
@@ -972,7 +950,7 @@ void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[])
free_sec_desc_buf(&sec_buf);
}
- res4 = res4 ? do_reg_get_key_sec(smb_cli, fnum, &key_pol,
+ res4 = res4 ? reg_get_key_sec(&key_pol,
sec_info,
&sec_buf_size, &sec_buf) : False;
@@ -982,7 +960,7 @@ void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[])
display_sec_desc(out_hnd, ACTION_ENUMERATE, sec_buf.sec);
display_sec_desc(out_hnd, ACTION_FOOTER , sec_buf.sec);
- res4 = res4 ? do_reg_set_key_sec(smb_cli, fnum, &key_pol,
+ res4 = res4 ? reg_set_key_sec(&key_pol,
sec_info, sec_buf_size, sec_buf.sec) : False;
free_sec_desc_buf(&sec_buf);
@@ -991,14 +969,11 @@ void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[])
/* close the key handle */
if ((*key_name) != 0)
{
- res3 = res3 ? do_reg_close(smb_cli, fnum, &key_pol) : False;
+ res3 = res3 ? reg_close(&key_pol) : False;
}
/* close the registry handles */
- res = res ? do_reg_close(smb_cli, fnum, &pol_con) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, fnum);
+ res = res ? reg_close(&pol_con) : False;
if (res && res3 && res4)
{
@@ -1016,7 +991,6 @@ nt registry security info
****************************************************************************/
void cmd_reg_get_key_sec(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
BOOL res3 = True;
BOOL res4 = True;
@@ -1034,7 +1008,11 @@ void cmd_reg_get_key_sec(struct client_info *info, int argc, char *argv[])
SEC_DESC_BUF sec_buf;
uint32 sec_info = 0x7;
- DEBUG(5, ("cmd_reg_get_key_sec: smb_cli->fd:%d\n", smb_cli->fd));
+ fstring srv_name;
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
if (argc < 2)
{
@@ -1044,17 +1022,14 @@ void cmd_reg_get_key_sec(struct client_info *info, int argc, char *argv[])
full_keyname = argv[1];
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG, &fnum) : False;
-
/* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, fnum, full_keyname, key_name,
+ res = res ? reg_connect(srv_name, full_keyname, key_name,
&pol_con) : False;
if ((*key_name) != 0)
{
/* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, fnum, &pol_con,
+ res3 = res ? reg_open_entry(&pol_con,
key_name, 0x02000000, &key_pol) : False;
}
else
@@ -1063,14 +1038,14 @@ void cmd_reg_get_key_sec(struct client_info *info, int argc, char *argv[])
}
/* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, fnum, &pol_con,
+ res3 = res ? reg_open_entry(&pol_con,
key_name, 0x02000000, &key_pol) : False;
/* query key sec info. first call sets sec_buf_size. */
sec_buf_size = 0;
ZERO_STRUCT(sec_buf);
- res4 = res3 ? do_reg_get_key_sec(smb_cli, fnum, &key_pol,
+ res4 = res3 ? reg_get_key_sec(&key_pol,
sec_info,
&sec_buf_size, &sec_buf) : False;
@@ -1079,7 +1054,7 @@ void cmd_reg_get_key_sec(struct client_info *info, int argc, char *argv[])
free_sec_desc_buf(&sec_buf);
}
- res4 = res4 ? do_reg_get_key_sec(smb_cli, fnum, &key_pol,
+ res4 = res4 ? reg_get_key_sec(&key_pol,
sec_info,
&sec_buf_size, &sec_buf) : False;
@@ -1095,14 +1070,11 @@ void cmd_reg_get_key_sec(struct client_info *info, int argc, char *argv[])
/* close the key handle */
if ((*key_name) != 0)
{
- res3 = res3 ? do_reg_close(smb_cli, fnum, &key_pol) : False;
+ res3 = res3 ? reg_close(&key_pol) : False;
}
/* close the registry handles */
- res = res ? do_reg_close(smb_cli, fnum, &pol_con) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, fnum);
+ res = res ? reg_close(&pol_con) : False;
if (res && res3 && res4)
{
@@ -1119,7 +1091,6 @@ nt registry shutdown
****************************************************************************/
void cmd_reg_shutdown(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
fstring msg;
@@ -1127,7 +1098,11 @@ void cmd_reg_shutdown(struct client_info *info, int argc, char *argv[])
uint16 flgs = 0;
int opt;
- DEBUG(5, ("cmd_reg_shutdown: smb_cli->fd:%d\n", smb_cli->fd));
+ fstring srv_name;
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
argc--;
argv++;
@@ -1171,14 +1146,8 @@ void cmd_reg_shutdown(struct client_info *info, int argc, char *argv[])
}
}
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG, &fnum) : False;
-
/* create an entry */
- res = res ? do_reg_shutdown(smb_cli, fnum, msg, timeout, flgs) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, fnum);
+ res = res ? reg_shutdown(srv_name, msg, timeout, flgs) : False;
if (res)
{
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 6891d4435b..da20431b6c 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -903,6 +903,7 @@ static char *complete_regenum(char *text, int state)
if (state == 0)
{
+ fstring srv_name;
if (cmd_argc >= 2 && cmd_argv != NULL && cmd_argv[1] != NULL)
{
char *sep;
@@ -914,8 +915,12 @@ static char *complete_regenum(char *text, int state)
}
}
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, cli_info.dest_host);
+ strupper(srv_name);
+
/* Iterate all keys / values */
- if (!msrpc_reg_enum_key(smb_cli, full_keyname,
+ if (!msrpc_reg_enum_key(srv_name, full_keyname,
reg_init, reg_key_list, reg_val_list))
{
return NULL;