The branch, master has been updated
       via  c9571f7... s4:provisioning - Fixed minor bugs in provisioning tool 
and partition module.
       via  b5ce975... libcli/nbt Move more of lmhosts lookup into common code
       via  5a8f21c... lib/util Fix comments in rfc1738.c.
      from  ccdd146... s3-netlogon: make sure we protect some function codes in 
_netr_LogonControl2Ex().

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c9571f7277b1cf68e034ec3482c5474885d9381f
Author: Endi S. Dewata <[email protected]>
Date:   Tue Nov 3 19:45:22 2009 -0600

    s4:provisioning - Fixed minor bugs in provisioning tool and partition 
module.

commit b5ce97511aa33aa439a371f114ba7bb0cf822a16
Author: Andrew Bartlett <[email protected]>
Date:   Tue Nov 3 14:15:07 2009 +1100

    libcli/nbt Move more of lmhosts lookup into common code
    
    This aims to eventually share this with Samba4.
    
    Andrew Bartlett

commit 5a8f21cb88e7579c12b3d97299f355bb64957a87
Author: Andrew Bartlett <[email protected]>
Date:   Mon Nov 2 16:39:31 2009 +1100

    lib/util Fix comments in rfc1738.c.
    
    The Samba version does not use static buffers
    
    Andrew Bartlett

-----------------------------------------------------------------------

Summary of changes:
 lib/util/rfc1738.c                                 |    6 +-
 libcli/nbt/libnbt.h                                |    6 ++
 libcli/nbt/lmhosts.c                               |   79 ++++++++++++++++++++
 source3/libsmb/namequery.c                         |   60 ++++-----------
 source4/dsdb/samdb/ldb_modules/partition_init.c    |    4 +-
 source4/scripting/python/samba/provisionbackend.py |    3 +-
 6 files changed, 107 insertions(+), 51 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/rfc1738.c b/lib/util/rfc1738.c
index 1de3193..b45310a 100644
--- a/lib/util/rfc1738.c
+++ b/lib/util/rfc1738.c
@@ -158,7 +158,7 @@ rfc1738_do_escape(TALLOC_CTX *mem_ctx, const char *url, int 
encode_reserved)
 }
 
 /*
- * rfc1738_escape - Returns a static buffer that contains the RFC
+ * rfc1738_escape - Returns a buffer that contains the RFC
  * 1738 compliant, escaped version of the given url. (escapes unsafe and % 
characters)
  */
 char *
@@ -168,7 +168,7 @@ rfc1738_escape(TALLOC_CTX *mem_ctx, const char *url)
 }
 
 /*
- * rfc1738_escape_unescaped - Returns a static buffer that contains
+ * rfc1738_escape_unescaped - Returns a buffer that contains
  * the RFC 1738 compliant, escaped version of the given url (escapes unsafe 
chars only)
  */
 char *
@@ -178,7 +178,7 @@ rfc1738_escape_unescaped(TALLOC_CTX *mem_ctx, const char 
*url)
 }
 
 /*
- * rfc1738_escape_part - Returns a static buffer that contains the RFC
+ * rfc1738_escape_part - Returns a buffer that contains the RFC
  * 1738 compliant, escaped version of the given url segment. (escapes
  * unsafe, reserved and % chars) It would mangle the :// in http://,
  * and mangle paths (because of /).
diff --git a/libcli/nbt/libnbt.h b/libcli/nbt/libnbt.h
index 2abcb56..6d6a4a4 100644
--- a/libcli/nbt/libnbt.h
+++ b/libcli/nbt/libnbt.h
@@ -360,4 +360,10 @@ bool getlmhostsent(TALLOC_CTX *ctx, XFILE *fp, char 
**pp_name, int *name_type,
                struct sockaddr_storage *pss);
 void endlmhosts(XFILE *fp);
 
+NTSTATUS resolve_lmhosts_file_as_sockaddr(const char *lmhosts_file, 
+                                         const char *name, int name_type,
+                                         TALLOC_CTX *mem_ctx, 
+                                         struct sockaddr_storage 
**return_iplist,
+                                         int *return_count);
+
 #endif /* __LIBNBT_H__ */
diff --git a/libcli/nbt/lmhosts.c b/libcli/nbt/lmhosts.c
index 11703a2..317ccc5 100644
--- a/libcli/nbt/lmhosts.c
+++ b/libcli/nbt/lmhosts.c
@@ -155,3 +155,82 @@ void endlmhosts(XFILE *fp)
        x_fclose(fp);
 }
 
+/********************************************************
+ Resolve via "lmhosts" method.
+*********************************************************/
+
+NTSTATUS resolve_lmhosts_file_as_sockaddr(const char *lmhosts_file, 
+                                         const char *name, int name_type,
+                                         TALLOC_CTX *mem_ctx, 
+                                         struct sockaddr_storage 
**return_iplist,
+                                         int *return_count)
+{
+       /*
+        * "lmhosts" means parse the local lmhosts file.
+        */
+
+       XFILE *fp;
+       char *lmhost_name = NULL;
+       int name_type2;
+       struct sockaddr_storage return_ss;
+       NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
+       TALLOC_CTX *ctx = NULL;
+
+       *return_iplist = NULL;
+       *return_count = 0;
+
+       DEBUG(3,("resolve_lmhosts: "
+               "Attempting lmhosts lookup for name %s<0x%x>\n",
+               name, name_type));
+
+       fp = startlmhosts(lmhosts_file);
+
+       if ( fp == NULL )
+               return NT_STATUS_NO_SUCH_FILE;
+
+       ctx = talloc_new(mem_ctx);
+       if (!ctx) {
+               endlmhosts(fp);
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       while (getlmhostsent(ctx, fp, &lmhost_name, &name_type2, &return_ss)) {
+
+               if (!strequal(name, lmhost_name)) {
+                       TALLOC_FREE(lmhost_name);
+                       continue;
+               }
+
+               if ((name_type2 != -1) && (name_type != name_type2)) {
+                       TALLOC_FREE(lmhost_name);
+                       continue;
+               }
+               
+               *return_iplist = talloc_realloc(ctx, (*return_iplist), 
+                                               struct sockaddr_storage,
+                                               (*return_count)+1);
+
+               if ((*return_iplist) == NULL) {
+                       TALLOC_FREE(ctx);
+                       endlmhosts(fp);
+                       DEBUG(3,("resolve_lmhosts: talloc_realloc fail !\n"));
+                       return NT_STATUS_NO_MEMORY;
+               }
+
+               (*return_iplist)[*return_count] = return_ss;
+               *return_count += 1;
+
+               /* we found something */
+               status = NT_STATUS_OK;
+
+               /* Multiple names only for DC lookup */
+               if (name_type != 0x1c)
+                       break;
+       }
+
+       talloc_steal(mem_ctx, *return_iplist);
+       TALLOC_FREE(ctx);
+       endlmhosts(fp);
+       return status;
+}
+
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 930f0a5..a6fc612 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -1101,11 +1101,7 @@ static NTSTATUS resolve_lmhosts(const char *name, int 
name_type,
        /*
         * "lmhosts" means parse the local lmhosts file.
         */
-
-       XFILE *fp;
-       char *lmhost_name = NULL;
-       int name_type2;
-       struct sockaddr_storage return_ss;
+       struct sockaddr_storage *ss_list;
        NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
        TALLOC_CTX *ctx = NULL;
 
@@ -1116,54 +1112,28 @@ static NTSTATUS resolve_lmhosts(const char *name, int 
name_type,
                "Attempting lmhosts lookup for name %s<0x%x>\n",
                name, name_type));
 
-       fp = startlmhosts(get_dyn_LMHOSTSFILE());
-
-       if ( fp == NULL )
-               return NT_STATUS_NO_SUCH_FILE;
-
        ctx = talloc_init("resolve_lmhosts");
        if (!ctx) {
-               endlmhosts(fp);
                return NT_STATUS_NO_MEMORY;
        }
 
-       while (getlmhostsent(ctx, fp, &lmhost_name, &name_type2, &return_ss)) {
-
-               if (!strequal(name, lmhost_name)) {
-                       TALLOC_FREE(lmhost_name);
-                       continue;
-               }
-
-               if ((name_type2 != -1) && (name_type != name_type2)) {
-                       TALLOC_FREE(lmhost_name);
-                       continue;
-               }
-
-               *return_iplist = SMB_REALLOC_ARRAY((*return_iplist),
-                                       struct ip_service,
-                                       (*return_count)+1);
-
-               if ((*return_iplist) == NULL) {
-                       TALLOC_FREE(ctx);
-                       endlmhosts(fp);
-                       DEBUG(3,("resolve_lmhosts: malloc fail !\n"));
+       status = resolve_lmhosts_file_as_sockaddr(get_dyn_LMHOSTSFILE(), 
+                                                 name, name_type, 
+                                                 ctx, 
+                                                 &ss_list, 
+                                                 return_count);
+       if (NT_STATUS_IS_OK(status)) {
+               if (convert_ss2service(return_iplist, 
+                                      ss_list,
+                                      *return_count)) {
+                       talloc_free(ctx);
+                       return NT_STATUS_OK;
+               } else {
+                       talloc_free(ctx);
                        return NT_STATUS_NO_MEMORY;
                }
-
-               (*return_iplist)[*return_count].ss = return_ss;
-               (*return_iplist)[*return_count].port = PORT_NONE;
-               *return_count += 1;
-
-               /* we found something */
-               status = NT_STATUS_OK;
-
-               /* Multiple names only for DC lookup */
-               if (name_type != 0x1c)
-                       break;
        }
-
-       TALLOC_FREE(ctx);
-       endlmhosts(fp);
+       talloc_free(ctx);
        return status;
 }
 
diff --git a/source4/dsdb/samdb/ldb_modules/partition_init.c 
b/source4/dsdb/samdb/ldb_modules/partition_init.c
index f98b1d8..db99b75 100644
--- a/source4/dsdb/samdb/ldb_modules/partition_init.c
+++ b/source4/dsdb/samdb/ldb_modules/partition_init.c
@@ -132,7 +132,7 @@ static int partition_reload_metadata(struct ldb_module 
*module, struct partition
        struct ldb_message *msg;
        struct ldb_result *res;
        struct ldb_context *ldb = ldb_module_get_ctx(module);
-       const char *attrs[] = { "partition", "replicateEntries", "modules", 
NULL };
+       const char *attrs[] = { "partition", "replicateEntries", "modules", 
"ldapBackend", NULL };
        /* perform search for @PARTITION, looking for module, replicateEntries 
and ldapBackend */
        ret = dsdb_module_search_dn(module, mem_ctx, &res, 
                                    ldb_dn_new(mem_ctx, ldb, DSDB_PARTITION_DN),
@@ -239,7 +239,7 @@ static int new_partition_from_dn(struct ldb_context *ldb, 
struct partition_priva
        ctrl->version = DSDB_CONTROL_CURRENT_PARTITION_VERSION;
        ctrl->dn = talloc_steal(ctrl, dn);
        
-       ret = ldb_connect_backend(ldb, backend_url, NULL, &backend_module);
+       ret = ldb_connect_backend(ldb, (*partition)->backend_url, NULL, 
&backend_module);
        if (ret != LDB_SUCCESS) {
                return ret;
        }
diff --git a/source4/scripting/python/samba/provisionbackend.py 
b/source4/scripting/python/samba/provisionbackend.py
index 8f1b94f..f809202 100644
--- a/source4/scripting/python/samba/provisionbackend.py
+++ b/source4/scripting/python/samba/provisionbackend.py
@@ -31,6 +31,7 @@ import sys
 import uuid
 import time
 import shutil
+import subprocess
 
 from samba import read_and_sub_file
 from samba import Ldb
@@ -203,7 +204,7 @@ class ProvisionBackend(object):
 
         self.slapd_command_escaped = "\'" + "\' \'".join(self.slapd_command) + 
"\'"
         setup_file(setup_path("ldap_backend_startup.sh"), paths.ldapdir + 
"/ldap_backend_startup.sh", {
-                "SLAPD_COMMAND" : slapd_command})
+                "SLAPD_COMMAND" : self.slapd_command_escaped})
 
         # Now start the slapd, so we can provision onto it.  We keep the
         # subprocess context around, to kill this off at the successful


-- 
Samba Shared Repository

Reply via email to