followup on utmp/wtmp logging

Jason Haar Jason.Haar at
Thu Nov 25 22:57:48 GMT 1999

On Wed, Nov 24, 1999 at 11:57:57PM +1100, David Collier-Brown wrote:
> R.S. van Mook wrote:
> > /etc/samba/logging.conf:
> > root preexec = echo "LOGIN %u $PPID \"%S\" %M %T" >> /var/log/utmp-samba"
> > root postexec= echo "LOGOUT %u $PPID \"%S\" %M %T" >>/var/log/utmp-samba"
> 	Optionally, you could write a small stand-alone program
> 	that's vendor-specific to update utmp.  Perl might be
> 	an obvious language to use...

Most modern Unixes come with sessreg - exactly what you need to update
utmp/etc for login/logouts.

However, note that logouts hardly ever occur. I ended up with 100's of
people "logged in" for months before I realised WinBlows has a
million-and-one ways of disconnecting from a share - of which only one is a
formal logout (that would run postexec).

Anyway, I use the following under Linux and HP-UX - defined at each share

root preexec = sh -c "/usr/local/bin/sessreg -a -l smb%d -h ShareName@%m %U"
root postexec = sh -c "/usr/local/bin/sessreg -d -l smb%d -h ShareName@%m %U"


Jason Haar

Unix/Network Specialist, Trimble NZ
Phone: +64 3 3391 377 Fax: +64 3 3391 417

More information about the samba-technical mailing list