summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-01-26 11:48:42 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-01-26 11:48:42 +0000
commit5dfba2cf536f761b0aee314ed9e30dc53900b691 (patch)
tree6d8c6437446d37ed841fe0d4d64685bf8ab2c3d3
parent151dd7bc6c61e19a993017e5e0b50314801e26de (diff)
downloadsamba-5dfba2cf536f761b0aee314ed9e30dc53900b691.tar.gz
Back out some of the less well thought out ideas from last weeks work on
winbind default domains, particulary now I understand whats going on a lot better. This ensures that the RPC client code does as little 'magic' as possible - this is up to the application/user. (Where - for to name->sid code - it was all along). This leaves the change that allows the sid->name code to return domains and usernames in seperate paramaters. Andrew Bartlett
-rw-r--r--source/libsmb/cli_lsarpc.c4
-rw-r--r--source/nsswitch/winbindd_rpc.c21
-rw-r--r--source/rpc_parse/parse_lsa.c14
-rw-r--r--source/rpcclient/cmd_lsarpc.c11
-rw-r--r--source/utils/smbcacls.c7
5 files changed, 24 insertions, 33 deletions
diff --git a/source/libsmb/cli_lsarpc.c b/source/libsmb/cli_lsarpc.c
index 66504d8355c..7e0abd583c0 100644
--- a/source/libsmb/cli_lsarpc.c
+++ b/source/libsmb/cli_lsarpc.c
@@ -336,7 +336,7 @@ NTSTATUS cli_lsa_lookup_sids(struct cli_state *cli, TALLOC_CTX *mem_ctx,
/** Lookup a list of names */
NTSTATUS cli_lsa_lookup_names(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol, int num_names, const char **dom_names, const char **names,
+ POLICY_HND *pol, int num_names, const char **names,
DOM_SID **sids, uint32 **types, int *num_sids)
{
prs_struct qbuf, rbuf;
@@ -356,7 +356,7 @@ NTSTATUS cli_lsa_lookup_names(struct cli_state *cli, TALLOC_CTX *mem_ctx,
/* Marshall data and send request */
- init_q_lookup_names(mem_ctx, &q, pol, num_names, dom_names, names);
+ init_q_lookup_names(mem_ctx, &q, pol, num_names, names);
if (!lsa_io_q_lookup_names("", &q, &qbuf, 0) ||
!rpc_api_pipe_req(cli, LSA_LOOKUPNAMES, &qbuf, &rbuf)) {
diff --git a/source/nsswitch/winbindd_rpc.c b/source/nsswitch/winbindd_rpc.c
index 7d9a26f906c..67fcd5de669 100644
--- a/source/nsswitch/winbindd_rpc.c
+++ b/source/nsswitch/winbindd_rpc.c
@@ -177,17 +177,28 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
DOM_SID *sids = NULL;
uint32 *types = NULL;
int num_sids;
- const char *domain_name = domain->name;
+ const char *full_name;
- if (!(mem_ctx = talloc_init_named("name_to_sid[rpc]")))
+ if (!(mem_ctx = talloc_init_named("name_to_sid[rpc] for [%s]\\[%s]", domain->name, name))) {
+ DEBUG(0, ("talloc_init failed!\n"));
return NT_STATUS_NO_MEMORY;
+ }
- if (!(hnd = cm_get_lsa_handle(domain->name)))
+ if (!(hnd = cm_get_lsa_handle(domain->name))) {
+ talloc_destroy(mem_ctx);
return NT_STATUS_UNSUCCESSFUL;
+ }
+ full_name = talloc_asprintf(mem_ctx, "%s\\%s", domain->name, name);
+
+ if (!full_name) {
+ DEBUG(0, ("talloc_asprintf failed!\n"));
+ talloc_destroy(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
status = cli_lsa_lookup_names(hnd->cli, mem_ctx, &hnd->pol, 1,
- &domain_name, &name,
- &sids, &types, &num_sids);
+ &full_name, &sids, &types, &num_sids);
/* Return rid and type if lookup successful */
if (NT_STATUS_IS_OK(status)) {
diff --git a/source/rpc_parse/parse_lsa.c b/source/rpc_parse/parse_lsa.c
index ae6068e3d60..a70d1e98a9e 100644
--- a/source/rpc_parse/parse_lsa.c
+++ b/source/rpc_parse/parse_lsa.c
@@ -1045,7 +1045,7 @@ makes a structure.
********************************************************************/
void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l,
- POLICY_HND *hnd, int num_names, const char **dom_names, const char **names)
+ POLICY_HND *hnd, int num_names, const char **names)
{
int i;
@@ -1071,19 +1071,11 @@ void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l,
}
for (i = 0; i < num_names; i++) {
- char *full_name;
int len;
-
- full_name = talloc_asprintf(mem_ctx, "%s\\%s", dom_names[i], names[i]);
- if (!full_name) {
- DEBUG(0, ("init_q_lookup_names(): out of memory doing talloc_asprintf\n"));
- return;
- }
-
- len = strlen(full_name);
+ len = strlen(names[i]);
init_uni_hdr(&q_l->hdr_name[i], len);
- init_unistr2(&q_l->uni_name[i], full_name, len);
+ init_unistr2(&q_l->uni_name[i], names[i], len);
}
}
diff --git a/source/rpcclient/cmd_lsarpc.c b/source/rpcclient/cmd_lsarpc.c
index 67efbb1ff73..1b733d25c36 100644
--- a/source/rpcclient/cmd_lsarpc.c
+++ b/source/rpcclient/cmd_lsarpc.c
@@ -80,8 +80,6 @@ static NTSTATUS cmd_lsa_lookup_names(struct cli_state *cli,
DOM_SID *sids;
uint32 *types;
int num_names, i;
- fstring name, domain;
- const char *name2, *domain2;
if (argc == 1) {
printf("Usage: %s [name1 [name2 [...]]]\n", argv[0]);
@@ -95,15 +93,8 @@ static NTSTATUS cmd_lsa_lookup_names(struct cli_state *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- /* Lookup the names */
-
- split_domain_name(argv[1], domain, name);
-
- name2 = talloc_strdup(mem_ctx, name);
- domain2 = talloc_strdup(mem_ctx, domain);
-
result = cli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1,
- &domain2, &name2, &sids,
+ (const char**)(argv + 1), &sids,
&types, &num_names);
if (!NT_STATUS_IS_OK(result))
diff --git a/source/utils/smbcacls.c b/source/utils/smbcacls.c
index d62907e14be..d2bec218fec 100644
--- a/source/utils/smbcacls.c
+++ b/source/utils/smbcacls.c
@@ -140,17 +140,14 @@ static BOOL StringToSid(DOM_SID *sid, const char *str)
DOM_SID *sids = NULL;
int num_sids;
BOOL result = True;
- fstring name, domain;
-
+
if (strncmp(str, "S-", 2) == 0) {
return string_to_sid(sid, str);
}
- split_domain_name(str, domain, name);
-
if (!cacls_open_policy_hnd() ||
!NT_STATUS_IS_OK(cli_lsa_lookup_names(&lsa_cli, lsa_cli.mem_ctx, &pol, 1,
- (const char **)&domain, (const char **)&name,
+ &str,
&sids, &types, &num_sids))) {
result = False;
goto done;