[GLLUG] Samba - root preexec & login scripts

Mike Rambo mrambo@lsd.k12.mi.us
Tue, 29 Oct 2002 11:08:19 -0500


Sean wrote:
> 
> Im far from a guru and therefore maybe slightly confused, but I thought
> the preexec script had to be .bat or .cmd files AND if it needed to be run
> at boot it also needed to be in the registry. The reason for the .bat
> files was simply because no other interpreter would be loaded at the time.

Nope, the root preexec statement is a smb.conf parameter for Samba on
the *nix server. The statements that preexec/root preexec can run are
supposed to be just about any *nix commands or scripts available - or at
least there doesn't appear to be restrictions in the smb.conf man page.
In this case Samba runs (or is supposed to run) the script in the
preexec statement at logon time to create the windows .bat file based
upon rules in an XML file. preexec/postexec is a samba share parameter
that can be used in any smb share to do something when the share is
accessed. Examples might be to give a message when a share is accessed,
or if used in a CDROM drive share it could mount the CD as the share is
requested etc. I found the script that I'm using at
http://www.0x0a.com/netlogon.php but there are others that are used for
the same purpose. 

> 
> I was also under the impression that with the preexec scripts were run
> after the drives were mounted but right before they were usuable by the
> user. kind of like an autorun script on a cd.
> 
> I am also kind of wondering if LDAP might offer a better solution.
> 
> Sean
> 
> On Tue, 29 Oct 2002, Mike Rambo wrote:
> 
> > Hey all,
> >
> > For those of you familiar with Samba...
> >
> > I've been trying to get dynamically created login scripts working for a
> > system I admin in Grand Ledge. I have a perl script that works from a
> > command prompt. It creates a login script for windows workstations that
> > sets the time and creates mapped shares based upon username and group
> > membership in /etc/group. As I said, it works from the command prompt
> > but I cannot get it to work automatically. Samba is set up as a domain
> > controller and works fine in that capacity. Manually created scripts are
> > run by the workstation at logon as they should. The relevent section of
> > my smb.conf is...
> >
> > [netlogon]
> >    comment = Network Logon Service
> >    path = /home/netlogon
> >    guest ok = yes
> >    read only = yes
> >    browseable = no
> >    printable = no
> >    write list = @adm
> >    share modes = no
> >    root preexec = /home/netlogon/netlogon.pl %U
> >    root postexec = rm -f /home/netlogon/%U.bat
> >
> > ...but doesn't work. I get a 'no domain controller available' message
> > when I try to log in with the root preexec statement in place.
> > Commenting it out will allow the domain login to succeed. I have set log
> > level to 3 but do not see anything in the logs to indicate what is
> > failing. Someone on the samba list suggested to try log level 5 which
> > I'll do tonight but I wanted to see if gllug has any samba experts that
> > might know what I can look for on this. One final thing. While working
> > on this problem, one thing I've done is to upgrade from samba 2.2.3a to
> > the new 2.2.6 version. Since doing that the problem symptoms have
> > changed slightly in that when I get the no domain controller error in
> > 2.2.6 I will also find a hung nmbd process on the server afterward. That
> > didn't happen under 2.2.3a. Perhaps that means something to someone...?
> >
> > Thanks.
> >
> >
> >

-- 
Mike Rambo
mrambo@lsd.k12.mi.us