LEFT | RIGHT |
(no file at all) | |
| 1 <?php |
| 2 //this programm is here to restart the daemons from the REST API (he works with
restart.sh, runas.sh and sudo.sh), it is very complicated because we have to be
root to restart services |
| 3 //get the password from the user POST request |
| 4 $password = $_POST["pass"]; |
| 5 //execute runas.sh [sudo.sh] [password] [student] [password] > outError.txt 2>&1
which means we first log as student user (because he is sudoer and by default w
ith REST API we are connected with www-data which is not sudoer) so thanks to ru
nas.sh, we run sudo.sh as student user. |
| 6 $cmd1 = "/var/www/html/API_REST/utils/runas.sh \"/var/www/html/API_REST/utils/su
do.sh ".$password."\" student ".$password . " > outError.txt 2>&1" ; |
| 7 $output= shell_exec($cmd1); |
| 8 |
| 9 |
| 10 //here we check if there is a mistake in outError.txt· |
| 11 $cmd2 = "cat /var/www/html/API_REST/utils/outError.txt | grep -c failure"; |
| 12 $output= shell_exec($cmd2); |
| 13 if ($output >= 1) { |
| 14 echo "password error"; |
| 15 } |
| 16 else{ |
| 17 echo "services restart"; |
| 18 } |
| 19 ?> |
LEFT | RIGHT |