s4:dsdb - always handle the attribute "options" as 32bit unsigned integer
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Tue, 1 Mar 2011 10:40:23 +0000 (11:40 +0100)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Tue, 1 Mar 2011 11:46:15 +0000 (12:46 +0100)
It is defined as LDAP syntax 2.5.5.9 so no need at all to treat it as
64-bit integer.

Reviewed by: Kamenim and Metze

Autobuild-User: Matthias Dieter Wallnöfer <mdw@samba.org>
Autobuild-Date: Tue Mar  1 12:46:15 CET 2011 on sn-devel-104

source4/dsdb/common/util.c
source4/dsdb/kcc/kcc_connection.c
source4/dsdb/kcc/kcc_topology.c
source4/rpc_server/drsuapi/dcesrv_drsuapi.c

index fb742f92bd509ba5711c31ee08723fd0558f2f00..d0efa057e7b4d7843f43c90a65370a154c5beba4 100644 (file)
@@ -1862,7 +1862,8 @@ failed:
 bool samdb_is_gc(struct ldb_context *ldb)
 {
        const char *attrs[] = { "options", NULL };
-       int ret, options;
+       uint32_t options;
+       int ret;
        struct ldb_result *res;
        TALLOC_CTX *tmp_ctx;
 
@@ -1883,7 +1884,7 @@ bool samdb_is_gc(struct ldb_context *ldb)
                return false;
        }
 
-       options = ldb_msg_find_attr_as_int(res->msgs[0], "options", 0);
+       options = ldb_msg_find_attr_as_uint(res->msgs[0], "options", 0);
        talloc_free(tmp_ctx);
 
        /* if options attribute has the 0x00000001 flag set, then enable the global catlog */
index 3c30909028348248052e37cca5db4480df87cc58..66cd41557f081ebff415fb9535e999c8913ce071 100644 (file)
@@ -80,7 +80,7 @@ static int kccsrv_add_connection(struct kccsrv_service *s,
        ldb_msg_add_string(msg, "enabledConnection", "TRUE");
        ldb_msg_add_linearized_dn(msg, "fromServer", server_dn);
        /* ldb_msg_add_value(msg, "schedule", &schedule_val, NULL); */
-       ldb_msg_add_string(msg, "options", "1");
+       samdb_msg_add_uint(s->samdb, msg, msg, "options", 1);
 
        ret = ldb_add(s->samdb, msg);
        if (ret == LDB_SUCCESS) {
index c13e330625acfebc0559104e2eb153a2232a1e35..6cf3d4115806ee5afe96c7fec20df18c30d4ecc0 100644 (file)
@@ -257,13 +257,14 @@ static int kcctpl_sort_bridgeheads(const void *bridgehead1,
                                   const void *bridgehead2)
 {
        const struct ldb_message *bh1, *bh2;
-       uint64_t bh1_opts, bh2_opts, cmp_gc;
+       uint32_t bh1_opts, bh2_opts;
+       int cmp_gc;
 
        bh1 = (const struct ldb_message *) bridgehead1;
        bh2 = (const struct ldb_message *) bridgehead2;
 
-       bh1_opts = ldb_msg_find_attr_as_int64(bh1, "options", 0);
-       bh2_opts = ldb_msg_find_attr_as_int64(bh2, "options", 0);
+       bh1_opts = ldb_msg_find_attr_as_uint(bh1, "options", 0);
+       bh2_opts = ldb_msg_find_attr_as_uint(bh2, "options", 0);
 
        cmp_gc = (bh1_opts & NTDSDSA_OPT_IS_GC) -
                 (bh2_opts & NTDSDSA_OPT_IS_GC);
@@ -619,7 +620,7 @@ static NTSTATUS kcctpl_create_edge(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
        }
 
        edge->repl_info.cost = ldb_msg_find_attr_as_int64(site_link, "cost", 0);
-       edge->repl_info.options = ldb_msg_find_attr_as_int64(site_link, "options", 0);
+       edge->repl_info.options = ldb_msg_find_attr_as_uint(site_link, "options", 0);
        edge->repl_info.interval = ldb_msg_find_attr_as_int64(site_link,
                                                      "replInterval", 0);
        /* TODO: edge->repl_info.schedule = site_link!schedule */
@@ -795,7 +796,7 @@ static NTSTATUS kcctpl_setup_graph(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
        unsigned int i;
        NTSTATUS status;
        struct ldb_message *site;
-       uint64_t site_opts;
+       uint32_t site_opts;
 
        tmp_ctx = talloc_new(mem_ctx);
        NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
@@ -850,7 +851,7 @@ static NTSTATUS kcctpl_setup_graph(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
                talloc_free(tmp_ctx);
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
-       site_opts = ldb_msg_find_attr_as_int64(site, "options", 0);
+       site_opts = ldb_msg_find_attr_as_uint(site, "options", 0);
 
        transports_dn = kcctpl_transports_dn(ldb, tmp_ctx);
        if (!transports_dn) {
@@ -878,7 +879,7 @@ static NTSTATUS kcctpl_setup_graph(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
                struct ldb_result *res_site_link;
                struct GUID transport_guid;
                unsigned int j;
-               uint64_t transport_opts;
+               uint32_t transport_opts;
 
                transport = res->msgs[i];
 
@@ -918,7 +919,7 @@ static NTSTATUS kcctpl_setup_graph(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
                        graph->edges.count++;
                }
 
-               transport_opts = ldb_msg_find_attr_as_int64(transport, "options", 0);
+               transport_opts = ldb_msg_find_attr_as_uint(transport, "options", 0);
                if (!(transport_opts & NTDSTRANSPORT_OPT_BRIDGES_REQUIRED) &&
                    !(site_opts & NTDSSETTINGS_OPT_W2K3_BRIDGES_REQUIRED)) {
                        struct kcctpl_multi_edge_set *edge_set, *new_data;
@@ -1008,7 +1009,7 @@ static NTSTATUS kcctpl_bridgehead_dc_failed(struct ldb_context *ldb,
        const char * const attrs[] = { "options", NULL };
        int ret;
        struct ldb_message *settings;
-       uint64_t settings_opts;
+       uint32_t settings_opts;
        bool failed;
 
        tmp_ctx = talloc_new(ldb);
@@ -1040,7 +1041,7 @@ static NTSTATUS kcctpl_bridgehead_dc_failed(struct ldb_context *ldb,
 
        settings = res->msgs[0];
 
-       settings_opts = ldb_msg_find_attr_as_int64(settings, "options", 0);
+       settings_opts = ldb_msg_find_attr_as_uint(settings, "options", 0);
        if (settings_opts & NTDSSETTINGS_OPT_IS_TOPL_DETECT_STALE_DISABLED) {
                failed = false;
        } else if (true) { /* TODO: how to get kCCFailedLinks and
@@ -1078,7 +1079,7 @@ static NTSTATUS kcctpl_get_all_bridgehead_dcs(struct kccsrv_service *service,
        struct ldb_message_element *el;
        unsigned int i;
        const char *transport_name, *transport_address_attr;
-       uint64_t site_opts;
+       uint32_t site_opts;
 
        ZERO_STRUCT(bridgeheads);
 
@@ -1176,7 +1177,7 @@ static NTSTATUS kcctpl_get_all_bridgehead_dcs(struct kccsrv_service *service,
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
 
-       site_opts = ldb_msg_find_attr_as_int64(site, "options", 0);
+       site_opts = ldb_msg_find_attr_as_uint(site, "options", 0);
 
        for (i = 0; i < res->count; i++) {
                struct ldb_message *dc, *new_data;
@@ -2869,13 +2870,13 @@ static NTSTATUS kcctpl_create_connection(struct kccsrv_service *service,
                                                    parent_dn) &&
                    kcctpl_message_list_contains_dn(r_bridgeheads_all,
                                                    from_server)) {
-                       uint64_t conn_opts;
+                       uint32_t conn_opts;
                        /* TODO: initialize conn_schedule from connection */
                        uint8_t conn_schedule[84];
                        struct ldb_dn *conn_transport_type;
 
-                       conn_opts = ldb_msg_find_attr_as_int64(connection,
-                                                      "options", 0);
+                       conn_opts = ldb_msg_find_attr_as_uint(connection,
+                                                             "options", 0);
 
                        conn_transport_type = samdb_result_dn(service->samdb, tmp_ctx,
                                                              connection,
@@ -2982,11 +2983,11 @@ static NTSTATUS kcctpl_create_connection(struct kccsrv_service *service,
                                                    parent_dn) &&
                    kcctpl_message_list_contains_dn(r_bridgeheads_all,
                                                    from_server)) {
-                       uint64_t conn_opts;
+                       uint32_t conn_opts;
                        struct ldb_dn *conn_transport_type;
 
-                       conn_opts = ldb_msg_find_attr_as_int64(connection,
-                                                      "options", 0);
+                       conn_opts = ldb_msg_find_attr_as_uint(connection,
+                                                             "options", 0);
 
                        conn_transport_type = samdb_result_dn(service->samdb, tmp_ctx,
                                                              connection,
index 592edb5879fd51ab77c173174655d2f7939f40f2..63eed63394cc9d00eee8ef56625c642f7076d13a 100644 (file)
@@ -702,7 +702,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta
                                                 LDB_SCOPE_BASE, attrs_ntds, "objectClass=nTDSDSA");
                        if (ret == LDB_SUCCESS && res_ntds->count == 1) {
                                ctr2->array[i].is_gc
-                                       = (ldb_msg_find_attr_as_int(res_ntds->msgs[0], "options", 0) == 1);
+                                       = (ldb_msg_find_attr_as_uint(res_ntds->msgs[0], "options", 0) == 1);
                                ctr2->array[i].ntds_guid 
                                        = samdb_result_guid(res_ntds->msgs[0], "objectGUID");
                                ctr2->array[i].ntds_dn = ldb_dn_get_linearized(res_ntds->msgs[0]->dn);