mirror of
https://github.com/Yubico/yubikey-ksm.git
synced 2025-01-19 07:52:17 +01:00
Added support for reading db config from /etc/ykksm/
This commit is contained in:
parent
d43308eb56
commit
6279082493
@ -55,10 +55,17 @@ sub usage {
|
||||
exit 1;
|
||||
}
|
||||
|
||||
#Support dbconfig-common generated database settings, if available
|
||||
our ($dbuser, $dbpass, $basepath, $dbname, $dbserver, $dbport, $dbtype);
|
||||
if( -e '/etc/ykksm/config-db.cfg' ) {
|
||||
require '/etc/ykksm/config-db.cfg';
|
||||
} else {
|
||||
$dbtype = 'mysql';
|
||||
$dbname = 'ykksm';
|
||||
}
|
||||
|
||||
my $verbose = 0;
|
||||
my $db = "dbi:mysql:ykksm";
|
||||
my $dbuser;
|
||||
my $dbpasswd;
|
||||
my $db = "dbi:$dbtype:$dbname";
|
||||
while ($ARGV[0] =~ m/^-(.*)/) {
|
||||
my $cmd = shift @ARGV;
|
||||
if (($cmd eq "-v") || ($cmd eq "--verbose")) {
|
||||
@ -70,7 +77,7 @@ while ($ARGV[0] =~ m/^-(.*)/) {
|
||||
} elsif ($cmd eq "--db-user") {
|
||||
$dbuser = shift;
|
||||
} elsif ($cmd eq "--db-passwd") {
|
||||
$dbpasswd = shift;
|
||||
$dbpass = shift;
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +85,7 @@ if ($#ARGV>=0) {
|
||||
usage();
|
||||
}
|
||||
|
||||
my $dbh = DBI->connect($db, $dbuser, $dbpasswd, {'RaiseError' => 1});
|
||||
my $dbh = DBI->connect($db, $dbuser, $dbpass, {'RaiseError' => 1});
|
||||
my $sth = $dbh->prepare ('SELECT serialnr, publicname, internalname, aeskey '.
|
||||
'FROM yubikeys '.
|
||||
'ORDER BY serialnr, publicname')
|
||||
|
@ -1,7 +1,18 @@
|
||||
<?php
|
||||
$db_dsn = "mysql:dbname=ykksm;host=127.0.0.1";
|
||||
$db_username = "ykksmreader";
|
||||
$db_password = "yourpassword";
|
||||
//ykksm will use the configuration stored in /etc/ykksm/config-db.php, if that file exists. If it does not exist, the below values will be used.
|
||||
|
||||
if(!include '/etc/ykksm/config-db.php') {
|
||||
$dbuser='ykksmreader';
|
||||
$dbpass='yourpassword';
|
||||
$basepath='';
|
||||
$dbname='ykksm';
|
||||
$dbserver='';
|
||||
$dbport='';
|
||||
}
|
||||
|
||||
$db_dsn = "$dbtype:dbname=$dbname;host=127.0.0.1";
|
||||
$db_username = $dbuser;
|
||||
$db_password = $dbpass;
|
||||
$db_options = array();
|
||||
$logfacility = LOG_LOCAL0;
|
||||
$logfacility = LOG_AUTH;
|
||||
?>
|
||||
|
17
ykksm-export
17
ykksm-export
@ -53,10 +53,17 @@ sub usage {
|
||||
exit 1;
|
||||
}
|
||||
|
||||
#Support dbconfig-common generated database settings, if available
|
||||
our ($dbuser, $dbpass, $basepath, $dbname, $dbserver, $dbport, $dbtype);
|
||||
if( -e '/etc/ykksm/config-db.cfg' ) {
|
||||
require '/etc/ykksm/config-db.cfg';
|
||||
} else {
|
||||
$dbtype = 'mysql';
|
||||
$dbname = 'ykksm';
|
||||
}
|
||||
|
||||
my $verbose = 0;
|
||||
my $db = "dbi:mysql:ykksm";
|
||||
my $dbuser;
|
||||
my $dbpasswd;
|
||||
my $db = "dbi:$dbtype:$dbname";
|
||||
while ($ARGV[0] =~ m/^-(.*)/) {
|
||||
my $cmd = shift @ARGV;
|
||||
if (($cmd eq "-v") || ($cmd eq "--verbose")) {
|
||||
@ -68,7 +75,7 @@ while ($ARGV[0] =~ m/^-(.*)/) {
|
||||
} elsif ($cmd eq "--db-user") {
|
||||
$dbuser = shift;
|
||||
} elsif ($cmd eq "--db-passwd") {
|
||||
$dbpasswd = shift;
|
||||
$dbpass = shift;
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,7 +83,7 @@ if ($#ARGV>=0) {
|
||||
usage();
|
||||
}
|
||||
|
||||
my $dbh = DBI->connect($db, $dbuser, $dbpasswd, {'RaiseError' => 1});
|
||||
my $dbh = DBI->connect($db, $dbuser, $dbpass, {'RaiseError' => 1});
|
||||
my $sth = $dbh->prepare
|
||||
('SELECT serialnr, publicname, internalname, aeskey, lockcode, created FROM yubikeys')
|
||||
or die "Couldn't prepare statement: " . $dbh->errstr;
|
||||
|
17
ykksm-import
17
ykksm-import
@ -57,11 +57,18 @@ sub usage {
|
||||
exit 1;
|
||||
}
|
||||
|
||||
#Support dbconfig-common generated database settings, if available
|
||||
our ($dbuser, $dbpass, $basepath, $dbname, $dbserver, $dbport, $dbtype);
|
||||
if( -e '/etc/ykksm/config-db.cfg' ) {
|
||||
require '/etc/ykksm/config-db.cfg';
|
||||
} else {
|
||||
$dbtype = 'mysql';
|
||||
$dbname = 'ykksm';
|
||||
}
|
||||
|
||||
my $verbose = 0;
|
||||
my $creator;
|
||||
my $db = "dbi:mysql:ykksm";
|
||||
my $dbuser;
|
||||
my $dbpasswd;
|
||||
my $db = "dbi:$dbtype:$dbname";
|
||||
while ($ARGV[0] =~ m/^-(.*)/) {
|
||||
my $cmd = shift @ARGV;
|
||||
if (($cmd eq "-v") || ($cmd eq "--verbose")) {
|
||||
@ -75,7 +82,7 @@ while ($ARGV[0] =~ m/^-(.*)/) {
|
||||
} elsif ($cmd eq "--db-user") {
|
||||
$dbuser = shift;
|
||||
} elsif ($cmd eq "--db-passwd") {
|
||||
$dbpasswd = shift;
|
||||
$dbpass = shift;
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +121,7 @@ print "signed by: " . $signed_by . "\n";
|
||||
|
||||
die "Input not signed?" if !$signed_by;
|
||||
|
||||
my $dbh = DBI->connect($db, $dbuser, $dbpasswd, {'RaiseError' => 1});
|
||||
my $dbh = DBI->connect($db, $dbuser, $dbpass, {'RaiseError' => 1});
|
||||
my $inserth = $dbh->prepare_cached(qq{
|
||||
INSERT INTO yubikeys (creator, created, serialnr,
|
||||
publicname, internalname, aeskey, lockcode)
|
||||
|
Loading…
x
Reference in New Issue
Block a user