@matheusbsbs / matheus-bagliano / commits / 473937ed44
Fork 0

cvsserver: Corrections to the database backend configuration

Don't include the scheme name in gitcvs.dbdriver, it is always 'dbi' anyway. Don't allow ':' in driver names nor ';' in database names for sanity reasons. Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Frank Lichtenheld committed Apr 7, 2007 at 16:58 UTC 473937ed44c112e5d3ced52ab3f9a9e53eccc272
1 file changed +4 -2
git-cvsserver.perl
+4 -2
@@ -2149,7 +2149,7 @@ sub new
2149 die "Git repo '$self->{git_path}' doesn't exist" unless ( -d $self->{git_path} );
2150
2151 $self->{dbdriver} = $cfg->{gitcvs}{$state->{method}}{dbdriver} ||
2152 - $cfg->{gitcvs}{dbdriver} || "dbi:SQLite";
2152 + $cfg->{gitcvs}{dbdriver} || "SQLite";
2153 $self->{dbname} = $cfg->{gitcvs}{$state->{method}}{dbname} ||
2154 $cfg->{gitcvs}{dbname} || "%Ggitcvs.%m.sqlite";
2155 $self->{dbuser} = $cfg->{gitcvs}{$state->{method}}{dbuser} ||
@@ -2165,7 +2165,9 @@ sub new
2165 $self->{dbname} =~ s/%([mauGg])/$mapping{$1}/eg;
2166 $self->{dbuser} =~ s/%([mauGg])/$mapping{$1}/eg;
2167
2168 - $self->{dbh} = DBI->connect("$self->{dbdriver}:dbname=$self->{dbname}",
2168 + die "Invalid char ':' in dbdriver" if $self->{dbdriver} =~ /:/;
2169 + die "Invalid char ';' in dbname" if $self->{dbname} =~ /;/;
2170 + $self->{dbh} = DBI->connect("dbi:$self->{dbdriver}:dbname=$self->{dbname}",
2171 $self->{dbuser},
2172 $self->{dbpass});
2173 die "Error connecting to database\n" unless defined $self->{dbh};