Reputation: 3099
I'm trying to build a simple php script to return a JSON formatted list of running processes.
This script of course is executed by apache.
I have everything figured out except one little detail. When the script is executed by apache the command only returns a list of running processes that are owned by the 'apache' user.
Is there anyway around this?
exec('ps -aeo',$output);
//then some code to parse the $output and return a JSON string
OUTPUT:
"processes": [
{
"cpu": "0.0",
"pid": "23698",
"user": "apache",
"command": "/usr/sbin/httpd"
},
{
"cpu": "0.0",
"pid": "23486",
"user": "apache",
"command": "/usr/sbin/httpd"
},
{
"cpu": "0.0",
"pid": "23485",
"user": "apache",
"command": "/usr/sbin/httpd"
},
{
"cpu": "0.0",
"pid": "23484",
"user": "apache",
"command": "/usr/sbin/httpd"
},
{
"cpu": "0.0",
"pid": "23483",
"user": "apache",
"command": "/usr/sbin/httpd"
},
{
"cpu": "0.0",
"pid": "23482",
"user": "apache",
"command": "/usr/sbin/httpd"
},
{
"cpu": "0.0",
"pid": "23481",
"user": "apache",
"command": "/usr/sbin/httpd"
},
{
"cpu": "0.0",
"pid": "23480",
"user": "apache",
"command": "/usr/sbin/httpd"
},
{
"cpu": "0.0",
"pid": "23479",
"user": "apache",
"command": "/usr/sbin/httpd"
},
{
"cpu": "0.0",
"pid": "23478",
"user": "apache",
"command": "/usr/sbin/httpd"
},
{
"cpu": "0.0",
"pid": "1008",
"user": "root",
"command": "/usr/sbin/httpd"
},
{
"cpu": "0.0",
"pid": "959",
"user": "root",
"command": "/usr/sbin/abrtd"
}
]
Upvotes: 0
Views: 706
Reputation: 156
i had the same problem, this solved it. (assuming you have root privileges)
# chcon -t unconfined_exec_t /sbin/httpd
probably not a good idea if the server is shared by untrustful users
Upvotes: 2