Allow overwriting config options with arguments.
Allow overwriting config options with arguments.
diff --git a/auth.php b/auth.php
index 6a62130..0ba30c1 100644
--- a/auth.php
+++ b/auth.php
@@ -14,11 +14,19 @@ $lockfile = fopen(__FILE__, 'r');
if ($lockfile === FALSE) die("Cannot open lock file\n");
if (!flock($lockfile, LOCK_EX)) die("Cannot acquire exclisive lock\n");
-$options = getopt("c:");
+$options = getopt("c:", [
+ 'secret:',
+ 'period:',
+ 'window:',
+ 'digest:',
+ 'digits:',
+ 'delay:'
+]);
if (isset($options['c'])) $config = load_config($options['c']); else $config = new stdClass();
$config_default = load_config(__DIR__.'/config_default.json');
foreach($config_default as $k => $v) if (!isset($config->{$k})) $config->{$k} = $v;
+foreach($options as $k => $v) if ($k !== 'c') $config->{$k} = $v;
if (!preg_match('/^[A-Z2-7]+$/i', $config->secret)) die("Base32 encoded secret required\n");
$totp = new TOTP(null, $config->secret, $config->period, $config->digest, $config->digits);