login | register
Tue 09 of Feb, 2010 [21:09 UTC]

voip-info.org

History

Asterisk gui vmail.cgi

Created by: oej,Last modification on Fri 10 of Oct, 2008 [18:42 UTC] by galdir

Web interface to Voicemail

There is a perl script included in the source distribution, vmail.cgi, located in

 /usr/src/asterisk/contrib/scripts/vmail.cgi

Note that 'make install' doesn't install this interface, instead you must run 'make webvmail' separatly.
The vmail.cgi script requires that perl, perl-suidperl and libdbi-perl packages be installed and of course a web server.

 rpm -q perl perl-suidperl httpd

On CentOS 5 you can just do 'yum install perl-suidperl'

This script may require some editing to get it working on your installation.
/usr/src/asterisk/images/*.gif copied to /_asterisk in the html tree
(or edit $astpath)

Also the CGI script needs to be made executable:

 chmod +x vmail.cgi

On RedHat, perl-suidperl doesn't exist. Instead /var/spool/asterisk/voicemail/ files need to be made world-readable (or group-readable & group set to whatever httpd runs at - e.g. 'apache'). Apparently a patch exists to fix permissions as files are created:
http://lists.digium.com/pipermail/asterisk-users/2003-May/011845.html
http://lists.digium.com/pipermail/asterisk-dev/2003-June/000953.html

On Fedora Core 3 you may need to disable SELinux to allow vmail.cgi access to your /var/spool/asterisk directory

After you get the script installed, you access it with http://yourserver/cgi-bin/vmail.cgi

An updated version of this script and PHP versions are forthcoming.

On Gentoo you will most probably have to take these additional steps in order to get a fully working vmail.cgi:
  • perl -MCPAN -e 'install Bundle::DBI'
  • perl -MCPAN -e 'install DBD::mysql'
Note thet DBD::mysql can be nasty to install since it wants to run all kind of weird tests on a mysql database called 'test' requiring an empty root password...! You can circumenvent this issue by manually downloading DBD::mysql as tar.gz file from www.cpan.org, then running 'Makefile.PL' followed by 'make' and 'make install'.

Nov 10, 2004: Asterisk-Users mailing list


"Attached is a patch I made to app_voicemail.c that will set the owner, group and perms of all files and directories that are created so that vmail.cgi can run as user/group apache without setuid on vmail.cgi. The owner/group/perms are configurable in some static variables at the top so if you need them to change, you only need to change them there. Hope this helps.

Adam Fineberg"


Link to patch

I was getting a broken pipe error when leaving a voicemail with this patch. My problem was that there was no apache group on the box I was saving voicemail to, so I changed the group to root and gave read/write to all by changing the following lines:

static char *gname = "root";
static mode_t dirMode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH;
static mode_t filMode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;

Adding the bold parts. A more secure way is to actually add the apache group (manually or by installing apache). Hope this helps anyone who spent weeks trying to figure out the broken pipe error. - flobi


Nov 21, 2005: The above patch by Adam Fineberg is not working any more on current CVS, so i manually patched app_voicemail.c. The hints of flobi still apply. - bladerunner


Patch against CVS Nov 21, 2005


Using webvmail on debian 3.1 (sarge)

See also this posting and that posting on asterisk-users.

You need to have the following debian packages installed
  • apache (the following does not apply to apache2!)
  • perl
  • perl-suid

The default apache /etc/apache/httpd.conf that the debian apache package installs needs to be changed as follows:

at line 556 change
<IfModule mod_alias.c>
   ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

to
<IfModule mod_alias.c>
   ScriptAlias /cgi-bin/ /var/www/cgi-bin/


at line 562 change
<Directory /usr/lib/cgi-bin/>

to
<Directory /var/www/cgi-bin/>


now restart apache
/etc/init.d/apache restart

in /var/www make sure you have a cgi-bin folder and a html folder in /var/www. If not
cd /var/www mkdir cgi-bin html

now in your asterisk source directory (/usr/src/asterisk) type
make webvmail

now edit the cgi file /var/www/cgi-bin/vmail.cgi with your favorite text editor
edit line 18 "$context=""; # Define here your by default context (so you don't need to put voicemail@context in the login" as needed and save.

go to http://your.ip.address/cgi-bin/vmail.cgi and login (:wink:)

The externnotify approach

In order for a user to have access to their voicemail, something must be done to the files in /var/spool/asterisk/voicemail/. I added the command "chmod -R a+rw /var/spool/asterisk/voicemail/default/" in a script that is called whenever a voicemail is left. That script is referenced in voicemail.conf as "externnotify=". This will allow anyone to read/write the voicemail files. No one has a login to my asterisk server so I don't care. You might want to set up a group or something.

vmail.cgi, AsteriskGUI, and users.conf

The current version of vmail.cgi (part of 1.4.21.2) only looks in the voicemail.conf file for information on voicemailboxes. The AsteriskGUI, however, also puts voicemail configuration information in the users.conf file. The result is that vmail.cgi does not currently provide access to the voicemail of users defined through the AsteriskGUI.


See also

  • Asterisk voicemail: Overview
  • Asterisk gui tycho: "Tycho" Ecllipse based Voicemail Client and Dial-Assistant
  • ARI: Asterisk Recording Interface (for Monitor() and Voicemail)
  • Asterisk Realtime Voicemail: Store voicemail in a database (Asterisk 1.2)
  • Asterisk GUI: Graphical user interfaces to Asterisk, especially look at ARI there
  • voicemail-20050331.patch
  • bug/patch 6334: Solving the access right problem for voicemail files, included in Asterisk 1.4.0
  • bug/patch 5929: Modifies group permissions for voicemail files, included in Asterisk 1.2.5


Comments

Comments Filter
222

333DBI.pm

by galdir, Friday 10 of October, 2008 [18:41:30 UTC]
Depends on package libdbi-perl
222

333Possible multi externnotify scripts?

by jakex, Friday 27 of January, 2006 [15:58:30 UTC]
Is it possible to have multiple 'externotify' scripts/apps being run? i.e. one after another? I currently have a .pl script run to organize the 'new' vmails in our mysql db. I want to have it chmod the dir right after a message is left. Anyone?

Would I use something like:
externnotify=/usr/bin/index-mysql.pl, /usr/bin/chmod-vmail.sh


222

333A better solution?

by jlewis, Friday 06 of May, 2005 [14:04:27 UTC]
If you setup * to run as non-root (search the wiki for non-root), then you can run vmail.cgi as that uid rather than as root. You just have to make it suid and sgid to the appropriate user/group...at least I do since voicemail.conf is root:asterisk 640. This can be done either via suidperl or suexec if you run vmail.cgi from a user directory or in a vhost (the only places apache will do suexec).

222

333permissions permissions...

by , Thursday 10 of February, 2005 [07:01:47 UTC]
I ran
chown root:apache /var/spool/asterisk/voicemail/YOUR_CONTEXT/YOUR_MAILBOX
chmod 775 /var/spool/asterisk/voicemail/YOUR_CONTEXT/YOUR_MAILBOX

and have the following set in /etc/asterisk/voicemail.conf
externnotify=/usr/bin/voicemailapp.sh

and /usr/bin/voicemailapp.sh looks like:
#!/bin/sh
chmod 777 ` find /var/spool/asterisk/voicemail/ -name "*.txt" -o -name "*.wav"`

chmod 755 vmail.cgi (no need to suid). Delete and voicemail works for me. in the above chown command, make sure "apache" is replaced with the user that your web server runs with.

check this by putting $ then less than (stupid post wont use <) at the end of the copywrite (or a noticable chunk of text" and matching that user up with your distro's user file gentoo uses "apache"
222

333SELinux

by alX, Wednesday 09 of February, 2005 [21:56:50 UTC]
In Fedora Core 3 I had to disable SELinux - run system-config-securitylevel in X, uncheck 'enable' on the SELinux tab and reboot.
222

333cron job for message permissions

by hbarnard, Thursday 13 of January, 2005 [14:01:37 UTC]
I've made a cron job to modify the ownership of the voice mail files I want to access from apache. Currently, also, I've just added a directory definition to httpd.conf so that I can have a page of messages and click on them.

This, of course, is pretty crude and will only suit home use (my current setup).
222

333Premature end of script headers

by , Tuesday 21 of December, 2004 [16:10:39 UTC]
You will get the Error "Premature end of script headers" when trying to execute the cgi script if you do not have mysql installed on the machine. I believe the script expects certain database drivers in place before execution, specifically DBI.pm
Add mysql to the list or prerequisites on this page.
222

333Modify Asterisk Source

by , Wednesday 14 of July, 2004 [23:03:01 UTC]
To make this work well, you should modify file.c and app_voicemail.c to write out the files with the same owner and group ID as the directories they are in.

You can do that after figuring out what the owner and group of the directory is or just chown the files to root:apache and chmod 660.

It can be a pain setting this up so it doesn't get screwed up. You have to make sure that the directories created for new mailboxes are 770 as well as 660 for any files, modifying the copy and file writing files in file.c and where they are called(the mode parameter) in app_voicemail.c.

Too bad the Asterisk devs don't have this built in or a configure option when compiling. Checking your voicemail from the web is very convenient.
222

333TheCara

by , Thursday 01 of July, 2004 [13:47:03 UTC]
(:confused:)As always, a better explanation and didatical text would be a piece of heaen on our lives