0

So I'm running dokuwiki under Apache on RHEL6 and working on a plugin that calls proc_open in a php script. My problem is that I'm trying to call an application that has been installed locally for apache (under ~/.local/bin), but the program that gets called from php is a different one. This is probably better understood this way:

When I log in as user apache:

$ sudo su - user

And I check my application version:

$ /var/www/.local/bin/rst2html.py --version

I get:

rst2html.py (Docutils 0.12 [release], Python 2.6.6, on linux2)

However, when I make the same call in my php application (with proc_open) that runs under apache I get:

rst2html.py (Docutils 0.6 [release], Python 2.6.6, on linux2)

Which is the version that is installed globally, i.e., is available to all users.

So what's causing this discrepancy, is there something in the environment that I need to set up?

Note: the python application was installed using pip

  • How are you testing that it is opening something as root? – Zoredache May 6 '16 at 22:40
  • @Zoredache I edited the proc_open call to instead run echo \$USER which returned 'root'. – toes May 6 '16 at 22:53
  • 1
    I am not sure that is a valid test. That variable may not be coming from the shell. Also, I think apache puts the effective user in APACHE_RUN_USER, not USER. If you create a file who is the owner of the file? Or what if you execute id, or whoami in your passthrough? You mention using apache, but which method? The module, or fcgi, cgi, or something else? – Zoredache May 6 '16 at 23:14
  • Rather than echo, try using id to show the effective user. – BillThor May 7 '16 at 3:31
  • @Zoredache Ah, I didn't know USER was not necessarily valid. Indeed, when I try running whomai I get the correct apache user. So I guess that changes my question. I will update it. – toes May 9 '16 at 14:28
0

From the sounds of it, you are not running it through the web, you are running it from the command line - in that case, the script will run as the user who is running it (indeed, it does not even involve apache here) - thus if you are root when you run it, it will run as root.

If you want to run the script as apache, try something like sudo -u apache "/path/to/script"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.