mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
Convert dbwrap_trans_store to NTSTATUS
Signed-off-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
parent
f1dd915ce8
commit
5f4de856af
@ -123,7 +123,7 @@ static bool add_mapping_entry(GROUP_MAP *map, int flag)
|
||||
{
|
||||
char *key, *buf;
|
||||
int len;
|
||||
int res;
|
||||
NTSTATUS status;
|
||||
|
||||
key = group_mapping_key(talloc_tos(), &map->sid);
|
||||
if (key == NULL) {
|
||||
@ -141,13 +141,13 @@ static bool add_mapping_entry(GROUP_MAP *map, int flag)
|
||||
len = tdb_pack((uint8 *)buf, len, "ddff", map->gid,
|
||||
map->sid_name_use, map->nt_name, map->comment);
|
||||
|
||||
res = dbwrap_trans_store(
|
||||
status = dbwrap_trans_store(
|
||||
db, string_term_tdb_data(key),
|
||||
make_tdb_data((uint8_t *)buf, len), flag);
|
||||
|
||||
TALLOC_FREE(key);
|
||||
|
||||
return (res == 0);
|
||||
return NT_STATUS_IS_OK(status);
|
||||
}
|
||||
|
||||
|
||||
|
@ -156,8 +156,8 @@ int32 dbwrap_change_int32_atomic(struct db_context *db, const char *keystr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dbwrap_trans_store(struct db_context *db, TDB_DATA key, TDB_DATA dbuf,
|
||||
int flag)
|
||||
NTSTATUS dbwrap_trans_store(struct db_context *db, TDB_DATA key, TDB_DATA dbuf,
|
||||
int flag)
|
||||
{
|
||||
int res;
|
||||
struct db_record *rec;
|
||||
@ -166,12 +166,13 @@ int dbwrap_trans_store(struct db_context *db, TDB_DATA key, TDB_DATA dbuf,
|
||||
res = db->transaction_start(db);
|
||||
if (res != 0) {
|
||||
DEBUG(5, ("transaction_start failed\n"));
|
||||
return res;
|
||||
return NT_STATUS_INTERNAL_DB_CORRUPTION;
|
||||
}
|
||||
|
||||
rec = db->fetch_locked(db, talloc_tos(), key);
|
||||
if (rec == NULL) {
|
||||
DEBUG(5, ("fetch_locked failed\n"));
|
||||
status = NT_STATUS_NO_MEMORY;
|
||||
goto cancel;
|
||||
}
|
||||
|
||||
@ -186,15 +187,17 @@ int dbwrap_trans_store(struct db_context *db, TDB_DATA key, TDB_DATA dbuf,
|
||||
res = db->transaction_commit(db);
|
||||
if (res != 0) {
|
||||
DEBUG(5, ("tdb_transaction_commit failed\n"));
|
||||
status = NT_STATUS_INTERNAL_DB_CORRUPTION;
|
||||
goto cancel;
|
||||
}
|
||||
|
||||
return res;
|
||||
return NT_STATUS_OK;
|
||||
|
||||
cancel:
|
||||
if (db->transaction_cancel(db) != 0) {
|
||||
smb_panic("Cancelling transaction failed");
|
||||
}
|
||||
return -1;
|
||||
return status;
|
||||
}
|
||||
|
||||
int dbwrap_trans_delete(struct db_context *db, TDB_DATA key)
|
||||
@ -237,17 +240,15 @@ int dbwrap_trans_delete(struct db_context *db, TDB_DATA key)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int dbwrap_trans_store_int32(struct db_context *db, const char *keystr, int32_t v)
|
||||
NTSTATUS dbwrap_trans_store_int32(struct db_context *db, const char *keystr,
|
||||
int32_t v)
|
||||
{
|
||||
int ret;
|
||||
int32 v_store;
|
||||
|
||||
SIVAL(&v_store, 0, v);
|
||||
|
||||
ret = dbwrap_trans_store(db, string_term_tdb_data(keystr),
|
||||
make_tdb_data((const uint8 *)&v_store,
|
||||
return dbwrap_trans_store(db, string_term_tdb_data(keystr),
|
||||
make_tdb_data((const uint8 *)&v_store,
|
||||
sizeof(v_store)),
|
||||
TDB_REPLACE);
|
||||
|
||||
return ret;
|
||||
TDB_REPLACE);
|
||||
}
|
||||
|
@ -229,10 +229,11 @@ bool set_share_security(const char *share_name, SEC_DESC *psd)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dbwrap_trans_store(share_db, string_term_tdb_data(key), blob,
|
||||
TDB_REPLACE) == -1) {
|
||||
DEBUG(1,("set_share_security: Failed to store secdesc for "
|
||||
"%s\n", share_name ));
|
||||
status = dbwrap_trans_store(share_db, string_term_tdb_data(key), blob,
|
||||
TDB_REPLACE);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(1, ("set_share_security: Failed to store secdesc for "
|
||||
"%s: %s\n", share_name, nt_errstr(status)));
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -140,13 +140,16 @@ void *secrets_fetch(const char *key, size_t *size)
|
||||
*/
|
||||
bool secrets_store(const char *key, const void *data, size_t size)
|
||||
{
|
||||
NTSTATUS status;
|
||||
|
||||
if (!secrets_init()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return dbwrap_trans_store(db_ctx, string_tdb_data(key),
|
||||
make_tdb_data((const uint8 *)data, size),
|
||||
TDB_REPLACE) == 0;
|
||||
status = dbwrap_trans_store(db_ctx, string_tdb_data(key),
|
||||
make_tdb_data((const uint8 *)data, size),
|
||||
TDB_REPLACE);
|
||||
return NT_STATUS_IS_OK(status);
|
||||
}
|
||||
|
||||
|
||||
|
@ -349,12 +349,14 @@ bool regdb_init(void)
|
||||
vers_id = dbwrap_fetch_int32(regdb, vstring);
|
||||
|
||||
if ( vers_id != REGVER_V1 ) {
|
||||
NTSTATUS status;
|
||||
/* any upgrade code here if needed */
|
||||
DEBUG(10, ("regdb_init: got %s = %d != %d\n", vstring,
|
||||
vers_id, REGVER_V1));
|
||||
if (dbwrap_trans_store_int32(regdb, vstring, REGVER_V1) != 0) {
|
||||
DEBUG(0, ("regdb_init: error storing %s = %d\n",
|
||||
vstring, REGVER_V1));
|
||||
status = dbwrap_trans_store_int32(regdb, vstring, REGVER_V1);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(0, ("regdb_init: error storing %s = %d: %s\n",
|
||||
vstring, REGVER_V1, nt_errstr(status)));
|
||||
return false;
|
||||
} else {
|
||||
DEBUG(10, ("regdb_init: stored %s = %d\n",
|
||||
@ -881,7 +883,8 @@ bool regdb_store_values( const char *key, REGVAL_CTR *values )
|
||||
TDB_DATA old_data, data;
|
||||
char *keystr = NULL;
|
||||
TALLOC_CTX *ctx = talloc_stackframe();
|
||||
int len, ret;
|
||||
int len;
|
||||
NTSTATUS status;
|
||||
bool result = false;
|
||||
|
||||
DEBUG(10,("regdb_store_values: Looking for value of key [%s] \n", key));
|
||||
@ -920,9 +923,10 @@ bool regdb_store_values( const char *key, REGVAL_CTR *values )
|
||||
goto done;
|
||||
}
|
||||
|
||||
ret = dbwrap_trans_store(regdb, string_term_tdb_data(keystr), data,
|
||||
TDB_REPLACE);
|
||||
result = (ret != -1);
|
||||
status = dbwrap_trans_store(regdb, string_term_tdb_data(keystr), data,
|
||||
TDB_REPLACE);
|
||||
|
||||
result = NT_STATUS_IS_OK(status);
|
||||
|
||||
done:
|
||||
TALLOC_FREE(ctx);
|
||||
@ -972,6 +976,7 @@ static WERROR regdb_set_secdesc(const char *key,
|
||||
{
|
||||
TALLOC_CTX *mem_ctx = talloc_stackframe();
|
||||
char *tdbkey;
|
||||
NTSTATUS status;
|
||||
WERROR err = WERR_NOMEM;
|
||||
TDB_DATA tdbdata;
|
||||
int tdb_ret;
|
||||
@ -1001,10 +1006,10 @@ static WERROR regdb_set_secdesc(const char *key,
|
||||
goto done;
|
||||
}
|
||||
|
||||
tdb_ret = dbwrap_trans_store(regdb, string_term_tdb_data(tdbkey),
|
||||
tdbdata, 0);
|
||||
if (tdb_ret != 0) {
|
||||
err = ntstatus_to_werror(map_nt_error_from_unix(errno));
|
||||
status = dbwrap_trans_store(regdb, string_term_tdb_data(tdbkey),
|
||||
tdbdata, 0);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
err = ntstatus_to_werror(status);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user