[OpenSIPS-Users] Possible problem in osipsconsole

5evra arve5 at online.no
Mon Aug 17 15:27:39 CEST 2009


In each create db function this if - else is exist:

        if ( -d $DATA_DIR."/mysql" ) {
                $DB_SCHEMA=$DATA_DIR."/postgres";
        } else {
                $DB_SCHEMA="./postgres";
        }

If you DONT install 'mysql' or this directory for a reason is not in
$DATA_DIR, DB_SCHEMA will fallback to current workdir without notice, which
is bad. 

Suggested solution:

move if - else out from all functions that checks for the $DB_SCHEMA value,
and call ONE function to handle this logic. I.e. read and analyse the output
from DATA_DIR and return the exact directory or local workdir with an
informative warning.

e.g.

sub validate_datadir{
 my $type = shift;
 if( -d "$DATA_DIR."/$type" ) {
   return "$DATA_DIR."/$type";
 }
 print "Warn fallback to local workdir ./$type"\n";
 return "./$type";
}
-- 
View this message in context: http://n2.nabble.com/Possible-problem-in-osipsconsole-tp3458993p3458993.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.



More information about the Users mailing list