[Samba] Re: Starting a process from a windows client

Martin Thomas mthomas at rhrk.uni-kl.de
Tue Feb 25 17:25:11 GMT 2003


>Date: Tue, 25 Feb 2003 11:23:34 -0000
>From: "Scattergood, Ivan" <Ivan.Scattergood at uk.fid-intl.com>
>To: "'samba at lists.samba.org'" <samba at lists.samba.org>
>Subject: [Samba] Starting a process from a windows client 
>Message-ID: <7B729E8C5D69D411B2B6001083FD190403321D43 at ukldn703nts.ldn.uk.fid-intl.com>
>Content-Type: text/plain
>MIME-Version: 1.0
>Precedence: list
>Message: 60
>
>I am hoping to run a Unix process from code running on a windows client, I
>am told this can be done using Samba, does any one have any example code to
>do this? 
>
>Regards 
>Ivan Scattergood 
>London  Software Development
>Internal 8-727-4929 (Lovat Lane)
>Internal 8-727-4756 (Cannon Street)
>External +44 (0) 20 7961 4929 
>Fax +44 (0) 20 7961 4860 
><http://www.fidelity.co.uk> 

The preexec option might help, for
example:

[procstrater]
path = /tmp
preexec = /usr/local/scripts/test.sh &
preexec close = yes   # ?
... other options (path etc.) ...

Now everytime a user accesses the procstrater share
the program gets startet with the users unix-access-rights
You may use root preexec = /...  and pass the Users
name as an option (root preexec = /test.sh %U).
Then the script is startet with root privileges (...warning...)
an the script can manage the user rights internaly with
the username passed in the command line.

I'm not sure about preexec close. If "test.sh"
returns a non-zero value the share gets closed according 
to the Samba-Documentation if this option is set.
This might prevent the share from staying open
and not executing preexec during the next connection
from the client. I never used the preexec close option.

Another option might be to "abuse" the print command,
for example:

[procstarter]
printable = yes
print command = /usr/local/scripts/test.sh &; rm %s
# or 
# print command = /usr/local/scripts/test.sh %s 
# print command = /usr/local/scripts/test.sh %U %s 
... other options (path etc.) ...

Now everytime a user "prints" something to the
procstarter-"printer" test.sh is startet with the users 
accessrights. You can set the script SUID root 
(...usual warnings about this....) and can manage the 
access rights internaly by passing the users name with %U.
Don't forget to remove the print-file (%s), to clean up
Or even more "tricky" bind a postscipt-printer-driver or
"text-only-driver" to the print-share. You can parse the 
print-file (Name in %s) for input to your process (and 
remove it afterwards). 
I'm not sure about the syntax but "man smb.conf"
should help you.
Both "share-access" and "printing" can be done 
from within a Windows-programm, when this is
what you mean by "code running on the client".

There may be better methods than using Samba
to start/control processes an a server (rpc, rmi).

Martin







More information about the samba mailing list