[Samba] Closing sessions and smbstatus

Vlastimil Šetka setka at spsostrov.cz
Mon Oct 20 19:10:37 GMT 2008


> Hi,
>
> When are client sessions closed?  
>
> Let me explain what I'm trying to do...  we're in a School district and
> we try to stop kids logging more than once.  They way I did this before
> was to dump the active sessions from our previous Server2003 fileserver
> into a file once a minute and process it with a Perl script to check who
> was connected from where, rebooting machines remotely as needed!  This
> work well enough with the odd 'hung' session causing minor problems.
>   
I'm in exactly the same situation. The school, PDC for ~100 computers, 
hundreds of users.
We need to track the logon / logoff. I can't find any usable tools so I 
made my own system.
I found that most reliable is the smbstatus output. Windows do strange 
thinks with connections during domain logons so use of preexec script is 
complicated.
By the Perl script I run smbstatus every 5 seconds, scan the changes 
from previous run and write it to the MySQL DB. That's all woks fine.
> So now I'm trying to do the same thing with our new Samba (3.0.31)
> fileserver using the output from smbstatus.  However, in many cases
> sessions are still in there long after the user has logged out of the
> machine.  I'm even seeing two sessions for different people on the same
> machine with the same pid number!  How is this working?  Why are not all
> sessions ending when the user logs off?  Am I going to be able to use
> this for what I'm trying to do?!!
>   
I have some problems with this too. See this thread:
  [Samba] smbstatus - switched off computers are sometimes showed
  http://lists.samba.org/archive/samba/2008-September/143701.html

Now I get some new experience with it. The main problem is that samba 
sometimes doesn't update the sessionid.tdb file when the process exits. 
This records is not showed in smbstatus output, because smbstatus checks 
if the PID exists. I patched the smbstatus so it showed me that there is 
the records with no related PID. Then, maybe after 1 day or so, this PID 
is used for other proccess and I can see the "ghost" logon in my 
tracking system (and in most cases logoff at next run - after 5 seconds).
On the list is now the thread "[Samba] processes not closing" where is 
described some self-repair function related do sessionid.tdf file. The 
samba process when writing to this file should check all records and 
delete it if the PID doesn't exist. It will be nice but In my situation 
it doesn't work. Maybe it's because of Samba version (3.0.24, official 
Debian Etch package).

The most strange think I've seen is that I get some fake logon records 
for one user day-by-day at the same time. Let say USER1 at COMP1 - tracked 
logon at tuesday 14:10:12, then at the same time at wednesday and 
thursday. In fact the COMP1 is switched off or other user is loged on at 
the time. The USER1 were loged on the COMP1 at monday.
> The fileserver itself is working great, we have over 2000 users happily
> using it with less problems than we had on the Windows box.  I really
> appreciate all the work the Samba team does!
>   
The same experience. Samba-based solution with one PDC is rock-stable 
for us in comparsion with several Windows 2003 AD servers running before.
> Many thanks,
>
> Steve Rippl
> Woodland School District
>   


More information about the samba mailing list