removed 2 unnecessary args from make_uni_hdr.
[ira/wip.git] / source / rpc_parse / parse_lsa.c
index cb88e715362b34c218c21667dcba43ca3f3e8cbe..628b6ebe4f06d16847eb85e2d58ccc75a88436c1 100644 (file)
@@ -35,7 +35,7 @@ void make_lsa_trans_name(LSA_TRANS_NAME *trn, UNISTR2 *uni_name,
        int len_name = strlen(name);
 
        trn->sid_name_use = sid_name_use;
-       make_uni_hdr(&(trn->hdr_name), len_name, len_name, 1);
+       make_uni_hdr(&(trn->hdr_name), len_name);
        make_unistr2(uni_name, name, len_name);
        trn->domain_idx = idx;
 }
@@ -71,7 +71,6 @@ static void lsa_io_dom_r_ref(char *desc,  DOM_R_REF *r_r, prs_struct *ps, int de
 
        prs_align(ps);
        
-       prs_uint32("undoc_buffer  ", ps, depth, &(r_r->undoc_buffer  )); /* undocumented buffer pointer. */
        prs_uint32("num_ref_doms_1", ps, depth, &(r_r->num_ref_doms_1)); /* num referenced domains? */
        prs_uint32("ptr_ref_dom   ", ps, depth, &(r_r->ptr_ref_dom   )); /* undocumented buffer pointer. */
        prs_uint32("max_entries   ", ps, depth, &(r_r->max_entries   )); /* 32 - max number of entries */
@@ -380,6 +379,169 @@ void lsa_io_q_query(char *desc,  LSA_Q_QUERY_INFO *q_q, prs_struct *ps, int dept
        prs_uint16("info_class", ps, depth, &(q_q->info_class));
 }
 
+/*******************************************************************
+makes an LSA_Q_OPEN_SECRET structure.
+********************************************************************/
+void make_q_open_secret(LSA_Q_OPEN_SECRET *q_o, POLICY_HND *pol_hnd,
+                       char *secret_name, uint32 desired_access)
+{
+       int len = strlen(secret_name);
+
+       if (q_o == NULL) return;
+
+       DEBUG(5,("make_q_open_secret"));
+
+       memcpy(&(q_o->pol), pol_hnd, sizeof(q_o->pol));
+
+       make_uni_hdr(&(q_o->hdr_secret), len);
+       make_unistr2(&(q_o->uni_secret), secret_name, len);
+
+       q_o->des_access = desired_access;
+}
+
+/*******************************************************************
+reads or writes an LSA_Q_OPEN_SECRET structure.
+********************************************************************/
+void lsa_io_q_open_secret(char *desc, LSA_Q_OPEN_SECRET *q_o, prs_struct *ps, int depth)
+{
+       if (q_o == NULL) return;
+
+       prs_debug(ps, depth, desc, "lsa_io_q_open_secret");
+       depth++;
+
+       smb_io_pol_hnd("", &(q_o->pol), ps, depth);
+
+       prs_align(ps);
+       smb_io_unihdr ("", &(q_o->hdr_secret), ps, depth);
+       smb_io_unistr2("", &(q_o->uni_secret), 1, ps, depth);
+
+       prs_align(ps);
+       prs_uint32("des_access", ps, depth, &(q_o->des_access));
+}
+
+/*******************************************************************
+reads or writes an LSA_R_OPEN_SECRET structure.
+********************************************************************/
+void lsa_io_r_open_secret(char *desc, LSA_R_OPEN_SECRET *r_o, prs_struct *ps, int depth)
+{
+       if (r_o == NULL) return;
+
+       prs_debug(ps, depth, desc, "lsa_io_r_open_secret");
+       depth++;
+
+       smb_io_pol_hnd("", &(r_o->pol), ps, depth);
+
+       prs_uint32("status", ps, depth, &(r_o->status));
+}
+
+/*******************************************************************
+reads or writes an LSA_SECRET_VALUE structure.
+********************************************************************/
+void lsa_io_secret_value(char *desc, LSA_SECRET_VALUE *value, prs_struct *ps, int depth)
+{
+       if (value == NULL) return;
+
+       prs_debug(ps, depth, desc, "lsa_io_secret_value");
+       depth++;
+
+       prs_align(ps);
+       prs_uint32("ptr_secret", ps, depth, &(value->ptr_secret));
+
+       if (value->ptr_secret != 0)
+       {
+               smb_io_strhdr2("hdr_secret", &(value->hdr_secret), ps, depth);
+               smb_io_string2("secret"    , &(value->enc_secret),
+                              value->hdr_secret.buffer, ps, depth);
+       }
+}
+
+/*******************************************************************
+reads or writes an LSA_SECRET_INFO structure.
+********************************************************************/
+void lsa_io_secret_info(char *desc, LSA_SECRET_INFO *info, prs_struct *ps, int depth)
+{
+       if (info == NULL) return;
+
+       prs_debug(ps, depth, desc, "lsa_io_secret_info");
+       depth++;
+
+       prs_align(ps);
+       prs_uint32("ptr_value ", ps, depth, &(info->ptr_value ));
+
+       if (info->ptr_value != 0)
+       {
+               lsa_io_secret_value("", &(info->value), ps, depth);
+       }
+
+       prs_align(ps);
+       prs_uint32("ptr_update", ps, depth, &(info->ptr_update));
+
+       if (info->ptr_update != 0)
+       {
+               ps->align = 8;
+               prs_align(ps);
+               ps->align = 4;
+
+               smb_io_time("last_update", &(info->last_update), ps, depth);
+       }
+}
+
+/*******************************************************************
+makes an LSA_Q_QUERY_SECRET structure.
+********************************************************************/
+void make_q_query_secret(LSA_Q_QUERY_SECRET *q_q, POLICY_HND *pol)
+{
+       if (q_q == NULL) return;
+
+       DEBUG(5,("make_q_query_secret"));
+
+       memcpy(&(q_q->pol), pol, sizeof(q_q->pol));
+
+       /* Want secret */
+       q_q->info.ptr_value = 1;
+       q_q->info.value.ptr_secret = 0;
+
+       /* Want last change time */
+       q_q->info.ptr_update = 1;
+
+       /* Don't care about old info */
+       q_q->oldinfo.ptr_value = 0;
+       q_q->oldinfo.ptr_update = 0;
+}
+
+/*******************************************************************
+reads or writes an LSA_Q_QUERY_SECRET structure.
+********************************************************************/
+void lsa_io_q_query_secret(char *desc, LSA_Q_QUERY_SECRET *q_q, prs_struct *ps, int depth)
+{
+       if (q_q == NULL) return;
+
+       prs_debug(ps, depth, desc, "lsa_io_q_query_secret");
+       depth++;
+
+       smb_io_pol_hnd("", &(q_q->pol), ps, depth);
+
+       lsa_io_secret_info("", &(q_q->info   ), ps, depth);
+       lsa_io_secret_info("", &(q_q->oldinfo), ps, depth);
+}
+
+/*******************************************************************
+reads or writes an LSA_Q_QUERY_SECRET structure.
+********************************************************************/
+void lsa_io_r_query_secret(char *desc, LSA_R_QUERY_SECRET *r_q, prs_struct *ps, int depth)
+{
+       if (r_q == NULL) return;
+
+       prs_debug(ps, depth, desc, "lsa_io_r_query_secret");
+       depth++;
+
+       lsa_io_secret_info("", &(r_q->info   ), ps, depth);
+       lsa_io_secret_info("", &(r_q->oldinfo), ps, depth);
+
+       prs_align(ps);
+       prs_uint32("status", ps, depth, &(r_q->status));
+}
+
 /*******************************************************************
 reads or writes an LSA_Q_ENUM_TRUST_DOM structure.
 ********************************************************************/
@@ -418,7 +580,7 @@ void make_r_enum_trust_dom(LSA_R_ENUM_TRUST_DOM *r_e,
                r_e->ptr_enum_domains = 1;
                r_e->num_domains2 = 1;
 
-               make_uni_hdr2(&(r_e->hdr_domain_name ), len_domain_name, len_domain_name, 4);
+               make_uni_hdr2(&(r_e->hdr_domain_name ), len_domain_name);
                make_unistr2 (&(r_e->uni_domain_name ), domain_name, len_domain_name);
                make_dom_sid2(&(r_e->other_domain_sid), domain_sid);
        }
@@ -690,7 +852,7 @@ void make_q_lookup_names(LSA_Q_LOOKUP_NAMES *q_l, POLICY_HND *hnd,
        {
                const char* name = names[i];
                int len = strlen(name);
-               make_uni_hdr(&q_l->hdr_name[i], len, len, len != 0);
+               make_uni_hdr(&q_l->hdr_name[i], len);
                make_unistr2(&q_l->uni_name[i], name, len);
        }
 
@@ -752,15 +914,29 @@ void lsa_io_r_lookup_names(char *desc,  LSA_R_LOOKUP_NAMES *r_r, prs_struct *ps,
 
        prs_align(ps);
        
-       lsa_io_dom_r_ref("", r_r->dom_ref, ps, depth); /* domain reference info */
+       prs_uint32("ptr_dom_ref", ps, depth, &(r_r->ptr_dom_ref));
+       if (r_r->ptr_dom_ref != 0)
+       {
+               lsa_io_dom_r_ref("", r_r->dom_ref, ps, depth);
+       }
 
-       prs_uint32("num_entries ", ps, depth, &(r_r->num_entries));
-       prs_uint32("undoc_buffer", ps, depth, &(r_r->undoc_buffer));
-       prs_uint32("num_entries2", ps, depth, &(r_r->num_entries2));
+       prs_uint32("num_entries", ps, depth, &(r_r->num_entries));
+       prs_uint32("ptr_entries", ps, depth, &(r_r->ptr_entries));
 
-       for (i = 0; i < r_r->num_entries2; i++)
+       if (r_r->ptr_entries != 0)
        {
-               smb_io_dom_rid2("", &(r_r->dom_rid[i]), ps, depth); /* domain RIDs being looked up */
+               prs_uint32("num_entries2", ps, depth, &(r_r->num_entries2));
+
+               if (r_r->num_entries2 != r_r->num_entries)
+               {
+                       /* RPC fault */
+                       return;
+               }
+
+               for (i = 0; i < r_r->num_entries2; i++)
+               {
+                       smb_io_dom_rid2("", &(r_r->dom_rid[i]), ps, depth); /* domain RIDs being looked up */
+               }
        }
 
        prs_uint32("mapped_count", ps, depth, &(r_r->mapped_count));