diff options
author | Andrew Bartlett <abartlet@samba.org> | 2001-08-22 19:11:55 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2001-08-22 19:11:55 +0000 |
commit | 2051bb7d0366e07c5ecda5e5f7cfedc4153d6228 (patch) | |
tree | ed0c6282879b77e9ba56a5d8b9b3e53ed355437f /source3/smbd/session.c | |
parent | 28b206f16303d69694174d69fdfe2853bcee56c8 (diff) | |
download | samba-2051bb7d0366e07c5ecda5e5f7cfedc4153d6228.tar.gz samba-2051bb7d0366e07c5ecda5e5f7cfedc4153d6228.tar.bz2 samba-2051bb7d0366e07c5ecda5e5f7cfedc4153d6228.zip |
A few changes:
drop paramaters:
status
utmp hostname
change session code to always record each vuid current on the server. The sessionid struct is no longer packed, as I couldn't get that to work ;-)
change smbstatus to show this info and less of the connections.tdb info (its not actualy that accurate).
I'll get swat doing some of this shortly.
(This used to be commit b068ad300527c44673bbee0aede7849199c89de7)
Diffstat (limited to 'source3/smbd/session.c')
-rw-r--r-- | source3/smbd/session.c | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 7616689fe0..78c635d7cf 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -28,17 +28,9 @@ #include "includes.h" -#if defined(WITH_PAM) || defined(WITH_UTMP) +extern fstring remote_machine; static TDB_CONTEXT *tdb; -struct sessionid { - fstring username; - fstring hostname; - fstring id_str; - uint32 id_num; - uint32 pid; -}; - /* called when a session is created */ BOOL session_claim(uint16 vuid) { @@ -98,6 +90,10 @@ BOOL session_claim(uint16 vuid) slprintf(sessionid.id_str, sizeof(sessionid.id_str)-1, SESSION_TEMPLATE, i); sessionid.id_num = i; sessionid.pid = pid; + sessionid.uid = vuser->uid; + sessionid.gid = vuser->gid; + fstrcpy(sessionid.remote_machine, remote_machine); + fstrcpy(sessionid.ip_addr, client_addr()); if (!smb_pam_claim_session(sessionid.username, sessionid.id_str, sessionid.hostname)) { DEBUG(1,("pam_session rejected the session for %s [%s]\n", @@ -106,12 +102,8 @@ BOOL session_claim(uint16 vuid) return False; } - dlen = tdb_pack(dbuf, sizeof(dbuf), "fffdd", - sessionid.username, sessionid.hostname, sessionid.id_str, - sessionid.id_num, sessionid.pid); - - data.dptr = dbuf; - data.dsize = dlen; + data.dptr = (char *)&sessionid; + data.dsize = sizeof(sessionid); if (tdb_store(tdb, key, data, TDB_MODIFY) != 0) { DEBUG(1,("session_claim: unable to create session id record\n")); return False; @@ -132,7 +124,7 @@ BOOL session_claim(uint16 vuid) void session_yield(uint16 vuid) { user_struct *vuser = get_valid_user_struct(vuid); - TDB_DATA data; + TDB_DATA dbuf; struct sessionid sessionid; TDB_DATA key; fstring keystr; @@ -148,17 +140,15 @@ void session_yield(uint16 vuid) key.dptr = keystr; key.dsize = strlen(keystr)+1; - data = tdb_fetch(tdb, key); - if (data.dptr == NULL) { + dbuf = tdb_fetch(tdb, key); + + if (dbuf.dsize != sizeof(sessionid)) return; - } - tdb_unpack(data.dptr, data.dsize, "fffdd", - &sessionid.username, &sessionid.hostname, &sessionid.id_str, - &sessionid.id_num, &sessionid.pid); + memcpy(&sessionid, dbuf.dptr, sizeof(sessionid)); - safe_free(data.dptr); - data.dptr = NULL; + safe_free(dbuf.dptr); + dbuf.dptr = NULL; #if WITH_UTMP if (lp_utmp()) { @@ -172,8 +162,3 @@ void session_yield(uint16 vuid) tdb_delete(tdb, key); } -#else - /* null functions - no session support needed */ - BOOL session_claim(uint16 vuid) { return True; } - void session_yield(uint16 vuid) {} -#endif |