Project

General

Profile

Download (1.5 KB) Statistics
| Branch: | Tag: | Revision:
1
/*
2
 * pfanchordrill
3
 *
4
 * part of pfSense (https://www.pfsense.org)
5
 * Copyright (c) 2016 Electric Sheep Fencing
6
 * Copyright (c) 2016-2022 Rubicon Communications, LLC (Netgate)
7
 * All rights reserved.
8
 *
9
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 * http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20
 */
21
/* Recursively check anchors for rules/nat and also for anchors inside anchors (like those used by UPnP) */
22

    
23
include_once('globals.inc');
24

    
25
function anchor_recurse($name = '') {
26
	$anchor_list = "";
27
	if ($name) {
28
		$name = ' -a ' . escapeshellarg($name);
29
	}
30
	exec("/sbin/pfctl -vsA{$name} 2>/dev/null", $anchor_list);
31
	foreach ($anchor_list as $anchor) {
32
		$anchor = trim($anchor);
33
		echo "\n{$anchor} rules/nat contents:\n";
34
		if (strpos($anchor, CPPREFIX) !== false) {
35
			system("/sbin/pfctl -a " . escapeshellarg($anchor) . " -se");
36
		} else {
37
			system("/sbin/pfctl -a " . escapeshellarg($anchor) . " -sn");
38
			system("/sbin/pfctl -a " . escapeshellarg($anchor) . " -sr");
39
		}
40
		anchor_recurse($anchor);
41
	}
42
}
43

    
44
/* Start with a the root list of anchors */
45
anchor_recurse();
(17-17/27)