Revision 6a4635fc
Added by BBcan177 . over 6 years ago
src/etc/inc/services.inc | ||
---|---|---|
2204 | 2204 |
} |
2205 | 2205 |
} |
2206 | 2206 |
|
2207 |
$python_mode = false; |
|
2208 |
if (isset($config['unbound']['python']) && !empty($config['unbound']['python_script'])) { |
|
2209 |
$python_mode = true; |
|
2210 |
} |
|
2211 |
|
|
2212 |
/* Include any additional functions as defined by python script include file */ |
|
2213 |
if (file_exists("{$g['unbound_chroot_path']}/{$config['unbound']['python_script']}_include.inc")) { |
|
2214 |
exec("/usr/local/bin/php -l " . escapeshellarg("{$g['unbound_chroot_path']}/{$config['unbound']['python_script']}_include.inc") |
|
2215 |
. " 2>&1", $py_output, $py_retval); |
|
2216 |
if ($py_retval == 0) { |
|
2217 |
require_once("{$g['unbound_chroot_path']}/{$config['unbound']['python_script']}_include.inc"); |
|
2218 |
} |
|
2219 |
} |
|
2220 |
|
|
2207 | 2221 |
/* DNS Resolver python integration */ |
2208 | 2222 |
$base_folder = '/usr/local'; |
2209 | 2223 |
foreach (array('/bin', '/lib') as $dir) { |
2210 |
$validate = exec("/sbin/mount | /usr/bin/grep '{$g['unbound_chroot_path']}{$base_folder}{$dir}' 2>&1");
|
|
2211 |
if (isset($config['unbound']['python']) && !empty($config['unbound']['python_script'])) {
|
|
2224 |
$validate = exec("/sbin/mount | /usr/bin/grep " . escapeshellarg("{$g['unbound_chroot_path']}{$base_folder}{$dir} (nullfs") . " 2>&1");
|
|
2225 |
if ($python_mode) {
|
|
2212 | 2226 |
|
2213 | 2227 |
// Add DNS Resolver python integration |
2214 | 2228 |
if (empty($validate)) { |
2215 | 2229 |
if (!is_dir("{$g['unbound_chroot_path']}{$base_folder}{$dir}")) { |
2216 | 2230 |
safe_mkdir("{$g['unbound_chroot_path']}{$base_folder}{$dir}"); |
2217 | 2231 |
} |
2218 |
exec("/sbin/mount_nullfs -o ro " . escapeshellarg("/usr/local{$dir}") . " " . escapeshellarg("{$g['unbound_chroot_path']}{$base_folder}{$dir}") . " 2>&1", $output, $retval); |
|
2219 |
|
|
2232 |
$output = $retval = ''; |
|
2233 |
exec("/sbin/mount_nullfs -o ro " . escapeshellarg("/usr/local{$dir}") . ' ' |
|
2234 |
. escapeshellarg("{$g['unbound_chroot_path']}{$base_folder}{$dir}") . " 2>&1", $output, $retval); |
|
2235 |
|
|
2220 | 2236 |
// Disable Unbound python on mount failure |
2221 | 2237 |
if ($retval != 0) { |
2222 | 2238 |
$config['unbound']['python'] = ''; |
... | ... | |
2233 | 2249 |
if ($retval == 0) { |
2234 | 2250 |
foreach (array( "/usr/local{$dir}", '/usr/local', '/usr') as $folder) { |
2235 | 2251 |
if (!empty($g['unbound_chroot_path']) && $g['unbound_chroot_path'] != '/' && is_dir("{$g['unbound_chroot_path']}{$folder}")) { |
2236 |
rmdir("{$g['unbound_chroot_path']}{$folder}");
|
|
2252 |
@rmdir(escapeshellarg("{$g['unbound_chroot_path']}{$folder}"));
|
|
2237 | 2253 |
} |
2238 | 2254 |
|
2239 | 2255 |
// Delete remaining subfolders on next loop |
Also available in: Unified diff
Unbound python mod - services.inc