Users running as root, but reported as user in smbstatus

Tim Potter tpot at
Tue Oct 31 23:05:28 GMT 2000

Mike Fedyk writes:

> > > Is this normal?  I don't understand why some smbd
> > > processes are running as the user and some aren't.
> > 
> > smbd always runs as root except with it is
> > performing operations under the effective uid of
> > the connected user (e.g. opening a file).
> I thought smbd starts as root, grabs the <1023 port and runs
> completely as that user from then forward... guess I'm wrong
> then.

What happens is smbd starts as root and whenever a smb packet
for which something needs to happen as the authenticated unix
user, switches to that user.  It should then switch back to root,
but in order to save on system calls, it does not until 30
seconds later or a packet arrives that requires root permissions
to execute.  

This optimisation is made because in general large numbers of
packets arrive in bursts that require user access (i.e sequential
reads and writes) and doing setuid for each packet would slow
samba down.

If you're really keen, check out smbd/process.c in particular the
smb_messages[] array and the switch_message() function.



> -- 
> Mike Fedyk                   "They that can give up essential liberty
> Information Systems           to obtain a little temporary safety
> Match Mail Productions Inc.   deserve neither liberty nor safety."
> mfedyk at                                   Ben Franklin

More information about the samba mailing list