diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/groupdb/mapping_tdb.c | 9 | ||||
-rw-r--r-- | source3/lib/dbwrap/dbwrap.c | 14 | ||||
-rw-r--r-- | source3/lib/dbwrap/dbwrap.h | 12 | ||||
-rw-r--r-- | source3/lib/dbwrap/dbwrap_util.c | 18 | ||||
-rw-r--r-- | source3/lib/privileges.c | 5 | ||||
-rw-r--r-- | source3/lib/sharesec.c | 4 | ||||
-rw-r--r-- | source3/param/loadparm.c | 21 | ||||
-rw-r--r-- | source3/passdb/pdb_tdb.c | 11 | ||||
-rw-r--r-- | source3/printing/printer_list.c | 10 | ||||
-rw-r--r-- | source3/registry/reg_backend_db.c | 15 | ||||
-rw-r--r-- | source3/registry/reg_objects.c | 6 | ||||
-rw-r--r-- | source3/utils/net_idmap_check.c | 5 | ||||
-rw-r--r-- | source3/winbindd/idmap_autorid.c | 10 | ||||
-rw-r--r-- | source3/winbindd/idmap_tdb.c | 8 | ||||
-rw-r--r-- | source3/winbindd/idmap_tdb2.c | 12 |
15 files changed, 93 insertions, 67 deletions
diff --git a/source3/groupdb/mapping_tdb.c b/source3/groupdb/mapping_tdb.c index 47f743d146..8f417a524a 100644 --- a/source3/groupdb/mapping_tdb.c +++ b/source3/groupdb/mapping_tdb.c @@ -173,6 +173,7 @@ static bool get_group_map_from_sid(struct dom_sid sid, GROUP_MAP *map) TDB_DATA dbuf; char *key; int ret = 0; + NTSTATUS status; /* the key is the SID, retrieving is direct */ @@ -181,8 +182,8 @@ static bool get_group_map_from_sid(struct dom_sid sid, GROUP_MAP *map) return false; } - dbuf = dbwrap_fetch_bystring(db, key, key); - if (dbuf.dptr == NULL) { + status = dbwrap_fetch_bystring(db, key, key, &dbuf); + if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(key); return false; } @@ -404,8 +405,8 @@ static NTSTATUS one_alias_membership(const struct dom_sid *member, slprintf(key, sizeof(key), "%s%s", MEMBEROF_PREFIX, sid_to_fstring(tmp, member)); - dbuf = dbwrap_fetch_bystring(db, frame, key); - if (dbuf.dptr == NULL) { + status = dbwrap_fetch_bystring(db, frame, key, &dbuf); + if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(frame); return NT_STATUS_OK; } diff --git a/source3/lib/dbwrap/dbwrap.c b/source3/lib/dbwrap/dbwrap.c index d5e9689895..38404a876c 100644 --- a/source3/lib/dbwrap/dbwrap.c +++ b/source3/lib/dbwrap/dbwrap.c @@ -130,16 +130,18 @@ struct db_record *dbwrap_fetch_locked(struct db_context *db, return db->fetch_locked(db, mem_ctx, key); } -TDB_DATA dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, - TDB_DATA key) +NTSTATUS dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, + TDB_DATA key, TDB_DATA *value) { - TDB_DATA result; + if (value == NULL) { + return NT_STATUS_INVALID_PARAMETER; + } - if (db->fetch(db, mem_ctx, key, &result) != 0) { - return make_tdb_data(NULL, 0); + if (db->fetch(db, mem_ctx, key, value) != 0) { + return NT_STATUS_NOT_FOUND; } - return result; + return NT_STATUS_OK; } bool dbwrap_exists(struct db_context *db, TDB_DATA key) diff --git a/source3/lib/dbwrap/dbwrap.h b/source3/lib/dbwrap/dbwrap.h index 145fabd536..b5fc018158 100644 --- a/source3/lib/dbwrap/dbwrap.h +++ b/source3/lib/dbwrap/dbwrap.h @@ -72,8 +72,8 @@ struct db_record *dbwrap_fetch_locked(struct db_context *db, NTSTATUS dbwrap_delete(struct db_context *db, TDB_DATA key); NTSTATUS dbwrap_store(struct db_context *db, TDB_DATA key, TDB_DATA data, int flags); -TDB_DATA dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, - TDB_DATA key); +NTSTATUS dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, + TDB_DATA key, TDB_DATA *value); bool dbwrap_exists(struct db_context *db, TDB_DATA key); NTSTATUS dbwrap_traverse(struct db_context *db, int (*f)(struct db_record*, void*), @@ -100,8 +100,8 @@ int dbwrap_transaction_cancel(struct db_context *db); NTSTATUS dbwrap_delete_bystring(struct db_context *db, const char *key); NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key, TDB_DATA data, int flags); -TDB_DATA dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx, - const char *key); +NTSTATUS dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx, + const char *key, TDB_DATA *value); int32_t dbwrap_fetch_int32(struct db_context *db, const char *keystr); int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v); @@ -140,7 +140,7 @@ NTSTATUS dbwrap_trans_traverse(struct db_context *db, NTSTATUS dbwrap_delete_bystring_upper(struct db_context *db, const char *key); NTSTATUS dbwrap_store_bystring_upper(struct db_context *db, const char *key, TDB_DATA data, int flags); -TDB_DATA dbwrap_fetch_bystring_upper(struct db_context *db, TALLOC_CTX *mem_ctx, - const char *key); +NTSTATUS dbwrap_fetch_bystring_upper(struct db_context *db, TALLOC_CTX *mem_ctx, + const char *key, TDB_DATA *value); #endif /* __DBWRAP_H__ */ diff --git a/source3/lib/dbwrap/dbwrap_util.c b/source3/lib/dbwrap/dbwrap_util.c index b9963f2706..a4f249270d 100644 --- a/source3/lib/dbwrap/dbwrap_util.c +++ b/source3/lib/dbwrap/dbwrap_util.c @@ -458,10 +458,10 @@ NTSTATUS dbwrap_store_bystring(struct db_context *db, const char *key, return dbwrap_store(db, string_term_tdb_data(key), data, flags); } -TDB_DATA dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx, - const char *key) +NTSTATUS dbwrap_fetch_bystring(struct db_context *db, TALLOC_CTX *mem_ctx, + const char *key, TDB_DATA *value) { - return dbwrap_fetch(db, mem_ctx, string_term_tdb_data(key)); + return dbwrap_fetch(db, mem_ctx, string_term_tdb_data(key), value); } @@ -499,19 +499,19 @@ NTSTATUS dbwrap_store_bystring_upper(struct db_context *db, const char *key, return status; } -TDB_DATA dbwrap_fetch_bystring_upper(struct db_context *db, TALLOC_CTX *mem_ctx, - const char *key) +NTSTATUS dbwrap_fetch_bystring_upper(struct db_context *db, TALLOC_CTX *mem_ctx, + const char *key, TDB_DATA *value) { char *key_upper; - TDB_DATA result; + NTSTATUS status; key_upper = talloc_strdup_upper(talloc_tos(), key); if (key_upper == NULL) { - return make_tdb_data(NULL, 0); + return NT_STATUS_NO_MEMORY; } - result = dbwrap_fetch_bystring(db, mem_ctx, key_upper); + status = dbwrap_fetch_bystring(db, mem_ctx, key_upper, value); talloc_free(key_upper); - return result; + return status; } diff --git a/source3/lib/privileges.c b/source3/lib/privileges.c index 0e9c77dea6..2bae8e1732 100644 --- a/source3/lib/privileges.c +++ b/source3/lib/privileges.c @@ -76,6 +76,7 @@ static bool get_privileges( const struct dom_sid *sid, uint64_t *mask ) struct db_context *db = get_account_pol_db(); fstring tmp, keystr; TDB_DATA data; + NTSTATUS status; /* Fail if the admin has not enable privileges */ @@ -90,9 +91,9 @@ static bool get_privileges( const struct dom_sid *sid, uint64_t *mask ) fstr_sprintf(keystr, "%s%s", PRIVPREFIX, sid_to_fstring(tmp, sid)); - data = dbwrap_fetch_bystring( db, talloc_tos(), keystr ); + status = dbwrap_fetch_bystring(db, talloc_tos(), keystr, &data); - if ( !data.dptr ) { + if (!NT_STATUS_IS_OK(status)) { DEBUG(4, ("get_privileges: No privileges assigned to SID " "[%s]\n", sid_string_dbg(sid))); return False; diff --git a/source3/lib/sharesec.c b/source3/lib/sharesec.c index 86f89ffe8e..b95c9d6c78 100644 --- a/source3/lib/sharesec.c +++ b/source3/lib/sharesec.c @@ -288,11 +288,11 @@ struct security_descriptor *get_share_security( TALLOC_CTX *ctx, const char *ser TALLOC_FREE(c_servicename); - data = dbwrap_fetch_bystring(share_db, talloc_tos(), key); + status = dbwrap_fetch_bystring(share_db, talloc_tos(), key, &data); TALLOC_FREE(key); - if (data.dptr == NULL) { + if (!NT_STATUS_IS_OK(status)) { return get_share_security_default(ctx, psize, SEC_RIGHTS_DIR_ALL); } diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index a8d16a7162..aa27d2cba3 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -6399,6 +6399,7 @@ static int getservicebyname(const char *pszServiceName, struct loadparm_service int iService = -1; char *canon_name; TDB_DATA data; + NTSTATUS status; if (ServiceHash == NULL) { return -1; @@ -6406,9 +6407,13 @@ static int getservicebyname(const char *pszServiceName, struct loadparm_service canon_name = canonicalize_servicename(talloc_tos(), pszServiceName); - data = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name); + status = dbwrap_fetch_bystring(ServiceHash, canon_name, canon_name, + &data); - if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) { + if (NT_STATUS_IS_OK(status) && + (data.dptr != NULL) && + (data.dsize == sizeof(iService))) + { iService = *(int *)data.dptr; } @@ -8541,12 +8546,18 @@ static int process_usershare_file(const char *dir_name, const char *file_name, i } { - TDB_DATA data = dbwrap_fetch_bystring( - ServiceHash, canon_name, canon_name); + TDB_DATA data; + NTSTATUS status; + + status = dbwrap_fetch_bystring(ServiceHash, canon_name, + canon_name, &data); iService = -1; - if ((data.dptr != NULL) && (data.dsize == sizeof(iService))) { + if (NT_STATUS_IS_OK(status) && + (data.dptr != NULL) && + (data.dsize == sizeof(iService))) + { iService = *(int *)data.dptr; } } diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c index 32051b198a..3ecb31d88e 100644 --- a/source3/passdb/pdb_tdb.c +++ b/source3/passdb/pdb_tdb.c @@ -537,6 +537,7 @@ static NTSTATUS tdbsam_getsampwnam (struct pdb_methods *my_methods, TDB_DATA data; fstring keystr; fstring name; + NTSTATUS status; if ( !user ) { DEBUG(0,("pdb_getsampwnam: struct samu is NULL.\n")); @@ -559,8 +560,8 @@ static NTSTATUS tdbsam_getsampwnam (struct pdb_methods *my_methods, /* get the record */ - data = dbwrap_fetch_bystring(db_sam, talloc_tos(), keystr); - if (!data.dptr) { + status = dbwrap_fetch_bystring(db_sam, talloc_tos(), keystr, &data); + if (!NT_STATUS_IS_OK(status)) { DEBUG(5,("pdb_getsampwnam (TDB): error fetching database.\n")); DEBUGADD(5, (" Key: %s\n", keystr)); return NT_STATUS_NO_SUCH_USER; @@ -611,10 +612,10 @@ static NTSTATUS tdbsam_getsampwrid (struct pdb_methods *my_methods, /* get the record */ - data = dbwrap_fetch_bystring(db_sam, talloc_tos(), keystr); - if (!data.dptr) { + nt_status = dbwrap_fetch_bystring(db_sam, talloc_tos(), keystr, &data); + if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(5,("pdb_getsampwrid (TDB): error looking up RID %d by key %s.\n", rid, keystr)); - return NT_STATUS_UNSUCCESSFUL; + return nt_status; } fstrcpy(name, (const char *)data.dptr); diff --git a/source3/printing/printer_list.c b/source3/printing/printer_list.c index 82c43bf3b0..61475fe539 100644 --- a/source3/printing/printer_list.c +++ b/source3/printing/printer_list.c @@ -90,10 +90,9 @@ NTSTATUS printer_list_get_printer(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } - data = dbwrap_fetch_bystring_upper(db, key, key); - if (data.dptr == NULL) { + status = dbwrap_fetch_bystring_upper(db, key, key, &data); + if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Failed to fetch record!\n")); - status = NT_STATUS_NOT_FOUND; goto done; } @@ -216,10 +215,9 @@ NTSTATUS printer_list_get_last_refresh(time_t *last_refresh) ZERO_STRUCT(data); - data = dbwrap_fetch_bystring(db, talloc_tos(), PL_TIMESTAMP_KEY); - if (data.dptr == NULL) { + status = dbwrap_fetch_bystring(db, talloc_tos(), PL_TIMESTAMP_KEY, &data); + if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Failed to fetch record!\n")); - status = NT_STATUS_NOT_FOUND; goto done; } diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index e22a73ad05..7dfaf52406 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -1431,13 +1431,17 @@ static TDB_DATA regdb_fetch_key_internal(struct db_context *db, { char *path = NULL; TDB_DATA data; + NTSTATUS status; path = normalize_reg_path(mem_ctx, key); if (!path) { return make_tdb_data(NULL, 0); } - data = dbwrap_fetch_bystring(db, mem_ctx, path); + status = dbwrap_fetch_bystring(db, mem_ctx, path, &data); + if (!NT_STATUS_IS_OK(status)) { + data = tdb_null; + } TALLOC_FREE(path); return data; @@ -1796,9 +1800,10 @@ static NTSTATUS regdb_store_values_internal(struct db_context *db, goto done; } - old_data = dbwrap_fetch_bystring(db, ctx, keystr); + status = dbwrap_fetch_bystring(db, ctx, keystr, &old_data); - if ((old_data.dptr != NULL) + if (NT_STATUS_IS_OK(status) + && (old_data.dptr != NULL) && (old_data.dsize == data.dsize) && (memcmp(old_data.dptr, data.dptr, data.dsize) == 0)) { @@ -1871,8 +1876,8 @@ static WERROR regdb_get_secdesc(TALLOC_CTX *mem_ctx, const char *key, goto done; } - data = dbwrap_fetch_bystring(regdb, tmp_ctx, tdbkey); - if (data.dptr == NULL) { + status = dbwrap_fetch_bystring(regdb, tmp_ctx, tdbkey, &data); + if (!NT_STATUS_IS_OK(status)) { err = WERR_BADFILE; goto done; } diff --git a/source3/registry/reg_objects.c b/source3/registry/reg_objects.c index 3e6ca67e80..c27685c97e 100644 --- a/source3/registry/reg_objects.c +++ b/source3/registry/reg_objects.c @@ -170,13 +170,15 @@ static WERROR regsubkey_ctr_index_for_keyname(struct regsubkey_ctr *ctr, uint32_t *idx) { TDB_DATA data; + NTSTATUS status; if ((ctr == NULL) || (keyname == NULL)) { return WERR_INVALID_PARAM; } - data = dbwrap_fetch_bystring_upper(ctr->subkeys_hash, ctr, keyname); - if (data.dptr == NULL) { + status = dbwrap_fetch_bystring_upper(ctr->subkeys_hash, ctr, keyname, + &data); + if (!NT_STATUS_IS_OK(status)) { return WERR_NOT_FOUND; } diff --git a/source3/utils/net_idmap_check.c b/source3/utils/net_idmap_check.c index 17389a53bb..95e5b2d6e6 100644 --- a/source3/utils/net_idmap_check.c +++ b/source3/utils/net_idmap_check.c @@ -318,7 +318,10 @@ static int add_record(struct check_ctx* ctx, TDB_DATA key, TDB_DATA value) return -1; }; if (rec->value.dptr == 0) { /* first entry */ - diff.oval = dbwrap_fetch(ctx->db, ctx->diff, key); + status = dbwrap_fetch(ctx->db, ctx->diff, key, &diff.oval); + if (!NT_STATUS_IS_OK(status)) { + diff.oval = tdb_null; + } } else { diff = unpack_diff(rec->value); talloc_free(diff.nval.dptr); diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c index 85ddca2242..780f533c56 100644 --- a/source3/winbindd/idmap_autorid.c +++ b/source3/winbindd/idmap_autorid.c @@ -136,6 +136,7 @@ static NTSTATUS idmap_autorid_id_to_sid(struct autorid_global_config *cfg, TDB_DATA data; char *keystr; struct dom_sid sid; + NTSTATUS status; /* can this be one of our ids? */ if (map->xid.id < cfg->minvalue) { @@ -160,10 +161,10 @@ static NTSTATUS idmap_autorid_id_to_sid(struct autorid_global_config *cfg, return NT_STATUS_NO_MEMORY; } - data = dbwrap_fetch_bystring(autorid_db, talloc_tos(), keystr); + status = dbwrap_fetch_bystring(autorid_db, talloc_tos(), keystr, &data); TALLOC_FREE(keystr); - if (!data.dptr) { + if (!NT_STATUS_IS_OK(status)) { DEBUG(4, ("id %d belongs to range %d which does not have " "domain mapping, ignoring mapping request\n", map->xid.id, range)); @@ -383,10 +384,11 @@ static struct autorid_global_config *idmap_autorid_loadconfig(TALLOC_CTX * ctx) TDB_DATA data; struct autorid_global_config *cfg; unsigned long minvalue, rangesize, maxranges; + NTSTATUS status; - data = dbwrap_fetch_bystring(autorid_db, ctx, CONFIGKEY); + status = dbwrap_fetch_bystring(autorid_db, ctx, CONFIGKEY, &data); - if (!data.dptr) { + if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("No saved config found\n")); return NULL; } diff --git a/source3/winbindd/idmap_tdb.c b/source3/winbindd/idmap_tdb.c index 5e3e9c08b6..c1fa42d27d 100644 --- a/source3/winbindd/idmap_tdb.c +++ b/source3/winbindd/idmap_tdb.c @@ -723,9 +723,9 @@ static NTSTATUS idmap_tdb_id_to_sid(struct idmap_domain *dom, struct id_map *map DEBUG(10,("Fetching record %s\n", keystr)); /* Check if the mapping exists */ - data = dbwrap_fetch_bystring(ctx->db, NULL, keystr); + ret = dbwrap_fetch_bystring(ctx->db, NULL, keystr, &data); - if (!data.dptr) { + if (!NT_STATUS_IS_OK(ret)) { DEBUG(10,("Record %s not found\n", keystr)); ret = NT_STATUS_NONE_MAPPED; goto done; @@ -772,8 +772,8 @@ static NTSTATUS idmap_tdb_sid_to_id(struct idmap_domain *dom, struct id_map *map DEBUG(10,("Fetching record %s\n", keystr)); /* Check if sid is present in database */ - data = dbwrap_fetch_bystring(ctx->db, tmp_ctx, keystr); - if (!data.dptr) { + ret = dbwrap_fetch_bystring(ctx->db, tmp_ctx, keystr, &data); + if (!NT_STATUS_IS_OK(ret)) { DEBUG(10,("Record %s not found\n", keystr)); ret = NT_STATUS_NONE_MAPPED; goto done; diff --git a/source3/winbindd/idmap_tdb2.c b/source3/winbindd/idmap_tdb2.c index 07b91e5b00..456bb8f509 100644 --- a/source3/winbindd/idmap_tdb2.c +++ b/source3/winbindd/idmap_tdb2.c @@ -355,8 +355,8 @@ static NTSTATUS idmap_tdb2_set_mapping_action(struct db_context *db, DEBUG(10, ("Storing %s <-> %s map\n", state->ksidstr, state->kidstr)); /* check wheter sid mapping is already present in db */ - data = dbwrap_fetch_bystring(db, tmp_ctx, state->ksidstr); - if (data.dptr) { + ret = dbwrap_fetch_bystring(db, tmp_ctx, state->ksidstr, &data); + if (!NT_STATUS_IS_OK(ret)) { ret = NT_STATUS_OBJECT_NAME_COLLISION; goto done; } @@ -585,9 +585,9 @@ static NTSTATUS idmap_tdb2_id_to_sid(struct idmap_domain *dom, struct id_map *ma DEBUG(10,("Fetching record %s\n", keystr)); /* Check if the mapping exists */ - data = dbwrap_fetch_bystring(ctx->db, keystr, keystr); + status = dbwrap_fetch_bystring(ctx->db, keystr, keystr, &data); - if (!data.dptr) { + if (!NT_STATUS_IS_OK(status)) { char *sidstr; struct idmap_tdb2_set_mapping_context store_state; @@ -659,8 +659,8 @@ static NTSTATUS idmap_tdb2_sid_to_id(struct idmap_domain *dom, struct id_map *ma DEBUG(10,("Fetching record %s\n", keystr)); /* Check if sid is present in database */ - data = dbwrap_fetch_bystring(ctx->db, tmp_ctx, keystr); - if (!data.dptr) { + ret = dbwrap_fetch_bystring(ctx->db, tmp_ctx, keystr, &data); + if (!NT_STATUS_IS_OK(ret)) { char *idstr; struct idmap_tdb2_set_mapping_context store_state; |