Jump to content

Execute/control binary from php


shadowjig

Recommended Posts

I am running Apache with the PHP module installed on Debian Linux.  My goal is to launch a binary in a background process and then feed it commands via fifo.

 

The binary I need to launch has a config file which lives in the home directory of the apache user (in my case the user name apache is started with is www-data). www-data's home dir was the web root so I changed it to /home/www-data.  I also change the shell from /bin/sh to /bin/bash for www-data.

 

Neither of these changes are present when I load a php file from a browser.

 

This script:

 

<?php
echo "User: " . exec('whoami') . "<br>";
echo "Shell: " . exec('ps -p $$ | grep sh') . "<br>";
?>

 

Outputs this:

 

User: www-data
Shell: 9179 ? 00:00:00 sh

 

Also if I execute the binary it does seem to read the config file which is in the www-data users directory.  I have set the home dir and the web root to be owned by www-data and it's read and writeable.

 

How do I get php to execute the binary so it has access to the users home directory and uses the bash shell?

Are there any other ways to launch and control a binary on a unix system via php?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.