summaryrefslogtreecommitdiffstats
path: root/source/rpc_client
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1998-11-11 14:23:55 +0000
committerLuke Leighton <lkcl@samba.org>1998-11-11 14:23:55 +0000
commit13a0ee851fe0ce9acddfe57f9aba19fc78085c39 (patch)
treeb81bc35aedd705fa25b8d7d83dce638ddd1fbde0 /source/rpc_client
parenta41defc36756eef0054f66dcbd46890453ad5ae3 (diff)
downloadsamba-13a0ee851fe0ce9acddfe57f9aba19fc78085c39.tar.gz
samba-13a0ee851fe0ce9acddfe57f9aba19fc78085c39.tar.xz
samba-13a0ee851fe0ce9acddfe57f9aba19fc78085c39.zip
changed syntax of registry commands so keys can start with HKLM or HKU.
sorted lookupsids command
Diffstat (limited to 'source/rpc_client')
-rw-r--r--source/rpc_client/cli_lsarpc.c91
-rw-r--r--source/rpc_client/cli_reg.c71
2 files changed, 110 insertions, 52 deletions
diff --git a/source/rpc_client/cli_lsarpc.c b/source/rpc_client/cli_lsarpc.c
index c2809294179..079d3e935b7 100644
--- a/source/rpc_client/cli_lsarpc.c
+++ b/source/rpc_client/cli_lsarpc.c
@@ -105,7 +105,8 @@ BOOL do_lsa_lookup_sids(struct cli_state *cli,
POLICY_HND *hnd,
int num_sids,
DOM_SID **sids,
- char **names)
+ char ***names,
+ int *num_names)
{
prs_struct rbuf;
prs_struct buf;
@@ -150,8 +151,53 @@ BOOL do_lsa_lookup_sids(struct cli_state *cli,
if (p)
{
- valid_response = True;
- *names = NULL;
+ if (t_names.ptr_trans_names != 0 && ref.undoc_buffer != 0)
+ {
+ valid_response = True;
+ }
+ }
+
+ if (num_names != NULL && valid_response)
+ {
+ (*num_names) = t_names.num_entries;
+ }
+ if (valid_response)
+ {
+ int i;
+ for (i = 0; i < t_names.num_entries; i++)
+ {
+ if (t_names.name[i].domain_idx >= ref.num_ref_doms_1)
+ {
+ DEBUG(0,("LSA_LOOKUP_SIDS: domain index out of bounds\n"));
+ valid_response = False;
+ break;
+ }
+ }
+ }
+
+ if (names != NULL && valid_response && t_names.num_entries != 0)
+ {
+ (*names) = (char**)malloc((*num_names) * sizeof(char*));
+ }
+
+ if (names != NULL && (*names) != NULL)
+ {
+ int i;
+ /* take each name, construct a \DOMAIN\name string */
+ for (i = 0; i < (*num_names); i++)
+ {
+ fstring name;
+ fstring dom_name;
+ fstring full_name;
+ uint32 dom_idx = t_names.name[i].domain_idx;
+ fstrcpy(dom_name, unistr2(ref.ref_dom[dom_idx].uni_dom_name.buffer));
+ fstrcpy(name , unistr2(t_names.uni_name[i].buffer));
+
+ snprintf(full_name, sizeof(full_name), "\\%s\\%s",
+ dom_name, name);
+
+ (*names)[i] = strdup(full_name);
+ }
}
}
@@ -166,13 +212,16 @@ do a LSA Query Info Policy
****************************************************************************/
BOOL do_lsa_query_info_pol(struct cli_state *cli,
POLICY_HND *hnd, uint16 info_class,
- fstring domain_name, fstring domain_sid)
+ fstring domain_name, DOM_SID *domain_sid)
{
prs_struct rbuf;
prs_struct buf;
LSA_Q_QUERY_INFO q_q;
BOOL valid_response = False;
+ ZERO_STRUCTP(domain_sid);
+ domain_name[0] = 0;
+
if (hnd == NULL || domain_name == NULL || domain_sid == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@@ -214,25 +263,38 @@ BOOL do_lsa_query_info_pol(struct cli_state *cli,
if (p)
{
+ fstring sid_str;
/* ok, at last: we're happy. */
switch (r_q.info_class)
{
case 3:
{
- char *dom_name = unistrn2(r_q.dom.id3.uni_domain_name.buffer,
- r_q.dom.id3.uni_domain_name.uni_str_len);
- fstrcpy(domain_name, dom_name);
- sid_to_string(domain_sid, &(r_q.dom.id3.dom_sid.sid));
+ if (r_q.dom.id3.buffer_dom_name != 0)
+ {
+ char *dom_name = unistrn2(r_q.dom.id3.uni_domain_name.buffer,
+ r_q.dom.id3.uni_domain_name.uni_str_len);
+ fstrcpy(domain_name, dom_name);
+ }
+ if (r_q.dom.id3.buffer_dom_sid != 0)
+ {
+ *domain_sid = r_q.dom.id3.dom_sid.sid;
+ }
valid_response = True;
break;
}
case 5:
{
- char *dom_name = unistrn2(r_q.dom.id5.uni_domain_name.buffer,
- r_q.dom.id5.uni_domain_name.uni_str_len);
- fstrcpy(domain_name, dom_name);
- sid_to_string(domain_sid, &(r_q.dom.id5.dom_sid.sid));
+ if (r_q.dom.id5.buffer_dom_name != 0)
+ {
+ char *dom_name = unistrn2(r_q.dom.id5.uni_domain_name.buffer,
+ r_q.dom.id5.uni_domain_name.uni_str_len);
+ fstrcpy(domain_name, dom_name);
+ }
+ if (r_q.dom.id5.buffer_dom_sid != 0)
+ {
+ *domain_sid = r_q.dom.id5.dom_sid.sid;
+ }
valid_response = True;
break;
@@ -241,13 +303,14 @@ BOOL do_lsa_query_info_pol(struct cli_state *cli,
{
DEBUG(3,("LSA_QUERYINFOPOLICY: unknown info class\n"));
domain_name[0] = 0;
- domain_sid [0] = 0;
break;
}
}
+
+ sid_to_string(sid_str, domain_sid);
DEBUG(3,("LSA_QUERYINFOPOLICY (level %x): domain:%s domain sid:%s\n",
- r_q.info_class, domain_name, domain_sid));
+ r_q.info_class, domain_name, sid_str));
}
}
diff --git a/source/rpc_client/cli_reg.c b/source/rpc_client/cli_reg.c
index 240a1fbb67d..27c1c8e7605 100644
--- a/source/rpc_client/cli_reg.c
+++ b/source/rpc_client/cli_reg.c
@@ -31,62 +31,57 @@
extern int DEBUGLEVEL;
-
/****************************************************************************
do a REG Open Policy
****************************************************************************/
-BOOL do_reg_connect(struct cli_state *cli, char *full_keyname,
- POLICY_HND *reg_hnd,
- POLICY_HND *key_hnd)
+BOOL do_reg_connect(struct cli_state *cli, char *full_keyname, char *key_name,
+ POLICY_HND *reg_hnd)
{
- fstring key_name;
- char *srch;
- BOOL res1;
- BOOL res = False;
- BOOL hklm = False;
- BOOL hku = False;
+ BOOL res = True;
+ uint32 reg_type = 0;
if (full_keyname == NULL)
{
return False;
}
- srch = "HKLM";
- if (strnequal(full_keyname, srch, strlen(srch)))
+ ZERO_STRUCTP(reg_hnd);
+
+ /*
+ * open registry receive a policy handle
+ */
+
+ if (!reg_split_key(full_keyname, &reg_type, key_name))
+ {
+ DEBUG(0,("do_reg_connect: unrecognised key name %s\n", full_keyname));
+ return False;
+ }
+
+ switch (reg_type)
{
- full_keyname += strlen(srch);
- if (*full_keyname == '\\')
+ case HKEY_LOCAL_MACHINE:
{
- full_keyname++;
- fstrcpy(key_name, full_keyname);
+ res = res ? do_reg_open_hklm(cli,
+ 0x84E0, 0x02000000,
+ reg_hnd) : False;
+ break;
}
- else if (*full_keyname != 0)
+
+ case HKEY_USERS:
{
+ res = res ? do_reg_open_hku(cli,
+ 0x84E0, 0x02000000,
+ reg_hnd) : False;
+ break;
+ }
+ default:
+ {
+ DEBUG(0,("do_reg_connect: unrecognised hive key\n"));
return False;
}
}
- /* open registry receive a policy handle */
-
- if (hklm)
- {
- res = do_reg_open_hklm(cli,
- 0x84E0, 0x02000000,
- reg_hnd);
- }
-
- if (hku)
- {
- res = do_reg_open_hku(cli,
- 0x84E0, 0x02000000,
- reg_hnd);
- }
-
- /* open an entry */
- res1 = res ? do_reg_open_entry(cli, reg_hnd,
- key_name, 0x02000000, key_hnd) : False;
-
- return res1 && res;
+ return res;
}
/****************************************************************************