Project

General

Profile

Feature #16287 » 0001-etc-ipsec-Initialize-swanctl-directory-using-skeleton.patch

Jimmy Thrasibule, 06/28/2025 05:08 PM

View differences:

src/etc/inc/globals.inc
111 111
	'cp_prefix' => 'cpzoneid',
112 112
	'booting' => false,
113 113
	'rrddbpath' => '/var/db/rrd',
114
	'rrdtool' => '/usr/bin/nice -n20 /usr/local/bin/rrdtool'
114
	'rrdtool' => '/usr/bin/nice -n20 /usr/local/bin/rrdtool',
115
	'usretc_path' => '/usr/local/etc'
115 116
];
116 117

  
117 118
/* IP TOS flags */
src/etc/inc/ipsec.inc
1391 1391
}
1392 1392

  
1393 1393
global $g, $ipsec_swanctl_basedir, $ipsec_swanctl_dirs;
1394
$ipsec_swanctl_sysdir = "{$g['usretc_path']}/swanctl";
1394 1395
$ipsec_swanctl_basedir = "{$g['varetc_path']}/ipsec";
1395 1396
$ipsec_swanctl_dirs = array(
1396 1397
	'conf'     => "{$ipsec_swanctl_basedir}/conf.d",
......
1446 1447
	}
1447 1448
}
1448 1449

  
1450
function ipsec_copy_skel() {
1451
	global $g, $ipsec_swanctl_basedir, $ipsec_swanctl_sysdir,
1452
		$ipsec_swanctl_dirs;
1453

  
1454
	foreach (array_values($ipsec_swanctl_dirs) as $path) {
1455
		$dirname = basename($path, $ipsec_swanctl_basedir);
1456
		if (is_dir("{$ipsec_swanctl_sysdir}/{$dirname}")) {
1457
			/* If the directory exists, copy it to the new location */
1458
			@copydir("{$ipsec_swanctl_sysdir}/{$dirname}", $path);
1459
		}
1460
	}
1461
}
1462

  
1449 1463
/****f* ipsec/ipsec_setup_gwifs
1450 1464
 * NAME
1451 1465
 *   ipsec_setup_gwifs - Setup IPsec-related interfaces and gateways
......
3168 3182
	}
3169 3183
	/* Create directory structure for IPsec */
3170 3184
	ipsec_create_dirs();
3185
	/* Setup swanctl directories */
3186
	ipsec_copy_skel();
3171 3187
	/* Setup gateways and interfaces */
3172 3188
	ipsec_setup_gwifs();
3173 3189
	/* Setup and write strongswan.conf */
src/etc/inc/pfsense-utils.inc
1002 1002
	return;
1003 1003
}
1004 1004

  
1005
function copydir($path, $dest, $recursive=false) {
1006
	$dir = opendir($path);
1007
	while ($entry = readdir($dir)) {
1008
		if ($entry == '.' || $entry == '..') {
1009
			continue;
1010
		}
1011
		if (is_dir("{$path}/{$entry}")) {
1012
			if ($recursive) {
1013
				if (!file_exists("{$dest}/{$entry}")) {
1014
					mkdir("{$dest}/{$entry}", 0755, true);
1015
				}
1016
				copydir("{$path}/{$entry}", "{$dest}/{$entry}", true);
1017
			}
1018
		} elseif (is_file("{$path}/{$entry}")) {
1019
			copy("{$path}/{$entry}", "{$dest}/{$entry}");
1020
		}
1021
	}
1022
	closedir($dir);
1023
}
1024

  
1005 1025
/*
1006 1026
 * host_firmware_version(): Return the versions used in this install
1007 1027
 */
(2-2/2)