I am trying to write a php script to kill users in a redhat machine.
I know that it is possible (and very unsafe) to give apache the ability to do something as root, but I need to be able to kill any user from a web page, does anyone have good working scripts or point me to a place to find additional information? I can use this code (which I took from php.net) to make it work, but I assume that it will only work if I allow root for apache or run apache as root.
<?php
exec("kill -9 $pid");
?>
This command pulls out the user and their process identifier, which, as I assume, when the problem with apache is resolved, will work fine to capture the list of users for output.
who -u | awk '{print $1" "$7}'
I can’t think of any other information I can give about this, so let me know if I forgot something.
source
share