diff options
author | Oliver Tappe | 2007-07-31 23:38:03 +0200 |
---|---|---|
committer | Oliver Tappe | 2007-07-31 23:38:03 +0200 |
commit | 880ba4090cd8af757f17604af3284afab6fd198c (patch) | |
tree | 4d37ef92b0cefc2ab1149d875b78fe0cf05dcd9e /config-db/OpenSLX/MetaDB/mysql.pm | |
parent | * Fixed another bug reported by Bastian: (diff) | |
download | core-880ba4090cd8af757f17604af3284afab6fd198c.tar.gz core-880ba4090cd8af757f17604af3284afab6fd198c.tar.xz core-880ba4090cd8af757f17604af3284afab6fd198c.zip |
* dropped support for CSV databases, as they are simply not good enough
* added support for db-user and db-passwd:
+ the mysql backend will now ask for the password upon connect
+ you can specify the db-user and db-passwd via slxsettings (so you never
have to enter it manually afterwards)
* slxsettings now checks db-type against an explicit pattern to avoid
problems caused by typos
git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1295 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'config-db/OpenSLX/MetaDB/mysql.pm')
-rw-r--r-- | config-db/OpenSLX/MetaDB/mysql.pm | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/config-db/OpenSLX/MetaDB/mysql.pm b/config-db/OpenSLX/MetaDB/mysql.pm index 8206ec2a..865b035d 100644 --- a/config-db/OpenSLX/MetaDB/mysql.pm +++ b/config-db/OpenSLX/MetaDB/mysql.pm @@ -44,10 +44,22 @@ sub connect ## no critic (ProhibitBuiltinHomonyms) # build $dbSpec from individual parameters: $dbSpec = "database=$openslxConfig{'db-name'}"; } - my $user = (getpwuid($>))[0]; - vlog(1, "trying to connect user <$user> to mysql-database <$dbSpec>"); + my $dbUser + = $openslxConfig{'db-user'} + ? $openslxConfig{'db-user'} + : (getpwuid($>))[0]; + my $dbPasswd = $openslxConfig{'db-passwd'}; + if (!defined $dbPasswd) { + use Term::ReadLine; + my $term = Term::ReadLine->new('slx'); + my $attribs = $term->Attribs; + $attribs->{redisplay_function} = $attribs->{shadow_redisplay}; + $dbPasswd = $term->readline("db-password> "); + } + + vlog(1, "trying to connect user '$dbUser' to mysql-database '$dbSpec'"); $self->{'dbh'} = DBI->connect( - "dbi:mysql:$dbSpec", $user, 'secret', {PrintError => 0} + "dbi:mysql:$dbSpec", $dbUser, $dbPasswd, {PrintError => 0} ) or die _tr("Cannot connect to database '%s' (%s)", $dbSpec, $DBI::errstr); return 1; } |