From 4ca6fb5448c33da842f8a4fa3be645a553b9657a Mon Sep 17 00:00:00 2001 From: Jean Paul Galea Date: Mon, 20 Jul 2015 19:20:04 +0000 Subject: [PATCH] Refactor database configuration. - don't repeat config-db.php file path - add @is_readable, we might not have the proper permissions. - use 'require_once' instead of 'include', this file should only be included once and we should fail dramatically if we can't load it. - better documentation. --- ykval-config.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ykval-config.php b/ykval-config.php index 3fce759..0c180f7 100644 --- a/ykval-config.php +++ b/ykval-config.php @@ -27,10 +27,16 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// ykval will use the configuration stored in /etc/yubico/val/config-db.php, if that file exists. If it does not exist, the below values will be used. -if (file_exists('/etc/yubico/val/config-db.php')) + +/** + * Load database configuration settings from config-db.php if available, + * otherwise default to values specified below. + */ +$dbfile = '/etc/yubico/val/config-db.php'; + +if (file_exists($dbfile) && @is_readable($dbfile)) { - include '/etc/yubico/val/config-db.php'; + require_once $dbfile; } else {