summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-03-27 10:43:32 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:55 -0500
commita3a4d6721b451807d55e9c5199275aad57db26fb (patch)
treee2629ec3ce8f2e85a87a82db2dc854dbc08b6780
parent6e2a411795cbcc8a1ceaf957ff45570fb8016dca (diff)
downloadsamba-a3a4d6721b451807d55e9c5199275aad57db26fb.tar.gz
samba-a3a4d6721b451807d55e9c5199275aad57db26fb.tar.bz2
samba-a3a4d6721b451807d55e9c5199275aad57db26fb.zip
r21982: make use of tdb_*_bystring() and string_term_tdb_data()
to avoid creating the TDB_DATA struct from strings "by hand" metze (This used to be commit 9ebaa4c573ea5784a8c9cd9d29561b760d62bb18)
-rw-r--r--source3/passdb/pdb_tdb.c41
1 files changed, 12 insertions, 29 deletions
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index e9beaa0536..37ee19028a 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -1025,7 +1025,7 @@ static NTSTATUS tdbsam_getsampwent(struct pdb_methods *my_methods, struct samu *
static NTSTATUS tdbsam_getsampwnam (struct pdb_methods *my_methods, struct samu *user, const char *sname)
{
- TDB_DATA data, key;
+ TDB_DATA data;
fstring keystr;
fstring name;
@@ -1040,8 +1040,6 @@ static NTSTATUS tdbsam_getsampwnam (struct pdb_methods *my_methods, struct samu
/* set search key */
slprintf(keystr, sizeof(keystr)-1, "%s%s", USERPREFIX, name);
- key.dptr = keystr;
- key.dsize = strlen(keystr) + 1;
/* open the database */
@@ -1052,7 +1050,7 @@ static NTSTATUS tdbsam_getsampwnam (struct pdb_methods *my_methods, struct samu
/* get the record */
- data = tdb_fetch(tdbsam, key);
+ data = tdb_fetch_bystring(tdbsam, keystr);
if (!data.dptr) {
DEBUG(5,("pdb_getsampwnam (TDB): error fetching database.\n"));
DEBUGADD(5, (" Error: %s\n", tdb_errorstr(tdbsam)));
@@ -1085,7 +1083,7 @@ static NTSTATUS tdbsam_getsampwnam (struct pdb_methods *my_methods, struct samu
static NTSTATUS tdbsam_getsampwrid (struct pdb_methods *my_methods, struct samu *user, uint32 rid)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- TDB_DATA data, key;
+ TDB_DATA data;
fstring keystr;
fstring name;
@@ -1097,8 +1095,6 @@ static NTSTATUS tdbsam_getsampwrid (struct pdb_methods *my_methods, struct samu
/* set search key */
slprintf(keystr, sizeof(keystr)-1, "%s%.8x", RIDPREFIX, rid);
- key.dptr = keystr;
- key.dsize = strlen (keystr) + 1;
/* open the database */
@@ -1109,7 +1105,7 @@ static NTSTATUS tdbsam_getsampwrid (struct pdb_methods *my_methods, struct samu
/* get the record */
- data = tdb_fetch (tdbsam, key);
+ data = tdb_fetch_bystring (tdbsam, keystr);
if (!data.dptr) {
DEBUG(5,("pdb_getsampwrid (TDB): error looking up RID %d by key %s.\n", rid, keystr));
DEBUGADD(5, (" Error: %s\n", tdb_errorstr(tdbsam)));
@@ -1142,7 +1138,6 @@ static NTSTATUS tdbsam_getsampwsid(struct pdb_methods *my_methods, struct samu *
static BOOL tdb_delete_samacct_only( struct samu *sam_pass )
{
- TDB_DATA key;
fstring keystr;
fstring name;
@@ -1152,12 +1147,10 @@ static BOOL tdb_delete_samacct_only( struct samu *sam_pass )
/* set the search key */
slprintf(keystr, sizeof(keystr)-1, "%s%s", USERPREFIX, name);
- key.dptr = keystr;
- key.dsize = strlen (keystr) + 1;
/* it's outaa here! 8^) */
- if (tdb_delete(tdbsam, key) != TDB_SUCCESS) {
+ if (tdb_delete_bystring(tdbsam, keystr) != TDB_SUCCESS) {
DEBUG(5, ("Error deleting entry from tdb passwd database!\n"));
DEBUGADD(5, (" Error: %s\n", tdb_errorstr(tdbsam)));
return False;
@@ -1173,7 +1166,6 @@ static BOOL tdb_delete_samacct_only( struct samu *sam_pass )
static NTSTATUS tdbsam_delete_sam_account(struct pdb_methods *my_methods, struct samu *sam_pass)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- TDB_DATA key;
fstring keystr;
uint32 rid;
fstring name;
@@ -1192,14 +1184,12 @@ static NTSTATUS tdbsam_delete_sam_account(struct pdb_methods *my_methods, struct
/* set the search key */
slprintf(keystr, sizeof(keystr)-1, "%s%s", USERPREFIX, name);
- key.dptr = keystr;
- key.dsize = strlen (keystr) + 1;
rid = pdb_get_user_rid(sam_pass);
/* it's outaa here! 8^) */
- if ( tdb_delete(tdbsam, key) != TDB_SUCCESS ) {
+ if ( tdb_delete_bystring(tdbsam, keystr) != TDB_SUCCESS ) {
DEBUG(5, ("Error deleting entry from tdb passwd database!\n"));
DEBUGADD(5, (" Error: %s\n", tdb_errorstr(tdbsam)));
nt_status = NT_STATUS_UNSUCCESSFUL;
@@ -1209,12 +1199,10 @@ static NTSTATUS tdbsam_delete_sam_account(struct pdb_methods *my_methods, struct
/* set the search key */
slprintf(keystr, sizeof(keystr)-1, "%s%.8x", RIDPREFIX, rid);
- key.dptr = keystr;
- key.dsize = strlen (keystr) + 1;
/* it's outaa here! 8^) */
- if ( tdb_delete(tdbsam, key) != TDB_SUCCESS ) {
+ if ( tdb_delete_bystring(tdbsam, keystr) != TDB_SUCCESS ) {
DEBUG(5, ("Error deleting entry from tdb rid database!\n"));
DEBUGADD(5, (" Error: %s\n", tdb_errorstr(tdbsam)));
nt_status = NT_STATUS_UNSUCCESSFUL;
@@ -1236,7 +1224,7 @@ static NTSTATUS tdbsam_delete_sam_account(struct pdb_methods *my_methods, struct
****************************************************************************/
static BOOL tdb_update_samacct_only( struct samu* newpwd, int flag )
{
- TDB_DATA key, data;
+ TDB_DATA data;
uint8 *buf = NULL;
fstring keystr;
fstring name;
@@ -1260,12 +1248,10 @@ static BOOL tdb_update_samacct_only( struct samu* newpwd, int flag )
/* setup the USER index key */
slprintf(keystr, sizeof(keystr)-1, "%s%s", USERPREFIX, name);
- key.dptr = keystr;
- key.dsize = strlen(keystr) + 1;
/* add the account */
- if ( tdb_store(tdbsam, key, data, flag) != TDB_SUCCESS ) {
+ if ( tdb_store_bystring(tdbsam, keystr, data, flag) != TDB_SUCCESS ) {
DEBUG(0, ("Unable to modify passwd TDB!"));
DEBUGADD(0, (" Error: %s", tdb_errorstr(tdbsam)));
DEBUGADD(0, (" occured while storing the main record (%s)\n",
@@ -1287,7 +1273,7 @@ done:
****************************************************************************/
static BOOL tdb_update_ridrec_only( struct samu* newpwd, int flag )
{
- TDB_DATA key, data;
+ TDB_DATA data;
fstring keystr;
fstring name;
@@ -1295,16 +1281,13 @@ static BOOL tdb_update_ridrec_only( struct samu* newpwd, int flag )
strlower_m(name);
/* setup RID data */
- data.dsize = strlen(name) + 1;
- data.dptr = name;
+ data = string_term_tdb_data(name);
/* setup the RID index key */
slprintf(keystr, sizeof(keystr)-1, "%s%.8x", RIDPREFIX, pdb_get_user_rid(newpwd));
- key.dptr = keystr;
- key.dsize = strlen (keystr) + 1;
/* add the reference */
- if (tdb_store(tdbsam, key, data, flag) != TDB_SUCCESS) {
+ if (tdb_store_bystring(tdbsam, keystr, data, flag) != TDB_SUCCESS) {
DEBUG(0, ("Unable to modify TDB passwd !"));
DEBUGADD(0, (" Error: %s\n", tdb_errorstr(tdbsam)));
DEBUGADD(0, (" occured while storing the RID index (%s)\n", keystr));