summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-03-28 11:53:00 +0100
committerStefan Metzmacher <metze@samba.org>2008-04-01 14:04:22 +0200
commitfcdfff1cc8c1214cbce1fdd863b1ede970234121 (patch)
treead50b65a4882ebcb5187305c9b56d61e13eef360 /source3/lib
parentd20f88c60302b9af21b3a04e1ebc536a0e0c0e36 (diff)
downloadsamba-fcdfff1cc8c1214cbce1fdd863b1ede970234121.tar.gz
samba-fcdfff1cc8c1214cbce1fdd863b1ede970234121.tar.bz2
samba-fcdfff1cc8c1214cbce1fdd863b1ede970234121.zip
Convert dbwrap_trans_store to NTSTATUS
Signed-off-by: Stefan Metzmacher <metze@samba.org> (This used to be commit 5f4de856af1abe63b13059bbe1615cb5877770d0)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/dbwrap_util.c25
-rw-r--r--source3/lib/sharesec.c9
2 files changed, 18 insertions, 16 deletions
diff --git a/source3/lib/dbwrap_util.c b/source3/lib/dbwrap_util.c
index 01d70556d8..1a636cc8a6 100644
--- a/source3/lib/dbwrap_util.c
+++ b/source3/lib/dbwrap_util.c
@@ -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);
}
diff --git a/source3/lib/sharesec.c b/source3/lib/sharesec.c
index 3d9e608387..33141a9671 100644
--- a/source3/lib/sharesec.c
+++ b/source3/lib/sharesec.c
@@ -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;
}