Back out some of the less well thought out ideas from last weeks work on
authorAndrew Bartlett <abartlet@samba.org>
Sat, 26 Jan 2002 11:48:42 +0000 (11:48 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 26 Jan 2002 11:48:42 +0000 (11:48 +0000)
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
(This used to be commit 5dfba2cf536f761b0aee314ed9e30dc53900b691)

source3/libsmb/cli_lsarpc.c
source3/nsswitch/winbindd_rpc.c
source3/rpc_parse/parse_lsa.c
source3/rpcclient/cmd_lsarpc.c
source3/utils/smbcacls.c

index 66504d8355cc7e1992ade3c66b069497ff877731..7e0abd583c0dd3325f102647623be5a6a47957e4 100644 (file)
@@ -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)) {
index 7d9a26f906c60b3b275bf6663bec56541deabc07..67fcd5de669bcb17bb54069a4cad008966569e2d 100644 (file)
@@ -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)) {
index ae6068e3d60e87d15356d07fd4c55d2c52cf3fd3..a70d1e98a9e09b36f8c3ede5b7265e226e424431 100644 (file)
@@ -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);
        }
 }
 
index 67efbb1ff739faf8a5d7aace6589301a9194b289..1b733d25c363f25fe773114b20ba57d75b5fd272 100644 (file)
@@ -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))
index d62907e14be0bc311b305eaa0ec8cb4dd13b7f21..d2bec218feca1181c5259ab2016691553b4c88b3 100644 (file)
@@ -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;