lib/ldb-samba: Align py_ldb_set_opaque_integer() with pyldb_set_opaque() and use...
authorAndrew Bartlett <abartlet@samba.org>
Mon, 4 Mar 2024 01:27:19 +0000 (14:27 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 5 Mar 2024 02:54:36 +0000 (02:54 +0000)
We need to change the internal types assumed in Samba for the opaque
integers to "unsigned long long" as this is what ldb.set_opaque() will
create, and we want to move to this interface rather than have a
duplicate.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
lib/ldb-samba/pyldb.c
source4/dsdb/common/util.c
source4/dsdb/samdb/ldb_modules/repl_meta_data.c
source4/dsdb/samdb/ldb_modules/rootdse.c

index 2241abc01df2b3255605371f119e55a887a2e5c9..fe6f44b57ca41fa6b4f4e351efbe8259f5d2694d 100644 (file)
@@ -95,7 +95,7 @@ static PyObject *py_ldb_set_credentials(PyObject *self, PyObject *args)
 static PyObject *py_ldb_set_opaque_integer(PyObject *self, PyObject *args)
 {
        int value;
-       int *old_val, *new_val;
+       unsigned long long *old_val, *new_val;
        char *py_opaque_name, *opaque_name_talloc;
        struct ldb_context *ldb;
        int ret;
@@ -107,7 +107,7 @@ static PyObject *py_ldb_set_opaque_integer(PyObject *self, PyObject *args)
        ldb = pyldb_Ldb_AS_LDBCONTEXT(self);
 
        /* see if we have a cached copy */
-       old_val = (int *)ldb_get_opaque(ldb, py_opaque_name);
+       old_val = (unsigned long long *)ldb_get_opaque(ldb, py_opaque_name);
        /* XXX: We shouldn't just blindly assume that the value that is 
         * already present has the size of an int and is not shared 
         * with other code that may rely on it not changing. 
@@ -124,7 +124,7 @@ static PyObject *py_ldb_set_opaque_integer(PyObject *self, PyObject *args)
                return NULL;
        }
 
-       new_val = talloc(tmp_ctx, int);
+       new_val = talloc(tmp_ctx, unsigned long long);
        if (new_val == NULL) {
                talloc_free(tmp_ctx);
                PyErr_NoMemory();
index fff0abaedaa3e28b123b1839a1374772b03664b7..d31d7d94f2d6985ec598d8fe02dfa7b952e21a17 100644 (file)
@@ -4122,8 +4122,8 @@ const char *samdb_cn_to_lDAPDisplayName(TALLOC_CTX *mem_ctx, const char *cn)
  */
 int dsdb_functional_level(struct ldb_context *ldb)
 {
-       int *domainFunctionality =
-               talloc_get_type(ldb_get_opaque(ldb, "domainFunctionality"), int);
+       unsigned long long *domainFunctionality =
+               talloc_get_type(ldb_get_opaque(ldb, "domainFunctionality"), unsigned long long);
        if (!domainFunctionality) {
                /* this is expected during initial provision */
                DEBUG(4,(__location__ ": WARNING: domainFunctionality not setup\n"));
@@ -4137,8 +4137,8 @@ int dsdb_functional_level(struct ldb_context *ldb)
  */
 int dsdb_forest_functional_level(struct ldb_context *ldb)
 {
-       int *forestFunctionality =
-               talloc_get_type(ldb_get_opaque(ldb, "forestFunctionality"), int);
+       unsigned long long *forestFunctionality =
+               talloc_get_type(ldb_get_opaque(ldb, "forestFunctionality"), unsigned long long);
        if (!forestFunctionality) {
                DEBUG(0,(__location__ ": WARNING: forestFunctionality not setup\n"));
                return DS_DOMAIN_FUNCTION_2000;
@@ -4151,8 +4151,8 @@ int dsdb_forest_functional_level(struct ldb_context *ldb)
  */
 int dsdb_dc_functional_level(struct ldb_context *ldb)
 {
-       int *dcFunctionality =
-               talloc_get_type(ldb_get_opaque(ldb, "domainControllerFunctionality"), int);
+       unsigned long long *dcFunctionality =
+               talloc_get_type(ldb_get_opaque(ldb, "domainControllerFunctionality"), unsigned long long);
        if (!dcFunctionality) {
                /* this is expected during initial provision */
                DEBUG(4,(__location__ ": WARNING: domainControllerFunctionality not setup\n"));
@@ -4296,7 +4296,7 @@ int dsdb_check_and_update_fl(struct ldb_context *ldb_ctx, struct loadparm_contex
         * will not re-read the DB
         */
        {
-               int *val = talloc(ldb_ctx, int);
+               unsigned long long *val = talloc(ldb_ctx, unsigned long long);
                if (!val) {
                        TALLOC_FREE(frame);
                        return LDB_ERR_OPERATIONS_ERROR;
index 7aec0063c9684ba23056941b4ee7cba34185b4ee..57098f0a8b789da51038aba9f01de1eebae4728a 100644 (file)
@@ -7644,10 +7644,10 @@ static int replmd_allow_missing_target(struct ldb_module *module,
                 * replication is completed, so failing now would just
                 * trigger errors, rather than trigger a GET_TGT
                 */
-               int *finished_full_join_ptr =
+               unsigned long long *finished_full_join_ptr =
                        talloc_get_type(ldb_get_opaque(ldb,
                                                       DSDB_FULL_JOIN_REPLICATION_COMPLETED_OPAQUE_NAME),
-                                       int);
+                                       unsigned long long);
                bool finished_full_join = finished_full_join_ptr && *finished_full_join_ptr;
 
                /*
index d80d2af485ce949a8d839dc13bc3fb9df20197b9..7541a2cf3762babe0e6c53f637ec81b4bc1fbfcb 100644 (file)
@@ -234,7 +234,7 @@ static int rootdse_add_dynamic(struct rootdse_context *ac, struct ldb_message *m
        const char * const *attrs = ac->req->op.search.attrs;
        const char **server_sasl = NULL;
        const struct dsdb_schema *schema;
-       int *val;
+       unsigned long long *val;
        struct ldb_control *edn_control;
        const char *dn_attrs[] = {
                "configurationNamingContext",
@@ -452,7 +452,7 @@ static int rootdse_add_dynamic(struct rootdse_context *ac, struct ldb_message *m
        }
 
        if (do_attribute(attrs, "domainControllerFunctionality")
-           && (val = talloc_get_type(ldb_get_opaque(ldb, "domainControllerFunctionality"), int))) {
+           && (val = talloc_get_type(ldb_get_opaque(ldb, "domainControllerFunctionality"), unsigned long long))) {
                if (samdb_msg_add_int(ldb, msg, msg,
                                      "domainControllerFunctionality",
                                      *val) != LDB_SUCCESS) {
@@ -1039,7 +1039,8 @@ static int rootdse_init(struct ldb_module *module)
                        = ldb_msg_find_attr_as_int(res->msgs[0],
                                                   "msDS-Behavior-Version", -1);
                if (domain_behaviour_version != -1) {
-                       int *val = talloc(ldb, int);
+                       unsigned long long *val
+                               = talloc(ldb, unsigned long long);
                        if (!val) {
                                talloc_free(mem_ctx);
                                return ldb_oom(ldb);
@@ -1064,7 +1065,8 @@ static int rootdse_init(struct ldb_module *module)
                        = ldb_msg_find_attr_as_int(res->msgs[0],
                                                   "msDS-Behavior-Version", -1);
                if (forest_behaviour_version != -1) {
-                       int *val = talloc(ldb, int);
+                       unsigned long long *val
+                               = talloc(ldb, unsigned long long);
                        if (!val) {
                                talloc_free(mem_ctx);
                                return ldb_oom(ldb);
@@ -1107,7 +1109,8 @@ static int rootdse_init(struct ldb_module *module)
                                        = ldb_msg_find_attr_as_int(res->msgs[0],
                                                                   "msDS-Behavior-Version", -1);
                                if (domain_controller_behaviour_version != -1) {
-                                       int *val = talloc(ldb, int);
+                                       unsigned long long *val
+                                               = talloc(ldb, unsigned long long);
                                        if (!val) {
                                                talloc_free(mem_ctx);
                                                return ldb_oom(ldb);