Shifted Database connection variables out into a configuration file
The permissions on this config file should also be strict, since they contain the database password. At a minimum, the apache user needs to be able to read it, as well as any other user that runs circ. I would suggest ownership of www-data.libadmins with no access to others. libadmins contain all users that use circ destined for v1.08
This commit is contained in:
parent
d0374d0037
commit
80a0cb638e
1 changed files with 21 additions and 5 deletions
|
@ -53,11 +53,27 @@ my $priv_func = sub {
|
|||
|
||||
sub C4Connect {
|
||||
my $dbname="c4";
|
||||
# my $dbh = DBI->connect("dbi:Pg:dbname=$dbname", "chris", "");
|
||||
my $database='c4test';
|
||||
my $hostname='localhost';
|
||||
my $user='hdl';
|
||||
my $pass='testing';
|
||||
my ($database,$hostname,$user,$pass,%configfile);
|
||||
open (KC, "/etc/koha.conf");
|
||||
while (<KC>) {
|
||||
chomp;
|
||||
(next) if (/^\s*#/);
|
||||
if (/(.*)\s*=\s*(.*)/) {
|
||||
my $variable=$1;
|
||||
my $value=$2;
|
||||
# Clean up white space at beginning and end
|
||||
$variable=~s/^\s*//g;
|
||||
$variable=~s/\s*$//g;
|
||||
$value=~s/^\s*//g;
|
||||
$value=~s/\s*$//g;
|
||||
$configfile{$variable}=$value;
|
||||
}
|
||||
}
|
||||
$database=$configfile{'database'};
|
||||
$hostname=$configfile{'hostname'};
|
||||
$user=$configfile{'user'};
|
||||
$pass=$configfile{'pass'};
|
||||
|
||||
my $dbh=DBI->connect("DBI:mysql:$database:$hostname",$user,$pass);
|
||||
return $dbh;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue