Browse Source

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
3.0.x
rangi 21 years ago
parent
commit
80a0cb638e
  1. 26
      C4/Database.pm

26
C4/Database.pm

@ -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…
Cancel
Save