[Asterisk-Users] Reload Asterisk from php or perl script

Justin B. Newman justin.newman at binhost.com
Fri Oct 8 07:43:29 MST 2004


>> >I have tried exec( asterisk -rx reload ) and shell_exec( <same cmd> )
>> >with php but there seems to be a permission issue with asterisk that
>> >stops these working. I was just wondering if anyone has a way around
>> >this with perl or php.
>> >
>>
>> The alternative is to explore options for allowing your webserver to
>run
>> programs as different userid's.  If you're running Apache, this page
>may
>> help:
>>    http://httpd.apache.org/docs/suexec.html
>>
>I am using apache but I would rather avoid this option if possible.
>
>Any other ideas?
>

Dee,

You're going to have to find _some_ way to get the scripts to run as the
asterisk uesr.  Or, to restart asterisk w/o being the asterisk user.

CGIWrap is one way that might work.  mod_perl has some setuid kind of
features.  You could write a program to login to the management interface and
execute reloads, or something.  None of it's pretty, all of it has
significant security implications.

One way is to have a cron job that looks for a particular file
(/tmp/reloadAsterisk, for instance).  When it sees the file, it reloads
Asterisk, then deletes the file.  Ugly, but it'll work because /tmp is
generally world-writable, and cron jobs generally run as root.  This would
allow anyone with access to the box to reload Asterisk, though.  

What you're trying to do is find a way around the security parameters put in
place by the operating system.  You should be very careful when doing
this...

-jbn
Justin B Newman
BinFone Telecom
Visit http://www.binfone.com for IAX termination and origination serivces.



More information about the asterisk-users mailing list