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