summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h6
-rw-r--r--source3/include/rpc_reg.h21
-rw-r--r--source3/rpc_client/cli_reg.c54
-rw-r--r--source3/rpc_parse/parse_reg.c51
-rw-r--r--source3/rpcclient/cmd_reg.c65
-rw-r--r--source3/rpcclient/rpcclient.c1
6 files changed, 198 insertions, 0 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 5a17ec2181..97c5156cc9 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1311,6 +1311,7 @@ BOOL do_reg_query_info(struct cli_state *cli, POLICY_HND *hnd,
char *type, uint32 *unk_0, uint32 *unk_1);
BOOL do_reg_get_key_sec(struct cli_state *cli, POLICY_HND *hnd,
uint32 *sec_buf_size, SEC_DESC_BUF *sec_buf);
+BOOL do_reg_delete_key(struct cli_state *cli, POLICY_HND *hnd, char *key_name);
BOOL do_reg_create_key(struct cli_state *cli, POLICY_HND *hnd,
char *key_name, char *key_class,
SEC_INFO *sam_access,
@@ -1620,6 +1621,10 @@ void make_reg_q_create_key(REG_Q_CREATE_KEY *q_c, POLICY_HND *hnd,
SEC_INFO *sam_access);
void reg_io_q_create_key(char *desc, REG_Q_CREATE_KEY *r_q, prs_struct *ps, int depth);
void reg_io_r_create_key(char *desc, REG_R_CREATE_KEY *r_r, prs_struct *ps, int depth);
+void make_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd,
+ char *name);
+void reg_io_q_delete_key(char *desc, REG_Q_DELETE_KEY *r_q, prs_struct *ps, int depth);
+void reg_io_r_delete_key(char *desc, REG_R_DELETE_KEY *r_r, prs_struct *ps, int depth);
void make_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd,
uint32 max_class_len);
void reg_io_q_query_key(char *desc, REG_Q_QUERY_KEY *r_q, prs_struct *ps, int depth);
@@ -2084,6 +2089,7 @@ void cmd_reg_enum(struct client_info *info);
void cmd_reg_query_key(struct client_info *info);
void cmd_reg_test2(struct client_info *info);
void cmd_reg_create_val(struct client_info *info);
+void cmd_reg_delete_key(struct client_info *info);
void cmd_reg_create_key(struct client_info *info);
void cmd_reg_get_key_sec(struct client_info *info);
diff --git a/source3/include/rpc_reg.h b/source3/include/rpc_reg.h
index 475661e833..33b7b72a25 100644
--- a/source3/include/rpc_reg.h
+++ b/source3/include/rpc_reg.h
@@ -33,6 +33,7 @@
#define REG_QUERY_KEY 0x10
#define REG_ENUM_KEY 0x09
#define REG_CREATE_KEY 0x06
+#define REG_DELETE_KEY 0x07
#define REG_CREATE_VALUE 0x16
#define REG_GET_KEY_SEC 0x0c
#define REG_ENUM_VALUE 0x0a
@@ -211,6 +212,7 @@ typedef struct q_reg_create_key_info
BUFFER2 buf_unk; /* 01 00 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
uint32 unknown_2; /* 0x0000 0000 */
+
} REG_Q_CREATE_KEY;
/* REG_R_CREATE_KEY */
@@ -223,6 +225,25 @@ typedef struct r_reg_create_key_info
} REG_R_CREATE_KEY;
+/* REG_Q_DELETE_KEY */
+typedef struct q_reg_delete_key_info
+{
+ POLICY_HND pnt_pol; /* parent key policy handle */
+
+ UNIHDR hdr_name;
+ UNISTR2 uni_name;
+} REG_Q_DELETE_KEY;
+
+/* REG_R_DELETE_KEY */
+typedef struct r_reg_delete_key_info
+{
+ POLICY_HND key_pol; /* policy handle */
+ uint32 unknown; /* 0x0000 0000 */
+
+ uint32 status; /* return status */
+
+} REG_R_DELETE_KEY;
+
/* REG_Q_QUERY_KEY */
typedef struct q_reg_query_info
{
diff --git a/source3/rpc_client/cli_reg.c b/source3/rpc_client/cli_reg.c
index 459a865fc0..3acd8281de 100644
--- a/source3/rpc_client/cli_reg.c
+++ b/source3/rpc_client/cli_reg.c
@@ -451,6 +451,60 @@ BOOL do_reg_get_key_sec(struct cli_state *cli, POLICY_HND *hnd,
}
/****************************************************************************
+do a REG Delete Key
+****************************************************************************/
+BOOL do_reg_delete_key(struct cli_state *cli, POLICY_HND *hnd, char *key_name)
+{
+ prs_struct rbuf;
+ prs_struct buf;
+ REG_Q_DELETE_KEY q_o;
+ BOOL valid_delete = False;
+
+ if (hnd == NULL) return False;
+
+ prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
+ prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
+
+ /* create and send a MSRPC command with api REG_DELETE_KEY */
+
+ DEBUG(4,("REG Delete Key: %s\n", key_name));
+
+ make_reg_q_delete_key(&q_o, hnd, key_name);
+
+ /* turn parameters into data stream */
+ reg_io_q_delete_key("", &q_o, &buf, 0);
+
+ /* send the data on \PIPE\ */
+ if (rpc_api_pipe_req(cli, REG_DELETE_KEY, &buf, &rbuf))
+ {
+ REG_R_DELETE_KEY r_o;
+ BOOL p;
+
+ ZERO_STRUCT(r_o);
+
+ reg_io_r_delete_key("", &r_o, &rbuf, 0);
+ p = rbuf.offset != 0;
+
+ if (p && r_o.status != 0)
+ {
+ /* report error code */
+ DEBUG(0,("REG_DELETE_KEY: %s\n", get_nt_error_msg(r_o.status)));
+ p = False;
+ }
+
+ if (p)
+ {
+ valid_delete = True;
+ }
+ }
+
+ prs_mem_free(&rbuf);
+ prs_mem_free(&buf );
+
+ return valid_delete;
+}
+
+/****************************************************************************
do a REG Create Key
****************************************************************************/
BOOL do_reg_create_key(struct cli_state *cli, POLICY_HND *hnd,
diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c
index d2f670188b..e329b7751d 100644
--- a/source3/rpc_parse/parse_reg.c
+++ b/source3/rpc_parse/parse_reg.c
@@ -234,6 +234,57 @@ void reg_io_r_create_key(char *desc, REG_R_CREATE_KEY *r_r, prs_struct *ps, int
/*******************************************************************
creates a structure.
********************************************************************/
+void make_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd,
+ char *name)
+{
+ int len_name = name != NULL ? strlen(name ) + 1: 0;
+ ZERO_STRUCTP(q_c);
+
+ memcpy(&(q_c->pnt_pol), hnd, sizeof(q_c->pnt_pol));
+
+ make_uni_hdr(&(q_c->hdr_name), len_name, len_name, 1);
+ make_unistr2(&(q_c->uni_name), name, len_name);
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void reg_io_q_delete_key(char *desc, REG_Q_DELETE_KEY *r_q, prs_struct *ps, int depth)
+{
+ if (r_q == NULL) return;
+
+ prs_debug(ps, depth, desc, "reg_io_q_delete_key");
+ depth++;
+
+ prs_align(ps);
+
+ smb_io_pol_hnd("", &(r_q->pnt_pol), ps, depth);
+
+ smb_io_unihdr ("", &(r_q->hdr_name), ps, depth);
+ smb_io_unistr2("", &(r_q->uni_name), r_q->hdr_name.buffer, ps, depth);
+ prs_align(ps);
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void reg_io_r_delete_key(char *desc, REG_R_DELETE_KEY *r_r, prs_struct *ps, int depth)
+{
+ if (r_r == NULL) return;
+
+ prs_debug(ps, depth, desc, "reg_io_r_delete_key");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("status", ps, depth, &(r_r->status));
+}
+
+
+/*******************************************************************
+creates a structure.
+********************************************************************/
void make_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd,
uint32 max_class_len)
{
diff --git a/source3/rpcclient/cmd_reg.c b/source3/rpcclient/cmd_reg.c
index 7c640a9a52..7dfc355569 100644
--- a/source3/rpcclient/cmd_reg.c
+++ b/source3/rpcclient/cmd_reg.c
@@ -513,6 +513,71 @@ void cmd_reg_create_val(struct client_info *info)
}
/****************************************************************************
+nt registry delete key
+****************************************************************************/
+void cmd_reg_delete_key(struct client_info *info)
+{
+ BOOL res = True;
+ BOOL res3 = True;
+ BOOL res4 = True;
+
+ POLICY_HND parent_pol;
+ fstring parent_name;
+ fstring key_name;
+
+ DEBUG(5, ("cmd_reg_delete_key: smb_cli->fd:%d\n", smb_cli->fd));
+
+ if (!next_token(NULL, parent_name, NULL, sizeof(parent_name)))
+ {
+ fprintf(out_hnd, "regcreate <parent key name> <key_name>\n");
+ return;
+ }
+
+ if (!next_token(NULL, key_name , NULL, sizeof(key_name )))
+ {
+ fprintf(out_hnd, "regcreate <parent key name> <key_name>\n");
+ return;
+ }
+
+ /* open WINREG session. */
+ res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG) : False;
+
+ /* open registry receive a policy handle */
+ res = res ? do_reg_open_policy(smb_cli,
+ 0x84E0, 0x02000000,
+ &info->dom.reg_pol_connect) : False;
+
+ /* open an entry */
+ res3 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect,
+ parent_name, 0x02000000, &parent_pol) : False;
+
+ /* create an entry */
+ res4 = res3 ? do_reg_delete_key(smb_cli, &parent_pol, key_name) : False;
+
+ /* some sort of "sync" or "refresh" on the parent key? */
+ res4 = res4 ? do_reg_unk_b(smb_cli, &parent_pol) : False;
+
+ /* close the key handle */
+ res3 = res3 ? do_reg_close(smb_cli, &parent_pol) : False;
+
+ /* close the registry handles */
+ res = res ? do_reg_close(smb_cli, &info->dom.reg_pol_connect) : False;
+
+ /* close the session */
+ cli_nt_session_close(smb_cli);
+
+ if (res && res3 && res4)
+ {
+ DEBUG(5,("cmd_reg_delete_key: query succeeded\n"));
+ fprintf(out_hnd,"OK\n");
+ }
+ else
+ {
+ DEBUG(5,("cmd_reg_delete_key: query failed\n"));
+ }
+}
+
+/****************************************************************************
nt registry create key
****************************************************************************/
void cmd_reg_create_key(struct client_info *info)
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 017183fa1d..234569acc1 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -106,6 +106,7 @@ struct
} commands[] =
{
{"regenum", cmd_reg_enum, "<keyname> Registry Enumeration (keys, values)"},
+ {"regdeletekey",cmd_reg_delete_key, "<parentname> <keyname> Registry Key Delete"},
{"regcreatekey",cmd_reg_create_key, "<parentname> <keyname> [keyclass] Registry Key Create"},
{"regquerykey",cmd_reg_query_key, "<keyname> Registry Key Query"},
{"regcreateval",cmd_reg_create_val, "<parentname> <valname> <valtype> <value> Registry Key Create"},