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
https://forums.phpfreaks.com/topic/225761-executecontrol-binary-from-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.