1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2025-03-03 18:29:18 +01:00

script for checksumming deactivated YubiKeys

This commit is contained in:
Klas Lindfors 2012-08-22 13:24:41 +02:00
parent 471ed5d077
commit c4bd4b0bae
2 changed files with 58 additions and 1 deletions

View File

@ -6,7 +6,7 @@ CODE = COPYING Makefile NEWS ykval-checksum-clients.php \
ykval-queue.php ykval-revoke.php ykval-synclib.php \
ykval-sync.php ykval-verify.php ykval-export-clients.php \
ykval-import-clients.php ykval-db-oci.php ykval-db-pdo.php \
ykval-db.oracle.sql ykval-resync.php
ykval-db.oracle.sql ykval-resync.php ykval-checksum-deactivated.php
MUNIN = ykval-munin-ksmlatency.php ykval-munin-vallatency.php \
ykval-munin-queuelength.php ykval-munin-responses.pl \
ykval-munin-yubikeystats.php
@ -44,6 +44,7 @@ install:
install -D ykval-export-clients.php $(DESTDIR)$(sbinprefix)/ykval-export-clients
install -D ykval-import-clients.php $(DESTDIR)$(sbinprefix)/ykval-import-clients
install -D ykval-checksum-clients.php $(DESTDIR)$(sbinprefix)/ykval-checksum-clients
install -D ykval-checksum-deactivated.php $(DESTDIR)$(sbinprefix)/ykval-checksum-deactivated
install -D ykval-munin-ksmlatency.php $(DESTDIR)$(muninprefix)/ykval_ksmlatency
install -D ykval-munin-vallatency.php $(DESTDIR)$(muninprefix)/ykval_vallatency
install -D ykval-munin-queuelength.php $(DESTDIR)$(muninprefix)/ykval_queuelength

56
ykval-checksum-deactivated.php Executable file
View File

@ -0,0 +1,56 @@
#!/usr/bin/php
<?php
$verbose = 0;
if (isset($argv[1])) {
if ($argv[1] == "-h" || $argv[1] == "--help") {
print "Usage: " . $argv[0] . " [-h|--help] [-v]\n";
exit(1);
}
if ($argv[1] && $argv[1] != "-v") {
print $argv[0] . ": invalid option -- '" . $argv[0] . "'\n";
print "Try `" . $argv[0] . " --help' for more information.\n";
exit(1);
}
$verbose = $argv[1] == "-v";
}
set_include_path(get_include_path() . PATH_SEPARATOR .
"/usr/share/ykval:/etc/ykval");
require_once 'ykval-config.php';
require_once 'ykval-db.php';
$logname="ykval-checksum-deactivated";
$myLog = new Log($logname);
$db = Db::GetDatabaseHandle($baseParams, $logname);
if (!$db->connect()) {
$myLog->log(LOG_WARNING, "Could not connect to database");
exit(1);
}
$everything = "";
$result=$db->customQuery("SELECT yk_publicname, yk_counter, yk_use ".
"FROM yubikeys WHERE active = false ".
"ORDER BY yk_publicname");
while($row = $result->fetch(PDO::FETCH_ASSOC)) {
$everything = $everything .
$row['yk_publicname'] . "\t" . $row['yk_counter'] . "\t" . $row['yk_use'] .
"\n";
}
$hash = sha1 ($everything);
if ($verbose) {
print $everything;
}
print substr ($hash, 0, 10) . "\n";
$result=null;
$db=null;
?>