Commit 29dc0b5e authored by Franco Fichtner's avatar Franco Fichtner

rc: improve the php config write

o Don't clobber manually installed extensions
o Remove the XDebug enable in favour of an autoload if available
o No longer install XDebug by default

Adds long overdue copyrights, been handling this file since 2014.
parent 68074f42
......@@ -73,7 +73,6 @@ CORE_DEPENDS?= apinger \
phalcon \
php-pfSense \
php-suhosin \
php-xdebug \
php56 \
php56-bcmath \
php56-ctype \
......
#!/bin/sh
# Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
# All rights reserved.
# Copyright (C) 2014-2016 Franco Fichtner <franco@opnsense.org>
# Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
if [ -d /usr/local/lib/php/20151012 ]; then
# PHP 7
......@@ -72,8 +73,13 @@ PHPMODULES="$PHPMODULES filter"
# OPNsense
PHPMODULES="$PHPMODULES phalcon"
_EXTENSIONS_INI=$(mktemp -q /tmp/extensions_ini.XXXXXX)
EXTENSIONS_INI=/usr/local/etc/php/extensions.ini
touch ${EXTENSIONS_INI}
cp ${EXTENSIONS_INI} ${_EXTENSIONS_INI}
# Clear the .ini file to make sure we are clean
rm -f /usr/local/etc/php/extensions.ini
rm -f /usr/local/etc/php.ini
rm -f /usr/local/lib/php.ini
......@@ -117,16 +123,15 @@ EOF
# Loop through and generate modules to load.
for EXT in ${PHPMODULES}; do
if [ -f "${EXTENSIONSDIR}${EXT}.so" ]; then
echo "extension=${EXT}.so" >> /usr/local/etc/php/extensions.ini
fi
sed -i '' -e "/${EXT}.so/d" ${_EXTENSIONS_INI}
echo "extension=${EXT}.so" >> ${_EXTENSIONS_INI}
done
# Enable XDebug if enabled in config
if [ ! -z `grep "<enable_xdebug>1</enable_xdebug>" /conf/config.xml` ]; then
cat >> /usr/local/etc/php/extensions.ini << EOF
zend_extension=xdebug.so
EOF
# Enable XDebug if installed
if [ -f "${EXTENSIONSDIR}xdebug.so" ]; then
sed -i '' -e "/xdebug.so/d" ${_EXTENSIONS_INI}
echo "zend_extension=${EXTENSIONSDIR}xdebug.so" >> ${_EXTENSIONS_INI}
cat >> /usr/local/lib/php.ini << EOF
[xdebug]
......@@ -156,3 +161,4 @@ EOF
# Copy php.ini file to etc/ too (cli)
cp /usr/local/lib/php.ini /usr/local/etc/php.ini
mv ${_EXTENSIONS_INI} ${EXTENSIONS_INI}
......@@ -46,7 +46,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['noantilockout'] = isset($config['system']['webgui']['noantilockout']);
$pconfig['nodnsrebindcheck'] = isset($config['system']['webgui']['nodnsrebindcheck']);
$pconfig['nohttpreferercheck'] = isset($config['system']['webgui']['nohttpreferercheck']);
$pconfig['enable_xdebug'] = isset($config['system']['webgui']['enable_xdebug']) ;
$pconfig['loginautocomplete'] = isset($config['system']['webgui']['loginautocomplete']);
$pconfig['althostnames'] = $config['system']['webgui']['althostnames'];
$pconfig['enableserial'] = $config['system']['enableserial'];
......@@ -152,12 +151,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
unset($config['system']['webgui']['nohttpreferercheck']);
}
if ($pconfig['enable_xdebug'] == "yes") {
$config['system']['webgui']['enable_xdebug'] = true;
} elseif (isset($config['system']['webgui']['enable_xdebug'])) {
unset($config['system']['webgui']['enable_xdebug']);
}
if ($pconfig['loginautocomplete'] == "yes") {
$config['system']['webgui']['loginautocomplete'] = true;
} elseif (isset($config['system']['webgui']['loginautocomplete'])) {
......@@ -467,18 +460,6 @@ include("head.inc");
</div>
</td>
</tr>
<tr>
<td><a id="help_for_xdebug" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Enable XDebug"); ?></td>
<td width="78%">
<input name="enable_xdebug" type="checkbox" value="yes" <?=!empty($pconfig['enable_xdebug']) ? "checked=\"checked\"" : "";?> />
<strong><?=gettext("Enable debugger / profiler (developer mode, do not enable in production environment)"); ?></strong>
<div class="hidden" for="help_for_xdebug">
<?php echo gettext("When this is checked, php XDebug will be enabled and profiling output can be analysed using webgrind which will be available at [this-url]/webgrind/"); ?>
<br />
<?php echo gettext("For more information about XDebug profiling and how to enable it for your requests, please visit http://www.xdebug.org/docs/all_settings#profiler_enable_trigger"); ?>
</div>
</td>
</tr>
<tr>
<th colspan="2"><?=gettext("Secure Shell"); ?></th>
</tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment