Project

General

Profile

« Previous | Next » 

Revision 12cbb18a

Added by Jim Pingle over 1 year ago

Improve validation of DNS Resolver Python script. Fixes #15135

View differences:

src/etc/inc/services.inc
4283 4283
		}
4284 4284

  
4285 4285
		$python_mode = false;
4286
		$python_script = config_get_path('unbound/python_script');
4286
		$python_script = basename(config_get_path('unbound/python_script'));
4287 4287
		if (config_path_enabled('unbound','python') && !empty($python_script)) {
4288 4288
			$python_mode = true;
4289 4289
		}
src/usr/local/www/services_unbound.php
34 34
require_once("pfsense-utils.inc");
35 35
require_once("system.inc");
36 36

  
37
$python_files = glob("{$g['unbound_chroot_path']}/*.py");
38
$python_scripts = array();
39
if (!empty($python_files)) {
40
	foreach ($python_files as $file) {
41
		$file = pathinfo($file, PATHINFO_FILENAME);
42
		$python_scripts[$file] = $file;
43
	}
44
}
45
else {
46
	$python_scripts = array('' => 'No Python Module scripts found');
47
}
48

  
37 49
$pconfig['enable'] = config_path_enabled('unbound');
38 50
$pconfig['enablessl'] = config_path_enabled('unbound', 'enablessl');
39 51
$pconfig['strictout'] = config_path_enabled('unbound', 'strictout');
......
140 152
		$input_errors[] = gettext('A System Domain Local Zone Type of "redirect" is not compatible with dynamic DHCP Registration.');
141 153
	}
142 154

  
155
	if (isset($pconfig['python']) &&
156
	    !array_key_exists(array_get_path($pconfig, 'python_script'), $python_scripts)) {
157
		array_del_path($pconfig, 'python_script');
158
		$input_errors[] = gettext('The submitted Python Module Script does not exist or is invalid.');
159
	}
160

  
143 161
	$display_custom_options = $pconfig['custom_options'];
144 162
	$pconfig['custom_options'] = base64_encode(str_replace("\r\n", "\n", $pconfig['custom_options']));
145 163

  
......
365 383
	$pconfig['python']
366 384
))->setHelp('Enable the Python Module.');
367 385

  
368
$python_files = glob("{$g['unbound_chroot_path']}/*.py");
369
$python_scripts = array();
370
if (!empty($python_files)) {
371
	foreach ($python_files as $file) {
372
		$file = pathinfo($file, PATHINFO_FILENAME);
373
		$python_scripts[$file] = $file;
374
	}
375
}
376
else {
377
	$python_scripts = array('' => 'No Python Module scripts found');
378
}
379

  
380 386
$section->addInput(new Form_Select(
381 387
	'python_order',
382 388
	'Python Module Order',

Also available in: Unified diff