1
|
<?php
|
2
|
/*
|
3
|
* ipsec.attributes.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2011-2013 BSD Perimeter
|
7
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8
|
* Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate)
|
9
|
* All rights reserved.
|
10
|
*
|
11
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
12
|
* you may not use this file except in compliance with the License.
|
13
|
* You may obtain a copy of the License at
|
14
|
*
|
15
|
* http://www.apache.org/licenses/LICENSE-2.0
|
16
|
*
|
17
|
* Unless required by applicable law or agreed to in writing, software
|
18
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
19
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
20
|
* See the License for the specific language governing permissions and
|
21
|
* limitations under the License.
|
22
|
*/
|
23
|
|
24
|
global $attributes;
|
25
|
|
26
|
if (empty($common_name)) {
|
27
|
$common_name = getenv("common_name");
|
28
|
if (empty($common_name)) {
|
29
|
$common_name = getenv("username");
|
30
|
}
|
31
|
}
|
32
|
|
33
|
$rules = parse_cisco_acl($attributes, 'enc0');
|
34
|
if (!empty($rules)) {
|
35
|
$pid = posix_getpid();
|
36
|
@file_put_contents("/tmp/ipsec_{$pid}{$common_name}.rules", $rules);
|
37
|
mwexec("/sbin/pfctl -a " . escapeshellarg("ipsec/{$common_name}") . " -f {$g['tmp_path']}/ipsec_{$pid}" . escapeshellarg($common_name) . ".rules");
|
38
|
@unlink("{$g['tmp_path']}/ipsec_{$pid}{$common_name}.rules");
|
39
|
}
|
40
|
|
41
|
?>
|