Script runs local-- now over the web
Dear all
At our university server, I patched together a script (lets call it connect.py) that kind of glues together a series of calls to different other programs (the first one is in Python2.X, the second is a binary so I use os.system('/path/to/program input.pot') to start it, and the last is in Python3.X). It kind of seems to work well now when working under my user account, where the script has the permissions to call the programs, because I installed them. Now, when I want to start the connect script by pressing a submit button in an HTML form, naturally I start running into trouble. Now its no longer my user who is calling, but the server (Apache) with very limited rights. In the progress of writing the connect.py script, I had to do quite some environment adjustment so the various Python modules could be imported. What is the easiest way to get the script started from an HTML form? I guess it would not be good practice to start extending the PATH variables of Apache, would it? |
Hello,
I can't tell you exactly what you need to do. I can tell you a couple of important things to remember when programming for the web: First: the script will run as the user that the apache server runs as. This is because it is the apache server that starts up the script when you press submit. Second: Even if you were able to login as the apache user, the interactive environment is likely different from that under apache. Look for a python function that acts like phpinfo(). This php function dumps out the php environment, so you can see exactly how things are configured. Likely, you just need to find what changes are necessary to make your script run in a limited environment. I hope this helps... --jason |
Quote:
|
Quote:
@unSpawn: this sounds pretty much like something that would help me. I noticed what you said about precautions, and I'm definitely not ignoring them. At the moment though, I need to find a way of getting this running, that has the highest priority. I was reading suexec is something people rather not tend to encourage using, as far as i remember correctly, its not in the default installation of apache.. could you maybe elaborate what it is that you mean with routing the script to sudo cmndalias? Does this mean Apache would temporarily switch its ID in order to execute the script? |
Quote:
Quote:
Quote:
|
thanks for the feedback, very helpful.
I worked around the whole issue now in a rather different way though, what i did is I installed the required program under the apache account, so it naturally has access to it. What I am wondering now is to figure out how I can adjust the PATH variable of Apache, so it can run the program from any directory. The httpd.conf looks something like this Code:
SetEnv PATH $PATH:/var/www/programs/vmd What can I do? |
Hello,
When you login as the apache user, the http.conf file is not being read. This file is only read when apache is being started up. I recommend you create a php script that calls phpinfo(). That will display most of apache's environment back to you. Create the DocumentRoot/phpinfo.php file with the following contents: Quote:
|
Quote:
@jason: I'll be seeing what i get out from that, thanks for the hint. OK, i checked out the information from phpinfo(). What appears strange to me is that when I echo $PATH as www-data (in the shell), i get the following output: Code:
sh-3.1$ echo $PATH Code:
PATH /usr/local/bin:/usr/bin:/bin Anyway, still i would like to know how I can edit the $PATH variable of Apache correctly. |
nice one
|
All times are GMT -5. The time now is 06:45 PM. |