Handle unix: MySQL socket format

This commit is contained in:
Jamie Cameron
2007-12-25 05:54:59 +00:00
parent 3045b881c0
commit 5e91d93dad

View File

@@ -1864,7 +1864,14 @@ local @hosts = split(/\s+/, $config{'mysql_hosts'} || $conf->{'hosts'});
local $dbh;
foreach my $host (@hosts) {
local $dbistr = "database=$conf->{'dbname'}";
$dbistr .= ";host=$host" if ($host);
if ($host =~ /^unix:(.*)$/) {
# Socket file
$dbistr .= ";mysql_socket=$1";
}
elsif ($host) {
# Remote host
$dbistr .= ";host=$host";
}
$dbh = $drh->connect($dbistr,
$config{'mysql_user'} || $conf->{'user'},
$config{'mysql_pass'} || $conf->{'password'},
@@ -1879,8 +1886,6 @@ return $dbh;
# connect_ldap_db(&config)
# Attempts to connect to an LDAP server with Postfix maps. Returns
# a driver handle on success, or an error message string on failure.
# XXX try all hosts
# XXX handle :port syntax and ldap: syntax
sub connect_ldap_db
{
local ($conf) = @_;