diff options
author | Volker Lendecke <vl@samba.org> | 2008-03-28 11:57:54 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2008-04-01 14:04:22 +0200 |
commit | 16198dc51e8f03d22de73883c0bb6823c464b8c6 (patch) | |
tree | 144c5eb5a076b47788e73a6a1d2e47858dcfcbdc | |
parent | fcdfff1cc8c1214cbce1fdd863b1ede970234121 (diff) | |
download | samba-16198dc51e8f03d22de73883c0bb6823c464b8c6.tar.gz samba-16198dc51e8f03d22de73883c0bb6823c464b8c6.tar.xz samba-16198dc51e8f03d22de73883c0bb6823c464b8c6.zip |
Convert dbwrap_trans_delete to NTSTATUS
Signed-off-by: Stefan Metzmacher <metze@samba.org>
(This used to be commit dead193f46c2b19955ab3e5ac5ba343694f4858a)
-rw-r--r-- | source3/groupdb/mapping_tdb.c | 6 | ||||
-rw-r--r-- | source3/lib/dbwrap_util.c | 11 | ||||
-rw-r--r-- | source3/lib/sharesec.c | 6 | ||||
-rw-r--r-- | source3/passdb/secrets.c | 5 | ||||
-rw-r--r-- | source3/registry/reg_backend_db.c | 9 |
5 files changed, 22 insertions, 15 deletions
diff --git a/source3/groupdb/mapping_tdb.c b/source3/groupdb/mapping_tdb.c index 718804b1e57..05a473c7222 100644 --- a/source3/groupdb/mapping_tdb.c +++ b/source3/groupdb/mapping_tdb.c @@ -282,17 +282,17 @@ static bool get_group_map_from_ntname(const char *name, GROUP_MAP *map) static bool group_map_remove(const DOM_SID *sid) { char *key; - int res; + NTSTATUS status; key = group_mapping_key(talloc_tos(), sid); if (key == NULL) { return false; } - res = dbwrap_trans_delete(db, string_term_tdb_data(key)); + status = dbwrap_trans_delete(db, string_term_tdb_data(key)); TALLOC_FREE(key); - return (res == 0); + return NT_STATUS_IS_OK(status); } /**************************************************************************** diff --git a/source3/lib/dbwrap_util.c b/source3/lib/dbwrap_util.c index 1a636cc8a6f..1005f36b60c 100644 --- a/source3/lib/dbwrap_util.c +++ b/source3/lib/dbwrap_util.c @@ -200,7 +200,7 @@ NTSTATUS dbwrap_trans_store(struct db_context *db, TDB_DATA key, TDB_DATA dbuf, return status; } -int dbwrap_trans_delete(struct db_context *db, TDB_DATA key) +NTSTATUS dbwrap_trans_delete(struct db_context *db, TDB_DATA key) { int res; struct db_record *rec; @@ -209,12 +209,13 @@ int dbwrap_trans_delete(struct db_context *db, TDB_DATA key) 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; } @@ -229,15 +230,17 @@ int dbwrap_trans_delete(struct db_context *db, TDB_DATA key) 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; } NTSTATUS dbwrap_trans_store_int32(struct db_context *db, const char *keystr, diff --git a/source3/lib/sharesec.c b/source3/lib/sharesec.c index 33141a96717..471363b4bed 100644 --- a/source3/lib/sharesec.c +++ b/source3/lib/sharesec.c @@ -253,6 +253,7 @@ bool delete_share_security(const char *servicename) { TDB_DATA kbuf; char *key; + NTSTATUS status; if (!(key = talloc_asprintf(talloc_tos(), "SECDESC/%s", servicename))) { @@ -260,9 +261,10 @@ bool delete_share_security(const char *servicename) } kbuf = string_term_tdb_data(key); - if (dbwrap_trans_delete(share_db, kbuf) != 0) { + status = dbwrap_trans_delete(share_db, kbuf); + if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("delete_share_security: Failed to delete entry for " - "share %s\n", servicename)); + "share %s: %s\n", servicename, nt_errstr(status))); return False; } diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c index 71db81c0e42..34a87bd0d0e 100644 --- a/source3/passdb/secrets.c +++ b/source3/passdb/secrets.c @@ -157,11 +157,14 @@ bool secrets_store(const char *key, const void *data, size_t size) */ bool secrets_delete(const char *key) { + NTSTATUS status; if (!secrets_init()) { return false; } - return dbwrap_trans_delete(db_ctx, string_tdb_data(key)) == 0; + status = dbwrap_trans_delete(db_ctx, string_tdb_data(key)); + + return NT_STATUS_IS_OK(status); } /** diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c index 4b8a4b4c374..fd442d63272 100644 --- a/source3/registry/reg_backend_db.c +++ b/source3/registry/reg_backend_db.c @@ -979,7 +979,6 @@ static WERROR regdb_set_secdesc(const char *key, NTSTATUS status; WERROR err = WERR_NOMEM; TDB_DATA tdbdata; - int tdb_ret; tdbkey = talloc_asprintf(mem_ctx, "%s/%s", REG_SECDESC_PREFIX, key); if (tdbkey == NULL) { @@ -989,12 +988,12 @@ static WERROR regdb_set_secdesc(const char *key, if (secdesc == NULL) { /* assuming a delete */ - tdb_ret = dbwrap_trans_delete(regdb, - string_term_tdb_data(tdbkey)); - if (tdb_ret == 0) { + status = dbwrap_trans_delete(regdb, + string_term_tdb_data(tdbkey)); + if (NT_STATUS_IS_OK(status)) { err = WERR_OK; } else { - err = ntstatus_to_werror(map_nt_error_from_unix(errno)); + err = ntstatus_to_werror(status); } goto done; } |