From 80a0cb638e979eefb4d9809af734e1b7b0429cb7 Mon Sep 17 00:00:00 2001 From: rangi Date: Thu, 21 Dec 2000 19:56:43 +0000 Subject: [PATCH] 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 --- C4/Database.pm | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/C4/Database.pm b/C4/Database.pm index 81ae6f38ab..11664e1fcf 100755 --- a/C4/Database.pm +++ b/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 () { + 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; } -- 2.39.2