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>
> 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?I can't imagine how this would work. Perhaps ssh would be what you're looking for? There's an excellent windows client at http://www.chiark.greenend.org.uk/~sgtatham/putty/
>Date: Tue, 25 Feb 2003 11:23:34 -0000 >From: "Scattergood, Ivan" <Ivan.Scattergood@uk.fid-intl.com> >To: "'samba@lists.samba.org'" <samba@lists.samba.org> >Subject: [Samba] Starting a process from a windows client >Message-ID: <7B729E8C5D69D411B2B6001083FD190403321D43@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
Thanks for the Advice chaps. I have found out that I can run scripts through Xstart, the NT service portion of or terminal program. It in turn uses SSH. I think that's going to be the easiest solution. -----Original Message----- From: Steve Williams [mailto:swilliams@rinax.com] Sent: Tuesday, February 25, 2003 17:10 To: Jon Niehof Cc: Scattergood, Ivan; 'samba@lists.samba.org' Subject: Re: [Samba] Starting a process from a windows client Hi, An amazingly powerful tool that I have used before to accomplish what you are talking about. **WARNING** make sure that you consider security when you design your project, this is very powerful, hence DANGEROUS! Cheers, Steve From man smb.conf: magic script (S) This parameter specifies the name of a file which, if opened, will be executed by the server when the file is closed. This allows a UNIX script to be sent to the Samba host and executed on behalf of the connected user. Scripts executed in this way will be deleted upon completion assuming that the user has the appropriate level of privilege and the file permissions allow the deletion. If the script generates output, output will be sent to the file specified by the /magic output/ <#MAGICOUTPUT> parameter (see above). Note that some shells are unable to interpret scripts containing CR/LF instead of CR as the end-of-line marker. Magic scripts must be executable /as is/ on the host, which for some hosts and some shells will require filtering at the DOS end. Magic scripts are /EXPERIMENTAL/ and should /NOT/ be relied upon. Default: /None. Magic scripts disabled./ Example: *magic script = user.csh* Jon Niehof wrote:>> 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? > > I can't imagine how this would work. Perhaps ssh would be what you're > looking for? There's an excellent windows client at > http://www.chiark.greenend.org.uk/~sgtatham/putty/ > > >