From eaca40dffe3f8bd349163e04f4f0489978a40029 Mon Sep 17 00:00:00 2001 From: Ermal Date: Tue, 14 Dec 2010 22:27:32 +0000 Subject: Cleanup of whitespace and use exclusive lock during reconfiguration of vouchers. --- etc/inc/voucher.inc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'etc/inc/voucher.inc') diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc index 3b8e1ac..98a5340 100644 --- a/etc/inc/voucher.inc +++ b/etc/inc/voucher.inc @@ -250,15 +250,15 @@ function voucher_auth($voucher_received, $test = 0) { function voucher_configure() { global $config, $g; - - /* kill any running minicron */ - killbypid("{$g['varrun_path']}/vouchercron.pid"); - if (isset($config['voucher']['enable'])) { + /* kill any running minicron */ + killbypid("{$g['varrun_path']}/vouchercron.pid"); - if ($g['booting']) { + if (isset($config['voucher']['enable'])) + return 0; + + if ($g['booting']) echo "Enabling voucher support... "; - } // start cron if we're asked to save runtime DB periodically // to XML config if it changed @@ -269,7 +269,8 @@ function voucher_configure() { "/etc/rc.savevoucher"); } - $voucherlck = lock('voucher'); + $voucherlck = lock('voucher', LOCK_EX); + /* write public key used to verify vouchers */ $pubkey = base64_decode($config['voucher']['publickey']); $fd = fopen("{$g['varetc_path']}/voucher.public", "w"); @@ -323,8 +324,8 @@ function voucher_configure() { unlock($voucherlck); echo "done\n"; } - } - return 0; + + return 0; } /* write bitstring of used vouchers to ramdisk. @@ -483,4 +484,4 @@ function voucher_save_db_to_config() { return; } -?> \ No newline at end of file +?> -- cgit v1.1