mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-21 04:46:29 +00:00
Clicking forward without selecting a message leaves an errant .lock file.
(closes issue #12528) Reported by: pukepail Patches: patch.diff uploaded by pukepail (license 431) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114689 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -21,7 +21,7 @@ use DBI;
|
|||||||
use Fcntl qw ( O_WRONLY O_CREAT O_EXCL );
|
use Fcntl qw ( O_WRONLY O_CREAT O_EXCL );
|
||||||
use Time::HiRes qw ( usleep );
|
use Time::HiRes qw ( usleep );
|
||||||
|
|
||||||
$context=""; # Define here your by default context (so you dont need to put voicemail@context in the login
|
$context=""; # Define here your by default context (so you dont need to put voicemail@context in the login)
|
||||||
|
|
||||||
@validfolders = ( "INBOX", "Old", "Work", "Family", "Friends", "Cust1", "Cust2", "Cust3", "Cust4", "Cust5" );
|
@validfolders = ( "INBOX", "Old", "Work", "Family", "Friends", "Cust1", "Cust2", "Cust3", "Cust4", "Cust5" );
|
||||||
|
|
||||||
@@ -46,10 +46,10 @@ $context=""; # Define here your by default context (so you dont need to put voic
|
|||||||
$astpath = "/_asterisk";
|
$astpath = "/_asterisk";
|
||||||
|
|
||||||
$stdcontainerstart = "<table align=center width=600><tr><td>\n";
|
$stdcontainerstart = "<table align=center width=600><tr><td>\n";
|
||||||
$footer = "<hr><font size=-1><a href=\"http://www.asterisk.org\">The Asterisk Open Source PBX</a> Copyright 2004, <a href=\"http://www.digium.com\">Digium, Inc.</a></a>";
|
$footer = "<hr><font size=-1><a href=\"http://www.asterisk.org\">The Asterisk Open Source PBX</a> Copyright 2004-2008, <a href=\"http://www.digium.com\">Digium, Inc.</a></a>";
|
||||||
$stdcontainerend = "</td></tr><tr><td align=right>$footer</td></tr></table>\n";
|
$stdcontainerend = "</td></tr><tr><td align=right>$footer</td></tr></table>\n";
|
||||||
|
|
||||||
sub lock_path() {
|
sub lock_path($) {
|
||||||
|
|
||||||
my($path) = @_;
|
my($path) = @_;
|
||||||
my $rand;
|
my $rand;
|
||||||
@@ -80,14 +80,14 @@ sub lock_path() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub unlock_path() {
|
sub unlock_path($) {
|
||||||
|
|
||||||
my($path) = @_;
|
my($path) = @_;
|
||||||
|
|
||||||
unlink("$path/.lock");
|
unlink("$path/.lock");
|
||||||
}
|
}
|
||||||
|
|
||||||
sub untaint() {
|
sub untaint($) {
|
||||||
|
|
||||||
my($data) = @_;
|
my($data) = @_;
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ sub untaint() {
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub login_screen() {
|
sub login_screen($) {
|
||||||
print header;
|
print header;
|
||||||
my ($message) = @_;
|
my ($message) = @_;
|
||||||
print <<_EOH;
|
print <<_EOH;
|
||||||
@@ -126,7 +126,7 @@ _EOH
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_login()
|
sub check_login($$)
|
||||||
{
|
{
|
||||||
local ($filename, $startcat) = @_;
|
local ($filename, $startcat) = @_;
|
||||||
local ($mbox, $context) = split(/\@/, param('mailbox'));
|
local ($mbox, $context) = split(/\@/, param('mailbox'));
|
||||||
@@ -178,7 +178,7 @@ sub check_login()
|
|||||||
my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost",$dbuser,$dbpass);
|
my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost",$dbuser,$dbpass);
|
||||||
my $sth = $dbh->prepare(qq{select fullname,context from voicemail where mailbox='$mbox' and password='$pass' and context='$context'});
|
my $sth = $dbh->prepare(qq{select fullname,context from voicemail where mailbox='$mbox' and password='$pass' and context='$context'});
|
||||||
$sth->execute();
|
$sth->execute();
|
||||||
if (($fullname, $category) = $sth->fetchrow_array()) {;
|
if (($fullname, $category) = $sth->fetchrow_array()) {
|
||||||
return ($fullname ? $fullname : "Extension $mbox in $context",$category);
|
return ($fullname ? $fullname : "Extension $mbox in $context",$category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ sub check_login()
|
|||||||
return ("", $category);
|
return ("", $category);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub validmailbox()
|
sub validmailbox($$$$)
|
||||||
{
|
{
|
||||||
local ($context, $mbox, $filename, $startcat) = @_;
|
local ($context, $mbox, $filename, $startcat) = @_;
|
||||||
local $category = $startcat;
|
local $category = $startcat;
|
||||||
@@ -242,7 +242,7 @@ sub validmailbox()
|
|||||||
my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost",$dbuser,$dbpass);
|
my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost",$dbuser,$dbpass);
|
||||||
my $sth = $dbh->prepare(qq{select fullname,context from voicemail where mailbox='$mbox' and password='$pass' and context='$context'});
|
my $sth = $dbh->prepare(qq{select fullname,context from voicemail where mailbox='$mbox' and password='$pass' and context='$context'});
|
||||||
$sth->execute();
|
$sth->execute();
|
||||||
if (($fullname, $context) = $sth->fetchrow_array()) {;
|
if (($fullname, $context) = $sth->fetchrow_array()) {
|
||||||
return ($fullname ? $fullname : "unknown", $category);
|
return ($fullname ? $fullname : "unknown", $category);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -587,7 +587,7 @@ sub message_index()
|
|||||||
my $message2;
|
my $message2;
|
||||||
my $msgcount;
|
my $msgcount;
|
||||||
my $hasmsg;
|
my $hasmsg;
|
||||||
my $newmessages, $oldmessages;
|
my ($newmessages, $oldmessages);
|
||||||
my $format = param('format');
|
my $format = param('format');
|
||||||
if (!$format) {
|
if (!$format) {
|
||||||
$format = &getcookie('format');
|
$format = &getcookie('format');
|
||||||
@@ -737,7 +737,7 @@ sub folder_list()
|
|||||||
sub message_rename()
|
sub message_rename()
|
||||||
{
|
{
|
||||||
my ($context, $mbox, $oldfolder, $old, $newfolder, $new) = @_;
|
my ($context, $mbox, $oldfolder, $old, $newfolder, $new) = @_;
|
||||||
my $oldfile, $newfile;
|
my ($oldfile, $newfile);
|
||||||
return if ($old eq $new) && ($oldfolder eq $newfolder);
|
return if ($old eq $new) && ($oldfolder eq $newfolder);
|
||||||
|
|
||||||
if ($context =~ /^(\w+)$/) {
|
if ($context =~ /^(\w+)$/) {
|
||||||
@@ -780,7 +780,7 @@ sub message_rename()
|
|||||||
$path =~ /^(.*)$/;
|
$path =~ /^(.*)$/;
|
||||||
$path = $1;
|
$path = $1;
|
||||||
mkdir $path, 0770;
|
mkdir $path, 0770;
|
||||||
my $path = "/var/spool/asterisk/voicemail/$context/$mbox/$oldfolder";
|
$path = "/var/spool/asterisk/voicemail/$context/$mbox/$oldfolder";
|
||||||
opendir(DIR, $path) || die("Unable to open directory\n");
|
opendir(DIR, $path) || die("Unable to open directory\n");
|
||||||
my @files = grep /^msg${old}\.\w+$/, readdir(DIR);
|
my @files = grep /^msg${old}\.\w+$/, readdir(DIR);
|
||||||
closedir(DIR);
|
closedir(DIR);
|
||||||
@@ -818,7 +818,7 @@ sub file_copy()
|
|||||||
sub message_copy()
|
sub message_copy()
|
||||||
{
|
{
|
||||||
my ($context, $mbox, $newmbox, $oldfolder, $old, $new) = @_;
|
my ($context, $mbox, $newmbox, $oldfolder, $old, $new) = @_;
|
||||||
my $oldfile, $newfile;
|
my ($oldfile, $newfile);
|
||||||
return if ($mbox eq $newmbox);
|
return if ($mbox eq $newmbox);
|
||||||
|
|
||||||
if ($mbox =~ /^(\w+)$/) {
|
if ($mbox =~ /^(\w+)$/) {
|
||||||
@@ -855,11 +855,11 @@ sub message_copy()
|
|||||||
$path =~ /^(.*)$/;
|
$path =~ /^(.*)$/;
|
||||||
$path = $1;
|
$path = $1;
|
||||||
mkdir $path, 0770;
|
mkdir $path, 0770;
|
||||||
my $path = "/var/spool/asterisk/voicemail/$context/$newmbox/INBOX";
|
$path = "/var/spool/asterisk/voicemail/$context/$newmbox/INBOX";
|
||||||
$path =~ /^(.*)$/;
|
$path =~ /^(.*)$/;
|
||||||
$path = $1;
|
$path = $1;
|
||||||
mkdir $path, 0770;
|
mkdir $path, 0770;
|
||||||
my $path = "/var/spool/asterisk/voicemail/$context/$mbox/$oldfolder";
|
$path = "/var/spool/asterisk/voicemail/$context/$mbox/$oldfolder";
|
||||||
opendir(DIR, $path) || die("Unable to open directory\n");
|
opendir(DIR, $path) || die("Unable to open directory\n");
|
||||||
my @files = grep /^msg${old}\.\w+$/, readdir(DIR);
|
my @files = grep /^msg${old}\.\w+$/, readdir(DIR);
|
||||||
closedir(DIR);
|
closedir(DIR);
|
||||||
@@ -936,6 +936,7 @@ sub message_forward()
|
|||||||
$context = &untaint($context);
|
$context = &untaint($context);
|
||||||
$newmbox = &untaint($newmbox);
|
$newmbox = &untaint($newmbox);
|
||||||
my $path = "/var/spool/asterisk/voicemail/$context/$newmbox/INBOX";
|
my $path = "/var/spool/asterisk/voicemail/$context/$newmbox/INBOX";
|
||||||
|
if ($msgs[0]) {
|
||||||
if (&lock_path($path) == 0) {
|
if (&lock_path($path) == 0) {
|
||||||
$msgcount = &msgcount($context, $newmbox, "INBOX");
|
$msgcount = &msgcount($context, $newmbox, "INBOX");
|
||||||
|
|
||||||
@@ -954,6 +955,9 @@ sub message_forward()
|
|||||||
} else {
|
} else {
|
||||||
$txt = "Cannot forward messages: Unable to lock path.\n";
|
$txt = "Cannot forward messages: Unable to lock path.\n";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$txt = "Please Select Message(s) for this action.\n";
|
||||||
|
}
|
||||||
if ($toindex) {
|
if ($toindex) {
|
||||||
&message_index($folder, $txt);
|
&message_index($folder, $txt);
|
||||||
} else {
|
} else {
|
||||||
@@ -966,7 +970,7 @@ sub message_delete_or_move()
|
|||||||
my ($toindex, $del, @msgs) = @_;
|
my ($toindex, $del, @msgs) = @_;
|
||||||
my $txt;
|
my $txt;
|
||||||
my $path;
|
my $path;
|
||||||
my $y, $x;
|
my ($y, $x);
|
||||||
my $folder = param('folder');
|
my $folder = param('folder');
|
||||||
my $newfolder = param('newfolder') unless $del;
|
my $newfolder = param('newfolder') unless $del;
|
||||||
$newfolder =~ s/^(\w+)\s+.*$/$1/;
|
$newfolder =~ s/^(\w+)\s+.*$/$1/;
|
||||||
@@ -981,7 +985,8 @@ sub message_delete_or_move()
|
|||||||
$context = &untaint($context);
|
$context = &untaint($context);
|
||||||
$mbox = &untaint($mbox);
|
$mbox = &untaint($mbox);
|
||||||
$folder = &untaint($folder);
|
$folder = &untaint($folder);
|
||||||
my $path = "/var/spool/asterisk/voicemail/$context/$mbox/$folder";
|
$path = "/var/spool/asterisk/voicemail/$context/$mbox/$folder";
|
||||||
|
if ($msgs[0]) {
|
||||||
if (&lock_path($path) == 0) {
|
if (&lock_path($path) == 0) {
|
||||||
my $msgcount = &msgcount($context, $mbox, $folder);
|
my $msgcount = &msgcount($context, $mbox, $folder);
|
||||||
my $omsgcount = &msgcount($context, $mbox, $newfolder) if $newfolder;
|
my $omsgcount = &msgcount($context, $mbox, $newfolder) if $newfolder;
|
||||||
@@ -1015,6 +1020,9 @@ sub message_delete_or_move()
|
|||||||
} else {
|
} else {
|
||||||
$txt = "Cannot move/delete messages: Unable to lock path.\n";
|
$txt = "Cannot move/delete messages: Unable to lock path.\n";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$txt = "Please Select Message(s) for this action.\n";
|
||||||
|
}
|
||||||
# Not as many messages now
|
# Not as many messages now
|
||||||
$msgcount--;
|
$msgcount--;
|
||||||
if ($toindex || ($msgs[0] >= $msgcount)) {
|
if ($toindex || ($msgs[0] >= $msgcount)) {
|
||||||
|
Reference in New Issue
Block a user