summaryrefslogtreecommitdiff
path: root/source3/rpc_server/srv_lsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_server/srv_lsa.c')
-rw-r--r--source3/rpc_server/srv_lsa.c507
1 files changed, 252 insertions, 255 deletions
diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c
index fbe83b02c8..7094d842b4 100644
--- a/source3/rpc_server/srv_lsa.c
+++ b/source3/rpc_server/srv_lsa.c
@@ -29,82 +29,87 @@
extern int DEBUGLEVEL;
extern DOM_SID global_sam_sid;
-extern fstring global_sam_name;
-extern DOM_SID global_member_sid;
extern fstring global_myworkgroup;
-extern DOM_SID global_sid_S_1_5_20;
+extern pstring global_myname;
/***************************************************************************
-lsa_reply_open_policy2
+ lsa_reply_open_policy2
***************************************************************************/
-static void lsa_reply_open_policy2(prs_struct *rdata)
+
+static BOOL lsa_reply_open_policy2(prs_struct *rdata)
{
+ int i;
LSA_R_OPEN_POL2 r_o;
ZERO_STRUCT(r_o);
/* set up the LSA QUERY INFO response */
+ for (i = 4; i < POL_HND_SIZE; i++)
+ r_o.pol.data[i] = i;
r_o.status = 0x0;
- /* get a (unique) handle. open a policy on it. */
- if (!open_policy_hnd(&r_o.pol))
- {
- r_o.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ /* store the response in the SMB stream */
+ if(!lsa_io_r_open_pol2("", &r_o, rdata, 0)) {
+ DEBUG(0,("lsa_reply_open_policy2: unable to marshall LSA_R_OPEN_POL2.\n"));
+ return False;
}
- /* store the response in the SMB stream */
- lsa_io_r_open_pol2("", &r_o, rdata, 0);
+ return True;
}
/***************************************************************************
lsa_reply_open_policy
***************************************************************************/
-static void lsa_reply_open_policy(prs_struct *rdata)
+
+static BOOL lsa_reply_open_policy(prs_struct *rdata)
{
+ int i;
LSA_R_OPEN_POL r_o;
ZERO_STRUCT(r_o);
/* set up the LSA QUERY INFO response */
+ for (i = 4; i < POL_HND_SIZE; i++)
+ r_o.pol.data[i] = i;
r_o.status = 0x0;
- /* get a (unique) handle. open a policy on it. */
- if (!open_policy_hnd(&r_o.pol))
- {
- r_o.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ /* store the response in the SMB stream */
+ if(!lsa_io_r_open_pol("", &r_o, rdata, 0)) {
+ DEBUG(0,("lsa_reply_open_policy: unable to marshall LSA_R_OPEN_POL.\n"));
+ return False;
}
- /* store the response in the SMB stream */
- lsa_io_r_open_pol("", &r_o, rdata, 0);
+ return True;
}
/***************************************************************************
-make_dom_query
+Init dom_query
***************************************************************************/
-static void make_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid)
+
+static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid)
{
fstring sid_str;
int domlen = strlen(dom_name);
- d_q->uni_dom_str_len = (domlen+1) * 2;
d_q->uni_dom_max_len = domlen * 2;
+ d_q->uni_dom_str_len = domlen * 2;
d_q->buffer_dom_name = domlen != 0 ? 1 : 0; /* domain buffer pointer */
d_q->buffer_dom_sid = dom_sid != NULL ? 1 : 0; /* domain sid pointer */
/* this string is supposed to be character short */
- make_unistr2(&(d_q->uni_domain_name), dom_name, domlen);
- d_q->uni_domain_name.uni_max_len++;
+ init_unistr2(&d_q->uni_domain_name, dom_name, domlen);
sid_to_string(sid_str, dom_sid);
- make_dom_sid2(&(d_q->dom_sid), dom_sid);
+ init_dom_sid2(&d_q->dom_sid, dom_sid);
}
/***************************************************************************
-lsa_reply_query_info
+ lsa_reply_enum_trust_dom
***************************************************************************/
+
static void lsa_reply_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM *q_e,
prs_struct *rdata,
uint32 enum_context, char *dom_name, DOM_SID *dom_sid)
@@ -114,7 +119,7 @@ static void lsa_reply_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM *q_e,
ZERO_STRUCT(r_e);
/* set up the LSA QUERY INFO response */
- make_r_enum_trust_dom(&r_e, enum_context, dom_name, dom_sid,
+ init_r_enum_trust_dom(&r_e, enum_context, dom_name, dom_sid,
dom_name != NULL ? 0x0 : 0x80000000 | NT_STATUS_UNABLE_TO_FREE_VM);
/* store the response in the SMB stream */
@@ -124,63 +129,53 @@ static void lsa_reply_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM *q_e,
/***************************************************************************
lsa_reply_query_info
***************************************************************************/
-static void lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata,
+
+static BOOL lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata,
char *dom_name, DOM_SID *dom_sid)
{
LSA_R_QUERY_INFO r_q;
ZERO_STRUCT(r_q);
- /* get a (unique) handle. open a policy on it. */
- if (r_q.status == 0x0 && !open_policy_hnd(&q_q->pol))
- {
- r_q.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND;
- }
- else
- {
- /* set up the LSA QUERY INFO response */
+ /* set up the LSA QUERY INFO response */
- r_q.undoc_buffer = 0x1;
- r_q.info_class = q_q->info_class;
+ r_q.undoc_buffer = 0x22000000; /* bizarre */
+ r_q.info_class = q_q->info_class;
- make_dom_query(&r_q.dom.id5, dom_name, dom_sid);
+ init_dom_query(&r_q.dom.id5, dom_name, dom_sid);
+
+ r_q.status = 0x0;
- r_q.status = 0x0;
- }
/* store the response in the SMB stream */
- lsa_io_r_query("", &r_q, rdata, 0);
-}
+ if(!lsa_io_r_query("", &r_q, rdata, 0)) {
+ DEBUG(0,("lsa_reply_query_info: failed to marshall LSA_R_QUERY_INFO.\n"));
+ return False;
+ }
+ return True;
+}
/***************************************************************************
-make_dom_ref - adds a domain if it's not already in, returns the index
- ***************************************************************************/
-static int make_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid)
-
+ init_dom_ref - adds a domain if it's not already in, returns the index.
+***************************************************************************/
+
+static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid)
{
int num = 0;
int len;
- if (dom_name != NULL)
- {
- for (num = 0; num < ref->num_ref_doms_1; num++)
- {
+ if (dom_name != NULL) {
+ for (num = 0; num < ref->num_ref_doms_1; num++) {
fstring domname;
- unistr2_to_ascii(domname, &ref->ref_dom[num].uni_dom_name, sizeof(domname)-1);
+ fstrcpy(domname, dos_unistr2_to_str(&ref->ref_dom[num].uni_dom_name));
if (strequal(domname, dom_name))
- {
return num;
- }
}
-
- }
- else
- {
+ } else {
num = ref->num_ref_doms_1;
}
- if (num >= MAX_REF_DOMAINS)
- {
+ if (num >= MAX_REF_DOMAINS) {
/* index not found, already at maximum domain limit */
return -1;
}
@@ -190,95 +185,85 @@ static int make_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid)
ref->max_entries = MAX_REF_DOMAINS;
ref->num_ref_doms_2 = num+1;
- len = dom_name != NULL ? strlen(dom_name) : 0;
+ len = (dom_name != NULL) ? strlen(dom_name) : 0;
+ if(dom_name != NULL && len == 0)
+ len = 1;
- make_uni_hdr(&(ref->hdr_ref_dom[num].hdr_dom_name), len);
+ init_uni_hdr(&ref->hdr_ref_dom[num].hdr_dom_name, len);
ref->hdr_ref_dom[num].ptr_dom_sid = dom_sid != NULL ? 1 : 0;
- make_unistr2 (&(ref->ref_dom[num].uni_dom_name), dom_name, len);
- make_dom_sid2(&(ref->ref_dom[num].ref_dom ), dom_sid );
+ init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name, len);
+ init_dom_sid2(&ref->ref_dom[num].ref_dom, dom_sid );
return num;
}
/***************************************************************************
-make_lsa_rid2s
+ init_lsa_rid2s
***************************************************************************/
-static void make_lsa_rid2s(DOM_R_REF *ref,
- DOM_RID2 *rid2,
+
+static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2,
int num_entries, UNISTR2 name[MAX_LOOKUP_SIDS],
uint32 *mapped_count)
{
int i;
int total = 0;
- (*mapped_count) = 0;
+ *mapped_count = 0;
SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS);
- for (i = 0; i < num_entries; i++)
- {
- uint32 status = 0x0;
- DOM_SID find_sid;
+ for (i = 0; i < num_entries; i++) {
+ BOOL status = False;
+ DOM_SID dom_sid;
DOM_SID sid;
uint32 rid = 0xffffffff;
int dom_idx = -1;
- fstring find_name;
- char *dom_name = NULL;
+ pstring full_name;
+ fstring dom_name;
+ fstring user;
uint8 sid_name_use = SID_NAME_UNKNOWN;
- unistr2_to_ascii(find_name, &name[i], sizeof(find_name)-1);
- dom_name = strdup(find_name);
+ pstrcpy(full_name, dos_unistr2_to_str(&name[i]));
- if (map_domain_name_to_sid(&sid, &dom_name))
- {
- sid_name_use = SID_NAME_DOMAIN;
- dom_idx = make_dom_ref(ref, dom_name, &find_sid);
- }
+ /*
+ * Try and split the name into a DOMAIN and
+ * user component.
+ */
- if (lookup_name(find_name, &sid, &sid_name_use) == 0x0 &&
- sid_split_rid(&sid, &rid))
- {
- if (map_domain_sid_to_name(&sid, find_name))
- {
- dom_idx = make_dom_ref(ref, find_name, &sid);
- }
- else
- {
- status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
- }
- }
- else
- {
- status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
+ split_domain_name(full_name, dom_name, user);
+
+ /*
+ * We only do anything with this name if we
+ * can map the Domain into a SID we know.
+ */
+
+ if (map_domain_name_to_sid(&dom_sid, dom_name)) {
+ dom_idx = init_dom_ref(ref, dom_name, &dom_sid);
+
+ if (lookup_local_name(dom_name, user, &sid, &sid_name_use) && sid_split_rid(&sid, &rid))
+ status = True;
}
- if (status == 0x0)
- {
+ if (status)
(*mapped_count)++;
- }
- else
- {
+ else {
dom_idx = -1;
rid = 0xffffffff;
sid_name_use = SID_NAME_UNKNOWN;
}
- make_dom_rid2(&rid2[total], rid, sid_name_use, dom_idx);
+ init_dom_rid2(&rid2[total], rid, sid_name_use, dom_idx);
total++;
-
- if (dom_name != NULL)
- {
- free(dom_name);
- }
}
}
/***************************************************************************
-make_reply_lookup_names
+ init_reply_lookup_names
***************************************************************************/
-static void make_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l,
- DOM_R_REF *ref, uint32 num_entries,
- DOM_RID2 *rid2, uint32 mapped_count)
+
+static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l,
+ DOM_R_REF *ref, uint32 num_entries,
+ DOM_RID2 *rid2, uint32 mapped_count)
{
r_l->ptr_dom_ref = 1;
r_l->dom_ref = ref;
@@ -291,84 +276,74 @@ static void make_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l,
r_l->mapped_count = mapped_count;
if (mapped_count == 0)
- {
r_l->status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
- }
else
- {
r_l->status = 0x0;
- }
}
/***************************************************************************
-make_lsa_trans_names
+ Init lsa_trans_names.
***************************************************************************/
-static void make_lsa_trans_names(DOM_R_REF *ref,
- LSA_TRANS_NAME_ENUM *trn,
- int num_entries, DOM_SID2 sid[MAX_LOOKUP_SIDS],
- uint32 *mapped_count)
+
+static void init_lsa_trans_names(DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn,
+ int num_entries, DOM_SID2 sid[MAX_LOOKUP_SIDS], uint32 *mapped_count)
{
+ extern DOM_SID global_sid_S_1_5_0x20; /* BUILTIN sid. */
int i;
int total = 0;
- (*mapped_count) = 0;
+ *mapped_count = 0;
SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS);
- for (i = 0; i < num_entries; i++)
- {
- uint32 status = 0x0;
+ for (i = 0; i < num_entries; i++) {
+ BOOL status = False;
DOM_SID find_sid = sid[i].sid;
- DOM_SID tmp_sid = sid[i].sid;
uint32 rid = 0xffffffff;
int dom_idx = -1;
fstring name;
fstring dom_name;
uint8 sid_name_use = 0;
-
- memset(dom_name, 0, sizeof(dom_name));
- memset(name , 0, sizeof(name ));
- if (map_domain_sid_to_name(&find_sid, dom_name))
- {
+ memset(dom_name, '\0', sizeof(dom_name));
+ memset(name, '\0', sizeof(name));
+
+ /*
+ * First, check to see if the SID is one of the well
+ * known ones (this includes our own domain SID).
+ * Next, check if the domain prefix is one of the
+ * well known ones. If so and the domain prefix was
+ * either BUILTIN or our own global sid, then lookup
+ * the RID as a user or group id and translate to
+ * a name.
+ */
+
+ if (map_domain_sid_to_name(&find_sid, dom_name)) {
sid_name_use = SID_NAME_DOMAIN;
- dom_idx = make_dom_ref(ref, dom_name, &find_sid);
- }
- else if (sid_split_rid (&find_sid, &rid) &&
- map_domain_sid_to_name(&find_sid, dom_name))
- {
+ } else if (sid_split_rid(&find_sid, &rid) && map_domain_sid_to_name(&find_sid, dom_name)) {
if (sid_equal(&find_sid, &global_sam_sid) ||
- sid_equal(&find_sid, &global_sid_S_1_5_20))
- {
- /* lkclXXXX REPLACE THIS FUNCTION WITH
- samr_xxxx() routines
- */
- status = lookup_sid(&tmp_sid, name, &sid_name_use);
+ sid_equal(&find_sid, &global_sid_S_1_5_0x20)) {
+ status = lookup_local_rid(rid, name, &sid_name_use);
+ } else {
+ status = lookup_known_rid(&find_sid, rid, name, &sid_name_use);
}
- else
- {
- status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
- }
- }
- else
- {
- status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
}
- dom_idx = make_dom_ref(ref, dom_name, &find_sid);
+ DEBUG(10,("init_lsa_trans_names: adding domain '%s' sid %s to referenced list.\n",
+ dom_name, name ));
- if (status == 0x0)
- {
- (*mapped_count)++;
- }
- else
- {
- snprintf(name, sizeof(name), "%08x", rid);
- sid_name_use = SID_NAME_UNKNOWN;
+ dom_idx = init_dom_ref(ref, dom_name, &find_sid);
+ if(!status) {
+ slprintf(name, sizeof(name)-1, "unix.%08x", rid);
+ sid_name_use = SID_NAME_UNKNOWN;
}
- make_lsa_trans_name(&(trn->name [total]),
- &(trn->uni_name[total]),
- sid_name_use, name, dom_idx);
+
+ DEBUG(10,("init_lsa_trans_names: added user '%s\\%s' to referenced list.\n", dom_name, name ));
+
+ (*mapped_count)++;
+
+ init_lsa_trans_name(&trn->name[total], &trn->uni_name[total],
+ sid_name_use, name, dom_idx);
total++;
}
@@ -378,11 +353,12 @@ static void make_lsa_trans_names(DOM_R_REF *ref,
}
/***************************************************************************
-make_reply_lookup_sids
+ Init_reply_lookup_sids.
***************************************************************************/
-static void make_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l,
- DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *names,
- uint32 mapped_count)
+
+static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l,
+ DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *names,
+ uint32 mapped_count)
{
r_l->ptr_dom_ref = 1;
r_l->dom_ref = ref;
@@ -390,20 +366,16 @@ static void make_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l,
r_l->mapped_count = mapped_count;
if (mapped_count == 0)
- {
r_l->status = 0xC0000000 | NT_STATUS_NONE_MAPPED;
- }
else
- {
r_l->status = 0x0;
- }
}
/***************************************************************************
lsa_reply_lookup_sids
***************************************************************************/
-static void lsa_reply_lookup_sids(prs_struct *rdata,
- DOM_SID2 *sid, int num_entries)
+
+static BOOL lsa_reply_lookup_sids(prs_struct *rdata, DOM_SID2 *sid, int num_entries)
{
LSA_R_LOOKUP_SIDS r_l;
DOM_R_REF ref;
@@ -415,18 +387,24 @@ static void lsa_reply_lookup_sids(prs_struct *rdata,
ZERO_STRUCT(names);
/* set up the LSA Lookup SIDs response */
- make_lsa_trans_names(&ref, &names, num_entries, sid, &mapped_count);
- make_reply_lookup_sids(&r_l, &ref, &names, mapped_count);
+ init_lsa_trans_names(&ref, &names, num_entries, sid, &mapped_count);
+ init_reply_lookup_sids(&r_l, &ref, &names, mapped_count);
/* store the response in the SMB stream */
- lsa_io_r_lookup_sids("", &r_l, rdata, 0);
+ if(!lsa_io_r_lookup_sids("", &r_l, rdata, 0)) {
+ DEBUG(0,("lsa_reply_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS.\n"));
+ return False;
+ }
+
+ return True;
}
/***************************************************************************
lsa_reply_lookup_names
***************************************************************************/
-static void lsa_reply_lookup_names(prs_struct *rdata,
- UNISTR2 names[MAX_LOOKUP_SIDS], int num_entries)
+
+static BOOL lsa_reply_lookup_names(prs_struct *rdata,
+ UNISTR2 names[MAX_LOOKUP_SIDS], int num_entries)
{
LSA_R_LOOKUP_NAMES r_l;
DOM_R_REF ref;
@@ -435,20 +413,26 @@ static void lsa_reply_lookup_names(prs_struct *rdata,
ZERO_STRUCT(r_l);
ZERO_STRUCT(ref);
- ZERO_STRUCT(rids);
+ ZERO_ARRAY(rids);
/* set up the LSA Lookup RIDs response */
- make_lsa_rid2s(&ref, rids, num_entries, names, &mapped_count);
- make_reply_lookup_names(&r_l, &ref, num_entries, rids, mapped_count);
+ init_lsa_rid2s(&ref, rids, num_entries, names, &mapped_count);
+ init_reply_lookup_names(&r_l, &ref, num_entries, rids, mapped_count);
/* store the response in the SMB stream */
- lsa_io_r_lookup_names("", &r_l, rdata, 0);
+ if(!lsa_io_r_lookup_names("", &r_l, rdata, 0)) {
+ DEBUG(0,("lsa_reply_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n"));
+ return False;
+ }
+
+ return True;
}
/***************************************************************************
-api_lsa_open_policy
+ api_lsa_open_policy2
***************************************************************************/
-static void api_lsa_open_policy2( rpcsrv_struct *p, prs_struct *data,
+
+static BOOL api_lsa_open_policy2( uint16 vuid, prs_struct *data,
prs_struct *rdata )
{
LSA_Q_OPEN_POL2 q_o;
@@ -456,18 +440,24 @@ static void api_lsa_open_policy2( rpcsrv_struct *p, prs_struct *data,
ZERO_STRUCT(q_o);
/* grab the server, object attributes and desired access flag...*/
- lsa_io_q_open_pol2("", &q_o, data, 0);
+ if(!lsa_io_q_open_pol2("", &q_o, data, 0)) {
+ DEBUG(0,("api_lsa_open_policy2: unable to unmarshall LSA_Q_OPEN_POL2.\n"));
+ return False;
+ }
/* lkclXXXX having decoded it, ignore all fields in the open policy! */
/* return a 20 byte policy handle */
- lsa_reply_open_policy2(rdata);
+ if(!lsa_reply_open_policy2(rdata))
+ return False;
+
+ return True;
}
/***************************************************************************
api_lsa_open_policy
***************************************************************************/
-static void api_lsa_open_policy( rpcsrv_struct *p, prs_struct *data,
+static BOOL api_lsa_open_policy( uint16 vuid, prs_struct *data,
prs_struct *rdata )
{
LSA_Q_OPEN_POL q_o;
@@ -475,18 +465,24 @@ static void api_lsa_open_policy( rpcsrv_struct *p, prs_struct *data,
ZERO_STRUCT(q_o);
/* grab the server, object attributes and desired access flag...*/
- lsa_io_q_open_pol("", &q_o, data, 0);
+ if(!lsa_io_q_open_pol("", &q_o, data, 0)) {
+ DEBUG(0,("api_lsa_open_policy: unable to unmarshall LSA_Q_OPEN_POL.\n"));
+ return False;
+ }
/* lkclXXXX having decoded it, ignore all fields in the open policy! */
/* return a 20 byte policy handle */
- lsa_reply_open_policy(rdata);
+ if(!lsa_reply_open_policy(rdata))
+ return False;
+
+ return True;
}
/***************************************************************************
api_lsa_enum_trust_dom
***************************************************************************/
-static void api_lsa_enum_trust_dom( rpcsrv_struct *p, prs_struct *data,
+static BOOL api_lsa_enum_trust_dom( uint16 vuid, prs_struct *data,
prs_struct *rdata )
{
LSA_Q_ENUM_TRUST_DOM q_e;
@@ -498,12 +494,14 @@ static void api_lsa_enum_trust_dom( rpcsrv_struct *p, prs_struct *data,
/* construct reply. return status is always 0x0 */
lsa_reply_enum_trust_dom(&q_e, rdata, 0, NULL, NULL);
+
+ return True;
}
/***************************************************************************
api_lsa_query_info
***************************************************************************/
-static void api_lsa_query_info( rpcsrv_struct *p, prs_struct *data,
+static BOOL api_lsa_query_info( uint16 vuid, prs_struct *data,
prs_struct *rdata )
{
LSA_Q_QUERY_INFO q_i;
@@ -514,119 +512,118 @@ static void api_lsa_query_info( rpcsrv_struct *p, prs_struct *data,
ZERO_STRUCT(q_i);
/* grab the info class and policy handle */
- lsa_io_q_query("", &q_i, data, 0);
-
- switch (q_i.info_class)
- {
- case 0x03:
- {
- fstrcpy(name, global_myworkgroup);
- sid = &global_member_sid;
- break;
- }
- case 0x05:
- {
- fstrcpy(name, global_sam_name);
- sid = &global_sam_sid;
- break;
- }
- default:
- {
- DEBUG(5,("unknown info level in Lsa Query: %d\n",
- q_i.info_class));
- break;
- }
+ if(!lsa_io_q_query("", &q_i, data, 0)) {
+ DEBUG(0,("api_lsa_query_info: failed to unmarshall LSA_Q_QUERY_INFO.\n"));
+ return False;
+ }
+
+ switch (q_i.info_class) {
+ case 0x03:
+ fstrcpy(name, global_myworkgroup);
+ sid = &global_sam_sid;
+ break;
+ case 0x05:
+ fstrcpy(name, global_myname);
+ sid = &global_sam_sid;
+ break;
+ default:
+ DEBUG(0,("api_lsa_query_info: unknown info level in Lsa Query: %d\n", q_i.info_class));
+ break;
}
/* construct reply. return status is always 0x0 */
- lsa_reply_query_info(&q_i, rdata, name, sid);
+ if(!lsa_reply_query_info(&q_i, rdata, name, sid))
+ return False;
+
+ return True;
}
/***************************************************************************
-api_lsa_lookup_sids
+ api_lsa_lookup_sids
***************************************************************************/
-static void api_lsa_lookup_sids( rpcsrv_struct *p, prs_struct *data,
- prs_struct *rdata )
+
+static BOOL api_lsa_lookup_sids( uint16 vuid, prs_struct *data, prs_struct *rdata )
{
LSA_Q_LOOKUP_SIDS q_l;
ZERO_STRUCT(q_l);
/* grab the info class and policy handle */
- lsa_io_q_lookup_sids("", &q_l, data, 0);
+ if(!lsa_io_q_lookup_sids("", &q_l, data, 0)) {
+ DEBUG(0,("api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS.\n"));
+ return False;
+ }
/* construct reply. return status is always 0x0 */
- lsa_reply_lookup_sids(rdata, q_l.sids.sid, q_l.sids.num_entries);
+ if(!lsa_reply_lookup_sids(rdata, q_l.sids.sid, q_l.sids.num_entries))
+ return False;
+
+ return True;
}
/***************************************************************************
-api_lsa_lookup_names
+ api_lsa_lookup_names
***************************************************************************/
-static void api_lsa_lookup_names( rpcsrv_struct *p, prs_struct *data,
- prs_struct *rdata )
+
+static BOOL api_lsa_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rdata )
{
LSA_Q_LOOKUP_NAMES q_l;
ZERO_STRUCT(q_l);
/* grab the info class and policy handle */
- lsa_io_q_lookup_names("", &q_l, data, 0);
+ if(!lsa_io_q_lookup_names("", &q_l, data, 0)) {
+ DEBUG(0,("api_lsa_lookup_names: failed to unmarshall LSA_Q_LOOKUP_NAMES.\n"));
+ return False;
+ }
SMB_ASSERT_ARRAY(q_l.uni_name, q_l.num_entries);
- lsa_reply_lookup_names(rdata, q_l.uni_name, q_l.num_entries);
+ return lsa_reply_lookup_names(rdata, q_l.uni_name, q_l.num_entries);
}
/***************************************************************************
api_lsa_close
***************************************************************************/
-static void api_lsa_close( rpcsrv_struct *p, prs_struct *data,
+static BOOL api_lsa_close( uint16 vuid, prs_struct *data,
prs_struct *rdata)
{
LSA_R_CLOSE r_c;
- LSA_Q_CLOSE q_c;
-
- lsa_io_q_close("", &q_c, data, 0);
ZERO_STRUCT(r_c);
- r_c.status = 0x0;
-
- /* find the connection policy handle. */
- if (r_c.status == 0x0 && (find_policy_by_hnd(&(q_c.pol)) == -1))
- {
- r_c.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE;
- }
- if (r_c.status == 0x0)
- {
- close_policy_hnd(&(q_c.pol));
+ /* store the response in the SMB stream */
+ if (!lsa_io_r_close("", &r_c, rdata, 0)) {
+ DEBUG(0,("api_lsa_close: lsa_io_r_close failed.\n"));
+ return False;
}
- /* store the response in the SMB stream */
- lsa_io_r_close("", &r_c, rdata, 0);
+ return True;
}
/***************************************************************************
api_lsa_open_secret
***************************************************************************/
-static void api_lsa_open_secret( rpcsrv_struct *p, prs_struct *data,
+static BOOL api_lsa_open_secret( uint16 vuid, prs_struct *data,
prs_struct *rdata)
{
/* XXXX this is NOT good */
- char *q = mem_data(&(rdata->data), rdata->offset);
-
- SIVAL(q, 0, 0);
- q += 4;
- SIVAL(q, 0, 0);
- q += 4;
- SIVAL(q, 0, 0);
- q += 4;
- SIVAL(q, 0, 0);
- q += 4;
- SIVAL(q, 0, 0);
- q += 4;
- SIVAL(q, 0, 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND);
- q += 4;
-
- rdata->offset += 24;
+ size_t i;
+ uint32 dummy = 0;
+
+ for(i =0; i < 4; i++) {
+ if(!prs_uint32("api_lsa_close", rdata, 1, &dummy)) {
+ DEBUG(0,("api_lsa_open_secret: prs_uint32 %d failed.\n",
+ (int)i ));
+ return False;
+ }
+ }
+
+ dummy = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ if(!prs_uint32("api_lsa_close", rdata, 1, &dummy)) {
+ DEBUG(0,("api_lsa_open_secret: prs_uint32 status failed.\n"));
+ return False;
+ }
+
+ return True;
}
/***************************************************************************
@@ -648,7 +645,7 @@ static struct api_struct api_lsa_cmds[] =
/***************************************************************************
api_ntLsarpcTNP
***************************************************************************/
-BOOL api_ntlsa_rpc(rpcsrv_struct *p, prs_struct *data)
+BOOL api_ntlsa_rpc(pipes_struct *p, prs_struct *data)
{
return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds, data);
}