summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-03-27 09:17:31 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:54 -0500
commit38afa759654a8875babf00d86adee46be807d9e0 (patch)
tree8d8b65d96fafcbcb86f1b1f21a7e0f6643aebc42 /source3
parent0563eb86b36f79eba33c38a11dc9dd1423c1be40 (diff)
downloadsamba-38afa759654a8875babf00d86adee46be807d9e0.tar.gz
samba-38afa759654a8875babf00d86adee46be807d9e0.tar.bz2
samba-38afa759654a8875babf00d86adee46be807d9e0.zip
r21974: make use of tdb_*_bystring() and string_term_tdb_data() in groupdb/
to avoid creating the TDB_DATA struct from strings "by hand" metze (This used to be commit 2f2e9a7083b176412cd897119a49520a55a897a7)
Diffstat (limited to 'source3')
-rw-r--r--source3/groupdb/mapping_tdb.c53
1 files changed, 17 insertions, 36 deletions
diff --git a/source3/groupdb/mapping_tdb.c b/source3/groupdb/mapping_tdb.c
index cff557ff13..1d7eaa98d8 100644
--- a/source3/groupdb/mapping_tdb.c
+++ b/source3/groupdb/mapping_tdb.c
@@ -87,7 +87,7 @@ static TDB_CONTEXT *tdb; /* used for driver files */
****************************************************************************/
BOOL add_mapping_entry(GROUP_MAP *map, int flag)
{
- TDB_DATA kbuf, dbuf;
+ TDB_DATA dbuf;
pstring key, buf;
fstring string_sid="";
int len;
@@ -107,11 +107,9 @@ static TDB_CONTEXT *tdb; /* used for driver files */
slprintf(key, sizeof(key), "%s%s", GROUP_PREFIX, string_sid);
- kbuf.dsize = strlen(key)+1;
- kbuf.dptr = key;
dbuf.dsize = len;
dbuf.dptr = buf;
- if (tdb_store(tdb, kbuf, dbuf, flag) != 0) return False;
+ if (tdb_store_bystring(tdb, key, dbuf, flag) != 0) return False;
return True;
}
@@ -123,7 +121,7 @@ static TDB_CONTEXT *tdb; /* used for driver files */
BOOL get_group_map_from_sid(DOM_SID sid, GROUP_MAP *map)
{
- TDB_DATA kbuf, dbuf;
+ TDB_DATA dbuf;
pstring key;
fstring string_sid;
int ret = 0;
@@ -138,10 +136,7 @@ static TDB_CONTEXT *tdb; /* used for driver files */
sid_to_string(string_sid, &sid);
slprintf(key, sizeof(key), "%s%s", GROUP_PREFIX, string_sid);
- kbuf.dptr = key;
- kbuf.dsize = strlen(key)+1;
-
- dbuf = tdb_fetch(tdb, kbuf);
+ dbuf = tdb_fetch_bystring(tdb, key);
if (!dbuf.dptr)
return False;
@@ -266,7 +261,7 @@ static TDB_CONTEXT *tdb; /* used for driver files */
BOOL group_map_remove(const DOM_SID *sid)
{
- TDB_DATA kbuf, dbuf;
+ TDB_DATA dbuf;
pstring key;
fstring string_sid;
@@ -280,16 +275,13 @@ BOOL group_map_remove(const DOM_SID *sid)
sid_to_string(string_sid, sid);
slprintf(key, sizeof(key), "%s%s", GROUP_PREFIX, string_sid);
- kbuf.dptr = key;
- kbuf.dsize = strlen(key)+1;
-
- dbuf = tdb_fetch(tdb, kbuf);
+ dbuf = tdb_fetch_bystring(tdb, key);
if (!dbuf.dptr)
return False;
SAFE_FREE(dbuf.dptr);
- if(tdb_delete(tdb, kbuf) != TDB_SUCCESS)
+ if(tdb_delete_bystring(tdb, key) != TDB_SUCCESS)
return False;
return True;
@@ -400,7 +392,7 @@ BOOL enum_group_mapping(const DOM_SID *domsid, enum lsa_SidType sid_name_use, GR
DOM_SID **sids, size_t *num)
{
fstring key, string_sid;
- TDB_DATA kbuf, dbuf;
+ TDB_DATA dbuf;
const char *p;
if (!init_group_mapping()) {
@@ -411,10 +403,7 @@ BOOL enum_group_mapping(const DOM_SID *domsid, enum lsa_SidType sid_name_use, GR
sid_to_string(string_sid, member);
slprintf(key, sizeof(key), "%s%s", MEMBEROF_PREFIX, string_sid);
- kbuf.dsize = strlen(key)+1;
- kbuf.dptr = key;
-
- dbuf = tdb_fetch(tdb, kbuf);
+ dbuf = tdb_fetch_bystring(tdb, key);
if (dbuf.dptr == NULL) {
return NT_STATUS_OK;
@@ -478,7 +467,7 @@ static BOOL is_aliasmem(const DOM_SID *alias, const DOM_SID *member)
NTSTATUS add_aliasmem(const DOM_SID *alias, const DOM_SID *member)
{
GROUP_MAP map;
- TDB_DATA kbuf, dbuf;
+ TDB_DATA dbuf;
pstring key;
fstring string_sid;
char *new_memberstring;
@@ -502,10 +491,7 @@ static BOOL is_aliasmem(const DOM_SID *alias, const DOM_SID *member)
sid_to_string(string_sid, member);
slprintf(key, sizeof(key), "%s%s", MEMBEROF_PREFIX, string_sid);
- kbuf.dsize = strlen(key)+1;
- kbuf.dptr = key;
-
- dbuf = tdb_fetch(tdb, kbuf);
+ dbuf = tdb_fetch_bystring(tdb, key);
sid_to_string(string_sid, alias);
@@ -520,10 +506,9 @@ static BOOL is_aliasmem(const DOM_SID *alias, const DOM_SID *member)
return NT_STATUS_NO_MEMORY;
SAFE_FREE(dbuf.dptr);
- dbuf.dsize = strlen(new_memberstring)+1;
- dbuf.dptr = new_memberstring;
+ dbuf = string_term_tdb_data(new_memberstring);
- result = tdb_store(tdb, kbuf, dbuf, 0);
+ result = tdb_store_bystring(tdb, key, dbuf, 0);
SAFE_FREE(new_memberstring);
@@ -620,7 +605,7 @@ static int collect_aliasmem(TDB_CONTEXT *tdb_ctx, TDB_DATA key, TDB_DATA data,
size_t i, num;
BOOL found = False;
char *member_string;
- TDB_DATA kbuf, dbuf;
+ TDB_DATA dbuf;
pstring key;
fstring sid_string;
@@ -649,11 +634,8 @@ static int collect_aliasmem(TDB_CONTEXT *tdb_ctx, TDB_DATA key, TDB_DATA data,
sid_to_string(sid_string, member);
slprintf(key, sizeof(key), "%s%s", MEMBEROF_PREFIX, sid_string);
- kbuf.dsize = strlen(key)+1;
- kbuf.dptr = key;
-
if (num == 0)
- return tdb_delete(tdb, kbuf) == 0 ?
+ return tdb_delete_bystring(tdb, key) == 0 ?
NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
member_string = SMB_STRDUP("");
@@ -676,10 +658,9 @@ static int collect_aliasmem(TDB_CONTEXT *tdb_ctx, TDB_DATA key, TDB_DATA data,
}
}
- dbuf.dsize = strlen(member_string)+1;
- dbuf.dptr = member_string;
+ dbuf = string_term_tdb_data(member_string);
- result = tdb_store(tdb, kbuf, dbuf, 0) == 0 ?
+ result = tdb_store_bystring(tdb, key, dbuf, 0) == 0 ?
NT_STATUS_OK : NT_STATUS_ACCESS_DENIED;
SAFE_FREE(sids);