From 30f040efe6095e461050dde05b3ccc6ccc274123 Mon Sep 17 00:00:00 2001 From: joshua Date: Mon, 21 Jan 2019 01:12:40 +0100 Subject: [PATCH 1/3] Add options for resolv.conf https://redmine.pfsense.org/issues/790 --- src/etc/inc/system.inc | 5 +++++ src/usr/local/www/system.php | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 5751e838580..7096d935a03 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -151,6 +151,11 @@ function system_resolvconf_generate($dynupdate = false) { $resolvconf .= "options edns0\n"; } + // Add options + if (isset($config['system']['resolvconfoptions']) && !empty($config['system']['resolvconfoptions'])) { + $resolvconf .= base64_decode($config['system']['resolvconfoptions']); + } + $dnslock = lock('resolvconf', LOCK_EX); $fd = fopen("{$g['etc_path']}/resolv.conf", "w"); diff --git a/src/usr/local/www/system.php b/src/usr/local/www/system.php index 9cf50e79659..97ad7f0d917 100644 --- a/src/usr/local/www/system.php +++ b/src/usr/local/www/system.php @@ -77,6 +77,7 @@ $pconfig['statusmonitoringsettingspanel'] = isset($config['system']['webgui']['statusmonitoringsettingspanel']); $pconfig['webguihostnamemenu'] = $config['system']['webgui']['webguihostnamemenu']; $pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']); +$pconfig['resolvconfoptions'] = isset($config['system']['resolvconfoptions']) ? base64_decode($config['system']['resolvconfoptions']) : ''; //$pconfig['dashboardperiod'] = isset($config['widgets']['period']) ? $config['widgets']['period']:"10"; $pconfig['roworderdragging'] = isset($config['system']['webgui']['roworderdragging']); $pconfig['loginshowhost'] = isset($config['system']['webgui']['loginshowhost']); @@ -341,7 +342,13 @@ function is_timezone($elt) { } else { unset($config['system']['dnslocalhost']); } - + + if ($_POST['resolvconfoptions']) { + $config['system']['resolvconfoptions'] = base64_encode(trim($_POST['resolvconfoptions'])); + } else { + unset($config['system']['resolvconfoptions']); + } + /* which interface should the dns servers resolve through? */ $dnscounter = 0; // The $_POST array key of the DNS IP (starts from 0) @@ -567,6 +574,12 @@ function is_timezone($elt) { 'listen on localhost, so system can use the local DNS service to perform '. 'lookups. Checking this box omits localhost from the list of DNS servers in resolv.conf.'); +$section->addInput(new Form_Textarea( + 'resolvconfoptions', + 'Add options in resolv.conf ', + $pconfig['resolvconfoptions'] +))->setHelp('Add here options for resolv.conf file. They will be added at the end of the /etc/resolv.conf file.
Example :
options timeout:1
options attempts:1'); + $form->add($section); $section = new Form_Section('Localization'); From e6f95525ad6891ac46f88583e1a90f4bef79bed0 Mon Sep 17 00:00:00 2001 From: joshua Date: Wed, 23 Jan 2019 20:12:12 +0100 Subject: [PATCH 2/3] resolv.conf options : switch to system_advanced_network tab --- src/usr/local/www/system.php | 13 ------------ src/usr/local/www/system_advanced_network.php | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/usr/local/www/system.php b/src/usr/local/www/system.php index 97ad7f0d917..8d9f18a8100 100644 --- a/src/usr/local/www/system.php +++ b/src/usr/local/www/system.php @@ -77,7 +77,6 @@ $pconfig['statusmonitoringsettingspanel'] = isset($config['system']['webgui']['statusmonitoringsettingspanel']); $pconfig['webguihostnamemenu'] = $config['system']['webgui']['webguihostnamemenu']; $pconfig['dnslocalhost'] = isset($config['system']['dnslocalhost']); -$pconfig['resolvconfoptions'] = isset($config['system']['resolvconfoptions']) ? base64_decode($config['system']['resolvconfoptions']) : ''; //$pconfig['dashboardperiod'] = isset($config['widgets']['period']) ? $config['widgets']['period']:"10"; $pconfig['roworderdragging'] = isset($config['system']['webgui']['roworderdragging']); $pconfig['loginshowhost'] = isset($config['system']['webgui']['loginshowhost']); @@ -343,12 +342,6 @@ function is_timezone($elt) { unset($config['system']['dnslocalhost']); } - if ($_POST['resolvconfoptions']) { - $config['system']['resolvconfoptions'] = base64_encode(trim($_POST['resolvconfoptions'])); - } else { - unset($config['system']['resolvconfoptions']); - } - /* which interface should the dns servers resolve through? */ $dnscounter = 0; // The $_POST array key of the DNS IP (starts from 0) @@ -574,12 +567,6 @@ function is_timezone($elt) { 'listen on localhost, so system can use the local DNS service to perform '. 'lookups. Checking this box omits localhost from the list of DNS servers in resolv.conf.'); -$section->addInput(new Form_Textarea( - 'resolvconfoptions', - 'Add options in resolv.conf ', - $pconfig['resolvconfoptions'] -))->setHelp('Add here options for resolv.conf file. They will be added at the end of the /etc/resolv.conf file.
Example :
options timeout:1
options attempts:1'); - $form->add($section); $section = new Form_Section('Localization'); diff --git a/src/usr/local/www/system_advanced_network.php b/src/usr/local/www/system_advanced_network.php index d8f6bb62131..386d8725eb2 100644 --- a/src/usr/local/www/system_advanced_network.php +++ b/src/usr/local/www/system_advanced_network.php @@ -48,6 +48,8 @@ $pconfig['disablesegmentationoffloading'] = isset($config['system']['disablesegmentationoffloading']); $pconfig['disablelargereceiveoffloading'] = isset($config['system']['disablelargereceiveoffloading']); $pconfig['ip_change_kill_states'] = $config['system']['ip_change_kill_states']; +$pconfig['resolvconfoptions'] = isset($config['system']['resolvconfoptions']) ? base64_decode($config['system']['resolvconfoptions']) : ''; + if ($_POST) { @@ -171,6 +173,13 @@ unset($config['system']['ip_change_kill_states']); } + if (!empty(trim($_POST['resolvconfoptions']))) { + $config['system']['resolvconfoptions'] = base64_encode(trim($_POST['resolvconfoptions'])); + } else { + unset($config['system']['resolvconfoptions']); + } + + setup_microcode(); // Write out configuration (config.xml) @@ -404,6 +413,18 @@ } $form->add($section); + +// section resolv.conf options +$section = new Form_Section('Add persistent resolv.conf configuration options'); + +$section->addInput(new Form_Textarea( + 'resolvconfoptions', + 'Add configuration options', + $pconfig['resolvconfoptions'] +))->setHelp('You can add persistent configuration options here.
Lines will be added at the end of the /etc/resolv.conf file.
Example (man resolv.conf):
options timeout:1
options attempts:1'); + +$form->add($section); + print $form; ?> From 27e768278b9c6a41d2ac0a36141ba72fd5baf773 Mon Sep 17 00:00:00 2001 From: joshua Date: Wed, 23 Jan 2019 20:14:59 +0100 Subject: [PATCH 3/3] remove spaces --- src/usr/local/www/system.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usr/local/www/system.php b/src/usr/local/www/system.php index 8d9f18a8100..9cf50e79659 100644 --- a/src/usr/local/www/system.php +++ b/src/usr/local/www/system.php @@ -341,7 +341,7 @@ function is_timezone($elt) { } else { unset($config['system']['dnslocalhost']); } - + /* which interface should the dns servers resolve through? */ $dnscounter = 0; // The $_POST array key of the DNS IP (starts from 0)