s4:param: pass flags via secrets_db_connect() to ldb_wrap_connect()
[metze/samba/wip.git] / auth / credentials / credentials_secrets.c
index 58a87ac9fdb9d21f8fca771fc216f0876a39b464..270c1b3f13628fee2d7bede0f50ccd8f285ef245 100644 (file)
@@ -84,7 +84,7 @@ static NTSTATUS cli_credentials_set_secrets_lct(struct cli_credentials *cred,
 
        if (!ldb) {
                /* Local secrets are stored in secrets.ldb */
-               ldb = secrets_db_connect(mem_ctx, lp_ctx);
+               ldb = secrets_db_connect(mem_ctx, lp_ctx, 0);
                if (!ldb) {
                        *error_string = talloc_strdup(cred, "Could not open secrets.ldb");
                        talloc_free(mem_ctx);
@@ -120,7 +120,10 @@ static NTSTATUS cli_credentials_set_secrets_lct(struct cli_credentials *cred,
                return NT_STATUS_NOT_FOUND;
        }
 
-       if (lct == secrets_tdb_last_change_time && secrets_tdb_password && strcmp(password, secrets_tdb_password) != 0) {
+       if ((lct == secrets_tdb_last_change_time) &&
+           (secrets_tdb_password != NULL) &&
+           (password != NULL) &&
+           (strcmp(password, secrets_tdb_password) != 0)) {
                talloc_free(mem_ctx);
                return NT_STATUS_NOT_FOUND;
        }
@@ -235,16 +238,25 @@ _PUBLIC_ NTSTATUS cli_credentials_set_machine_account(struct cli_credentials *cr
 {
        struct db_context *db_ctx;
        char *secrets_tdb_path;
+       int hash_size, tdb_flags;
 
        secrets_tdb_path = lpcfg_private_db_path(cred, lp_ctx, "secrets");
        if (secrets_tdb_path == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
 
-       db_ctx = dbwrap_local_open(cred, lp_ctx, secrets_tdb_path, 0,
-                                  TDB_DEFAULT, O_RDWR, 0600,
-                                  DBWRAP_LOCK_ORDER_1,
-                                  DBWRAP_FLAG_NONE);
+       hash_size = lpcfg_tdb_hash_size(lp_ctx, secrets_tdb_path);
+       tdb_flags = lpcfg_tdb_flags(lp_ctx, TDB_DEFAULT);
+
+       db_ctx = dbwrap_local_open(
+               cred,
+               secrets_tdb_path,
+               hash_size,
+               tdb_flags,
+               O_RDWR,
+               0600,
+               DBWRAP_LOCK_ORDER_1,
+               DBWRAP_FLAG_NONE);
        TALLOC_FREE(secrets_tdb_path);
 
        /*