I have a python script which is owned by a particular user and I want to run it from a browser. When I access it from the browser it comes in as www-data user which obviously has very little permissions. Can I do this without changing any permissions or groups? I have tried a few things like Running python script as another user and use pexpect module of python but as www-data has no permissions I cannot fire my script as a different user. My script does not return anything, it generates new data so it needs write permissions.
1 Answer
If...
- the script has read permissions for all
- it only writes to the current directory (or you can configure where it writes)
- you have a web server on the local machine
- you can put scripts on that web server
...then something equivalent to this would work:
subprocess.call(['python', '/path/to/script.py'], cwd='/tmp')
-
I cannot move my scripts from its current location. I know about this framework called apache thrift which is used for cross language service development. I imagine it to work like a root user which can interact between platforms. I am starting to wonder if my issue is even solvable. Isn't not letting the client make changes in the server a fundamental security feature of client-server architecture? Commented Aug 8, 2013 at 21:07
-
apache thrift is one of many frameworks for client server interaction, but it requires changes on the server (you need to run a thrift service on the server) so you have the same problem. Generally, clients can make changes on servers, but only under the control of server programs. For instance, stackoverflow lets me write this comment which is stored on the server. It doesn't let me take over its server farm to crack passwords. In your case, you have a script on a server that the server doesn't want to let you run. It would be a security violation if you could do it anyway.– tdelaneyCommented Aug 8, 2013 at 21:15
chmod
it.do_GET
function which will write the return data to a webpage and send it to the webbrowser. However, you are too unclear in the OP.