/*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 */
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);
/*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));
/****************************************************************************
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)
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, ®_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;
}
{
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;
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;
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;
}
}
/****************************************************************************
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;
/****************************************************************************
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;
/****************************************************************************
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;
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);
/****************************************************************************
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,
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);
/****************************************************************************
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);
/****************************************************************************
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)
{
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);
/****************************************************************************
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)
{
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);
/****************************************************************************
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)
{
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);
/****************************************************************************
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);
/****************************************************************************
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);
/****************************************************************************
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)
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);
/****************************************************************************
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)
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);
/****************************************************************************
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;
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);
/****************************************************************************
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)
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);
/****************************************************************************
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)
{
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);
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);
}
}
/****************************************************************************
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 */
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);
prs_mem_free(&rbuf);
prs_mem_free(&buf );
+ cli_state_free(cli, fnum);
+
return valid_shutdown;
}
extern int DEBUGLEVEL;
-extern struct cli_state *smb_cli;
-extern int smb_tidx;
-
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
/****************************************************************************
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;
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
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,
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)
}
/* 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;
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)
}
/* 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;
/* 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)
{
{
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");
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))
****************************************************************************/
void cmd_reg_query_info(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
BOOL res1 = True;
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)
{
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
}
/* 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)
/* 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)
{
****************************************************************************/
void cmd_reg_query_key(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
BOOL res1 = True;
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)
{
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
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,
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,
/* 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)
{
****************************************************************************/
void cmd_reg_create_val(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
BOOL res3 = True;
BOOL res4 = True;
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)
{
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
}
/* 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)
{
****************************************************************************/
void cmd_reg_delete_val(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
BOOL res3 = True;
BOOL res4 = True;
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)
{
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
}
/* 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)
{
****************************************************************************/
void cmd_reg_delete_key(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
BOOL res3 = True;
BOOL res4 = True;
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)
{
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
}
/* 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)
{
****************************************************************************/
void cmd_reg_create_key(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
BOOL res3 = True;
BOOL res4 = True;
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)
{
return;
}
- if (argc < 3)
+ if (argc > 2)
{
fstrcpy(key_class, argv[2]);
}
/* 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
}
/* 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)
{
****************************************************************************/
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;
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)
{
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
}
/* 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;
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;
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);
/* 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)
{
****************************************************************************/
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;
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)
{
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
}
/* 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;
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;
/* 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)
{
****************************************************************************/
void cmd_reg_shutdown(struct client_info *info, int argc, char *argv[])
{
- uint16 fnum;
BOOL res = True;
fstring msg;
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++;
}
}
- /* 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)
{