summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-03-27 10:20:50 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:55 -0500
commitf61062b31d8d58f7f1ddd0f9f7932ca6f6499aaa (patch)
treeba4da91a62653fbf7f87a4289a9b764ef18e4693 /source3/smbd
parentc2f09ee288b71a47f2bb3fcc0b6ad98ae426a3e8 (diff)
downloadsamba-f61062b31d8d58f7f1ddd0f9f7932ca6f6499aaa.tar.gz
samba-f61062b31d8d58f7f1ddd0f9f7932ca6f6499aaa.tar.bz2
samba-f61062b31d8d58f7f1ddd0f9f7932ca6f6499aaa.zip
r21980: make use of tdb_*_bystring() and string_term_tdb_data() in smbd/
to avoid creating the TDB_DATA struct from strings "by hand" metze (This used to be commit 09b477ed85e46bc780ce3c1461472883a6b952f9)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/mangle_hash.c3
-rw-r--r--source3/smbd/session.c21
2 files changed, 6 insertions, 18 deletions
diff --git a/source3/smbd/mangle_hash.c b/source3/smbd/mangle_hash.c
index 320e31ab67..f20e473079 100644
--- a/source3/smbd/mangle_hash.c
+++ b/source3/smbd/mangle_hash.c
@@ -437,8 +437,7 @@ static void cache_mangled_name( const char mangled_name[13], char *raw_name )
}
/* Allocate a new cache entry. If the allocation fails, just return. */
- data_val.dptr = raw_name;
- data_val.dsize = strlen(raw_name)+1;
+ data_val = string_term_tdb_data(raw_name);
if (tdb_store_bystring(tdb_mangled_cache, mangled_name_key, data_val, TDB_REPLACE) != 0) {
DEBUG(0,("cache_mangled_name: Error storing entry %s -> %s\n", mangled_name_key, raw_name));
} else {
diff --git a/source3/smbd/session.c b/source3/smbd/session.c
index bcb840a3fe..da2ab40338 100644
--- a/source3/smbd/session.c
+++ b/source3/smbd/session.c
@@ -61,7 +61,6 @@ BOOL session_claim(user_struct *vuser)
struct in_addr *client_ip;
struct sessionid sessionid;
uint32 pid = (uint32)sys_getpid();
- TDB_DATA key;
fstring keystr;
char * hostname;
int tdb_store_flag; /* If using utmp, we do an inital 'lock hold' store,
@@ -87,10 +86,8 @@ BOOL session_claim(user_struct *vuser)
if (lp_utmp()) {
for (i=1;i<MAX_SESSION_ID;i++) {
slprintf(keystr, sizeof(keystr)-1, "ID/%d", i);
- key.dptr = keystr;
- key.dsize = strlen(keystr)+1;
- if (tdb_store(tdb, key, data, TDB_INSERT) == 0) break;
+ if (tdb_store_bystring(tdb, keystr, data, TDB_INSERT) == 0) break;
}
if (i == MAX_SESSION_ID) {
@@ -108,10 +105,6 @@ BOOL session_claim(user_struct *vuser)
slprintf(sessionid.id_str, sizeof(sessionid.id_str)-1,
SESSION_TEMPLATE, (long unsigned int)sys_getpid(),
vuser->vuid);
-
- key.dptr = keystr;
- key.dsize = strlen(keystr)+1;
-
tdb_store_flag = TDB_REPLACE;
}
@@ -142,14 +135,14 @@ BOOL session_claim(user_struct *vuser)
DEBUG(1,("pam_session rejected the session for %s [%s]\n",
sessionid.username, sessionid.id_str));
if (tdb_store_flag == TDB_MODIFY) {
- tdb_delete(tdb, key);
+ tdb_delete_bystring(tdb, keystr);
}
return False;
}
data.dptr = (char *)&sessionid;
data.dsize = sizeof(sessionid);
- if (tdb_store(tdb, key, data, tdb_store_flag) != 0) {
+ if (tdb_store_bystring(tdb, keystr, data, tdb_store_flag) != 0) {
DEBUG(1,("session_claim: unable to create session id record\n"));
return False;
}
@@ -177,7 +170,6 @@ void session_yield(user_struct *vuser)
TDB_DATA dbuf;
struct sessionid sessionid;
struct in_addr *client_ip;
- TDB_DATA key;
if (!tdb) return;
@@ -185,10 +177,7 @@ void session_yield(user_struct *vuser)
return;
}
- key.dptr = vuser->session_keystr;
- key.dsize = strlen(vuser->session_keystr)+1;
-
- dbuf = tdb_fetch(tdb, key);
+ dbuf = tdb_fetch_bystring(tdb, vuser->session_keystr);
if (dbuf.dsize != sizeof(sessionid))
return;
@@ -207,7 +196,7 @@ void session_yield(user_struct *vuser)
smb_pam_close_session(sessionid.username, sessionid.id_str, sessionid.hostname);
- tdb_delete(tdb, key);
+ tdb_delete_bystring(tdb, vuser->session_keystr);
}
/********************************************************************