Project

General

Profile

Download (1.41 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-2024 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_list() {
26
	$anchor_list = [];
27
	exec("/sbin/pfctl -vsA 2>/dev/null | /usr/bin/sort -u", $anchor_list);
28
	foreach ($anchor_list as $anchor) {
29
		$anchor = trim($anchor);
30
		echo "\n{$anchor} rules/nat contents:\n";
31
		if (strpos($anchor, CPPREFIX) !== false) {
32
			system("/sbin/pfctl -a " . escapeshellarg($anchor) . " -se");
33
		} else {
34
			system("/sbin/pfctl -a " . escapeshellarg($anchor) . " -sn");
35
			system("/sbin/pfctl -a " . escapeshellarg($anchor) . " -sr");
36
		}
37
	}
38
}
39

    
40
/* Start with a the root list of anchors */
41
anchor_list();
(17-17/27)