From 78dfd81e275b4605d1a2152e6bd39c1e0cfb57d5 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 23 Feb 2015 06:17:08 +0100 Subject: [PATCH] system: add fallback chain for openssl --- src/etc/inc/system.inc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index d106913a3..1afba4c92 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -803,11 +803,25 @@ EOD; return $retval; } -function system_webgui_start() { +function system_webgui_start() +{ global $config, $g; - if ($g['booting']) + if (file_exists('/usr/local/bin/openssl')) { + /* use the ports version */ + $bin_openssl = '/usr/local/bin/openssl'; + } elseif (file_exists('/usr/bin/openssl')) { + /* use the base version (legacy fallback) */ + $bin_openssl = '/usr/bin/openssl'; + } else { + /* the infamous "this should never happen" */ + log_error(_('Could not find an OpenSSL implementation on your system.')); + } + + if ($g['booting']) { + /* XXX no no no no no no no no */ echo gettext("Starting webConfigurator..."); + } chdir('/usr/local/www'); @@ -841,7 +855,7 @@ function system_webgui_start() { $openssl_args .= ' -subj "/C=NL/ST=Zuid-Holland/L=Middelharnis/O=OPNsense"'; $openssl_args .= ' -keyout /tmp/ssl.key'; $openssl_args .= ' -out /tmp/ssl.crt'; - mwexec('/usr/bin/openssl' . $openssl_args); + mwexec($bin_openssl . $openssl_args); $crt = file_get_contents('/tmp/ssl.crt'); $key = file_get_contents('/tmp/ssl.key'); unlink('/tmp/ssl.key');