From 3b4d7082cb9723214fe2410dd7a1e2d11d0f748f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 18 Apr 2001 16:42:07 +0000 Subject: new files for head (This used to be commit c0d4a1f5dd34e49843c879dd88fc78c7dffd9269) --- source3/smbd/session.c | 175 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 source3/smbd/session.c (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c new file mode 100644 index 0000000000..653a3d9c02 --- /dev/null +++ b/source3/smbd/session.c @@ -0,0 +1,175 @@ +/* + Unix SMB/Netbios implementation. + Version 2.0 + session handling for utmp and PAM + Copyright (C) tridge@samba.org 2001 + Copyright (C) abartlet@pcug.org.au 2001 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* a "session" is claimed when we do a SessionSetupX operation + and is yielded when the corresponding vuid is destroyed. + + sessions are used to populate utmp and PAM session structures +*/ + +#include "includes.h" + +#if defined(WITH_PAM) || defined(WITH_UTMP) + +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) +{ + user_struct *vuser = get_valid_user_struct(vuid); + int i; + TDB_DATA data; + struct sessionid sessionid; + pstring dbuf; + int dlen; + uint32 pid = (uint32)sys_getpid(); + TDB_DATA key; + fstring keystr; + + vuser->session_id = 0; + + /* don't register sessions for the guest user - its just too + expensive to go through pam session code for browsing etc */ + if (strequal(vuser->user.unix_name,lp_guestaccount(-1))) { + return True; + } + + if (!tdb) { + tdb = tdb_open(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST, + O_RDWR | O_CREAT, 0644); + if (!tdb) { + DEBUG(1,("session_claim: failed to open sessionid tdb\n")); + return False; + } + } + + ZERO_STRUCT(sessionid); + + data.dptr = NULL; + data.dsize = 0; + + for (i=1;iuser.unix_name); + fstrcpy(sessionid.hostname, lp_utmp_hostname()); + slprintf(sessionid.id_str, sizeof(sessionid.id_str)-1, SESSION_TEMPLATE, i); + sessionid.id_num = i; + sessionid.pid = pid; + + 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; + if (tdb_store(tdb, key, data, TDB_MODIFY) != 0) { + DEBUG(1,("session_claim: unable to create session id record\n")); + return False; + } + +#if WITH_PAM + if (!pam_session(True, sessionid.username, sessionid.id_str)) { + DEBUG(1,("pam_session rejected the session for %s [%s]\n", + sessionid.username, sessionid.id_str)); + tdb_delete(tdb, key); + return False; + } +#endif + +#if WITH_UTMP + if (lp_utmp()) { + sys_utmp_claim(sessionid.username, sessionid.hostname, + sessionid.id_str, sessionid.id_num); + } +#endif + + vuser->session_id = i; + return True; +} + +/* called when a session is destroyed */ +void session_yield(uint16 vuid) +{ + user_struct *vuser = get_valid_user_struct(vuid); + TDB_DATA data; + struct sessionid sessionid; + TDB_DATA key; + fstring keystr; + + if (!tdb) return; + + if (vuser->session_id == 0) { + return; + } + + slprintf(keystr, sizeof(keystr)-1, "ID/%d", vuser->session_id); + + key.dptr = keystr; + key.dsize = strlen(keystr)+1; + + data = tdb_fetch(tdb, key); + if (data.dptr == NULL) { + return; + } + + tdb_unpack(data.dptr, data.dsize, "fffdd", + &sessionid.username, &sessionid.hostname, &sessionid.id_str, + &sessionid.id_num, &sessionid.pid); + +#if WITH_UTMP + if (lp_utmp()) { + sys_utmp_yield(sessionid.username, sessionid.hostname, + sessionid.id_str, sessionid.id_num); + } +#endif + +#if WITH_PAM + pam_session(False, sessionid.username, sessionid.id_str); +#endif + + tdb_delete(tdb, key); +} + +#else + /* null functions - no session support needed */ + BOOL session_claim(uint16 vuid) { return True; } + void session_yield(uint16 vuid) {} +#endif -- cgit From e129db422b7e2bf9a567ed4b778e7ca326e14a4b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 21 Apr 2001 07:43:54 +0000 Subject: Fixed compile bug when using --with-pam but not --with-utmp. Jeremy. (This used to be commit 1e098744677e022547707ebff500fb4515402871) --- source3/smbd/session.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 653a3d9c02..4ede1d9a68 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -89,7 +89,14 @@ BOOL session_claim(uint16 vuid) } fstrcpy(sessionid.username, vuser->user.unix_name); +#if WITH_UTMP fstrcpy(sessionid.hostname, lp_utmp_hostname()); +#else + { + extern fstring remote_machine; + fstrcpy(sessionid.hostname, remote_machine); + } +#endif slprintf(sessionid.id_str, sizeof(sessionid.id_str)-1, SESSION_TEMPLATE, i); sessionid.id_num = i; sessionid.pid = pid; -- cgit From e277c08631316ccda875a09a67ebb220c495c5a9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 22 Apr 2001 07:20:24 +0000 Subject: Commit of a modified version of Andrew Bartlett's patch that removes the horrid utmp hostname parameter - now uses the client name instead. Also tidies up some of the unencrypted password checking when PAM is compiled in. FIXME ! An pam_accountcheck() is being called even when smb encrypted passwords are negotiated. Is this the correct thing to do when winbindd is running ! This needs *SEVERE* testing.... Jeremy. (This used to be commit 071c799f479dd25efdb9c41745fc8f2beea7b568) --- source3/smbd/session.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 4ede1d9a68..fb13019812 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -51,6 +51,7 @@ BOOL session_claim(uint16 vuid) uint32 pid = (uint32)sys_getpid(); TDB_DATA key; fstring keystr; + char * hostname; vuser->session_id = 0; @@ -88,15 +89,12 @@ BOOL session_claim(uint16 vuid) return False; } + hostname = client_name(); + if (strequal(hostname,"UNKNOWN")) + hostname = client_addr(); + fstrcpy(sessionid.username, vuser->user.unix_name); -#if WITH_UTMP - fstrcpy(sessionid.hostname, lp_utmp_hostname()); -#else - { - extern fstring remote_machine; - fstrcpy(sessionid.hostname, remote_machine); - } -#endif + fstrcpy(sessionid.hostname, hostname); slprintf(sessionid.id_str, sizeof(sessionid.id_str)-1, SESSION_TEMPLATE, i); sessionid.id_num = i; sessionid.pid = pid; @@ -113,7 +111,7 @@ BOOL session_claim(uint16 vuid) } #if WITH_PAM - if (!pam_session(True, sessionid.username, sessionid.id_str)) { + if (!pam_session(True, sessionid.username, sessionid.id_str, sessionid.hostname)) { DEBUG(1,("pam_session rejected the session for %s [%s]\n", sessionid.username, sessionid.id_str)); tdb_delete(tdb, key); @@ -169,7 +167,7 @@ void session_yield(uint16 vuid) #endif #if WITH_PAM - pam_session(False, sessionid.username, sessionid.id_str); + pam_session(False, sessionid.username, sessionid.id_str, sessionid.hostname); #endif tdb_delete(tdb, key); -- cgit From ae8418d0c400f6458c1eb0b79881fd02629e5acd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 23 Apr 2001 04:15:35 +0000 Subject: Added smb_ prefix to all Samba wrapper pam functions. Fixed off by one bug using StrnCpy instead of strdup(). Jeremy. (This used to be commit d4b1c0be2e700c86a4338bb497777f97e3c960a7) --- source3/smbd/session.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index fb13019812..2f86832b4a 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -111,8 +111,8 @@ BOOL session_claim(uint16 vuid) } #if WITH_PAM - if (!pam_session(True, sessionid.username, sessionid.id_str, sessionid.hostname)) { - DEBUG(1,("pam_session rejected the session for %s [%s]\n", + if (!smb_pam_session(True, sessionid.username, sessionid.id_str, sessionid.hostname)) { + DEBUG(1,("smb_pam_session rejected the session for %s [%s]\n", sessionid.username, sessionid.id_str)); tdb_delete(tdb, key); return False; @@ -167,7 +167,7 @@ void session_yield(uint16 vuid) #endif #if WITH_PAM - pam_session(False, sessionid.username, sessionid.id_str, sessionid.hostname); + smb_pam_session(False, sessionid.username, sessionid.id_str, sessionid.hostname); #endif tdb_delete(tdb, key); -- cgit From 30daf2e939b6dbc50e9389f26f3b1f4a4d6d5c2e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 23 Apr 2001 23:07:31 +0000 Subject: Fixed memory leak in new session code. Jeremy. (This used to be commit 43b69e5d6e78a30563d7c1d03c7e920d529487b5) --- source3/smbd/session.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 2f86832b4a..3131fb9f54 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -159,6 +159,9 @@ void session_yield(uint16 vuid) &sessionid.username, &sessionid.hostname, &sessionid.id_str, &sessionid.id_num, &sessionid.pid); + safe_free(data.dptr); + data.dptr = NULL; + #if WITH_UTMP if (lp_utmp()) { sys_utmp_yield(sessionid.username, sessionid.hostname, -- cgit From c3a999409db6a9e0d38928feb02ab6815bd28d57 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 30 Apr 2001 21:05:58 +0000 Subject: Based on an original PAM patch by Andrew Bartlett, re-written by me to remove global static PAM variables, and to tidy up the PAM internals code. Now looks like the rest of Samba. Still needs testing. Jeremy. (This used to be commit 1648ac64a75de74d1a1575eb49cccc4f75488bfa) --- source3/smbd/session.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 3131fb9f54..40654c0f43 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -99,6 +99,13 @@ BOOL session_claim(uint16 vuid) sessionid.id_num = i; sessionid.pid = pid; + if (!smb_pam_claim_session(sessionid.username, sessionid.id_str, sessionid.hostname)) { + DEBUG(1,("pam_session rejected the session for %s [%s]\n", + sessionid.username, sessionid.id_str)); + tdb_delete(tdb, key); + return False; + } + dlen = tdb_pack(dbuf, sizeof(dbuf), "fffdd", sessionid.username, sessionid.hostname, sessionid.id_str, sessionid.id_num, sessionid.pid); @@ -110,15 +117,6 @@ BOOL session_claim(uint16 vuid) return False; } -#if WITH_PAM - if (!smb_pam_session(True, sessionid.username, sessionid.id_str, sessionid.hostname)) { - DEBUG(1,("smb_pam_session rejected the session for %s [%s]\n", - sessionid.username, sessionid.id_str)); - tdb_delete(tdb, key); - return False; - } -#endif - #if WITH_UTMP if (lp_utmp()) { sys_utmp_claim(sessionid.username, sessionid.hostname, @@ -169,9 +167,7 @@ void session_yield(uint16 vuid) } #endif -#if WITH_PAM - smb_pam_session(False, sessionid.username, sessionid.id_str, sessionid.hostname); -#endif + smb_pam_close_session(sessionid.username, sessionid.id_str, sessionid.hostname); tdb_delete(tdb, key); } -- cgit From 05fc3e578c895f632b351969d09cd00feb7599c7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Jun 2001 05:13:59 +0000 Subject: use LDSHFLAGS not -shared in several places (This used to be commit 8ec9c87b5d1a7dae17d5b1a30f58effaf5e69e4b) --- source3/smbd/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 40654c0f43..8f6907c537 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -62,7 +62,7 @@ BOOL session_claim(uint16 vuid) } if (!tdb) { - tdb = tdb_open(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST, + tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST, O_RDWR | O_CREAT, 0644); if (!tdb) { DEBUG(1,("session_claim: failed to open sessionid tdb\n")); -- cgit From 996719cce26700c68ff0e456e6a25d20085d091f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 30 Jul 2001 22:21:31 +0000 Subject: Added "use mmap" for HPUX. Jeremy. (This used to be commit 840802f10677cb0009cb4df4c37c7d01aa5edacd) --- source3/smbd/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 8f6907c537..7616689fe0 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -62,7 +62,7 @@ BOOL session_claim(uint16 vuid) } if (!tdb) { - tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST, + tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST|USE_TDB_MMAP_FLAG, O_RDWR | O_CREAT, 0644); if (!tdb) { DEBUG(1,("session_claim: failed to open sessionid tdb\n")); -- cgit From 2051bb7d0366e07c5ecda5e5f7cfedc4153d6228 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 22 Aug 2001 19:11:55 +0000 Subject: 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) --- source3/smbd/session.c | 43 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) (limited to 'source3/smbd/session.c') 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 -- cgit From 2f6486b55f05947205c380e071b16cd40af4d057 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 23 Aug 2001 18:13:56 +0000 Subject: Fix up some unused variables and functions, fix up formatting (This used to be commit bfce4ba7b6db261d981a60a7e262f2f690355f5c) --- source3/smbd/session.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 78c635d7cf..eaff78c685 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -38,8 +38,6 @@ BOOL session_claim(uint16 vuid) int i; TDB_DATA data; struct sessionid sessionid; - pstring dbuf; - int dlen; uint32 pid = (uint32)sys_getpid(); TDB_DATA key; fstring keystr; -- cgit From 9a9ac2739bbdc993ecdfa78298bdd9c059328378 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Sep 2001 22:08:19 +0000 Subject: got rid of USE_TDB_MMAP_FLAG as its not needed any more (This used to be commit c26e0d3f27a05ecc8bd2390f9aab7f9451524e47) --- source3/smbd/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index eaff78c685..6a27cd7326 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -52,7 +52,7 @@ BOOL session_claim(uint16 vuid) } if (!tdb) { - tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST|USE_TDB_MMAP_FLAG, + tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, O_RDWR | O_CREAT, 0644); if (!tdb) { DEBUG(1,("session_claim: failed to open sessionid tdb\n")); -- cgit From 61b2794968faa35dc91edce17e9b91e5366c3514 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 17 Sep 2001 11:25:41 +0000 Subject: move to SAFE_FREE() (This used to be commit a95943fde0ad89ae3f2deca2f7ba9cb5ab612b74) --- source3/smbd/session.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 6a27cd7326..faf1bb249f 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -145,8 +145,7 @@ void session_yield(uint16 vuid) memcpy(&sessionid, dbuf.dptr, sizeof(sessionid)); - safe_free(dbuf.dptr); - dbuf.dptr = NULL; + SAFE_FREE(dbuf.dptr); #if WITH_UTMP if (lp_utmp()) { -- cgit From a443dea5d1f6b63c464711a16fbea87541621394 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Mon, 22 Oct 2001 18:14:42 +0000 Subject: server support for RAP session list function (This used to be commit d42c28fbadf577a23fb8c1da9e1c64a2f34fe133) --- source3/smbd/session.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index faf1bb249f..60c2a6e54d 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -159,3 +159,16 @@ void session_yield(uint16 vuid) tdb_delete(tdb, key); } +BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *), void *state) +{ + if (!tdb) { + DEBUG(3, ("No tdb opened\n")); + return False; + } + + tdb_traverse(tdb, fn, state); + return True; +} + + + -- cgit From 55dfb66079333acd8e0aee91c0ee90d0a413a8e6 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 8 Nov 2001 22:19:01 +0000 Subject: Change to guest logon code. This changes the way we process guest logons - we now treat them as normal logons, but set the 'guest' flag. In particular this is needed becouse Win2k will do an NTLMSSP login with username "", therefore missing our previous guest connection code - this is getting a pain to do as a special case all over the shop. Tridge: We don't seem to be setting a guest bit for NTLMSSP, in either the anonymous or authenticated case, can you take a look at this? Also some cleanups in the check_password() code that should make some of the debugs clearer. Various other minor cleanups: - change the session code to just take a vuser, rather than having to do a vuid lookup on vuser.vuid - Change some of the global_client_caps linking - Better debug in authorise_login(): show the vuid. Andrew Bartlett (This used to be commit 62f4e4bd0aef9ade653b3f8d575d2864c166ab4d) --- source3/smbd/session.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 60c2a6e54d..9efc3e6b75 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -32,9 +32,8 @@ extern fstring remote_machine; static TDB_CONTEXT *tdb; /* called when a session is created */ -BOOL session_claim(uint16 vuid) +BOOL session_claim(user_struct *vuser) { - user_struct *vuser = get_valid_user_struct(vuid); int i; TDB_DATA data; struct sessionid sessionid; @@ -47,7 +46,7 @@ BOOL session_claim(uint16 vuid) /* don't register sessions for the guest user - its just too expensive to go through pam session code for browsing etc */ - if (strequal(vuser->user.unix_name,lp_guestaccount(-1))) { + if (vuser->guest) { return True; } @@ -119,9 +118,8 @@ BOOL session_claim(uint16 vuid) } /* called when a session is destroyed */ -void session_yield(uint16 vuid) +void session_yield(user_struct *vuser) { - user_struct *vuser = get_valid_user_struct(vuid); TDB_DATA dbuf; struct sessionid sessionid; TDB_DATA key; -- cgit From 4d5175c832d905e06c0840388b925e14b58024af Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 19 Nov 2001 04:27:39 +0000 Subject: Don't resolve the hostname in smbd as we can pause for a long time while waiting for DNS timeouts to occur. The correct place to do this is in the code that displays the session information. (This used to be commit 2e89165f22d9e9c1fa749ae54957d0ec84a1497d) --- source3/smbd/session.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 9efc3e6b75..d483f12d16 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -78,9 +78,12 @@ BOOL session_claim(user_struct *vuser) return False; } - hostname = client_name(); - if (strequal(hostname,"UNKNOWN")) - hostname = client_addr(); + /* Don't resolve the hostname in smbd as we can pause for a long + time while waiting for DNS timeouts to occur. The correct + place to do this is in the code that displays the session + information. */ + + hostname = client_addr(); fstrcpy(sessionid.username, vuser->user.unix_name); fstrcpy(sessionid.hostname, hostname); -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/smbd/session.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index d483f12d16..c8f77aaa61 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -1,6 +1,5 @@ /* - Unix SMB/Netbios implementation. - Version 2.0 + Unix SMB/CIFS implementation. session handling for utmp and PAM Copyright (C) tridge@samba.org 2001 Copyright (C) abartlet@pcug.org.au 2001 -- cgit From c1d83be9b5e8f928e2234528d5f99a771d23ca37 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 9 Feb 2002 03:29:36 +0000 Subject: Do the reverse DNS lookup, but only if 'hostname lookups = yes' Andrew Bartlett (This used to be commit dfecd6a4534743a3e140eafc9836911286793951) --- source3/smbd/session.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index c8f77aaa61..6f9d62edfd 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -77,12 +77,14 @@ BOOL session_claim(user_struct *vuser) return False; } - /* Don't resolve the hostname in smbd as we can pause for a long - time while waiting for DNS timeouts to occur. The correct - place to do this is in the code that displays the session - information. */ + /* If 'hostname lookup' == yes, then do the DNS lookup. This is + needed becouse utmp and PAM both expect DNS names */ - hostname = client_addr(); + if (lp_hostname_lookups()) { + hostname = client_name(); + } else { + hostname = client_addr(); + } fstrcpy(sessionid.username, vuser->user.unix_name); fstrcpy(sessionid.hostname, hostname); -- cgit From 1c92b99c80632bfdaeba60be2ba885ad84285460 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 23 Mar 2002 09:00:27 +0000 Subject: Correctly store the hostname of the remote machine if so configured. If the reverse DNS fails, then store the IP. (This used to be commit d97771aa80b48fbdb9cae3e9712e35fcc895b148) --- source3/smbd/session.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 6f9d62edfd..05a7b24da2 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -78,11 +78,13 @@ BOOL session_claim(user_struct *vuser) } /* If 'hostname lookup' == yes, then do the DNS lookup. This is - needed becouse utmp and PAM both expect DNS names */ + needed becouse utmp and PAM both expect DNS names + + client_name() handles this case internally. + */ - if (lp_hostname_lookups()) { - hostname = client_name(); - } else { + hostname = client_name(); + if (strcmp(hostname, "UNKNOWN") == 0) { hostname = client_addr(); } -- cgit From e90b65284812aaa5ff9e9935ce9bbad7791cbbcd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Jul 2002 10:35:28 +0000 Subject: updated the 3.0 branch from the head branch - ready for alpha18 (This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce) --- source3/smbd/session.c | 52 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 7 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 05a7b24da2..dade953ec1 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -163,16 +163,54 @@ void session_yield(user_struct *vuser) tdb_delete(tdb, key); } -BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *), void *state) +static BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *), void *state) { - if (!tdb) { - DEBUG(3, ("No tdb opened\n")); - return False; - } + if (!tdb) { + DEBUG(3, ("No tdb opened\n")); + return False; + } - tdb_traverse(tdb, fn, state); - return True; + tdb_traverse(tdb, fn, state); + return True; } +struct session_list { + int count; + struct sessionid *sessions; +}; + +static int gather_sessioninfo(TDB_CONTEXT *stdb, TDB_DATA kbuf, TDB_DATA dbuf, + void *state) +{ + struct session_list *sesslist = (struct session_list *) state; + const struct sessionid *current = (const struct sessionid *) dbuf.dptr; + + sesslist->count += 1; + sesslist->sessions = REALLOC(sesslist->sessions, sesslist->count * + sizeof(struct sessionid)); + + memcpy(&sesslist->sessions[sesslist->count - 1], current, + sizeof(struct sessionid)); + DEBUG(7,("gather_sessioninfo session from %s@%s\n", + current->username, current->remote_machine)); + return 0; +} +int list_sessions(struct sessionid **session_list) +{ + struct session_list sesslist; + + sesslist.count = 0; + sesslist.sessions = NULL; + + if (!session_traverse(gather_sessioninfo, (void *) &sesslist)) { + DEBUG(3, ("Session traverse failed\n")); + SAFE_FREE(sesslist.sessions); + *session_list = NULL; + return 0; + } + *session_list = sesslist.sessions; + return sesslist.count; +} + -- cgit From 127e77e6e334fdc33086bffcbe00d340c0ba0097 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 17 Aug 2002 15:27:10 +0000 Subject: Sync 3.0 branch with head (This used to be commit 42615b945e2e48e53a21ea47f2e45407913a6a1e) --- source3/smbd/session.c | 74 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 26 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index dade953ec1..54b7a24b07 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -27,21 +27,22 @@ #include "includes.h" -extern fstring remote_machine; - static TDB_CONTEXT *tdb; /* called when a session is created */ BOOL session_claim(user_struct *vuser) { - int i; + int i = 0; TDB_DATA data; 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, + but we don't need this if we are just using the + (unique) pid/vuid combination */ - vuser->session_id = 0; + vuser->session_keystr = NULL; /* don't register sessions for the guest user - its just too expensive to go through pam session code for browsing etc */ @@ -63,18 +64,37 @@ BOOL session_claim(user_struct *vuser) data.dptr = NULL; data.dsize = 0; - for (i=1;ivuid); + 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; - - if (tdb_store(tdb, key, data, TDB_INSERT) == 0) break; - } - - if (i == MAX_SESSION_ID) { - DEBUG(1,("session_claim: out of session IDs (max is %d)\n", - MAX_SESSION_ID)); - return False; + + tdb_store_flag = TDB_REPLACE; } /* If 'hostname lookup' == yes, then do the DNS lookup. This is @@ -90,24 +110,25 @@ BOOL session_claim(user_struct *vuser) fstrcpy(sessionid.username, vuser->user.unix_name); fstrcpy(sessionid.hostname, hostname); - slprintf(sessionid.id_str, sizeof(sessionid.id_str)-1, SESSION_TEMPLATE, i); - sessionid.id_num = i; + sessionid.id_num = i; /* Only valid for utmp sessions */ sessionid.pid = pid; sessionid.uid = vuser->uid; sessionid.gid = vuser->gid; - fstrcpy(sessionid.remote_machine, remote_machine); + fstrcpy(sessionid.remote_machine, get_remote_machine_name()); 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", sessionid.username, sessionid.id_str)); - tdb_delete(tdb, key); + if (tdb_store_flag == TDB_MODIFY) { + tdb_delete(tdb, key); + } return False; } data.dptr = (char *)&sessionid; data.dsize = sizeof(sessionid); - if (tdb_store(tdb, key, data, TDB_MODIFY) != 0) { + if (tdb_store(tdb, key, data, tdb_store_flag) != 0) { DEBUG(1,("session_claim: unable to create session id record\n")); return False; } @@ -119,7 +140,11 @@ BOOL session_claim(user_struct *vuser) } #endif - vuser->session_id = i; + vuser->session_keystr = strdup(keystr); + if (!vuser->session_keystr) { + DEBUG(0, ("session_claim: strdup() failed for session_keystr\n")); + return False; + } return True; } @@ -129,18 +154,15 @@ void session_yield(user_struct *vuser) TDB_DATA dbuf; struct sessionid sessionid; TDB_DATA key; - fstring keystr; if (!tdb) return; - if (vuser->session_id == 0) { + if (!vuser->session_keystr) { return; } - slprintf(keystr, sizeof(keystr)-1, "ID/%d", vuser->session_id); - - key.dptr = keystr; - key.dsize = strlen(keystr)+1; + key.dptr = vuser->session_keystr; + key.dsize = strlen(vuser->session_keystr)+1; dbuf = tdb_fetch(tdb, key); -- cgit From 596de71fc60b622d7a9d5e12baf234db0bf22499 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 24 Apr 2003 09:52:29 +0000 Subject: When possible, store the IP address of the connecting client, not just the hostname. This makes 'last -i' show the IP. Thanks to Philip Anderson for the idea. Andrew Bartlett (This used to be commit 107731c080da1e3e4e13e966f8b79bfd2692a952) --- source3/smbd/session.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 54b7a24b07..2478b34d6e 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -33,6 +33,8 @@ BOOL session_claim(user_struct *vuser) { int i = 0; TDB_DATA data; + struct sockaddr sa; + struct in_addr *client_ip; struct sessionid sessionid; uint32 pid = (uint32)sys_getpid(); TDB_DATA key; @@ -117,6 +119,8 @@ BOOL session_claim(user_struct *vuser) fstrcpy(sessionid.remote_machine, get_remote_machine_name()); fstrcpy(sessionid.ip_addr, client_addr()); + client_ip = client_inaddr(&sa); + if (!smb_pam_claim_session(sessionid.username, sessionid.id_str, sessionid.hostname)) { DEBUG(1,("pam_session rejected the session for %s [%s]\n", sessionid.username, sessionid.id_str)); @@ -136,6 +140,7 @@ BOOL session_claim(user_struct *vuser) #if WITH_UTMP if (lp_utmp()) { sys_utmp_claim(sessionid.username, sessionid.hostname, + client_ip, sessionid.id_str, sessionid.id_num); } #endif @@ -153,7 +158,8 @@ void session_yield(user_struct *vuser) { TDB_DATA dbuf; struct sessionid sessionid; - TDB_DATA key; + struct in_addr client_ip; + TDB_DATA key; if (!tdb) return; @@ -171,11 +177,14 @@ void session_yield(user_struct *vuser) memcpy(&sessionid, dbuf.dptr, sizeof(sessionid)); + inet_pton(AF_INET, sessionid.ip_addr, &client_ip); + SAFE_FREE(dbuf.dptr); #if WITH_UTMP if (lp_utmp()) { sys_utmp_yield(sessionid.username, sessionid.hostname, + &client_ip, sessionid.id_str, sessionid.id_num); } #endif -- cgit From 4121d1611da65e13e0285a8714f21d6d6be2d4d7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 28 Apr 2003 09:19:09 +0000 Subject: inet_pton isn't portable, so use interpret_addr2. (This used to be commit 04d27381325561038bee1c27f10c748b9aaf447d) --- source3/smbd/session.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 2478b34d6e..ac06b9872d 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -158,7 +158,7 @@ void session_yield(user_struct *vuser) { TDB_DATA dbuf; struct sessionid sessionid; - struct in_addr client_ip; + struct in_addr *client_ip; TDB_DATA key; if (!tdb) return; @@ -177,14 +177,14 @@ void session_yield(user_struct *vuser) memcpy(&sessionid, dbuf.dptr, sizeof(sessionid)); - inet_pton(AF_INET, sessionid.ip_addr, &client_ip); + client_ip = interpret_addr2(sessionid.ip_addr); SAFE_FREE(dbuf.dptr); #if WITH_UTMP if (lp_utmp()) { sys_utmp_yield(sessionid.username, sessionid.hostname, - &client_ip, + client_ip, sessionid.id_str, sessionid.id_num); } #endif -- cgit From 402fbc518a5489b33f1c5eafb8e6acb9ee5addbd Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 14 May 2003 00:46:43 +0000 Subject: spelling (This used to be commit 865c11275685c85124b506c9bbd2a8bde2e760b9) --- source3/smbd/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index ac06b9872d..b7f3bc43e7 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -100,7 +100,7 @@ BOOL session_claim(user_struct *vuser) } /* If 'hostname lookup' == yes, then do the DNS lookup. This is - needed becouse utmp and PAM both expect DNS names + needed because utmp and PAM both expect DNS names client_name() handles this case internally. */ -- cgit From 71298881c4a630666c1a14be99048f8f86e48162 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 6 Jun 2003 22:33:43 +0000 Subject: * add in David Lee's utmp patch (defaults to on if available) * one more try at fixing builds when --with-ldap=no (This used to be commit b516ab7bdef6b6b2b7f0df8966dbd4c329f46a92) --- source3/smbd/session.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index b7f3bc43e7..4d8826d332 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -66,7 +66,6 @@ BOOL session_claim(user_struct *vuser) data.dptr = NULL; data.dsize = 0; -#if WITH_UTMP if (lp_utmp()) { for (i=1;isession_keystr = strdup(keystr); if (!vuser->session_keystr) { @@ -181,13 +177,11 @@ void session_yield(user_struct *vuser) SAFE_FREE(dbuf.dptr); -#if WITH_UTMP if (lp_utmp()) { sys_utmp_yield(sessionid.username, sessionid.hostname, client_ip, sessionid.id_str, sessionid.id_num); } -#endif smb_pam_close_session(sessionid.username, sessionid.id_str, sessionid.hostname); -- cgit From df6d2db4ced5586320804950da58a62248db4d56 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 12 Feb 2004 05:24:02 +0000 Subject: merge from old APP_HEAD * remove corrupt tdb and shutdown (only for printing tdbs, connections, sessionid & locking) * decrement smbd counter in connections.tdb in smb_panic() * various Makefile hack to get things to link 'max smbd processes' looks like it might be broken. The counter KEY is not being set. Will look into that tomorrow. (This used to be commit 6e22c5da929b6d9a4e32dc704c83112b2ad8fcfd) --- source3/smbd/session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 4d8826d332..a811a6e305 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -53,8 +53,8 @@ BOOL session_claim(user_struct *vuser) } if (!tdb) { - tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, - O_RDWR | O_CREAT, 0644); + tdb = tdb_open_ex(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, + O_RDWR | O_CREAT, 0644, smbd_tdb_log); if (!tdb) { DEBUG(1,("session_claim: failed to open sessionid tdb\n")); return False; -- cgit From 8eec62ebfb238133d95d7247b7126292f47c7093 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 19 Feb 2004 01:55:24 +0000 Subject: Fix the "too many fcntl locks" scalability problem raised by tridge. I've now tested this in daemon mode and also on xinetd and I'm pretty sure it's working. Jeremy. (This used to be commit 14dee038019b11300466b148c53515fc76e5e870) --- source3/smbd/session.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index a811a6e305..61118f13dd 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -28,6 +28,22 @@ #include "includes.h" static TDB_CONTEXT *tdb; + +BOOL session_init(void) +{ + if (tdb) + return True; + + tdb = tdb_open_ex(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, + O_RDWR | O_CREAT, 0644, smbd_tdb_log); + if (!tdb) { + DEBUG(1,("session_init: failed to open sessionid tdb\n")); + return False; + } + + return True; +} + /* called when a session is created */ BOOL session_claim(user_struct *vuser) { @@ -52,14 +68,8 @@ BOOL session_claim(user_struct *vuser) return True; } - if (!tdb) { - tdb = tdb_open_ex(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, - O_RDWR | O_CREAT, 0644, smbd_tdb_log); - if (!tdb) { - DEBUG(1,("session_claim: failed to open sessionid tdb\n")); - return False; - } - } + if (!session_init()) + return False; ZERO_STRUCT(sessionid); @@ -190,7 +200,7 @@ void session_yield(user_struct *vuser) static BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *), void *state) { - if (!tdb) { + if (!session_init()) { DEBUG(3, ("No tdb opened\n")); return False; } @@ -238,4 +248,3 @@ int list_sessions(struct sessionid **session_list) *session_list = sesslist.sessions; return sesslist.count; } - -- cgit From 386a11f49eff2ec60d75b9966ecdc5627b259f0d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 4 Jun 2004 17:26:09 +0000 Subject: r1011: fix bad merge (from a few months ago) and ensure that we always use tdb_open_log() instead of tdb_open_ex() (This used to be commit e65564ab4aa1240e84b8d272510aa770cad0ed0e) --- source3/smbd/session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 61118f13dd..91ebaeb830 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -34,8 +34,8 @@ BOOL session_init(void) if (tdb) return True; - tdb = tdb_open_ex(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, - O_RDWR | O_CREAT, 0644, smbd_tdb_log); + tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, + O_RDWR | O_CREAT, 0644); if (!tdb) { DEBUG(1,("session_init: failed to open sessionid tdb\n")); return False; -- cgit From acf9d61421faa6c0055d57fdee7db300dc5431aa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Dec 2004 18:25:53 +0000 Subject: r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a) --- source3/smbd/session.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 91ebaeb830..9a9a0d90b2 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -151,7 +151,7 @@ BOOL session_claim(user_struct *vuser) sessionid.id_str, sessionid.id_num); } - vuser->session_keystr = strdup(keystr); + vuser->session_keystr = SMB_STRDUP(keystr); if (!vuser->session_keystr) { DEBUG(0, ("session_claim: strdup() failed for session_keystr\n")); return False; @@ -221,8 +221,8 @@ static int gather_sessioninfo(TDB_CONTEXT *stdb, TDB_DATA kbuf, TDB_DATA dbuf, const struct sessionid *current = (const struct sessionid *) dbuf.dptr; sesslist->count += 1; - sesslist->sessions = REALLOC(sesslist->sessions, sesslist->count * - sizeof(struct sessionid)); + sesslist->sessions = SMB_REALLOC_ARRAY(sesslist->sessions, struct sessionid, + sesslist->count); memcpy(&sesslist->sessions[sesslist->count - 1], current, sizeof(struct sessionid)); -- cgit From 1bfb5b734b0d5e1bc093bb43513729ed458fe372 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 25 Nov 2005 12:31:40 +0000 Subject: r11909: Implement 'reset on zero vc'. This kills other connections when a session setup comes in with the vc (virtual connection) field set to zero. This is done by Windows, probably you can tweak that by some registry key. This boolean option controls whether an incoming session setup should kill other connections coming from the same IP. This matches the default Windows 2003 behaviour. Setting this parameter to yes becomes necessary when you have a flaky network and windows decides to reconnect while the old connection still has files with share modes open. These files become inaccessible over the new connection. The client sends a zero VC on the new connection, and Windows 2003 kills all other connections coming from the same IP. This way the locked files are accessible again. Please be aware that enabling this option will kill connections behind a masquerading router. Volker (This used to be commit 5629ca16235f0aa21fea3afd9e414309e4e1374e) --- source3/smbd/session.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 9a9a0d90b2..27f760a088 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -198,7 +198,8 @@ void session_yield(user_struct *vuser) tdb_delete(tdb, key); } -static BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *), void *state) +BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *), + void *state) { if (!session_init()) { DEBUG(3, ("No tdb opened\n")); -- cgit From 894358a8f3e338b339b6c37233edef794b312087 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Mar 2006 06:31:04 +0000 Subject: r13915: Fixed a very interesting class of realloc() bugs found by Coverity. realloc can return NULL in one of two cases - (1) the realloc failed, (2) realloc succeeded but the new size requested was zero, in which case this is identical to a free() call. The error paths dealing with these two cases should be different, but mostly weren't. Secondly the standard idiom for dealing with realloc when you know the new size is non-zero is the following : tmp = realloc(p, size); if (!tmp) { SAFE_FREE(p); return error; } else { p = tmp; } However, there were *many* *many* places in Samba where we were using the old (broken) idiom of : p = realloc(p, size) if (!p) { return error; } which will leak the memory pointed to by p on realloc fail. This commit (hopefully) fixes all these cases by moving to a standard idiom of : p = SMB_REALLOC(p, size) if (!p) { return error; } Where if the realloc returns null due to the realloc failing or size == 0 we *guarentee* that the storage pointed to by p has been freed. This allows me to remove a lot of code that was dealing with the standard (more verbose) method that required a tmp pointer. This is almost always what you want. When a realloc fails you never usually want the old memory, you want to free it and get into your error processing asap. For the 11 remaining cases where we really do need to keep the old pointer I have invented the new macro SMB_REALLOC_KEEP_OLD_ON_ERROR, which can be used as follows : tmp = SMB_REALLOC_KEEP_OLD_ON_ERROR(p, size); if (!tmp) { SAFE_FREE(p); return error; } else { p = tmp; } SMB_REALLOC_KEEP_OLD_ON_ERROR guarentees never to free the pointer p, even on size == 0 or realloc fail. All this is done by a hidden extra argument to Realloc(), BOOL free_old_on_error which is set appropriately by the SMB_REALLOC and SMB_REALLOC_KEEP_OLD_ON_ERROR macros (and their array counterparts). It remains to be seen what this will do to our Coverity bug count :-). Jeremy. (This used to be commit 1d710d06a214f3f1740e80e0bffd6aab44aac2b0) --- source3/smbd/session.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 27f760a088..41f8fd0ed4 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -224,6 +224,10 @@ static int gather_sessioninfo(TDB_CONTEXT *stdb, TDB_DATA kbuf, TDB_DATA dbuf, sesslist->count += 1; sesslist->sessions = SMB_REALLOC_ARRAY(sesslist->sessions, struct sessionid, sesslist->count); + if (!sesslist->sessions) { + sesslist->count = 0; + return -1; + } memcpy(&sesslist->sessions[sesslist->count - 1], current, sizeof(struct sessionid)); -- cgit From fbdcf2663b56007a438ac4f0d8d82436b1bfe688 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Jul 2006 18:01:26 +0000 Subject: r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8) --- source3/smbd/session.c | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 41f8fd0ed4..bcb840a3fe 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -1,8 +1,10 @@ /* Unix SMB/CIFS implementation. session handling for utmp and PAM - Copyright (C) tridge@samba.org 2001 - Copyright (C) abartlet@pcug.org.au 2001 + + Copyright (C) tridge@samba.org 2001 + Copyright (C) abartlet@samba.org 2001 + Copyright (C) Gerald (Jerry) Carter 2006 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +31,9 @@ static TDB_CONTEXT *tdb; +/******************************************************************** +********************************************************************/ + BOOL session_init(void) { if (tdb) @@ -44,7 +49,10 @@ BOOL session_init(void) return True; } -/* called when a session is created */ +/******************************************************************** + called when a session is created +********************************************************************/ + BOOL session_claim(user_struct *vuser) { int i = 0; @@ -126,6 +134,7 @@ BOOL session_claim(user_struct *vuser) sessionid.gid = vuser->gid; fstrcpy(sessionid.remote_machine, get_remote_machine_name()); fstrcpy(sessionid.ip_addr, client_addr()); + sessionid.connect_start = time(NULL); client_ip = client_inaddr(&sa); @@ -159,7 +168,10 @@ BOOL session_claim(user_struct *vuser) return True; } -/* called when a session is destroyed */ +/******************************************************************** + called when a session is destroyed +********************************************************************/ + void session_yield(user_struct *vuser) { TDB_DATA dbuf; @@ -198,6 +210,9 @@ void session_yield(user_struct *vuser) tdb_delete(tdb, key); } +/******************************************************************** +********************************************************************/ + BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *), void *state) { @@ -210,32 +225,40 @@ BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *), return True; } +/******************************************************************** +********************************************************************/ + struct session_list { int count; struct sessionid *sessions; }; -static int gather_sessioninfo(TDB_CONTEXT *stdb, TDB_DATA kbuf, TDB_DATA dbuf, - void *state) +static int gather_sessioninfo(TDB_CONTEXT *stdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state) { + uint32 i; struct session_list *sesslist = (struct session_list *) state; const struct sessionid *current = (const struct sessionid *) dbuf.dptr; - sesslist->count += 1; - sesslist->sessions = SMB_REALLOC_ARRAY(sesslist->sessions, struct sessionid, - sesslist->count); + i = sesslist->count; + + sesslist->sessions = SMB_REALLOC_ARRAY(sesslist->sessions, struct sessionid, i+1); if (!sesslist->sessions) { sesslist->count = 0; return -1; } - memcpy(&sesslist->sessions[sesslist->count - 1], current, - sizeof(struct sessionid)); + memcpy(&sesslist->sessions[i], current, sizeof(struct sessionid)); + sesslist->count++; + DEBUG(7,("gather_sessioninfo session from %s@%s\n", current->username, current->remote_machine)); + return 0; } +/******************************************************************** +********************************************************************/ + int list_sessions(struct sessionid **session_list) { struct session_list sesslist; -- cgit 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 From bc2b6436d0f5f3e9ffdfaeb7f1b32996a83d5478 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 29 Mar 2007 09:35:51 +0000 Subject: r22009: change TDB_DATA from char * to unsigned char * and fix all compiler warnings in the users metze (This used to be commit 3a28443079c141a6ce8182c65b56ca210e34f37f) --- source3/smbd/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index da2ab40338..a3334a353e 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -140,7 +140,7 @@ BOOL session_claim(user_struct *vuser) return False; } - data.dptr = (char *)&sessionid; + data.dptr = (uint8 *)&sessionid; data.dsize = sizeof(sessionid); if (tdb_store_bystring(tdb, keystr, data, tdb_store_flag) != 0) { DEBUG(1,("session_claim: unable to create session id record\n")); -- cgit From fb3835846ef89a632230ff808259dad1cddc05c0 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 2 Apr 2007 03:46:13 +0000 Subject: r22020: Make it more clear that both the vuser struct and it's contents are talloc_free()'ed at the end of a session. Rework the passwd cache code to use talloc_unlink and talloc_reference, to more carefully manage the cache. Andrew Bartlett (This used to be commit e3e0ec25e67308de314aa61852905ee42aa2c8fe) --- source3/smbd/session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index a3334a353e..05b1026f41 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -153,9 +153,9 @@ BOOL session_claim(user_struct *vuser) sessionid.id_str, sessionid.id_num); } - vuser->session_keystr = SMB_STRDUP(keystr); + vuser->session_keystr = talloc_strdup(vuser, keystr); if (!vuser->session_keystr) { - DEBUG(0, ("session_claim: strdup() failed for session_keystr\n")); + DEBUG(0, ("session_claim: talloc_strdup() failed for session_keystr\n")); return False; } return True; -- cgit From e26dee48f079f429690584aa2666f498e08e6810 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 28 Apr 2007 18:16:33 +0000 Subject: r22561: Fix a memleak in lanman.c: Nobody would free the session_list. Volker (This used to be commit 5d428400f77399b7fc30fb2a0fb10f0c74b96458) --- source3/smbd/session.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 05b1026f41..30ade8aedf 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -218,6 +218,7 @@ BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *), ********************************************************************/ struct session_list { + TALLOC_CTX *mem_ctx; int count; struct sessionid *sessions; }; @@ -230,7 +231,9 @@ static int gather_sessioninfo(TDB_CONTEXT *stdb, TDB_DATA kbuf, TDB_DATA dbuf, v i = sesslist->count; - sesslist->sessions = SMB_REALLOC_ARRAY(sesslist->sessions, struct sessionid, i+1); + sesslist->sessions = TALLOC_REALLOC_ARRAY( + sesslist->mem_ctx, sesslist->sessions, struct sessionid, i+1); + if (!sesslist->sessions) { sesslist->count = 0; return -1; @@ -248,10 +251,11 @@ static int gather_sessioninfo(TDB_CONTEXT *stdb, TDB_DATA kbuf, TDB_DATA dbuf, v /******************************************************************** ********************************************************************/ -int list_sessions(struct sessionid **session_list) +int list_sessions(TALLOC_CTX *mem_ctx, struct sessionid **session_list) { struct session_list sesslist; + sesslist.mem_ctx = mem_ctx; sesslist.count = 0; sesslist.sessions = NULL; -- cgit From 76ce309234adbe0a6a56b849a91714cab148c4a7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 7 May 2007 15:31:12 +0000 Subject: r22751: Next step for the cluster merge: sessionid.tdb should contain a 'struct server_id' instead of a 'uint32 pid' (This used to be commit be7bac55c37676a8137c59a22dfb2e4c4821ac21) --- source3/smbd/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 30ade8aedf..cd7511430e 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -60,7 +60,7 @@ BOOL session_claim(user_struct *vuser) struct sockaddr sa; struct in_addr *client_ip; struct sessionid sessionid; - uint32 pid = (uint32)sys_getpid(); + struct server_id pid = procid_self(); fstring keystr; char * hostname; int tdb_store_flag; /* If using utmp, we do an inital 'lock hold' store, -- cgit From fff51a9af20b7221844ffb11d7491372bbbcda0e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 28 May 2007 12:39:39 +0000 Subject: r23172: Change shutdown_other_smbds to use connections_traverse instead of session_traverse. (This used to be commit ccb5eb245e962b0264b337c2d0275c22e2a36830) --- source3/smbd/session.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index cd7511430e..f55576a7be 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -202,8 +202,9 @@ void session_yield(user_struct *vuser) /******************************************************************** ********************************************************************/ -BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, void *), - void *state) +static BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, + void *), + void *state) { if (!session_init()) { DEBUG(3, ("No tdb opened\n")); -- cgit From ba0bce2c6f7298840e0d223a5f170b777b8c9d64 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 28 May 2007 13:33:54 +0000 Subject: r23173: Convert sessionid.tdb to ctdb. The 3.0.26 patch is a bit larger because it brings across the tdb-based list_sessions (This used to be commit 0153386c1a3625b2f699863991893f399c40af48) --- source3/smbd/session.c | 171 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 118 insertions(+), 53 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index f55576a7be..837c37a49f 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -29,19 +29,25 @@ #include "includes.h" -static TDB_CONTEXT *tdb; - /******************************************************************** ********************************************************************/ -BOOL session_init(void) +static struct db_context *session_db_ctx(void) { - if (tdb) - return True; + static struct db_context *ctx; + + if (ctx) + return ctx; + + ctx = db_open(NULL, lock_path("sessionid.tdb"), 0, + TDB_CLEAR_IF_FIRST|TDB_DEFAULT, + O_RDWR | O_CREAT, 0644); + return ctx; +} - tdb = tdb_open_log(lock_path("sessionid.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, - O_RDWR | O_CREAT, 0644); - if (!tdb) { +BOOL session_init(void) +{ + if (session_db_ctx() == NULL) { DEBUG(1,("session_init: failed to open sessionid tdb\n")); return False; } @@ -55,17 +61,17 @@ BOOL session_init(void) BOOL session_claim(user_struct *vuser) { + TDB_DATA key, data; int i = 0; - TDB_DATA data; struct sockaddr sa; struct in_addr *client_ip; struct sessionid sessionid; struct server_id pid = procid_self(); fstring keystr; char * hostname; - int tdb_store_flag; /* If using utmp, we do an inital 'lock hold' store, - but we don't need this if we are just using the - (unique) pid/vuid combination */ + struct db_context *ctx; + struct db_record *rec; + NTSTATUS status; vuser->session_keystr = NULL; @@ -75,8 +81,9 @@ BOOL session_claim(user_struct *vuser) return True; } - if (!session_init()) + if (!(ctx = session_db_ctx())) { return False; + } ZERO_STRUCT(sessionid); @@ -84,30 +91,70 @@ BOOL session_claim(user_struct *vuser) data.dsize = 0; if (lp_utmp()) { + for (i=1;ifetch_locked(ctx, NULL, key); + + if (rec == NULL) { + DEBUG(1, ("Could not lock \"%s\"\n", keystr)); + return False; + } + + if (rec->value.dsize != sizeof(sessionid)) { + DEBUG(1, ("Re-using invalid record\n")); + break; + } + + sess_pid = ((struct sessionid *)rec->value.dptr)->pid; + + if (!process_exists(sess_pid)) { + DEBUG(5, ("%s has died -- re-using session\n", + procid_str_static(&sess_pid))); + break; + } + + TALLOC_FREE(rec); } if (i == MAX_SESSION_ID) { - DEBUG(1,("session_claim: out of session IDs (max is %d)\n", - MAX_SESSION_ID)); + SMB_ASSERT(rec == NULL); + DEBUG(1,("session_claim: out of session IDs " + "(max is %d)\n", MAX_SESSION_ID)); return False; } - slprintf(sessionid.id_str, sizeof(sessionid.id_str)-1, SESSION_UTMP_TEMPLATE, i); - tdb_store_flag = TDB_MODIFY; + + snprintf(sessionid.id_str, sizeof(sessionid.id_str), + SESSION_UTMP_TEMPLATE, i); } else { - slprintf(keystr, sizeof(keystr)-1, "ID/%lu/%u", - (long unsigned int)sys_getpid(), - vuser->vuid); - slprintf(sessionid.id_str, sizeof(sessionid.id_str)-1, + snprintf(keystr, sizeof(keystr), "ID/%s/%u", + procid_str_static(&pid), vuser->vuid); + key = string_term_tdb_data(keystr); + + rec = ctx->fetch_locked(ctx, NULL, key); + + if (rec == NULL) { + DEBUG(1, ("Could not lock \"%s\"\n", keystr)); + return False; + } + + snprintf(sessionid.id_str, sizeof(sessionid.id_str), SESSION_TEMPLATE, (long unsigned int)sys_getpid(), vuser->vuid); - tdb_store_flag = TDB_REPLACE; } + SMB_ASSERT(rec != NULL); + /* If 'hostname lookup' == yes, then do the DNS lookup. This is needed because utmp and PAM both expect DNS names @@ -131,19 +178,24 @@ BOOL session_claim(user_struct *vuser) client_ip = client_inaddr(&sa); - if (!smb_pam_claim_session(sessionid.username, sessionid.id_str, sessionid.hostname)) { + if (!smb_pam_claim_session(sessionid.username, sessionid.id_str, + sessionid.hostname)) { DEBUG(1,("pam_session rejected the session for %s [%s]\n", sessionid.username, sessionid.id_str)); - if (tdb_store_flag == TDB_MODIFY) { - tdb_delete_bystring(tdb, keystr); - } + + TALLOC_FREE(rec); return False; } data.dptr = (uint8 *)&sessionid; data.dsize = sizeof(sessionid); - if (tdb_store_bystring(tdb, keystr, data, tdb_store_flag) != 0) { - DEBUG(1,("session_claim: unable to create session id record\n")); + + status = rec->store(rec, data, TDB_REPLACE); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1,("session_claim: unable to create session id " + "record: %s\n", nt_errstr(status))); + TALLOC_FREE(rec); return False; } @@ -153,9 +205,12 @@ BOOL session_claim(user_struct *vuser) sessionid.id_str, sessionid.id_num); } + TALLOC_FREE(rec); + vuser->session_keystr = talloc_strdup(vuser, keystr); if (!vuser->session_keystr) { - DEBUG(0, ("session_claim: talloc_strdup() failed for session_keystr\n")); + DEBUG(0, ("session_claim: talloc_strdup() failed for " + "session_keystr\n")); return False; } return True; @@ -167,26 +222,30 @@ BOOL session_claim(user_struct *vuser) void session_yield(user_struct *vuser) { - TDB_DATA dbuf; + TDB_DATA key; struct sessionid sessionid; struct in_addr *client_ip; + struct db_context *ctx; + struct db_record *rec; - if (!tdb) return; + if (!(ctx = session_db_ctx())) return; if (!vuser->session_keystr) { return; } - dbuf = tdb_fetch_bystring(tdb, vuser->session_keystr); + key = string_term_tdb_data(vuser->session_keystr); - if (dbuf.dsize != sizeof(sessionid)) + if (!(rec = ctx->fetch_locked(ctx, NULL, key))) { return; + } - memcpy(&sessionid, dbuf.dptr, sizeof(sessionid)); + if (rec->value.dsize != sizeof(sessionid)) + return; - client_ip = interpret_addr2(sessionid.ip_addr); + memcpy(&sessionid, rec->value.dptr, sizeof(sessionid)); - SAFE_FREE(dbuf.dptr); + client_ip = interpret_addr2(sessionid.ip_addr); if (lp_utmp()) { sys_utmp_yield(sessionid.username, sessionid.hostname, @@ -194,24 +253,29 @@ void session_yield(user_struct *vuser) sessionid.id_str, sessionid.id_num); } - smb_pam_close_session(sessionid.username, sessionid.id_str, sessionid.hostname); + smb_pam_close_session(sessionid.username, sessionid.id_str, + sessionid.hostname); + + rec->delete_rec(rec); - tdb_delete_bystring(tdb, vuser->session_keystr); + TALLOC_FREE(rec); } /******************************************************************** ********************************************************************/ -static BOOL session_traverse(int (*fn)(TDB_CONTEXT *, TDB_DATA, TDB_DATA, - void *), - void *state) +static BOOL session_traverse(int (*fn)(struct db_record *db, + void *private_data), + void *private_data) { - if (!session_init()) { + struct db_context *ctx; + + if (!(ctx = session_db_ctx())) { DEBUG(3, ("No tdb opened\n")); return False; } - tdb_traverse(tdb, fn, state); + ctx->traverse(ctx, fn, private_data); return True; } @@ -224,23 +288,24 @@ struct session_list { struct sessionid *sessions; }; -static int gather_sessioninfo(TDB_CONTEXT *stdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state) +static int gather_sessioninfo(struct db_record *rec, void *state) { - uint32 i; struct session_list *sesslist = (struct session_list *) state; - const struct sessionid *current = (const struct sessionid *) dbuf.dptr; + const struct sessionid *current = + (const struct sessionid *) rec->value.dptr; - i = sesslist->count; - sesslist->sessions = TALLOC_REALLOC_ARRAY( - sesslist->mem_ctx, sesslist->sessions, struct sessionid, i+1); + sesslist->mem_ctx, sesslist->sessions, struct sessionid, + sesslist->count+1); if (!sesslist->sessions) { sesslist->count = 0; return -1; } - memcpy(&sesslist->sessions[i], current, sizeof(struct sessionid)); + memcpy(&sesslist->sessions[sesslist->count], current, + sizeof(struct sessionid)); + sesslist->count++; DEBUG(7,("gather_sessioninfo session from %s@%s\n", -- cgit From a9503016859dc4bc3f68eb302c1adf37bf311187 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 29 May 2007 18:04:38 +0000 Subject: r23220: Add traverse_read to dbwrap (This used to be commit b38dc5ffdfe9fdc2879c57dc181815f06b4747fe) --- source3/smbd/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 837c37a49f..d5973ef5c3 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -275,7 +275,7 @@ static BOOL session_traverse(int (*fn)(struct db_record *db, return False; } - ctx->traverse(ctx, fn, private_data); + ctx->traverse_read(ctx, fn, private_data); return True; } -- cgit From 4b70daaa59cd49afcdaa2934aee4b257f9157682 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 30 May 2007 07:02:40 +0000 Subject: r23236: Another bad merge: Correctly free and unlock the session record in session_claim. Jerry, this fixes the hanging smbstatus. Sorry for that, Volker (This used to be commit 86ff82a5df998045185682cf09b2db3d37f01004) --- source3/smbd/session.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index d5973ef5c3..6b1bb0cbee 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -192,10 +192,11 @@ BOOL session_claim(user_struct *vuser) status = rec->store(rec, data, TDB_REPLACE); + TALLOC_FREE(rec); + if (!NT_STATUS_IS_OK(status)) { DEBUG(1,("session_claim: unable to create session id " "record: %s\n", nt_errstr(status))); - TALLOC_FREE(rec); return False; } -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/smbd/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 6b1bb0cbee..62fa10f591 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -8,7 +8,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/smbd/session.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 62fa10f591..3cc93c1a7f 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -17,8 +17,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ /* a "session" is claimed when we do a SessionSetupX operation -- cgit From 0d87820380416955a132d565a479b4234f78c113 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 3 Oct 2007 20:43:55 +0000 Subject: r25492: Start adding IPv6 compatible code to lib/util_sock.c and deal with the ripple effects this causes. utmp has to change etc. Remove some global varables and store address/port in the unexpected db. Jeremy. (This used to be commit 18c6a2211d9e25233d01715b3f78977edcd6d869) --- source3/smbd/session.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 3cc93c1a7f..c7cdf41fb5 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -62,8 +62,6 @@ BOOL session_claim(user_struct *vuser) { TDB_DATA key, data; int i = 0; - struct sockaddr sa; - struct in_addr *client_ip; struct sessionid sessionid; struct server_id pid = procid_self(); fstring keystr; @@ -124,7 +122,7 @@ BOOL session_claim(user_struct *vuser) TALLOC_FREE(rec); } - + if (i == MAX_SESSION_ID) { SMB_ASSERT(rec == NULL); DEBUG(1,("session_claim: out of session IDs " @@ -147,16 +145,16 @@ BOOL session_claim(user_struct *vuser) return False; } - snprintf(sessionid.id_str, sizeof(sessionid.id_str), - SESSION_TEMPLATE, (long unsigned int)sys_getpid(), + snprintf(sessionid.id_str, sizeof(sessionid.id_str), + SESSION_TEMPLATE, (long unsigned int)sys_getpid(), vuser->vuid); } SMB_ASSERT(rec != NULL); /* If 'hostname lookup' == yes, then do the DNS lookup. This is - needed because utmp and PAM both expect DNS names - + needed because utmp and PAM both expect DNS names + client_name() handles this case internally. */ @@ -172,11 +170,9 @@ BOOL session_claim(user_struct *vuser) sessionid.uid = vuser->uid; sessionid.gid = vuser->gid; fstrcpy(sessionid.remote_machine, get_remote_machine_name()); - fstrcpy(sessionid.ip_addr, client_addr()); + fstrcpy(sessionid.ip_addr_str, client_addr()); sessionid.connect_start = time(NULL); - client_ip = client_inaddr(&sa); - if (!smb_pam_claim_session(sessionid.username, sessionid.id_str, sessionid.hostname)) { DEBUG(1,("pam_session rejected the session for %s [%s]\n", @@ -200,8 +196,8 @@ BOOL session_claim(user_struct *vuser) } if (lp_utmp()) { - sys_utmp_claim(sessionid.username, sessionid.hostname, - client_ip, + sys_utmp_claim(sessionid.username, sessionid.hostname, + sessionid.ip_addr_str, sessionid.id_str, sessionid.id_num); } @@ -224,7 +220,6 @@ void session_yield(user_struct *vuser) { TDB_DATA key; struct sessionid sessionid; - struct in_addr *client_ip; struct db_context *ctx; struct db_record *rec; @@ -245,11 +240,9 @@ void session_yield(user_struct *vuser) memcpy(&sessionid, rec->value.dptr, sizeof(sessionid)); - client_ip = interpret_addr2(sessionid.ip_addr); - if (lp_utmp()) { sys_utmp_yield(sessionid.username, sessionid.hostname, - client_ip, + sessionid.ip_addr_str, sessionid.id_str, sessionid.id_num); } -- cgit From e5a951325a6cac8567af3a66de6d2df577508ae4 Mon Sep 17 00:00:00 2001 From: "Gerald (Jerry) Carter" Date: Wed, 10 Oct 2007 15:34:30 -0500 Subject: [GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch. (This used to be commit 5c6c8e1fe93f340005110a7833946191659d88ab) --- source3/smbd/session.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index c7cdf41fb5..8dd321fad7 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -201,12 +201,9 @@ BOOL session_claim(user_struct *vuser) sessionid.id_str, sessionid.id_num); } - TALLOC_FREE(rec); - vuser->session_keystr = talloc_strdup(vuser, keystr); if (!vuser->session_keystr) { - DEBUG(0, ("session_claim: talloc_strdup() failed for " - "session_keystr\n")); + DEBUG(0, ("session_claim: talloc_strdup() failed for session_keystr\n")); return False; } return True; -- cgit From cb5436bcc3b55e0c221fb6b3fa3133f149a64384 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 11 Oct 2007 15:36:13 -0700 Subject: Add const to the get_peer_addr() and get_socket_addr() calls. Use the IPv6 varient for get_peer_addr(). Jeremy. (This used to be commit baf1f52e34ae2465a7a34be1065da29ed97e7bea) --- source3/smbd/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 8dd321fad7..54d2ddf721 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -65,7 +65,7 @@ BOOL session_claim(user_struct *vuser) struct sessionid sessionid; struct server_id pid = procid_self(); fstring keystr; - char * hostname; + const char * hostname; struct db_context *ctx; struct db_record *rec; NTSTATUS status; -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/smbd/session.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 54d2ddf721..ebbb40eb5a 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -44,7 +44,7 @@ static struct db_context *session_db_ctx(void) return ctx; } -BOOL session_init(void) +bool session_init(void) { if (session_db_ctx() == NULL) { DEBUG(1,("session_init: failed to open sessionid tdb\n")); @@ -58,7 +58,7 @@ BOOL session_init(void) called when a session is created ********************************************************************/ -BOOL session_claim(user_struct *vuser) +bool session_claim(user_struct *vuser) { TDB_DATA key, data; int i = 0; @@ -254,7 +254,7 @@ void session_yield(user_struct *vuser) /******************************************************************** ********************************************************************/ -static BOOL session_traverse(int (*fn)(struct db_record *db, +static bool session_traverse(int (*fn)(struct db_record *db, void *private_data), void *private_data) { -- cgit From 6658165d5e9cd186fea74e1581091233e8990e9b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Nov 2007 18:15:45 -0700 Subject: Stop get_peer_addr() and client_addr() from using global statics. Part of my library cleanups. Jeremy. (This used to be commit e848506c858bd16706c1d7f6b4b032005512b8ac) --- source3/smbd/session.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index ebbb40eb5a..15154162b9 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -69,6 +69,7 @@ bool session_claim(user_struct *vuser) struct db_context *ctx; struct db_record *rec; NTSTATUS status; + char addr[INET6_ADDRSTRLEN]; vuser->session_keystr = NULL; @@ -160,7 +161,7 @@ bool session_claim(user_struct *vuser) hostname = client_name(); if (strcmp(hostname, "UNKNOWN") == 0) { - hostname = client_addr(); + hostname = client_addr(addr); } fstrcpy(sessionid.username, vuser->user.unix_name); @@ -170,7 +171,7 @@ bool session_claim(user_struct *vuser) sessionid.uid = vuser->uid; sessionid.gid = vuser->gid; fstrcpy(sessionid.remote_machine, get_remote_machine_name()); - fstrcpy(sessionid.ip_addr_str, client_addr()); + fstrcpy(sessionid.ip_addr_str, client_addr(addr)); sessionid.connect_start = time(NULL); if (!smb_pam_claim_session(sessionid.username, sessionid.id_str, -- cgit From 25074433f412c4dd2531fd268d51be8753ddc11b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Nov 2007 18:41:26 -0700 Subject: I can't get away without a 'length' arg. :-). Jeremy. (This used to be commit 95d01279a5def709d0a5d5ae7224d6286006d120) --- source3/smbd/session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 15154162b9..69f4a37c85 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -161,7 +161,7 @@ bool session_claim(user_struct *vuser) hostname = client_name(); if (strcmp(hostname, "UNKNOWN") == 0) { - hostname = client_addr(addr); + hostname = client_addr(addr,sizeof(addr)); } fstrcpy(sessionid.username, vuser->user.unix_name); @@ -171,7 +171,7 @@ bool session_claim(user_struct *vuser) sessionid.uid = vuser->uid; sessionid.gid = vuser->gid; fstrcpy(sessionid.remote_machine, get_remote_machine_name()); - fstrcpy(sessionid.ip_addr_str, client_addr(addr)); + fstrcpy(sessionid.ip_addr_str, client_addr(addr,sizeof(addr))); sessionid.connect_start = time(NULL); if (!smb_pam_claim_session(sessionid.username, sessionid.id_str, -- cgit From 5b0b4f23ef5fec3d1ad518237f973d4e014b5766 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Nov 2007 23:20:10 -0700 Subject: Remove most of the remaining globals out of lib/util_sock.c. I have a plan for dealing with the remaining..... Watch this space. Jeremy. (This used to be commit 963fc7685212689f02b3adcc05b4273ee5c382d4) --- source3/smbd/session.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 69f4a37c85..000b2f5d9c 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -159,9 +159,9 @@ bool session_claim(user_struct *vuser) client_name() handles this case internally. */ - hostname = client_name(); + hostname = client_name(get_client_fd()); if (strcmp(hostname, "UNKNOWN") == 0) { - hostname = client_addr(addr,sizeof(addr)); + hostname = client_addr(get_client_fd(),addr,sizeof(addr)); } fstrcpy(sessionid.username, vuser->user.unix_name); @@ -171,7 +171,8 @@ bool session_claim(user_struct *vuser) sessionid.uid = vuser->uid; sessionid.gid = vuser->gid; fstrcpy(sessionid.remote_machine, get_remote_machine_name()); - fstrcpy(sessionid.ip_addr_str, client_addr(addr,sizeof(addr))); + fstrcpy(sessionid.ip_addr_str, + client_addr(get_client_fd(),addr,sizeof(addr))); sessionid.connect_start = time(NULL); if (!smb_pam_claim_session(sessionid.username, sessionid.id_str, -- cgit From c6d209f8342d56adc52a6c8ab99a4a2e17d409b2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 29 Apr 2008 13:43:10 +0200 Subject: Remove the unix token info from "struct user_struct" (This used to be commit aa2299d42adf4d27e707ac755e07be70d0af1bb4) --- source3/smbd/session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 000b2f5d9c..adfc4e300f 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -168,8 +168,8 @@ bool session_claim(user_struct *vuser) fstrcpy(sessionid.hostname, hostname); sessionid.id_num = i; /* Only valid for utmp sessions */ sessionid.pid = pid; - sessionid.uid = vuser->uid; - sessionid.gid = vuser->gid; + sessionid.uid = vuser->server_info->uid; + sessionid.gid = vuser->server_info->gid; fstrcpy(sessionid.remote_machine, get_remote_machine_name()); fstrcpy(sessionid.ip_addr_str, client_addr(get_client_fd(),addr,sizeof(addr))); -- cgit From 71ff1ba2deddf8fa12b034518e92e0a461871388 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 29 Apr 2008 13:45:58 +0200 Subject: Remove "guest" from "struct user_struct" (This used to be commit 570a6b80feb5b0dc23213ba936c721e766cd4818) --- source3/smbd/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index adfc4e300f..2b964d828f 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -75,7 +75,7 @@ bool session_claim(user_struct *vuser) /* don't register sessions for the guest user - its just too expensive to go through pam session code for browsing etc */ - if (vuser->guest) { + if (vuser->server_info->guest) { return True; } -- cgit From bec1dfab27be3db888eeb451b4547f16e08e93c3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 30 Apr 2008 17:42:39 +0200 Subject: Remove "userdom_struct user" from "struct user_struct" (This used to be commit 420de035237bb08bc470c9eb820f3da2edaa6805) --- source3/smbd/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 2b964d828f..5e5a184efa 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -164,7 +164,7 @@ bool session_claim(user_struct *vuser) hostname = client_addr(get_client_fd(),addr,sizeof(addr)); } - fstrcpy(sessionid.username, vuser->user.unix_name); + fstrcpy(sessionid.username, vuser->server_info->unix_name); fstrcpy(sessionid.hostname, hostname); sessionid.id_num = i; /* Only valid for utmp sessions */ sessionid.pid = pid; -- cgit From 40f5eab5eb515937e1b23cf6762b77c194d29b9d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 19 Jun 2008 16:54:12 +0200 Subject: Wrap the unix token info in a unix_user_token in auth_serversupplied_info No functional change, this is a preparation for more current_user ref removal (This used to be commit dcaedf345e62ab74ea87f0a3fa1e3199c75c5445) --- source3/smbd/session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/smbd/session.c') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 5e5a184efa..3b431a19be 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -168,8 +168,8 @@ bool session_claim(user_struct *vuser) fstrcpy(sessionid.hostname, hostname); sessionid.id_num = i; /* Only valid for utmp sessions */ sessionid.pid = pid; - sessionid.uid = vuser->server_info->uid; - sessionid.gid = vuser->server_info->gid; + sessionid.uid = vuser->server_info->utok.uid; + sessionid.gid = vuser->server_info->utok.gid; fstrcpy(sessionid.remote_machine, get_remote_machine_name()); fstrcpy(sessionid.ip_addr_str, client_addr(get_client_fd(),addr,sizeof(addr))); -- cgit