[Zope] Re: execv inside zope

Tres Seaver tseaver at palladion.com
Sat Mar 3 18:38:43 EST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Wombie Tomek wrote:
> How do i execute a command line program and get the output in to zope?  I
> seem to have permission issues with the following code which I think should
> work otherwise.
> 
> thanks,
> 
> import os, sys
> 
> print os.execv('/bin/echo', ['foo', 'bar'])
> return printed

Hmm, if we allowed it, this would be a nice way to kill your Zope
server. See the docs on that:

 $ pydoc os.execv
 Help on built-in function execv in os:

 os.execv = execv(...)
     execv(path, args)

     Execute an executable path with arguments, replacing current\
     process.

            path: path of executable file
            args: tuple or list of strings


In general, you can use any Python library module you like from
"trusted" code (code written in filesystem products).  "Untrusted" code
(written PythohScripts, PageTemplates, etc.) has access only to modules
which are specifically authorized.

At a guess, by the way, the function you want is 'os.system', or better
yet one of those offered by the 'subprocess' module.


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF6gcD+gerLs4ltQ4RAqnQAJ9VFWP94RvGB+ibSOWrPlBsd/QMtgCghAft
bUTkxlGvRPw9eTNb34TXuD4=
=M54Y
-----END PGP SIGNATURE-----



More information about the Zope mailing list