1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

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)
This commit is contained in:
Stefan Metzmacher 2007-03-27 10:20:50 +00:00 committed by Gerald (Jerry) Carter
parent c2f09ee288
commit f61062b31d
2 changed files with 6 additions and 18 deletions

View File

@ -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 {

View File

@ -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);
}
/********************************************************************