I have a webservice running on ubuntu server. This webservice has a method :
...
main()
{
soap_serve(soap_new());
}
ns_call(std::string who, std::string &result)
{
int j;
j=system ("asterisk -rx \"reload\"");
return SOAP_OK;
}
ON THE CLIENT SIDE THE RETURN IS OK BUT THE command line is not executed. WHY? please help. I am stacked
I am presuming that the command is actually running but it’s not able to connect to Asterisk and issue the reload command because the user that is running the web server does not have permission to connect to Asterisk.
Two solutions. The first one is recommended.
sudo
Configure
sudoto allow the web server user to execute the specific command “asterisk -rx reload” as theasteriskuser:And then use this as the command you pass to
system():socket permissions
asterisk -ruses a UNIX-domain socket to connect to the Asterisk server. The location of the socket may vary depending on your system but look for something like/var/run/asterisk.ctl. By default, the permissions of this socket are probably set so that only theasteriskuser (or root) can connect.You need to arrange for the web server user to have permission to read and write to this socket. For example, you could
chmodthe socket toa+rwxto make it usable by any user on the system. (Don’t do this if you have untrusted users on the system!) Or you could grant grant group write permission to this socket andchgrpit to the group that the web server runs as.No matter how you do it, be aware that you are granting permission for things to execute potentially dangerous actions on behalf of your Asterisk server.