summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2011-08-17 11:24:09 +0200
committerMichael Adam <obnox@samba.org>2011-10-11 14:17:57 +0200
commit79a4911d755a320557ca1a2d53525a7f56953a68 (patch)
tree963d798ecd2ad767fe070e10e7bbe1d374eb9b6c
parent736af260628aa725aa8c45410722e9fe9db9a80b (diff)
downloadsamba-79a4911d755a320557ca1a2d53525a7f56953a68.tar.gz
samba-79a4911d755a320557ca1a2d53525a7f56953a68.tar.bz2
samba-79a4911d755a320557ca1a2d53525a7f56953a68.zip
s3:privileges: convert privileges.c to use dbwrap wrapper functions.
Avoid direct use of the db_record and db_context structs.
-rw-r--r--source3/lib/privileges.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/source3/lib/privileges.c b/source3/lib/privileges.c
index 2bae8e1732..19ee688042 100644
--- a/source3/lib/privileges.c
+++ b/source3/lib/privileges.c
@@ -210,28 +210,34 @@ static int priv_traverse_fn(struct db_record *rec, void *state)
int prefixlen = strlen(PRIVPREFIX);
struct dom_sid sid;
fstring sid_string;
+ TDB_DATA key;
+
+ key = dbwrap_record_get_key(rec);
/* check we have a PRIV_+SID entry */
- if ( strncmp((char *)rec->key.dptr, PRIVPREFIX, prefixlen) != 0)
+ if (strncmp((char *)key.dptr, PRIVPREFIX, prefixlen) != 0)
return 0;
/* check to see if we are looking for a particular privilege */
- fstrcpy( sid_string, (char *)&(rec->key.dptr[strlen(PRIVPREFIX)]) );
+ fstrcpy( sid_string, (char *)&(key.dptr[strlen(PRIVPREFIX)]) );
if (priv->privilege != 0) {
uint64_t mask;
+ TDB_DATA value;
+
+ value = dbwrap_record_get_value(rec);
- if (rec->value.dsize == 4*4) {
- mask = map_old_SE_PRIV(rec->value.dptr);
+ if (value.dsize == 4*4) {
+ mask = map_old_SE_PRIV(value.dptr);
} else {
- if (rec->value.dsize != sizeof( uint64_t ) ) {
+ if (value.dsize != sizeof( uint64_t ) ) {
DEBUG(3, ("get_privileges: Invalid privileges record assigned to SID "
"[%s]\n", sid_string));
return 0;
}
- mask = BVAL(rec->value.dptr, 0);
+ mask = BVAL(value.dptr, 0);
}
/* if the SID does not have the specified privilege
@@ -272,6 +278,7 @@ NTSTATUS privilege_enumerate_accounts(struct dom_sid **sids, int *num_sids)
{
struct db_context *db = get_account_pol_db();
PRIV_SID_LIST priv;
+ NTSTATUS status;
if (db == NULL) {
return NT_STATUS_ACCESS_DENIED;
@@ -279,7 +286,10 @@ NTSTATUS privilege_enumerate_accounts(struct dom_sid **sids, int *num_sids)
ZERO_STRUCT(priv);
- db->traverse_read(db, priv_traverse_fn, &priv);
+ status = dbwrap_traverse_read(db, priv_traverse_fn, &priv, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
/* give the memory away; caller will free */
@@ -298,6 +308,7 @@ NTSTATUS privilege_enum_sids(enum sec_privilege privilege, TALLOC_CTX *mem_ctx,
{
struct db_context *db = get_account_pol_db();
PRIV_SID_LIST priv;
+ NTSTATUS status;
if (db == NULL) {
return NT_STATUS_ACCESS_DENIED;
@@ -308,7 +319,10 @@ NTSTATUS privilege_enum_sids(enum sec_privilege privilege, TALLOC_CTX *mem_ctx,
priv.privilege = sec_privilege_mask(privilege);
priv.mem_ctx = mem_ctx;
- db->traverse_read(db, priv_traverse_fn, &priv);
+ status = dbwrap_traverse_read(db, priv_traverse_fn, &priv, NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
/* give the memory away; caller will free */