From 9f91ec73d50bc1b9c0b5a9e7bad0dd84a184a5fc Mon Sep 17 00:00:00 2001 From: Piotr Pawlow Date: Sun, 19 Mar 2017 20:25:12 +0100 Subject: Allow overwriting config options with arguments. --- auth.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'auth.php') 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); -- cgit v1.2.3