From f61062b31d8d58f7f1ddd0f9f7932ca6f6499aaa Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 27 Mar 2007 10:20:50 +0000 Subject: 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) --- source3/smbd/session.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'source3/smbd/session.c') 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;ivuid); - - 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); } /******************************************************************** -- cgit