The branch, master has been updated
       via  229f3cc s4:netlogon RPC server - "LogonGetDomainInfo" - always 
check the LDB return codes
       via  a5fc937 s4:libnet_join.c - only write the really essential SPNs
       via  572774a s4:provision - remove the "servicePrincipalName" creation 
on the DC object
       via  01e7cc6 s4:setup/spn_update_list - reorder and update with other 
SPNs
       via  971ce6c s4:scripting/bin/samba_spnupdate - also support adding all 
possible "servicePrincipalName"s
       via  5f8adf0 s4:dsdb/dns/dns_update.c - increase the timeout for the SPN 
and DNS update scripts
       via  39d4089 s4:netlogon RPC server - point out that the 
"LogonGetDomainInfo" "servicePrincipalName" generation is still needed
       via  1168731 s4:sam.py - add a test for the "dNSHostName" - 
"servicePrincipalName" update mechanism
       via  3f66608 s4:samldb LDB module - implement the "dNSHostName" - 
"servicePrincipalName" change trigger
       via  771b10a s4:samldb LDB module - check for the number of results 
after a search operation
       via  8de1d72 s4:drsuapi RPC server - fix counter variables
      from  f6cfa86 talloc: Look harder for waf.

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


- Log -----------------------------------------------------------------
commit 229f3cc9e85eaf9909464886d152216f7ba44b7b
Author: Matthias Dieter Wallnöfer <[email protected]>
Date:   Sun Oct 31 19:41:12 2010 +0100

    s4:netlogon RPC server - "LogonGetDomainInfo" - always check the LDB return 
codes
    
    Plus some cosmetic indentation fixes
    
    Autobuild-User: Matthias Dieter Wallnöfer <[email protected]>
    Autobuild-Date: Sun Oct 31 19:26:45 UTC 2010 on sn-devel-104

commit a5fc9378df6e69338332762c7d1c8a72cad58153
Author: Matthias Dieter Wallnöfer <[email protected]>
Date:   Sun Oct 31 19:11:34 2010 +0100

    s4:libnet_join.c - only write the really essential SPNs
    
    If we are a DC then the others are added by the "samba_spnupdate" script.
    
    This fixes bug #7614.

commit 572774a7a0a1c646bc84d1310f5e8002a464216c
Author: Matthias Dieter Wallnöfer <[email protected]>
Date:   Sun Oct 31 14:00:14 2010 +0100

    s4:provision - remove the "servicePrincipalName" creation on the DC object
    
    This is now done by the "samba_spnupdate" script.

commit 01e7cc607cfdfb3b0b17048a30b470ac990ba736
Author: Matthias Dieter Wallnöfer <[email protected]>
Date:   Sun Oct 31 14:36:41 2010 +0100

    s4:setup/spn_update_list - reorder and update with other SPNs

commit 971ce6c5ed214bf01cc4a767d556279f71e77f9d
Author: Matthias Dieter Wallnöfer <[email protected]>
Date:   Sun Oct 31 14:07:52 2010 +0100

    s4:scripting/bin/samba_spnupdate - also support adding all possible 
"servicePrincipalName"s

commit 5f8adf0efd555e3595c90d4223d06b9638340b1b
Author: Matthias Dieter Wallnöfer <[email protected]>
Date:   Sun Oct 31 14:46:15 2010 +0100

    s4:dsdb/dns/dns_update.c - increase the timeout for the SPN and DNS update 
scripts
    
    Sometimes it can take longer than 10 sec.

commit 39d40892c6bf50fc1ed2a8336b4207b6320eb387
Author: Matthias Dieter Wallnöfer <[email protected]>
Date:   Sun Oct 31 12:30:52 2010 +0100

    s4:netlogon RPC server - point out that the "LogonGetDomainInfo" 
"servicePrincipalName" generation is still needed

commit 11687316b49af138d0e8c42ca170d12aa0665df0
Author: Matthias Dieter Wallnöfer <[email protected]>
Date:   Sun Oct 31 17:24:08 2010 +0100

    s4:sam.py - add a test for the "dNSHostName" - "servicePrincipalName" 
update mechanism

commit 3f66608da40970dd7cc5ef04789b4fd692fd8e35
Author: Matthias Dieter Wallnöfer <[email protected]>
Date:   Sun Oct 31 12:07:04 2010 +0100

    s4:samldb LDB module - implement the "dNSHostName" - "servicePrincipalName" 
change trigger
    
    When the "dNSHostName" changes then also the "servicePrincipalName"s are
    changed as well.

commit 771b10a421c287bb191192da632e73e5d1458cce
Author: Matthias Dieter Wallnöfer <[email protected]>
Date:   Sun Oct 31 11:03:59 2010 +0100

    s4:samldb LDB module - check for the number of results after a search 
operation
    
    Should always be done.

commit 8de1d727f18b28f660b6f88b14f307841c4ae6cb
Author: Matthias Dieter Wallnöfer <[email protected]>
Date:   Sun Oct 31 11:01:00 2010 +0100

    s4:drsuapi RPC server - fix counter variables

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

Summary of changes:
 source4/dsdb/dns/dns_update.c                 |    4 +-
 source4/dsdb/samdb/ldb_modules/samldb.c       |  158 +++++++++++++++++++++++++
 source4/dsdb/tests/python/sam.py              |  152 +++++++++++++++++++++++-
 source4/libnet/libnet_join.c                  |   15 +--
 source4/rpc_server/drsuapi/writespn.c         |    9 +-
 source4/rpc_server/netlogon/dcerpc_netlogon.c |   94 ++++++++++-----
 source4/scripting/bin/samba_spnupdate         |    5 +-
 source4/scripting/python/samba/provision.py   |    8 --
 source4/setup/provision_self_join.ldif        |   16 +--
 source4/setup/provision_self_join_modify.ldif |    3 -
 source4/setup/spn_update_list                 |   28 +++--
 11 files changed, 406 insertions(+), 86 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/dns/dns_update.c b/source4/dsdb/dns/dns_update.c
index 68ad03f..ae5be44 100644
--- a/source4/dsdb/dns/dns_update.c
+++ b/source4/dsdb/dns/dns_update.c
@@ -297,7 +297,7 @@ static void dnsupdate_check_names(struct dnsupdate_service 
*service)
        DEBUG(3,("Calling DNS name update script\n"));
        service->nameupdate.subreq = samba_runcmd_send(service,
                                                       service->task->event_ctx,
-                                                      timeval_current_ofs(10, 
0),
+                                                      timeval_current_ofs(20, 
0),
                                                       2, 0,
                                                       dns_update_command,
                                                       NULL);
@@ -312,7 +312,7 @@ static void dnsupdate_check_names(struct dnsupdate_service 
*service)
        DEBUG(3,("Calling SPN name update script\n"));
        service->nameupdate.spnreq = samba_runcmd_send(service,
                                                       service->task->event_ctx,
-                                                      timeval_current_ofs(10, 
0),
+                                                      timeval_current_ofs(20, 
0),
                                                       2, 0,
                                                       spn_update_command,
                                                       NULL);
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c 
b/source4/dsdb/samdb/ldb_modules/samldb.c
index 9b6d6e0..79b557d 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -1067,6 +1067,9 @@ static int samldb_prim_group_change(struct samldb_ctx *ac)
        if (ret != LDB_SUCCESS) {
                return ret;
        }
+       if (res->count != 1) {
+               return ldb_operr(ldb);
+       }
 
        /* Finds out the DN of the old primary group */
 
@@ -1441,6 +1444,152 @@ static int samldb_member_check(struct samldb_ctx *ac)
        return LDB_SUCCESS;
 }
 
+/* This trigger adapts the "servicePrincipalName" attributes if the
+ * "dNSHostName" attribute changes */
+static int samldb_service_principal_names_change(struct samldb_ctx *ac)
+{
+       struct ldb_context *ldb = ldb_module_get_ctx(ac->module);
+       struct ldb_message_element *el = NULL;
+       struct ldb_message *msg;
+       const char *attrs[] = { "servicePrincipalName", NULL };
+       struct ldb_result *res;
+       const char *dns_hostname, *old_dns_hostname;
+       unsigned int i;
+       int ret;
+
+       /* Here it's not the same logic as with "samldb_get_single_valued_attr".
+        * We need to:
+        *
+        * - consider "add" and "replace" operations - the last value we take
+        * - ignore "delete" operations - obviously this attribute isn't
+        *   write protected
+        */
+       for (i = 0; i < ac->msg->num_elements; i++) {
+               if (ldb_attr_cmp(ac->msg->elements[i].name,
+                                "dNSHostName") != 0) {
+                       continue;
+               }
+
+               if (LDB_FLAG_MOD_TYPE(ac->msg->elements[i].flags)
+                   != LDB_FLAG_MOD_DELETE) {
+                       el = &ac->msg->elements[i];
+               }
+       }
+       if (el == NULL) {
+               /* we are not affected */
+               return LDB_SUCCESS;
+       }
+
+       /* Create a temporary message for fetching the "dNSHostName" */
+       msg = ldb_msg_new(ac->msg);
+       if (msg == NULL) {
+               return ldb_module_oom(ac->module);
+       }
+       ret = ldb_msg_add(msg, el, 0);
+       if (ret != LDB_SUCCESS) {
+               return ret;
+       }
+       dns_hostname = ldb_msg_find_attr_as_string(msg, "dNSHostName", "");
+       talloc_free(msg);
+
+       old_dns_hostname = samdb_search_string(ldb, ac, ac->msg->dn,
+                                              "dNSHostName", NULL);
+       if ((old_dns_hostname == NULL) || (strcasecmp(old_dns_hostname,
+                                                     dns_hostname) == 0)) {
+               /* Well, if there's no old DNS hostname then we cannot do this.
+                * And if old and new DNS name do match we are also finished
+                * here. */
+               return LDB_SUCCESS;
+       }
+
+       /* Potential "servicePrincipalName" changes in the same request have to
+        * be handled before the update (Windows behaviour). */
+       el = ldb_msg_find_element(ac->msg, "servicePrincipalName");
+       if (el != NULL) {
+               msg = ldb_msg_new(ac->msg);
+               if (msg == NULL) {
+                       return ldb_module_oom(ac->module);
+               }
+               msg->dn = ac->msg->dn;
+
+               do {
+                       ret = ldb_msg_add(msg, el, el->flags);
+                       if (ret != LDB_SUCCESS) {
+                               return ret;
+                       }
+
+                       ldb_msg_remove_element(ac->msg, el);
+
+                       el = ldb_msg_find_element(ac->msg,
+                                                 "servicePrincipalName");
+               } while (el != NULL);
+
+               ret = dsdb_module_modify(ac->module, msg,
+                                        DSDB_FLAG_NEXT_MODULE);
+               if (ret != LDB_SUCCESS) {
+                       return ret;
+               }
+               talloc_free(msg);
+       }
+
+       /* Fetch the "servicePrincipalName"s if any */
+       ret = ldb_search(ldb, ac, &res, ac->msg->dn, LDB_SCOPE_BASE, attrs,
+                        NULL);
+       if (ret != LDB_SUCCESS) {
+               return ret;
+       }
+       if ((res->count != 1) || (res->msgs[0]->num_elements > 1)) {
+               return ldb_operr(ldb);
+       }
+
+       if (res->msgs[0]->num_elements == 1) {
+               /* Yes, we do have "servicePrincipalName"s. First we update them
+                * locally, that means we do always substitute the current
+                * "dNSHostName" with the new one and then we append this to the
+                * modification request (Windows behaviour). */
+
+               for (i = 0; i < res->msgs[0]->elements[0].num_values; i++) {
+                       char *old_str, *new_str, *pos;
+                       const char *tok;
+
+                       old_str = (char *)
+                               res->msgs[0]->elements[0].values[i].data;
+
+                       new_str = talloc_strdup(ac->msg,
+                                               strtok_r(old_str, "/", &pos));
+                       if (new_str == NULL) {
+                               return ldb_module_oom(ac->module);
+                       }
+
+                       while ((tok = strtok_r(NULL, "/", &pos)) != NULL) {
+                               if (strcasecmp(tok, old_dns_hostname) == 0) {
+                                       tok = dns_hostname;
+                               }
+
+                               new_str = talloc_asprintf(ac->msg, "%s/%s",
+                                                         new_str, tok);
+                               if (new_str == NULL) {
+                                       return ldb_module_oom(ac->module);
+                               }
+                       }
+
+                       ret = ldb_msg_add_string(ac->msg,
+                                                "servicePrincipalName",
+                                                new_str);
+                       if (ret != LDB_SUCCESS) {
+                               return ret;
+                       }
+               }
+
+               el = ldb_msg_find_element(ac->msg, "servicePrincipalName");
+               el->flags = LDB_FLAG_MOD_REPLACE;
+       }
+
+       talloc_free(res);
+
+       return LDB_SUCCESS;
+}
+
 
 /* add */
 static int samldb_add(struct ldb_module *module, struct ldb_request *req)
@@ -1627,6 +1776,15 @@ static int samldb_modify(struct ldb_module *module, 
struct ldb_request *req)
                }
        }
 
+       el = ldb_msg_find_element(ac->msg, "dNSHostName");
+       if (el != NULL) {
+               modified = true;
+               ret = samldb_service_principal_names_change(ac);
+               if (ret != LDB_SUCCESS) {
+                       return ret;
+               }
+       }
+
        if (modified) {
                struct ldb_request *child_req;
 
diff --git a/source4/dsdb/tests/python/sam.py b/source4/dsdb/tests/python/sam.py
index bbcc4a8..ac4b286 100755
--- a/source4/dsdb/tests/python/sam.py
+++ b/source4/dsdb/tests/python/sam.py
@@ -97,7 +97,7 @@ class SamTests(unittest.TestCase):
 
         self.delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn)
         self.delete_force(self.ldb, "cn=ldaptestuser2,cn=users," + 
self.base_dn)
-        self.delete_force(self.ldb, "cn=ldaptestcomputer,cn=users," + 
self.base_dn)
+        self.delete_force(self.ldb, "cn=ldaptestcomputer,cn=computers," + 
self.base_dn)
         self.delete_force(self.ldb, "cn=ldaptestgroup,cn=users," + 
self.base_dn)
         self.delete_force(self.ldb, "cn=ldaptestgroup2,cn=users," + 
self.base_dn)
 
@@ -1788,6 +1788,156 @@ class SamTests(unittest.TestCase):
         self.delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn)
         self.delete_force(self.ldb, "cn=ldaptestcomputer,cn=computers," + 
self.base_dn)
 
+    def test_dNSHostName(self):
+        """Test the dNSHostName behaviour"""
+        print "Testing dNSHostName behaviour\n"
+
+        ldb.add({
+            "dn": "cn=ldaptestcomputer,cn=computers," + self.base_dn,
+            "objectclass": "computer",
+            "dNSHostName": "testname.testdom"})
+
+        res = ldb.search("cn=ldaptestcomputer,cn=computers," + self.base_dn,
+                          scope=SCOPE_BASE, attrs=["servicePrincipalName"])
+        self.assertTrue(len(res) == 1)
+        self.assertFalse("servicePrincipalName" in res[0])
+
+        self.delete_force(self.ldb, "cn=ldaptestcomputer,cn=computers," + 
self.base_dn)
+
+        ldb.add({
+            "dn": "cn=ldaptestcomputer,cn=computers," + self.base_dn,
+            "objectclass": "computer",
+            "servicePrincipalName": "HOST/testname.testdom"})
+
+        res = ldb.search("cn=ldaptestcomputer,cn=computers," + self.base_dn,
+                          scope=SCOPE_BASE, attrs=["dNSHostName"])
+        self.assertTrue(len(res) == 1)
+        self.assertFalse("dNSHostName" in res[0])
+
+        self.delete_force(self.ldb, "cn=ldaptestcomputer,cn=computers," + 
self.base_dn)
+
+        ldb.add({
+            "dn": "cn=ldaptestcomputer,cn=computers," + self.base_dn,
+            "objectclass": "computer",
+            "dNSHostName": "testname2.testdom",
+            "servicePrincipalName": "HOST/testname.testdom"})
+
+        res = ldb.search("cn=ldaptestcomputer,cn=computers," + self.base_dn,
+                          scope=SCOPE_BASE, attrs=["dNSHostName"])
+        self.assertTrue(len(res) == 1)
+        self.assertEquals(res[0]["dNSHostName"][0], "testname2.testdom")
+
+        res = ldb.search("cn=ldaptestcomputer,cn=computers," + self.base_dn,
+                          scope=SCOPE_BASE, attrs=["servicePrincipalName"])
+        self.assertTrue(len(res) == 1)
+        self.assertEquals(res[0]["servicePrincipalName"][0],
+                          "HOST/testname.testdom")
+
+        m = Message()
+        m.dn = Dn(ldb, "cn=ldaptestcomputer,cn=computers," + self.base_dn)
+        m["dNSHostName"] = MessageElement("testname.testdoM",
+                                          FLAG_MOD_REPLACE, "dNSHostName")
+        ldb.modify(m)
+
+        res = ldb.search("cn=ldaptestcomputer,cn=computers," + self.base_dn,
+                          scope=SCOPE_BASE, attrs=["servicePrincipalName"])
+        self.assertTrue(len(res) == 1)
+        self.assertEquals(res[0]["servicePrincipalName"][0],
+                          "HOST/testname.testdom")
+
+        m = Message()
+        m.dn = Dn(ldb, "cn=ldaptestcomputer,cn=computers," + self.base_dn)
+        m["dNSHostName"] = MessageElement("testname2.testdom2",
+                                          FLAG_MOD_REPLACE, "dNSHostName")
+        ldb.modify(m)
+
+        res = ldb.search("cn=ldaptestcomputer,cn=computers," + self.base_dn,
+                          scope=SCOPE_BASE, attrs=["servicePrincipalName"])
+        self.assertTrue(len(res) == 1)
+        self.assertEquals(res[0]["servicePrincipalName"][0],
+                          "HOST/testname2.testdom2")
+
+        m = Message()
+        m.dn = Dn(ldb, "cn=ldaptestcomputer,cn=computers," + self.base_dn)
+        m["dNSHostName"] = MessageElement([],
+                                          FLAG_MOD_DELETE, "dNSHostName")
+        ldb.modify(m)
+
+        res = ldb.search("cn=ldaptestcomputer,cn=computers," + self.base_dn,
+                          scope=SCOPE_BASE, attrs=["servicePrincipalName"])
+        self.assertTrue(len(res) == 1)
+        self.assertEquals(res[0]["servicePrincipalName"][0],
+                          "HOST/testname2.testdom2")
+
+        m = Message()
+        m.dn = Dn(ldb, "cn=ldaptestcomputer,cn=computers," + self.base_dn)
+        m["dNSHostName"] = MessageElement("testname.testdom3",
+                                          FLAG_MOD_REPLACE, "dNSHostName")
+        ldb.modify(m)
+
+        res = ldb.search("cn=ldaptestcomputer,cn=computers," + self.base_dn,
+                          scope=SCOPE_BASE, attrs=["servicePrincipalName"])
+        self.assertTrue(len(res) == 1)
+        self.assertEquals(res[0]["servicePrincipalName"][0],
+                          "HOST/testname2.testdom2")
+
+        m = Message()
+        m.dn = Dn(ldb, "cn=ldaptestcomputer,cn=computers," + self.base_dn)
+        m["dNSHostName"] = MessageElement("testname2.testdom2",
+                                          FLAG_MOD_REPLACE, "dNSHostName")
+        ldb.modify(m)
+
+        m = Message()
+        m.dn = Dn(ldb, "cn=ldaptestcomputer,cn=computers," + self.base_dn)
+        m["dNSHostName"] = MessageElement("testname3.testdom3",
+                                          FLAG_MOD_REPLACE, "dNSHostName")
+        m["servicePrincipalName"] = MessageElement("HOST/testname2.testdom2",
+                                                   FLAG_MOD_REPLACE,
+                                                   "servicePrincipalName")
+        ldb.modify(m)
+
+        res = ldb.search("cn=ldaptestcomputer,cn=computers," + self.base_dn,
+                          scope=SCOPE_BASE, attrs=["servicePrincipalName"])
+        self.assertTrue(len(res) == 1)
+        self.assertEquals(res[0]["servicePrincipalName"][0],
+                          "HOST/testname3.testdom3")
+
+        m = Message()
+        m.dn = Dn(ldb, "cn=ldaptestcomputer,cn=computers," + self.base_dn)
+        m["servicePrincipalName"] = MessageElement("HOST/testname2.testdom2",
+                                                   FLAG_MOD_REPLACE,
+                                                   "servicePrincipalName")
+        m["dNSHostName"] = MessageElement("testname4.testdom4",
+                                          FLAG_MOD_REPLACE, "dNSHostName")
+        ldb.modify(m)
+
+        res = ldb.search("cn=ldaptestcomputer,cn=computers," + self.base_dn,
+                          scope=SCOPE_BASE, attrs=["servicePrincipalName"])
+        self.assertTrue(len(res) == 1)
+        self.assertEquals(res[0]["servicePrincipalName"][0],
+                          "HOST/testname2.testdom2")
+
+        m = Message()
+        m.dn = Dn(ldb, "cn=ldaptestcomputer,cn=computers," + self.base_dn)
+        m["servicePrincipalName"] = MessageElement([],
+                                                   FLAG_MOD_DELETE,
+                                                   "servicePrincipalName")
+        ldb.modify(m)
+
+        m = Message()
+        m.dn = Dn(ldb, "cn=ldaptestcomputer,cn=computers," + self.base_dn)
+        m["dNSHostName"] = MessageElement("testname2.testdom2",
+                                          FLAG_MOD_REPLACE, "dNSHostName")
+        ldb.modify(m)
+
+        res = ldb.search("cn=ldaptestcomputer,cn=computers," + self.base_dn,
+                          scope=SCOPE_BASE, attrs=["servicePrincipalName"])
+        self.assertTrue(len(res) == 1)
+        self.assertFalse("servicePrincipalName" in res[0])
+
+        self.delete_force(self.ldb, "cn=ldaptestcomputer,cn=computers," + 
self.base_dn)
+
+
 if not "://" in host:
     if os.path.isfile(host):
         host = "tdb://%s" % host
diff --git a/source4/libnet/libnet_join.c b/source4/libnet/libnet_join.c
index 50b5c1f..2353044 100644
--- a/source4/libnet/libnet_join.c
+++ b/source4/libnet/libnet_join.c
@@ -272,7 +272,7 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context 
*ctx, struct libnet_J
 
        {
                unsigned int i;
-               const char *service_principal_name[6];
+               const char *service_principal_name[2];
                const char *dns_host_name = strlower_talloc(tmp_ctx, 
                                                            
talloc_asprintf(tmp_ctx, 
                                                                            
"%s.%s", 
@@ -285,12 +285,10 @@ static NTSTATUS libnet_JoinADSDomain(struct 
libnet_context *ctx, struct libnet_J
                        return NT_STATUS_NO_MEMORY;
                }
 
-               service_principal_name[0] = talloc_asprintf(tmp_ctx, "host/%s", 
dns_host_name);
-               service_principal_name[1] = talloc_asprintf(tmp_ctx, "host/%s", 
strlower_talloc(tmp_ctx, r->in.netbios_name));
-               service_principal_name[2] = talloc_asprintf(tmp_ctx, 
"host/%s/%s", dns_host_name, realm);
-               service_principal_name[3] = talloc_asprintf(tmp_ctx, 
"host/%s/%s", strlower_talloc(tmp_ctx, r->in.netbios_name), realm);
-               service_principal_name[4] = talloc_asprintf(tmp_ctx, 
"host/%s/%s", dns_host_name, r->out.domain_name);
-               service_principal_name[5] = talloc_asprintf(tmp_ctx, 
"host/%s/%s", strlower_talloc(tmp_ctx, r->in.netbios_name), r->out.domain_name);
+               service_principal_name[0] = talloc_asprintf(tmp_ctx, "HOST/%s",
+                                                           dns_host_name);
+               service_principal_name[1] = talloc_asprintf(tmp_ctx, "HOST/%s",
+                                                           r->in.netbios_name);
                
                for (i=0; i < ARRAY_SIZE(service_principal_name); i++) {
                        if (!service_principal_name[i]) {
@@ -306,7 +304,8 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context 
*ctx, struct libnet_J
                        }
                }
 
-               rtn = samdb_msg_add_string(remote_ldb, tmp_ctx, msg, 
"dNSHostName", dns_host_name);
+               rtn = samdb_msg_add_string(remote_ldb, tmp_ctx, msg,
+                                          "dNSHostName", dns_host_name);
                if (rtn != LDB_SUCCESS) {
                        r->out.error_string = NULL;
                        talloc_free(tmp_ctx);
diff --git a/source4/rpc_server/drsuapi/writespn.c 
b/source4/rpc_server/drsuapi/writespn.c
index 71ff49d..2e7bd76 100644
--- a/source4/rpc_server/drsuapi/writespn.c
+++ b/source4/rpc_server/drsuapi/writespn.c
@@ -47,7 +47,9 @@ WERROR dcesrv_drsuapi_DsWriteAccountSpn(struct 
dcesrv_call_state *dce_call, TALL
                case 1: {
                        struct drsuapi_DsWriteAccountSpnRequest1 *req;
                        struct ldb_message *msg;
-                       int count, i, ret;
+                       uint32_t count;
+                       unsigned int i;
+                       int ret;
                        unsigned spn_count=0;
 
                        req = &r->in.req->req1;
@@ -96,8 +98,9 @@ WERROR dcesrv_drsuapi_DsWriteAccountSpn(struct 
dcesrv_call_state *dce_call, TALL
                        }
 
                        /* Apply to database */
-                       ret = dsdb_modify(b_state->sam_ctx, msg, 
DSDB_MODIFY_PERMISSIVE);
-                       if (ret != 0) {
+                       ret = dsdb_modify(b_state->sam_ctx, msg,
+                                         DSDB_MODIFY_PERMISSIVE);
+                       if (ret != LDB_SUCCESS) {
                                DEBUG(0,("Failed to modify SPNs on %s: %s\n",
                                         ldb_dn_get_linearized(msg->dn),
                                         ldb_errstring(b_state->sam_ctx)));
diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c 
b/source4/rpc_server/netlogon/dcerpc_netlogon.c
index 2f80c1b..79d2cbc 100644
--- a/source4/rpc_server/netlogon/dcerpc_netlogon.c
+++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c
@@ -1366,8 +1366,9 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct 
dcesrv_call_state *dce_cal
                }
 
                /* Gets the old DNS hostname */
-               old_dns_hostname = ldb_msg_find_attr_as_string(res1[0], 
"dNSHostName",
-                       NULL);
+               old_dns_hostname = ldb_msg_find_attr_as_string(res1[0],
+                                                              "dNSHostName",
+                                                              NULL);
 
                /*
                 * Updates the DNS hostname when the client wishes that the
@@ -1391,9 +1392,12 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct 
dcesrv_call_state *dce_cal
                new_msg->dn = workstation_dn;
 
                /* Sets the OS name */
-               samdb_msg_set_string(sam_ctx, mem_ctx, new_msg,
-                       "operatingSystem",
-                       r->in.query->workstation_info->os_name.string);
+               ret = samdb_msg_set_string(sam_ctx, mem_ctx, new_msg,
+                                          "operatingSystem",
+                                          
r->in.query->workstation_info->os_name.string);
+               if (ret != LDB_SUCCESS) {
+                       return NT_STATUS_NO_MEMORY;
+               }
 
                /*
                 * Sets informations from "os_version". On an empty structure
@@ -1402,24 +1406,35 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct 
dcesrv_call_state *dce_cal
                if (r->in.query->workstation_info->os_version.os != NULL) {
                        os_version = 
&r->in.query->workstation_info->os_version.os->os;
 
-                       samdb_msg_set_string(sam_ctx, mem_ctx, new_msg,
-                                            "operatingSystemServicePack",
-                                            os_version->CSDVersion);
-
-                       samdb_msg_set_string(sam_ctx, mem_ctx, new_msg,
-                               "operatingSystemVersion",
-                               talloc_asprintf(mem_ctx, "%d.%d (%d)",
-                                       os_version->MajorVersion,
-                                       os_version->MinorVersion,
-                                       os_version->BuildNumber
-                               )
-                       );
+                       ret = samdb_msg_set_string(sam_ctx, mem_ctx, new_msg,
+                                                  "operatingSystemServicePack",
+                                                  os_version->CSDVersion);
+                       if (ret != LDB_SUCCESS) {
+                               return NT_STATUS_NO_MEMORY;
+                       }
+
+                       ret = samdb_msg_set_string(sam_ctx, mem_ctx, new_msg,
+                                                  "operatingSystemVersion",
+                                                  talloc_asprintf(mem_ctx,


-- 
Samba Shared Repository

Reply via email to