summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/byteorder.h12
-rw-r--r--source3/include/proto.h11
-rw-r--r--source3/include/rpc_secdes.h5
-rw-r--r--source3/rpc_client/cli_reg.c4
-rw-r--r--source3/rpc_parse/parse_prs.c57
-rw-r--r--source3/rpc_parse/parse_reg.c16
-rw-r--r--source3/rpc_parse/parse_sec.c72
-rw-r--r--source3/rpcclient/cmd_reg.c11
-rw-r--r--source3/rpcclient/display.c2
9 files changed, 129 insertions, 61 deletions
diff --git a/source3/include/byteorder.h b/source3/include/byteorder.h
index 3371fd24cb..2a615e9dde 100644
--- a/source3/include/byteorder.h
+++ b/source3/include/byteorder.h
@@ -205,7 +205,7 @@ it also defines lots of intermediate macros, just ignore those :-)
#define DBG_RW_PCVAL(charmode,string,depth,base,read,inbuf,outbuf,len) \
RW_PCVAL(read,inbuf,outbuf,len) \
DEBUG(5,("%s%04x %s: ", \
- tab_depth(depth), PTR_DIFF(inbuf,base),string)); \
+ tab_depth(depth), base,string)); \
if (charmode) print_asc(5, (unsigned char*)(outbuf), (len)); else \
{ int idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%02x ", (outbuf)[idx])); } } \
DEBUG(5,("\n"));
@@ -213,7 +213,7 @@ it also defines lots of intermediate macros, just ignore those :-)
#define DBG_RW_PSVAL(charmode,string,depth,base,read,inbuf,outbuf,len) \
RW_PSVAL(read,inbuf,outbuf,len) \
DEBUG(5,("%s%04x %s: ", \
- tab_depth(depth), PTR_DIFF(inbuf,base),string)); \
+ tab_depth(depth), base,string)); \
if (charmode) print_asc(5, (unsigned char*)(outbuf), 2*(len)); else \
{ int idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%04x ", (outbuf)[idx])); } } \
DEBUG(5,("\n"));
@@ -221,7 +221,7 @@ it also defines lots of intermediate macros, just ignore those :-)
#define DBG_RW_PIVAL(charmode,string,depth,base,read,inbuf,outbuf,len) \
RW_PIVAL(read,inbuf,outbuf,len) \
DEBUG(5,("%s%04x %s: ", \
- tab_depth(depth), PTR_DIFF(inbuf,base),string)); \
+ tab_depth(depth), base,string)); \
if (charmode) print_asc(5, (unsigned char*)(outbuf), 4*(len)); else \
{ int idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%08x ", (outbuf)[idx])); } } \
DEBUG(5,("\n"));
@@ -229,15 +229,15 @@ it also defines lots of intermediate macros, just ignore those :-)
#define DBG_RW_CVAL(string,depth,base,read,inbuf,outbuf) \
RW_CVAL(read,inbuf,outbuf,0) \
DEBUG(5,("%s%04x %s: %02x\n", \
- tab_depth(depth), PTR_DIFF(inbuf,base), string, outbuf));
+ tab_depth(depth), base, string, outbuf));
#define DBG_RW_SVAL(string,depth,base,read,inbuf,outbuf) \
RW_SVAL(read,inbuf,outbuf,0) \
DEBUG(5,("%s%04x %s: %04x\n", \
- tab_depth(depth), PTR_DIFF(inbuf,base), string, outbuf));
+ tab_depth(depth), base, string, outbuf));
#define DBG_RW_IVAL(string,depth,base,read,inbuf,outbuf) \
RW_IVAL(read,inbuf,outbuf,0) \
DEBUG(5,("%s%04x %s: %08x\n", \
- tab_depth(depth), PTR_DIFF(inbuf,base), string, outbuf));
+ tab_depth(depth), base, string, outbuf));
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 7eb4f4e49d..1ed983d1a0 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1610,9 +1610,12 @@ BOOL prs_unistr2(BOOL charmode, char *name, prs_struct *ps, int depth, UNISTR2 *
BOOL prs_unistr3(BOOL charmode, char *name, UNISTR3 *str, prs_struct *ps, int depth);
BOOL prs_unistr(char *name, prs_struct *ps, int depth, UNISTR *str);
BOOL prs_string(char *name, prs_struct *ps, int depth, char *str, uint16 len, uint16 max_buf_size);
-BOOL prs_uint16_pre(char *name, prs_struct *ps, int depth, uint16 *data16, uint32 *off_ptr);
-BOOL prs_uint16_post(char *name, prs_struct *ps, int depth,
+BOOL prs_uint16_pre(char *name, prs_struct *ps, int depth, uint16 *data16, uint32 *offset);
+BOOL prs_uint16_post(char *name, prs_struct *ps, int depth, uint16 *data16,
uint32 ptr_uint16, uint32 start_offset);
+BOOL prs_uint32_pre(char *name, prs_struct *ps, int depth, uint32 *data32, uint32 *offset);
+BOOL prs_uint32_post(char *name, prs_struct *ps, int depth, uint32 *data32,
+ uint32 ptr_uint32, uint32 start_offset);
/*The following definitions come from rpc_parse/parse_reg.c */
@@ -1653,9 +1656,6 @@ void reg_io_r_close(char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int depth);
void make_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_i, POLICY_HND *pol,
uint32 buf_len, SEC_DESC_BUF *sec_buf);
void reg_io_q_get_key_sec(char *desc, REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, int depth);
-void make_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol,
- uint32 buf_len, uint8 *buf,
- uint32 status);
void reg_io_r_get_key_sec(char *desc, REG_R_GET_KEY_SEC *r_q, prs_struct *ps, int depth);
void make_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char *product_type,
time_t unix_time, uint8 major, uint8 minor);
@@ -1924,7 +1924,6 @@ void sec_io_info(char *desc, SEC_INFO *t, prs_struct *ps, int depth);
void sec_io_ace(char *desc, SEC_ACE *t, prs_struct *ps, int depth);
void sec_io_acl(char *desc, SEC_ACL *t, prs_struct *ps, int depth);
void sec_io_desc(char *desc, SEC_DESC *t, prs_struct *ps, int depth);
-void make_sec_desc_buf(SEC_DESC_BUF *buf, int len, uint32 buf_ptr);
void sec_io_desc_buf(char *desc, SEC_DESC_BUF *sec, prs_struct *ps, int depth);
/*The following definitions come from rpc_parse/parse_srv.c */
diff --git a/source3/include/rpc_secdes.h b/source3/include/rpc_secdes.h
index 587b31e3dc..1b438d3dfe 100644
--- a/source3/include/rpc_secdes.h
+++ b/source3/include/rpc_secdes.h
@@ -73,8 +73,7 @@ typedef struct security_acl_info
/* SEC_DESC */
typedef struct security_descriptor_info
{
- uint16 unknown_1; /* 0x0001 */
- uint16 unknown_2; /* 0x8004 */
+ uint32 unknown_1; /* 0x8004 0001 */
uint32 off_owner_sid; /* offset to owner sid */
uint32 off_pnt_sid ; /* offset to parent? sid */
@@ -94,7 +93,7 @@ typedef struct sec_desc_buf_info
uint32 undoc;
uint32 len;
- SEC_DESC sec;
+ SEC_DESC *sec;
} SEC_DESC_BUF;
diff --git a/source3/rpc_client/cli_reg.c b/source3/rpc_client/cli_reg.c
index 27c1c8e760..69982a8d44 100644
--- a/source3/rpc_client/cli_reg.c
+++ b/source3/rpc_client/cli_reg.c
@@ -471,6 +471,10 @@ BOOL do_reg_get_key_sec(struct cli_state *cli, POLICY_HND *hnd,
ZERO_STRUCT(r_o);
r_o.data = sec_buf;
+ if (*sec_buf_size != 0)
+ {
+ sec_buf->sec = (SEC_DESC*)malloc(*sec_buf_size);
+ }
reg_io_r_get_key_sec("", &r_o, &rbuf, 0);
p = rbuf.offset != 0;
diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c
index 873a689792..cc068778ac 100644
--- a/source3/rpc_parse/parse_prs.c
+++ b/source3/rpc_parse/parse_prs.c
@@ -303,14 +303,18 @@ BOOL prs_string(char *name, prs_struct *ps, int depth, char *str, uint16 len, ui
prs_uint16 wrapper. call this and it sets up a pointer to where the
uint16 should be stored, or gets the size if reading
********************************************************************/
-BOOL prs_uint16_pre(char *name, prs_struct *ps, int depth, uint16 *data16, uint32 *off_ptr)
+BOOL prs_uint16_pre(char *name, prs_struct *ps, int depth, uint16 *data16, uint32 *offset)
{
- (*off_ptr) = ps->offset;
+ (*offset) = ps->io;
if (ps->io)
{
/* reading. */
return prs_uint16(name, ps, depth, data16);
}
+ else
+ {
+ ps->offset += sizeof(uint16);
+ }
return True;
}
@@ -318,7 +322,7 @@ BOOL prs_uint16_pre(char *name, prs_struct *ps, int depth, uint16 *data16, uint3
prs_uint16 wrapper. call this and it retrospectively stores the size.
does nothing on reading, as that is already handled by ...._pre()
********************************************************************/
-BOOL prs_uint16_post(char *name, prs_struct *ps, int depth,
+BOOL prs_uint16_post(char *name, prs_struct *ps, int depth, uint16 *data16,
uint32 ptr_uint16, uint32 start_offset)
{
if (!ps->io)
@@ -331,6 +335,53 @@ BOOL prs_uint16_post(char *name, prs_struct *ps, int depth,
prs_uint16(name, ps, depth, &data_size);
ps->offset = old_offset;
}
+ else
+ {
+ ps->offset = start_offset + (*data16);
+ }
+ return True;
+}
+
+/*******************************************************************
+ prs_uint32 wrapper. call this and it sets up a pointer to where the
+ uint32 should be stored, or gets the size if reading
+ ********************************************************************/
+BOOL prs_uint32_pre(char *name, prs_struct *ps, int depth, uint32 *data32, uint32 *offset)
+{
+ (*offset) = ps->io;
+ if (ps->io)
+ {
+ /* reading. */
+ return prs_uint32(name, ps, depth, data32);
+ }
+ else
+ {
+ ps->offset += sizeof(uint32);
+ }
+ return True;
+}
+
+/*******************************************************************
+ prs_uint32 wrapper. call this and it retrospectively stores the size.
+ does nothing on reading, as that is already handled by ...._pre()
+ ********************************************************************/
+BOOL prs_uint32_post(char *name, prs_struct *ps, int depth, uint32 *data32,
+ uint32 ptr_uint32, uint32 start_offset)
+{
+ if (!ps->io)
+ {
+ /* storing: go back and do a retrospective job. i hate this */
+ uint32 data_size = ps->offset - start_offset;
+ uint32 old_offset = ps->offset;
+
+ ps->offset = ptr_uint32;
+ prs_uint32(name, ps, depth, &data_size);
+ ps->offset = old_offset;
+ }
+ else
+ {
+ ps->offset = start_offset + (*data32);
+ }
return True;
}
diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c
index fa63717e5b..b650847b80 100644
--- a/source3/rpc_parse/parse_reg.c
+++ b/source3/rpc_parse/parse_reg.c
@@ -553,11 +553,17 @@ void make_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_i, POLICY_HND *pol,
q_i->unknown = 0x7;
- q_i->ptr = 1;
+ q_i->ptr = sec_buf != NULL ? 1 : 0;
q_i->data = sec_buf;
- make_buf_hdr(&(q_i->hdr_sec), buf_len, 0);
- make_sec_desc_buf(q_i->data, buf_len, 0);
+ if (sec_buf != NULL)
+ {
+ make_buf_hdr(&(q_i->hdr_sec), buf_len, 0);
+ q_i->data->max_len = buf_len;
+ q_i->data->undoc = 0;
+ q_i->data->len = 0;
+ q_i->data->sec = NULL;
+ }
}
/*******************************************************************
@@ -586,10 +592,11 @@ void reg_io_q_get_key_sec(char *desc, REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, i
}
}
+#if 0
/*******************************************************************
makes a structure.
********************************************************************/
-void make_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol,
+ void make_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol,
uint32 buf_len, uint8 *buf,
uint32 status)
{
@@ -601,6 +608,7 @@ void make_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol,
r_i->status = status; /* 0x0000 0000 or 0x0000 007a */
}
+#endif
/*******************************************************************
reads or writes a structure.
diff --git a/source3/rpc_parse/parse_sec.c b/source3/rpc_parse/parse_sec.c
index bedf042b7f..af5da93bfb 100644
--- a/source3/rpc_parse/parse_sec.c
+++ b/source3/rpc_parse/parse_sec.c
@@ -66,11 +66,7 @@ void sec_io_ace(char *desc, SEC_ACE *t, prs_struct *ps, int depth)
prs_align(ps);
smb_io_dom_sid("sid ", &t->sid , ps, depth);
- prs_uint16_post("ace_size ", ps, depth, offset_ace_size, old_offset);
- if (ps->io)
- {
- ps->offset = old_offset + t->ace_size;
- }
+ prs_uint16_post("ace_size ", ps, depth, &t->ace_size, offset_ace_size, old_offset);
}
/*******************************************************************
@@ -105,11 +101,7 @@ void sec_io_acl(char *desc, SEC_ACL *t, prs_struct *ps, int depth)
prs_align(ps);
- prs_uint16_post("acl_size ", ps, depth, offset_acl_size, old_offset);
- if (ps->io)
- {
- ps->offset = old_offset + t->acl_size;
- }
+ prs_uint16_post("acl_size ", ps, depth, &t->acl_size, offset_acl_size, old_offset);
}
@@ -118,6 +110,12 @@ reads or writes a structure.
********************************************************************/
void sec_io_desc(char *desc, SEC_DESC *t, prs_struct *ps, int depth)
{
+ uint32 off_owner_sid;
+ uint32 off_pnt_sid ;
+ uint32 off_unknown ;
+ uint32 off_acl ;
+ uint32 old_offset;
+
if (t == NULL) return;
prs_debug(ps, depth, desc, "sec_io_desc");
@@ -125,39 +123,39 @@ void sec_io_desc(char *desc, SEC_DESC *t, prs_struct *ps, int depth)
prs_align(ps);
- prs_uint16("unknown_1", ps, depth, &(t->unknown_1));
- prs_uint16("unknown_2", ps, depth, &(t->unknown_2));
+ /* start of security descriptor stored for back-calc offset purposes */
+ old_offset = ps->offset;
+
+ prs_uint32("unknown_1", ps, depth, &(t->unknown_1));
- prs_uint32("off_owner_sid", ps, depth, &(t->off_owner_sid));
- prs_uint32("off_pnt_sid ", ps, depth, &(t->off_pnt_sid ));
- prs_uint32("off_unknown ", ps, depth, &(t->off_unknown ));
- prs_uint32("off_acl ", ps, depth, &(t->off_acl ));
+ prs_uint32_pre("off_owner_sid", ps, depth, &(t->off_owner_sid), &off_owner_sid);
+ prs_uint32_pre("off_pnt_sid ", ps, depth, &(t->off_pnt_sid ), &off_pnt_sid );
+ prs_uint32_pre("off_unknown ", ps, depth, &(t->off_unknown ), &off_unknown );
+ prs_uint32_pre("off_acl ", ps, depth, &(t->off_acl ), &off_acl );
+ prs_uint32_post("off_acl ", ps, depth, &(t->off_acl ), off_acl , old_offset);
sec_io_acl ("acl" , &t->acl , ps, depth);
+ prs_align(ps);
+
+ prs_uint32_post("off_unknown ", ps, depth, &(t->off_unknown ), off_unknown , ps->offset);
+
+ prs_uint32_post("off_owner_sid", ps, depth, &(t->off_owner_sid), off_owner_sid, old_offset);
smb_io_dom_sid("owner_sid ", &t->owner_sid , ps, depth);
prs_align(ps);
+
+ prs_uint32_post("off_pnt_sid ", ps, depth, &(t->off_pnt_sid ), off_pnt_sid , old_offset);
smb_io_dom_sid("parent_sid", &t->parent_sid, ps, depth);
prs_align(ps);
}
/*******************************************************************
-creates a SEC_DESC_BUF structure.
-********************************************************************/
-void make_sec_desc_buf(SEC_DESC_BUF *buf, int len, uint32 buf_ptr)
-{
- ZERO_STRUCTP(buf);
-
- /* max buffer size (allocated size) */
- buf->max_len = len;
- buf->undoc = 0;
- buf->len = buf_ptr != 0 ? len : 0;
-}
-
-/*******************************************************************
reads or writes a SEC_DESC_BUF structure.
********************************************************************/
void sec_io_desc_buf(char *desc, SEC_DESC_BUF *sec, prs_struct *ps, int depth)
{
+ uint32 off_len;
+ uint32 old_offset;
+
if (sec == NULL) return;
prs_debug(ps, depth, desc, "sec_io_desc_buf");
@@ -165,12 +163,18 @@ void sec_io_desc_buf(char *desc, SEC_DESC_BUF *sec, prs_struct *ps, int depth)
prs_align(ps);
- prs_uint32("max_len", ps, depth, &(sec->max_len));
- prs_uint32("undoc ", ps, depth, &(sec->undoc ));
- prs_uint32("len ", ps, depth, &(sec->len ));
+ prs_uint32 ("max_len", ps, depth, &(sec->max_len));
+ prs_uint32 ("undoc ", ps, depth, &(sec->undoc ));
+ prs_uint32_pre("len ", ps, depth, &(sec->len ), &off_len);
+
+ old_offset = ps->offset;
- if (sec->len != 0)
+ /* reading, length is non-zero; writing, descriptor is non-NULL */
+ if ((sec->len != 0 || (!ps->io)) && sec->sec != NULL)
{
- sec_io_desc("sec ", &sec->sec, ps, depth);
+ sec_io_desc("sec ", sec->sec, ps, depth);
}
+
+ prs_uint32_post("len ", ps, depth, &(sec->len ), off_len , old_offset);
}
+
diff --git a/source3/rpcclient/cmd_reg.c b/source3/rpcclient/cmd_reg.c
index 4d49d19b3b..fd5fc71828 100644
--- a/source3/rpcclient/cmd_reg.c
+++ b/source3/rpcclient/cmd_reg.c
@@ -766,17 +766,20 @@ void cmd_reg_get_key_sec(struct client_info *info)
/* query key sec info. first call sets sec_buf_size. */
sec_buf_size = 0;
+ sec_buf.sec = NULL;
+
res4 = res3 ? do_reg_get_key_sec(smb_cli, &key_pol,
&sec_buf_size, &sec_buf) : False;
res4 = res4 ? do_reg_get_key_sec(smb_cli, &key_pol,
&sec_buf_size, &sec_buf) : False;
- if (res4 && sec_buf.len > 0)
+ if (res4 && sec_buf.len > 0 && sec_buf.sec != NULL)
{
- display_sec_desc(out_hnd, ACTION_HEADER , &sec_buf.sec);
- display_sec_desc(out_hnd, ACTION_ENUMERATE, &sec_buf.sec);
- display_sec_desc(out_hnd, ACTION_FOOTER , &sec_buf.sec);
+ display_sec_desc(out_hnd, ACTION_HEADER , sec_buf.sec);
+ display_sec_desc(out_hnd, ACTION_ENUMERATE, sec_buf.sec);
+ display_sec_desc(out_hnd, ACTION_FOOTER , sec_buf.sec);
+ free(sec_buf.sec);
}
/* close the key handle */
diff --git a/source3/rpcclient/display.c b/source3/rpcclient/display.c
index c55358bc9c..c35f8db9af 100644
--- a/source3/rpcclient/display.c
+++ b/source3/rpcclient/display.c
@@ -1175,7 +1175,7 @@ void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *sec)
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "\tSecurity Descriptor\tunk 1,2: %x %x\n", sec->unknown_1, sec->unknown_2);
+ fprintf(out_hnd, "\tSecurity Descriptor\tunk 1: %x\n", sec->unknown_1);
fprintf(out_hnd, "\t-------------------\n");
break;