Question

i have this problem: i want execute a command freeradius from the instruction php exec(), but it doesn't work. the code is simple:

<?php
    exec('radzap -x -N 192.168.0.1 localhost  secret');
?>

If I run the code in the shell work, but into the script php doeesn't work, other instructions like 'ls' ,'cd' and the other 'classical' commando work. I utilize Fedora, maybe i don't have the permissions how user 'Apache' to utilize the dictionary Freeradius.

Sorry for my english, any suggestions? Thank

Update: the error is:

 dict_init: Couldn't open dictionary "/etc/raddb/dictionary": Permission denied 

Ok, i found the error (maybe), selinux don't permict the execution of this instruction, if i set selinix permessive work, if is enable doesn't work. It's work finally, i changed the file's permissions for user Httpd and the instruction go.

Était-ce utile?

La solution

The problem isn't just that the command is failing, but it's that you don't know how it's failing. exec() doesn't give you a whole lot of information by itself, so you'll need to capture the command output (including standard error):

$output = array();
$retcode = 0;
exec('radzap -x -N 192.168.0.1 localhost  secret 2>&1', $output, $retcode);
echo "Return code: $retcode\n";
print_r($output);

This gives you the command's return code and output, allowing you to see why the command is failing. There are too many possible problems to give you a specific answer.

Having said that, the most common reason for commands failing is that the binary can't be found, due to the $PATH environment variable. Try specifying the absolute path to radzap in exec, e.g. /usr/bin/radzap.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top