Re: 'becomes' script

Will Partain <[email protected]> Wed, 12 Jun 2002 14:23:01 +0100
Newsgroups gmane.comp.sysutils.ark.devel
Message-ID <[email protected]>
Jonathan writes:

> Aha. My plan here was to use os.popen rather than os.execl then pump in a
> literal string as input. So on the sending side you'd build a script
> something like:
> 
>     pyscript = """import os,sys
>     os.setgid( %d )
>     os.setuid( %d )
>     sh = os.popen( '%s', 'w', 0 )
>     sh.write( '''%s''' )
>     if sh.close() is not None:
>         sys.exit( 1 )
>     """ % ( gid, uid, shcmd, shscript )
> 
> then you'd throw this at 'ssh remote sudo python'.

OK, I've basically done this and checked it in.
ArkHost.run() *is* simpler -- even if none of you will
believe it :-) -- so I think it's to the good.
We're down to three cases:

* host/user/group all OK -- just run the code in the
interpreter required; e.g. fire up '/usr/local/bin/perl' and
shove the code into it.

* user/group OK -- ssh <remote> <interpreter> and shove the
code into it.

* otherwise: start either 'sudo python' or 'ssh <remote>
sudo python' and do as Jonathan suggested.

Now, *perhaps* we should get rid of the first two cases and
run python for them, too -- we might then be able to *lose*
most-or-all of the code in preamble{Sh,Py,Perl,...}.
I.e. put the preamble-y things in the Jonathan pyscript.

???

Will

_______________________________________________________________

Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/