summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2011-08-24 13:08:13 +0200
committerMichael Adam <obnox@samba.org>2011-10-11 14:17:56 +0200
commit0e28448a780cf231ae38fe03a85cf6e1ea9dded0 (patch)
tree91878c39866520bc06d968cd44cd8a86995cc8ad /source3/lib
parent25a9978c2c4d00eb64b212170f64f5cc136e032a (diff)
downloadsamba-0e28448a780cf231ae38fe03a85cf6e1ea9dded0.tar.gz
samba-0e28448a780cf231ae38fe03a85cf6e1ea9dded0.tar.bz2
samba-0e28448a780cf231ae38fe03a85cf6e1ea9dded0.zip
s3:dbwrap: convert dbwrap_fetch(), dbwrap_fetch_bystring() and dbwrap_fetch_bystring_upper() to NTSTATUS
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/dbwrap/dbwrap.c14
-rw-r--r--source3/lib/dbwrap/dbwrap.h12
-rw-r--r--source3/lib/dbwrap/dbwrap_util.c18
-rw-r--r--source3/lib/privileges.c5
-rw-r--r--source3/lib/sharesec.c4
5 files changed, 28 insertions, 25 deletions
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);
}