Revision 61e047a5
Added by Phil Davis over 10 years ago
etc/inc/radius.inc | ||
---|---|---|
6 | 6 |
Copyright (c) 2003, Michael Bretterklieber <michael@bretterklieber.com> |
7 | 7 |
All rights reserved. |
8 | 8 |
|
9 |
Redistribution and use in source and binary forms, with or without
|
|
10 |
modification, are permitted provided that the following conditions
|
|
9 |
Redistribution and use in source and binary forms, with or without |
|
10 |
modification, are permitted provided that the following conditions |
|
11 | 11 |
are met: |
12 | 12 |
|
13 |
1. Redistributions of source code must retain the above copyright
|
|
13 |
1. Redistributions of source code must retain the above copyright |
|
14 | 14 |
notice, this list of conditions and the following disclaimer. |
15 |
2. Redistributions in binary form must reproduce the above copyright
|
|
16 |
notice, this list of conditions and the following disclaimer in the
|
|
15 |
2. Redistributions in binary form must reproduce the above copyright |
|
16 |
notice, this list of conditions and the following disclaimer in the |
|
17 | 17 |
documentation and/or other materials provided with the distribution. |
18 |
3. The names of the authors may not be used to endorse or promote products
|
|
18 |
3. The names of the authors may not be used to endorse or promote products |
|
19 | 19 |
derived from this software without specific prior written permission. |
20 | 20 |
|
21 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
22 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
23 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
24 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
25 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
26 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
27 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
28 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
29 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
21 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
22 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
23 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
24 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
25 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
26 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
27 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
28 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
29 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
30 | 30 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 | 31 |
|
32 |
This code cannot simply be copied and put under the GNU Public License or
|
|
32 |
This code cannot simply be copied and put under the GNU Public License or |
|
33 | 33 |
any other GPL-like (LGPL, GPL2) License. |
34 | 34 |
|
35 | 35 |
This version of RADIUS.php has been modified by |
... | ... | |
73 | 73 |
* |
74 | 74 |
* Abstract base class for RADIUS |
75 | 75 |
* |
76 |
* @package Auth_RADIUS
|
|
76 |
* @package Auth_RADIUS |
|
77 | 77 |
*/ |
78 | 78 |
class Auth_RADIUS extends PEAR { |
79 | 79 |
|
... | ... | |
138 | 138 |
* |
139 | 139 |
* @return void |
140 | 140 |
*/ |
141 |
function Auth_RADIUS()
|
|
141 |
function Auth_RADIUS() |
|
142 | 142 |
{ |
143 | 143 |
$this->PEAR(); |
144 | 144 |
} |
... | ... | |
146 | 146 |
/** |
147 | 147 |
* Adds a RADIUS server to the list of servers for requests. |
148 | 148 |
* |
149 |
* At most 10 servers may be specified. When multiple servers
|
|
150 |
* are given, they are tried in round-robin fashion until a
|
|
149 |
* At most 10 servers may be specified. When multiple servers |
|
150 |
* are given, they are tried in round-robin fashion until a |
|
151 | 151 |
* valid response is received |
152 | 152 |
* |
153 | 153 |
* @access public |
... | ... | |
158 | 158 |
* @param integer $maxtries Max. retries for each request |
159 | 159 |
* @return void |
160 | 160 |
*/ |
161 |
function addServer($servername = 'localhost', $port = 0, $sharedSecret = 'testing123', $timeout = 3, $maxtries = 2)
|
|
161 |
function addServer($servername = 'localhost', $port = 0, $sharedSecret = 'testing123', $timeout = 3, $maxtries = 2) |
|
162 | 162 |
{ |
163 | 163 |
$this->_servers[] = array($servername, $port, $sharedSecret, $timeout, $maxtries); |
164 | 164 |
} |
... | ... | |
169 | 169 |
* @access public |
170 | 170 |
* @return string |
171 | 171 |
*/ |
172 |
function getError()
|
|
172 |
function getError() |
|
173 | 173 |
{ |
174 | 174 |
return radius_strerror($this->res); |
175 | 175 |
} |
... | ... | |
181 | 181 |
* @param string $file Path to the configuration file |
182 | 182 |
* @return void |
183 | 183 |
*/ |
184 |
function setConfigfile($file)
|
|
184 |
function setConfigfile($file) |
|
185 | 185 |
{ |
186 | 186 |
$this->_configfile = $file; |
187 | 187 |
} |
... | ... | |
195 | 195 |
* @param type $type Attribute-type |
196 | 196 |
* @return bool true on success, false on error |
197 | 197 |
*/ |
198 |
function putAttribute($attrib, $value, $type = null)
|
|
198 |
function putAttribute($attrib, $value, $type = null) |
|
199 | 199 |
{ |
200 | 200 |
if ($type == null) { |
201 | 201 |
$type = gettype($value); |
... | ... | |
225 | 225 |
* @param mixed $port Attribute-value |
226 | 226 |
* @param type $type Attribute-type |
227 | 227 |
* @return bool true on success, false on error |
228 |
*/
|
|
229 |
function putVendorAttribute($vendor, $attrib, $value, $type = null)
|
|
228 |
*/ |
|
229 |
function putVendorAttribute($vendor, $attrib, $value, $type = null) |
|
230 | 230 |
{ |
231 | 231 |
|
232 | 232 |
if ($type == null) { |
... | ... | |
270 | 270 |
} |
271 | 271 |
|
272 | 272 |
/** |
273 |
* Overwrite this.
|
|
273 |
* Overwrite this. |
|
274 | 274 |
* |
275 | 275 |
* @access public |
276 | 276 |
*/ |
277 |
function open()
|
|
277 |
function open() |
|
278 | 278 |
{ |
279 | 279 |
} |
280 | 280 |
|
... | ... | |
339 | 339 |
* @return bool true on success, false on error |
340 | 340 |
* @see addServer() |
341 | 341 |
*/ |
342 |
function putServer($servername, $port = 0, $sharedsecret = 'testing123', $timeout = 3, $maxtries = 3)
|
|
342 |
function putServer($servername, $port = 0, $sharedsecret = 'testing123', $timeout = 3, $maxtries = 3) |
|
343 | 343 |
{ |
344 | 344 |
if (!radius_add_server($this->res, $servername, $port, $sharedsecret, $timeout, $maxtries)) { |
345 | 345 |
return false; |
... | ... | |
354 | 354 |
* @param string $servername Servername or IP-Address |
355 | 355 |
* @return bool true on success, false on error |
356 | 356 |
*/ |
357 |
function putConfigfile($file)
|
|
357 |
function putConfigfile($file) |
|
358 | 358 |
{ |
359 | 359 |
if (!radius_config($this->res, $file)) { |
360 | 360 |
return false; |
... | ... | |
363 | 363 |
} |
364 | 364 |
|
365 | 365 |
/** |
366 |
* Initiates a RADIUS request.
|
|
366 |
* Initiates a RADIUS request. |
|
367 | 367 |
* |
368 | 368 |
* @access public |
369 |
* @return bool true on success, false on errors
|
|
370 |
*/
|
|
369 |
* @return bool true on success, false on errors |
|
370 |
*/ |
|
371 | 371 |
function start() |
372 | 372 |
{ |
373 | 373 |
if (!$this->open()) { |
... | ... | |
447 | 447 |
|
448 | 448 |
if (!is_array($attrib)) { |
449 | 449 |
return false; |
450 |
}
|
|
450 |
} |
|
451 | 451 |
|
452 | 452 |
$attr = $attrib['attr']; |
453 | 453 |
$data = $attrib['data']; |
... | ... | |
592 | 592 |
$this->attributes['url_logoff'] = radius_cvt_string($datav); |
593 | 593 |
break; |
594 | 594 |
} |
595 |
}
|
|
595 |
} |
|
596 | 596 |
|
597 | 597 |
elseif ($vendor == 14122) { /* RADIUS_VENDOR_WISPr Wi-Fi Alliance */ |
598 | 598 |
|
... | ... | |
719 | 719 |
* |
720 | 720 |
* Class for authenticating using PAP (Plaintext) |
721 | 721 |
* |
722 |
* @package Auth_RADIUS
|
|
722 |
* @package Auth_RADIUS |
|
723 | 723 |
*/ |
724 |
class Auth_RADIUS_PAP extends Auth_RADIUS
|
|
724 |
class Auth_RADIUS_PAP extends Auth_RADIUS |
|
725 | 725 |
{ |
726 | 726 |
|
727 | 727 |
/** |
... | ... | |
746 | 746 |
* |
747 | 747 |
* @return bool true on success, false on error |
748 | 748 |
*/ |
749 |
function open()
|
|
749 |
function open() |
|
750 | 750 |
{ |
751 | 751 |
$this->res = radius_auth_open(); |
752 | 752 |
if (!$this->res) { |
... | ... | |
756 | 756 |
} |
757 | 757 |
|
758 | 758 |
/** |
759 |
* Creates an authentication request
|
|
759 |
* Creates an authentication request |
|
760 | 760 |
* |
761 | 761 |
* Creates an authentication request. |
762 | 762 |
* You MUST call this method before you can put any attribute |
... | ... | |
772 | 772 |
} |
773 | 773 |
|
774 | 774 |
/** |
775 |
* Put authentication specific attributes
|
|
775 |
* Put authentication specific attributes |
|
776 | 776 |
* |
777 | 777 |
* @return void |
778 | 778 |
*/ |
... | ... | |
792 | 792 |
* class Auth_RADIUS_CHAP_MD5 |
793 | 793 |
* |
794 | 794 |
* Class for authenticating using CHAP-MD5 see RFC1994. |
795 |
* Instead og the plaintext password the challenge and
|
|
795 |
* Instead og the plaintext password the challenge and |
|
796 | 796 |
* the response are needed. |
797 | 797 |
* |
798 |
* @package Auth_RADIUS
|
|
798 |
* @package Auth_RADIUS |
|
799 | 799 |
*/ |
800 | 800 |
class Auth_RADIUS_CHAP_MD5 extends Auth_RADIUS_PAP |
801 | 801 |
{ |
... | ... | |
836 | 836 |
/** |
837 | 837 |
* Put CHAP-MD5 specific attributes |
838 | 838 |
* |
839 |
* For authenticating using CHAP-MD5 via RADIUS you have to put the challenge
|
|
839 |
* For authenticating using CHAP-MD5 via RADIUS you have to put the challenge |
|
840 | 840 |
* and the response. The chapid is inserted in the first byte of the response. |
841 | 841 |
* |
842 | 842 |
* @return void |
... | ... | |
844 | 844 |
function putAuthAttributes() |
845 | 845 |
{ |
846 | 846 |
if (isset($this->username)) { |
847 |
$this->putAttribute(RADIUS_USER_NAME, $this->username);
|
|
847 |
$this->putAttribute(RADIUS_USER_NAME, $this->username); |
|
848 | 848 |
} |
849 | 849 |
if (isset($this->response)) { |
850 | 850 |
$response = pack('C', $this->chapid) . $this->response; |
... | ... | |
877 | 877 |
* |
878 | 878 |
* Class for authenticating using MS-CHAPv1 see RFC2433 |
879 | 879 |
* |
880 |
* @package Auth_RADIUS
|
|
880 |
* @package Auth_RADIUS |
|
881 | 881 |
*/ |
882 |
class Auth_RADIUS_MSCHAPv1 extends Auth_RADIUS_CHAP_MD5
|
|
882 |
class Auth_RADIUS_MSCHAPv1 extends Auth_RADIUS_CHAP_MD5 |
|
883 | 883 |
{ |
884 | 884 |
/** |
885 | 885 |
* LAN-Manager-Response |
... | ... | |
895 | 895 |
var $flags = 1; |
896 | 896 |
|
897 | 897 |
/** |
898 |
* Put MS-CHAPv1 specific attributes
|
|
898 |
* Put MS-CHAPv1 specific attributes |
|
899 | 899 |
* |
900 |
* For authenticating using MS-CHAPv1 via RADIUS you have to put the challenge
|
|
900 |
* For authenticating using MS-CHAPv1 via RADIUS you have to put the challenge |
|
901 | 901 |
* and the response. The response has this structure: |
902 | 902 |
* struct rad_mschapvalue { |
903 | 903 |
* u_char ident; |
... | ... | |
930 | 930 |
* |
931 | 931 |
* Class for authenticating using MS-CHAPv2 see RFC2759 |
932 | 932 |
* |
933 |
* @package Auth_RADIUS
|
|
933 |
* @package Auth_RADIUS |
|
934 | 934 |
*/ |
935 |
class Auth_RADIUS_MSCHAPv2 extends Auth_RADIUS_MSCHAPv1
|
|
935 |
class Auth_RADIUS_MSCHAPv2 extends Auth_RADIUS_MSCHAPv1 |
|
936 | 936 |
{ |
937 | 937 |
/** |
938 | 938 |
* 16 Bytes binary challenge |
... | ... | |
947 | 947 |
var $peerChallenge = null; |
948 | 948 |
|
949 | 949 |
/** |
950 |
* Put MS-CHAPv2 specific attributes
|
|
950 |
* Put MS-CHAPv2 specific attributes |
|
951 | 951 |
* |
952 |
* For authenticating using MS-CHAPv1 via RADIUS you have to put the challenge
|
|
952 |
* For authenticating using MS-CHAPv1 via RADIUS you have to put the challenge |
|
953 | 953 |
* and the response. The response has this structure: |
954 | 954 |
* struct rad_mschapv2value { |
955 | 955 |
* u_char ident; |
... | ... | |
964 | 964 |
function putAuthAttributes() |
965 | 965 |
{ |
966 | 966 |
if (isset($this->username)) { |
967 |
$this->putAttribute(RADIUS_USER_NAME, $this->username);
|
|
967 |
$this->putAttribute(RADIUS_USER_NAME, $this->username); |
|
968 | 968 |
} |
969 | 969 |
if (isset($this->response) && isset($this->peerChallenge)) { |
970 |
// Response: chapid, flags (1 = use NT Response), Peer challenge, reserved, Response
|
|
971 |
$resp = pack('CCa16a8a24',$this->chapid , 1, $this->peerChallenge, str_repeat("\0", 8), $this->response);
|
|
970 |
// Response: chapid, flags (1 = use NT Response), Peer challenge, reserved, Response |
|
971 |
$resp = pack('CCa16a8a24',$this->chapid , 1, $this->peerChallenge, str_repeat("\0", 8), $this->response); |
|
972 | 972 |
$this->putVendorAttribute(RADIUS_VENDOR_MICROSOFT, RADIUS_MICROSOFT_MS_CHAP2_RESPONSE, $resp); |
973 | 973 |
} |
974 | 974 |
if (isset($this->challenge)) { |
... | ... | |
983 | 983 |
* attributes are filled with Nullbytes to leave nothing in the mem. |
984 | 984 |
* |
985 | 985 |
* @access public |
986 |
*/
|
|
986 |
*/ |
|
987 | 987 |
function close() |
988 | 988 |
{ |
989 | 989 |
Auth_RADIUS_MSCHAPv1::close(); |
... | ... | |
995 | 995 |
* class Auth_RADIUS_Acct |
996 | 996 |
* |
997 | 997 |
* Class for RADIUS accounting |
998 |
*
|
|
999 |
* @package Auth_RADIUS
|
|
998 |
* |
|
999 |
* @package Auth_RADIUS |
|
1000 | 1000 |
*/ |
1001 |
class Auth_RADIUS_Acct extends Auth_RADIUS
|
|
1001 |
class Auth_RADIUS_Acct extends Auth_RADIUS |
|
1002 | 1002 |
{ |
1003 | 1003 |
/** |
1004 | 1004 |
* Defines where the Authentication was made, possible values are: |
... | ... | |
1011 | 1011 |
* Defines the type of the accounting request, on of: |
1012 | 1012 |
* RADIUS_START, RADIUS_STOP, RADIUS_ACCOUNTING_ON, RADIUS_ACCOUNTING_OFF |
1013 | 1013 |
* @var integer |
1014 |
*/
|
|
1014 |
*/ |
|
1015 | 1015 |
var $status_type = null; |
1016 | 1016 |
|
1017 | 1017 |
/** |
1018 | 1018 |
* The time the user was logged in in seconds |
1019 | 1019 |
* @var integer |
1020 |
*/
|
|
1020 |
*/ |
|
1021 | 1021 |
var $session_time = null; |
1022 | 1022 |
|
1023 | 1023 |
/** |
1024 | 1024 |
* A uniq identifier for the session of the user, maybe the PHP-Session-Id |
1025 | 1025 |
* @var string |
1026 |
*/
|
|
1026 |
*/ |
|
1027 | 1027 |
var $session_id = null; |
1028 | 1028 |
|
1029 | 1029 |
/** |
... | ... | |
1066 | 1066 |
* |
1067 | 1067 |
* @return bool true on success, false on error |
1068 | 1068 |
*/ |
1069 |
function open()
|
|
1069 |
function open() |
|
1070 | 1070 |
{ |
1071 | 1071 |
$this->res = radius_acct_open(); |
1072 | 1072 |
if (!$this->res) { |
... | ... | |
1076 | 1076 |
} |
1077 | 1077 |
|
1078 | 1078 |
/** |
1079 |
* Creates an accounting request
|
|
1079 |
* Creates an accounting request |
|
1080 | 1080 |
* |
1081 | 1081 |
* Creates an accounting request. |
1082 | 1082 |
* You MUST call this method before you can put any attribute. |
... | ... | |
1094 | 1094 |
/** |
1095 | 1095 |
* Put attributes for accounting. |
1096 | 1096 |
* |
1097 |
* Here we put some accounting values. There many more attributes for accounting,
|
|
1097 |
* Here we put some accounting values. There many more attributes for accounting, |
|
1098 | 1098 |
* but for web-applications only certain attributes make sense. |
1099 | 1099 |
* @return void |
1100 |
*/
|
|
1100 |
*/ |
|
1101 | 1101 |
function putAuthAttributes() |
1102 | 1102 |
{ |
1103 | 1103 |
if (isset($this->username)) { |
... | ... | |
1121 | 1121 |
* class Auth_RADIUS_Acct_Start |
1122 | 1122 |
* |
1123 | 1123 |
* Class for RADIUS accounting. Its usualy used, after the user has logged in. |
1124 |
*
|
|
1124 |
* |
|
1125 | 1125 |
* @package Auth_RADIUS |
1126 | 1126 |
*/ |
1127 |
class Auth_RADIUS_Acct_Start extends Auth_RADIUS_Acct
|
|
1127 |
class Auth_RADIUS_Acct_Start extends Auth_RADIUS_Acct |
|
1128 | 1128 |
{ |
1129 | 1129 |
/** |
1130 | 1130 |
* Defines the type of the accounting request. |
etc/inc/rrd.inc | ||
---|---|---|
61 | 61 |
} |
62 | 62 |
unset($rrdrestore); |
63 | 63 |
$_gb = exec("cd /;LANG=C /usr/bin/tar -tf {$g['cf_conf_path']}/rrd.tgz", $rrdrestore, $rrdreturn); |
64 |
if($rrdreturn != 0) { |
|
64 |
if ($rrdreturn != 0) {
|
|
65 | 65 |
log_error("RRD restore failed exited with $rrdreturn, the error is: $rrdrestore\n"); |
66 | 66 |
return; |
67 | 67 |
} |
68 | 68 |
foreach ($rrdrestore as $xml_file) { |
69 | 69 |
$rrd_file = '/' . substr($xml_file, 0, -4) . '.rrd'; |
70 |
if (file_exists("{$rrd_file}")) |
|
70 |
if (file_exists("{$rrd_file}")) {
|
|
71 | 71 |
@unlink($rrd_file); |
72 |
} |
|
72 | 73 |
file_put_contents("{$g['tmp_path']}/rrd_restore", $xml_file); |
73 | 74 |
$_gb = exec("cd /;LANG=C /usr/bin/tar -xf {$g['cf_conf_path']}/rrd.tgz -T {$g['tmp_path']}/rrd_restore"); |
74 | 75 |
if (!file_exists("/{$xml_file}")) { |
... | ... | |
107 | 108 |
} |
108 | 109 |
|
109 | 110 |
function migrate_rrd_format($rrdoldxml, $rrdnewxml) { |
110 |
if(!file_exists("/tmp/rrd_notice_sent.txt")) { |
|
111 |
if (!file_exists("/tmp/rrd_notice_sent.txt")) {
|
|
111 | 112 |
$_gb = exec("echo 'Converting RRD configuration to new format. This might take a bit...' | wall"); |
112 | 113 |
@touch("/tmp/rrd_notice_sent.txt"); |
113 | 114 |
} |
... | ... | |
119 | 120 |
|
120 | 121 |
/* add data sources not found in the old array from the new array */ |
121 | 122 |
$i = 0; |
122 |
foreach($rrdnewxml['ds'] as $ds) { |
|
123 |
if(!is_array($rrdoldxml['ds'][$i])) { |
|
123 |
foreach ($rrdnewxml['ds'] as $ds) {
|
|
124 |
if (!is_array($rrdoldxml['ds'][$i])) {
|
|
124 | 125 |
$rrdoldxml['ds'][$i] = $rrdnewxml['ds'][$i]; |
125 | 126 |
/* set unknown values to 0 */ |
126 | 127 |
$rrdoldxml['ds'][$i]['last_ds'] = " 0.0000000000e+00 "; |
... | ... | |
134 | 135 |
$rracountold = count($rrdoldxml['rra']); |
135 | 136 |
$rracountnew = count($rrdnewxml['rra']); |
136 | 137 |
/* process each RRA, which contain a database */ |
137 |
foreach($rrdnewxml['rra'] as $rra) { |
|
138 |
if(!is_array($rrdoldxml['rra'][$i])) { |
|
138 |
foreach ($rrdnewxml['rra'] as $rra) {
|
|
139 |
if (!is_array($rrdoldxml['rra'][$i])) {
|
|
139 | 140 |
$rrdoldxml['rra'][$i] = $rrdnewxml['rra'][$i]; |
140 | 141 |
} |
141 | 142 |
|
142 | 143 |
$d = 0; |
143 | 144 |
/* process cdp_prep */ |
144 | 145 |
$cdp_prep = $rra['cdp_prep']; |
145 |
foreach($cdp_prep['ds'] as $ds) { |
|
146 |
if(!is_array($rrdoldxml['rra'][$i]['cdp_prep']['ds'][$d])) { |
|
146 |
foreach ($cdp_prep['ds'] as $ds) {
|
|
147 |
if (!is_array($rrdoldxml['rra'][$i]['cdp_prep']['ds'][$d])) {
|
|
147 | 148 |
$rrdoldxml['rra'][$i]['cdp_prep']['ds'][$d] = $rrdnewxml['rra'][$i]['cdp_prep']['ds'][$d]; |
148 | 149 |
$rrdoldxml['rra'][$i]['cdp_prep']['ds'][$d]['primary_value'] = " 0.0000000000e+00 "; |
149 | 150 |
$rrdoldxml['rra'][$i]['cdp_prep']['ds'][$d]['secondary_value'] = " 0.0000000000e+00 "; |
... | ... | |
163 | 164 |
$rowsdata = $rows; |
164 | 165 |
$rowsempty = array(); |
165 | 166 |
$r = 0; |
166 |
while($r < $rowcountdiff) { |
|
167 |
while ($r < $rowcountdiff) {
|
|
167 | 168 |
$rowsempty[] = $rrdnewxml['rra'][$i]['database']['row'][$r]; |
168 | 169 |
$r++; |
169 | 170 |
} |
170 | 171 |
$rows = $rowsempty + $rowsdata; |
171 | 172 |
/* now foreach the rows in the database */ |
172 |
foreach($rows['row'] as $row) { |
|
173 |
if(!is_array($rrdoldxml['rra'][$i]['database']['row'][$k])) { |
|
173 |
foreach ($rows['row'] as $row) {
|
|
174 |
if (!is_array($rrdoldxml['rra'][$i]['database']['row'][$k])) {
|
|
174 | 175 |
$rrdoldxml['rra'][$i]['database']['row'][$k] = $rrdnewxml['rra'][$i]['database']['row'][$k]; |
175 | 176 |
} |
176 | 177 |
$m = 0; |
177 | 178 |
$vcountold = count($rrdoldxml['rra'][$i]['database']['row'][$k]['v']); |
178 | 179 |
$vcountnew = count($rrdnewxml['rra'][$i]['database']['row'][$k]['v']); |
179 |
foreach($row['v'] as $value) { |
|
180 |
if(empty($rrdoldxml['rra'][$i]['database']['row'][$k]['v'][$m])) { |
|
181 |
if(isset($valid)) { |
|
180 |
foreach ($row['v'] as $value) {
|
|
181 |
if (empty($rrdoldxml['rra'][$i]['database']['row'][$k]['v'][$m])) {
|
|
182 |
if (isset($valid)) {
|
|
182 | 183 |
$rrdoldxml['rra'][$i]['database']['row'][$k]['v'][$m] = "0.0000000000e+00 "; |
183 | 184 |
} else { |
184 | 185 |
$rrdoldxml['rra'][$i]['database']['row'][$k]['v'][$m] = $rrdnewxml['rra'][$i]['database']['row'][$k]['v'][$m]; |
185 | 186 |
} |
186 | 187 |
} else { |
187 |
if($value <> " NaN ") { |
|
188 |
if ($value <> " NaN ") {
|
|
188 | 189 |
$valid = true; |
189 | 190 |
} else { |
190 | 191 |
$valid = false; |
... | ... | |
206 | 207 |
function enable_rrd_graphing() { |
207 | 208 |
global $config, $g, $altq_list_queues; |
208 | 209 |
|
209 |
if(platform_booting())
|
|
210 |
if (platform_booting()) {
|
|
210 | 211 |
echo gettext("Generating RRD graphs..."); |
212 |
} |
|
211 | 213 |
|
212 | 214 |
$rrddbpath = "/var/db/rrd/"; |
213 | 215 |
$rrdgraphpath = "/usr/local/www/rrd"; |
... | ... | |
309 | 311 |
/* IPsec counters */ |
310 | 312 |
$ifdescrs['ipsec'] = "IPsec"; |
311 | 313 |
/* OpenVPN server counters */ |
312 |
if(is_array($config['openvpn']['openvpn-server'])) { |
|
313 |
foreach($config['openvpn']['openvpn-server'] as $server) { |
|
314 |
if (is_array($config['openvpn']['openvpn-server'])) {
|
|
315 |
foreach ($config['openvpn']['openvpn-server'] as $server) {
|
|
314 | 316 |
$serverid = "ovpns" . $server['vpnid']; |
315 | 317 |
$ifdescrs[$serverid] = "{$server['description']}"; |
316 | 318 |
} |
317 | 319 |
} |
318 | 320 |
|
319 | 321 |
if (platform_booting()) { |
320 |
if (!is_dir("{$g['vardb_path']}/rrd")) |
|
322 |
if (!is_dir("{$g['vardb_path']}/rrd")) {
|
|
321 | 323 |
mkdir("{$g['vardb_path']}/rrd", 0775); |
324 |
} |
|
322 | 325 |
|
323 | 326 |
@chown("{$g['vardb_path']}/rrd", "nobody"); |
324 | 327 |
} |
... | ... | |
326 | 329 |
/* process all real and pseudo interfaces */ |
327 | 330 |
foreach ($ifdescrs as $ifname => $ifdescr) { |
328 | 331 |
$temp = get_real_interface($ifname); |
329 |
if($temp <> "") { |
|
332 |
if ($temp <> "") {
|
|
330 | 333 |
$realif = $temp; |
331 | 334 |
} |
332 | 335 |
|
... | ... | |
351 | 354 |
} |
352 | 355 |
|
353 | 356 |
/* enter UNKNOWN values in the RRD so it knows we rebooted. */ |
354 |
if(platform_booting()) { |
|
357 |
if (platform_booting()) {
|
|
355 | 358 |
mwexec("$rrdtool update $rrddbpath$ifname$traffic N:U:U:U:U:U:U:U:U"); |
356 | 359 |
} |
357 | 360 |
|
... | ... | |
384 | 387 |
} |
385 | 388 |
|
386 | 389 |
/* enter UNKNOWN values in the RRD so it knows we rebooted. */ |
387 |
if(platform_booting()) { |
|
390 |
if (platform_booting()) {
|
|
388 | 391 |
mwexec("$rrdtool update $rrddbpath$ifname$packets N:U:U:U:U:U:U:U:U"); |
389 | 392 |
} |
390 | 393 |
|
... | ... | |
397 | 400 |
$rrdupdatesh .= "END {print b4pi \":\" b4po \":\" b4bi \":\" b4bo \":\" b6pi \":\" b6po \":\" b6bi \":\" b6bo};'`\n"; |
398 | 401 |
|
399 | 402 |
/* WIRELESS, set up the rrd file */ |
400 |
if($config['interfaces'][$ifname]['wireless']['mode'] == "bss") { |
|
403 |
if ($config['interfaces'][$ifname]['wireless']['mode'] == "bss") {
|
|
401 | 404 |
if (!file_exists("$rrddbpath$ifname$wireless")) { |
402 | 405 |
$rrdcreate = "$rrdtool create $rrddbpath$ifname$wireless --step $rrdwirelessinterval "; |
403 | 406 |
$rrdcreate .= "DS:snr:GAUGE:$wirelessvalid:0:1000 "; |
... | ... | |
413 | 416 |
} |
414 | 417 |
|
415 | 418 |
/* enter UNKNOWN values in the RRD so it knows we rebooted. */ |
416 |
if(platform_booting()) { |
|
419 |
if (platform_booting()) {
|
|
417 | 420 |
mwexec("$rrdtool update $rrddbpath$ifname$wireless N:U:U:U"); |
418 | 421 |
} |
419 | 422 |
|
... | ... | |
424 | 427 |
} |
425 | 428 |
|
426 | 429 |
/* OpenVPN, set up the rrd file */ |
427 |
if(stristr($ifname, "ovpns")) { |
|
430 |
if (stristr($ifname, "ovpns")) {
|
|
428 | 431 |
if (!file_exists("$rrddbpath$ifname$vpnusers")) { |
429 | 432 |
$rrdcreate = "$rrdtool create $rrddbpath$ifname$vpnusers --step $rrdvpninterval "; |
430 | 433 |
$rrdcreate .= "DS:users:GAUGE:$vpnvalid:0:10000 "; |
... | ... | |
438 | 441 |
} |
439 | 442 |
|
440 | 443 |
/* enter UNKNOWN values in the RRD so it knows we rebooted. */ |
441 |
if(platform_booting()) { |
|
444 |
if (platform_booting()) {
|
|
442 | 445 |
mwexec("$rrdtool update $rrddbpath$ifname$vpnusers N:U"); |
443 | 446 |
} |
444 | 447 |
|
445 |
if(is_array($config['openvpn']['openvpn-server'])) { |
|
446 |
foreach($config['openvpn']['openvpn-server'] as $server) { |
|
447 |
if("ovpns{$server['vpnid']}" == $ifname) { |
|
448 |
if (is_array($config['openvpn']['openvpn-server'])) {
|
|
449 |
foreach ($config['openvpn']['openvpn-server'] as $server) {
|
|
450 |
if ("ovpns{$server['vpnid']}" == $ifname) {
|
|
448 | 451 |
$port = $server['local_port']; |
449 | 452 |
$vpnid = $server['vpnid']; |
450 | 453 |
} |
... | ... | |
520 | 523 |
unset($rrdcreate); |
521 | 524 |
} |
522 | 525 |
|
523 |
if(platform_booting()) { |
|
526 |
if (platform_booting()) {
|
|
524 | 527 |
$rrdqcommand = "-t "; |
525 | 528 |
$rrducommand = "N"; |
526 | 529 |
$qi = 0; |
527 | 530 |
foreach ($qlist as $qname => $q) { |
528 |
if($qi == 0) { |
|
531 |
if ($qi == 0) {
|
|
529 | 532 |
$rrdqcommand .= "{$qname}"; |
530 | 533 |
} else { |
531 | 534 |
$rrdqcommand .= ":{$qname}"; |
... | ... | |
573 | 576 |
} |
574 | 577 |
|
575 | 578 |
/* 3G interfaces */ |
576 |
if(preg_match("/ppp[0-9]+/i", $realif)) { |
|
579 |
if (preg_match("/ppp[0-9]+/i", $realif)) {
|
|
577 | 580 |
if (!file_exists("$rrddbpath$ifname$cellular")) { |
578 | 581 |
$rrdcreate = "$rrdtool create $rrddbpath$ifname$cellular --step $rrdcellularinterval "; |
579 | 582 |
$rrdcreate .= "DS:rssi:GAUGE:$cellularvalid:0:100 "; |
... | ... | |
588 | 591 |
} |
589 | 592 |
|
590 | 593 |
/* enter UNKNOWN values in the RRD so it knows we rebooted. */ |
591 |
if(platform_booting()) { |
|
594 |
if (platform_booting()) {
|
|
592 | 595 |
mwexec("$rrdtool update $rrddbpath$ifname$cellular N:U:U:U"); |
593 | 596 |
} |
594 | 597 |
|
... | ... | |
605 | 608 |
$ifname = "system"; |
606 | 609 |
|
607 | 610 |
/* STATES, create pf states database */ |
608 |
if(! file_exists("$rrddbpath$ifname$states")) {
|
|
611 |
if (!file_exists("$rrddbpath$ifname$states")) {
|
|
609 | 612 |
$rrdcreate = "$rrdtool create $rrddbpath$ifname$states --step $rrdstatesinterval "; |
610 | 613 |
$rrdcreate .= "DS:pfrate:GAUGE:$statesvalid:0:10000000 "; |
611 | 614 |
$rrdcreate .= "DS:pfstates:GAUGE:$statesvalid:0:10000000 "; |
... | ... | |
622 | 625 |
} |
623 | 626 |
|
624 | 627 |
/* enter UNKNOWN values in the RRD so it knows we rebooted. */ |
625 |
if(platform_booting()) { |
|
628 |
if (platform_booting()) {
|
|
626 | 629 |
mwexec("$rrdtool update $rrddbpath$ifname$states N:U:U:U:U:U"); |
627 | 630 |
} |
628 | 631 |
|
... | ... | |
640 | 643 |
/* End pf states statistics */ |
641 | 644 |
|
642 | 645 |
/* CPU, create CPU statistics database */ |
643 |
if(! file_exists("$rrddbpath$ifname$proc")) {
|
|
646 |
if (!file_exists("$rrddbpath$ifname$proc")) {
|
|
644 | 647 |
$rrdcreate = "$rrdtool create $rrddbpath$ifname$proc --step $rrdprocinterval "; |
645 | 648 |
$rrdcreate .= "DS:user:GAUGE:$procvalid:0:10000000 "; |
646 | 649 |
$rrdcreate .= "DS:nice:GAUGE:$procvalid:0:10000000 "; |
... | ... | |
657 | 660 |
} |
658 | 661 |
|
659 | 662 |
/* enter UNKNOWN values in the RRD so it knows we rebooted. */ |
660 |
if(platform_booting()) { |
|
663 |
if (platform_booting()) {
|
|
661 | 664 |
mwexec("$rrdtool update $rrddbpath$ifname$proc N:U:U:U:U:U"); |
662 | 665 |
} |
663 | 666 |
|
... | ... | |
670 | 673 |
/* End CPU statistics */ |
671 | 674 |
|
672 | 675 |
/* Memory, create Memory statistics database */ |
673 |
if(! file_exists("$rrddbpath$ifname$mem")) {
|
|
676 |
if (!file_exists("$rrddbpath$ifname$mem")) {
|
|
674 | 677 |
$rrdcreate = "$rrdtool create $rrddbpath$ifname$mem --step $rrdmeminterval "; |
675 | 678 |
$rrdcreate .= "DS:active:GAUGE:$memvalid:0:10000000 "; |
676 | 679 |
$rrdcreate .= "DS:inactive:GAUGE:$memvalid:0:10000000 "; |
... | ... | |
695 | 698 |
} |
696 | 699 |
|
697 | 700 |
/* enter UNKNOWN values in the RRD so it knows we rebooted. */ |
698 |
if(platform_booting()) { |
|
701 |
if (platform_booting()) {
|
|
699 | 702 |
mwexec("$rrdtool update $rrddbpath$ifname$mem N:U:U:U:U:U"); |
700 | 703 |
} |
701 | 704 |
|
... | ... | |
708 | 711 |
/* End Memory statistics */ |
709 | 712 |
|
710 | 713 |
/* mbuf, create mbuf statistics database */ |
711 |
if(! file_exists("$rrddbpath$ifname$mbuf")) {
|
|
714 |
if (!file_exists("$rrddbpath$ifname$mbuf")) {
|
|
712 | 715 |
$rrdcreate = "$rrdtool create $rrddbpath$ifname$mbuf --step $rrdmbufinterval "; |
713 | 716 |
$rrdcreate .= "DS:current:GAUGE:$mbufvalid:0:10000000 "; |
714 | 717 |
$rrdcreate .= "DS:cache:GAUGE:$mbufvalid:0:10000000 "; |
... | ... | |
732 | 735 |
} |
733 | 736 |
|
734 | 737 |
/* enter UNKNOWN values in the RRD so it knows we rebooted. */ |
735 |
if(platform_booting()) { |
|
738 |
if (platform_booting()) {
|
|
736 | 739 |
mwexec("$rrdtool update $rrddbpath$ifname$mbuf N:U:U:U:U"); |
737 | 740 |
} |
738 | 741 |
|
... | ... | |
745 | 748 |
|
746 | 749 |
/* SPAMD, set up the spamd rrd file */ |
747 | 750 |
if (isset($config['installedpackages']['spamdsettings']) && |
748 |
$config['installedpackages']['spamdsettings']['config'][0]['enablerrd']) {
|
|
751 |
$config['installedpackages']['spamdsettings']['config'][0]['enablerrd']) {
|
|
749 | 752 |
/* set up the spamd rrd file */ |
750 | 753 |
if (!file_exists("$rrddbpath$ifname$spamd")) { |
751 | 754 |
$rrdcreate = "$rrdtool create $rrddbpath$ifname$spamd --step $rrdspamdinterval "; |
... | ... | |
777 | 780 |
/* End System statistics */ |
778 | 781 |
|
779 | 782 |
/* Captive Portal statistics, set up the rrd file */ |
780 |
if(is_array($config['captiveportal'])) { |
|
783 |
if (is_array($config['captiveportal'])) {
|
|
781 | 784 |
foreach ($config['captiveportal'] as $cpkey => $cp) { |
782 |
if (!isset($cp['enable'])) |
|
785 |
if (!isset($cp['enable'])) {
|
|
783 | 786 |
continue; |
787 |
} |
|
784 | 788 |
|
785 | 789 |
$ifname= "captiveportal"; |
786 | 790 |
$concurrent_filename = $rrddbpath . $ifname . '-' . $cpkey . $captiveportalconcurrent; |
... | ... | |
809 | 813 |
} |
810 | 814 |
|
811 | 815 |
/* enter UNKNOWN values in the RRD so it knows we rebooted. */ |
812 |
if(platform_booting()) { |
|
816 |
if (platform_booting()) {
|
|
813 | 817 |
mwexec("$rrdtool update $concurrent_filename N:U"); |
814 | 818 |
} |
815 | 819 |
|
... | ... | |
845 | 849 |
} |
846 | 850 |
|
847 | 851 |
/* enter UNKNOWN values in the RRD so it knows we rebooted. */ |
848 |
if(platform_booting()) { |
|
852 |
if (platform_booting()) {
|
|
849 | 853 |
mwexec("$rrdtool update $loggedin_filename N:U"); |
850 | 854 |
} |
851 | 855 |
|
... | ... | |
888 | 892 |
} |
889 | 893 |
|
890 | 894 |
/* enter UNKNOWN values in the RRD so it knows we rebooted. */ |
891 |
if(platform_booting()) { |
|
892 |
mwexec("$rrdtool update $rrddbpath$ntpd N:U:U:U:U:U:U"); |
|
895 |
if (platform_booting()) {
|
|
896 |
mwexec("$rrdtool update $rrddbpath$ntpd N:U:U:U:U:U:U");
|
|
893 | 897 |
} |
894 | 898 |
|
895 | 899 |
/* the ntp stats gathering function. */ |
... | ... | |
931 | 935 |
} |
932 | 936 |
|
933 | 937 |
$databases = glob("{$rrddbpath}/*.rrd"); |
934 |
foreach($databases as $database) { |
|
938 |
foreach ($databases as $database) {
|
|
935 | 939 |
chown($database, "nobody"); |
936 | 940 |
} |
937 | 941 |
|
938 |
if(platform_booting())
|
|
942 |
if (platform_booting()) {
|
|
939 | 943 |
echo gettext("done.") . "\n"; |
944 |
} |
|
940 | 945 |
|
941 | 946 |
} |
942 | 947 |
|
... | ... | |
963 | 968 |
} |
964 | 969 |
|
965 | 970 |
/* enter UNKNOWN values in the RRD so it knows we rebooted. */ |
966 |
if(platform_booting()) { |
|
967 |
if (!is_dir("{$g['vardb_path']}/rrd")) |
|
971 |
if (platform_booting()) {
|
|
972 |
if (!is_dir("{$g['vardb_path']}/rrd")) {
|
|
968 | 973 |
mkdir("{$g['vardb_path']}/rrd", 0775); |
974 |
} |
|
969 | 975 |
|
970 | 976 |
@chown("{$g['vardb_path']}/rrd", "nobody"); |
971 | 977 |
|
etc/inc/sasl.inc | ||
---|---|---|
178 | 178 |
<purpose>Retrieve the values of one or more credentials to be used by |
179 | 179 |
the authentication mechanism classes.</purpose> |
180 | 180 |
<usage>This is meant to be used by authentication mechanism driver |
181 |
classes to retrieve the credentials that may be neede.</usage> |
|
181 |
classes to retrieve the credentials that may be needed.</usage>
|
|
182 | 182 |
<returnvalue>The function may return <tt>SASL_CONTINUE</tt> if it |
183 | 183 |
succeeded, or <tt>SASL_NOMECH</tt> if it was not possible to |
184 | 184 |
retrieve one of the requested credentials.</returnvalue> |
... | ... | |
359 | 359 |
<type>INTEGER</type> |
360 | 360 |
<documentation> |
361 | 361 |
<purpose>Process the authentication steps after the initial step, |
362 |
until the authetication iteration dialog is complete.</purpose> |
|
362 |
until the authentication iteration dialog is complete.</purpose>
|
|
363 | 363 |
<usage>Call this function iteratively after a successful initial |
364 | 364 |
step calling the <functionlink>Start</functionlink> function.</usage> |
365 | 365 |
<returnvalue>The function returns <tt>SASL_CONTINUE</tt> if step was |
etc/inc/service-utils.inc | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
/****h* pfSense/service-utils |
3 |
* NAME |
|
4 |
* service-utils.inc - Service facility |
|
5 |
* DESCRIPTION |
|
6 |
* This file contains various functions used by the pfSense service facility. |
|
7 |
* HISTORY |
|
8 |
* $Id$ |
|
9 |
****** |
|
10 |
* |
|
11 |
* Copyright (C) 2005-2006 Colin Smith (ethethlay@gmail.com) |
|
12 |
* All rights reserved. |
|
13 |
* Redistribution and use in source and binary forms, with or without |
|
14 |
* modification, are permitted provided that the following conditions are met: |
|
15 |
* |
|
16 |
* 1. Redistributions of source code must retain the above copyright notice, |
|
17 |
* this list of conditions and the following disclaimer. |
|
18 |
* |
|
19 |
* 2. Redistributions in binary form must reproduce the above copyright |
|
20 |
* notice, this list of conditions and the following disclaimer in the |
|
21 |
* documentation and/or other materials provided with the distribution. |
|
22 |
* |
|
23 |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
24 |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
|
25 |
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
26 |
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, |
|
27 |
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
28 |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
29 |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
30 |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
31 |
* RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
32 |
* POSSIBILITY OF SUCH DAMAGE. |
|
33 |
* |
|
3 |
NAME |
|
4 |
service-utils.inc - Service facility |
|
5 |
DESCRIPTION |
|
6 |
This file contains various functions used by the pfSense service facility. |
|
7 |
HISTORY |
|
8 |
$Id$ |
|
9 |
|
|
10 |
Copyright (C) 2005-2006 Colin Smith (ethethlay@gmail.com) |
|
11 |
All rights reserved. |
|
12 |
Redistribution and use in source and binary forms, with or without |
|
13 |
modification, are permitted provided that the following conditions are met: |
|
14 |
|
|
15 |
1. Redistributions of source code must retain the above copyright notice, |
|
16 |
this list of conditions and the following disclaimer. |
|
17 |
|
|
18 |
2. Redistributions in binary form must reproduce the above copyright |
|
19 |
notice, this list of conditions and the following disclaimer in the |
|
20 |
documentation and/or other materials provided with the distribution. |
|
21 |
|
|
22 |
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
|
23 |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
|
24 |
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
25 |
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, |
|
26 |
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
27 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
28 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
29 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
30 |
RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
31 |
POSSIBILITY OF SUCH DAMAGE. |
|
32 |
|
|
34 | 33 |
*/ |
35 | 34 |
|
36 | 35 |
/* |
... | ... | |
51 | 50 |
|
52 | 51 |
safe_mkdir(RCFILEPREFIX); |
53 | 52 |
$rcfile_fullname = RCFILEPREFIX . $params['file']; |
54 |
if (!file_exists($rcfile_fullname) && !is_link($rcfile_fullname) && !touch($rcfile_fullname)) |
|
53 |
if (!file_exists($rcfile_fullname) && !is_link($rcfile_fullname) && !touch($rcfile_fullname)) {
|
|
55 | 54 |
return false; |
55 |
} |
|
56 | 56 |
|
57 |
if (!is_writable($rcfile_fullname) || empty($params['start'])) |
|
57 |
if (!is_writable($rcfile_fullname) || empty($params['start'])) {
|
|
58 | 58 |
return false; |
59 |
} |
|
59 | 60 |
|
60 | 61 |
$towrite = "#!/bin/sh\n"; |
61 | 62 |
$towrite .= "# This file was automatically generated\n# by the {$g['product_name']} service handler.\n\n"; |
... | ... | |
64 | 65 |
$towrite .= "rc_start() {\n"; |
65 | 66 |
$towrite .= "\t{$params['start']}\n"; |
66 | 67 |
$towrite .= "}\n\n"; |
67 |
if(!empty($params['stop'])) { |
|
68 |
if (!empty($params['stop'])) {
|
|
68 | 69 |
$tokill =& $params['stop']; |
69 |
} else if(!empty($params['executable'])) { |
|
70 |
} else if (!empty($params['executable'])) {
|
|
70 | 71 |
/* just nuke the executable */ |
71 | 72 |
$tokill = "/usr/bin/killall " . escapeshellarg($params['executable']); |
72 | 73 |
} else { |
... | ... | |
90 | 91 |
function start_service($name) { |
91 | 92 |
global $config; |
92 | 93 |
|
93 |
if (empty($name)) |
|
94 |
if (empty($name)) {
|
|
94 | 95 |
return; |
96 |
} |
|
95 | 97 |
|
96 | 98 |
if (is_array($config['installedpackages']) && is_array($config['installedpackages']['service'])) { |
97 |
foreach($config['installedpackages']['service'] as $service) { |
|
98 |
if(strtolower($service['name']) == strtolower($name)) { |
|
99 |
if($service['rcfile']) { |
|
99 |
foreach ($config['installedpackages']['service'] as $service) {
|
|
100 |
if (strtolower($service['name']) == strtolower($name)) {
|
|
101 |
if ($service['rcfile']) {
|
|
100 | 102 |
$prefix = RCFILEPREFIX; |
101 | 103 |
if (!empty($service['prefix'])) { |
102 | 104 |
$prefix =& $service['prefix']; |
103 | 105 |
} |
104 |
if(file_exists("{$prefix}{$service['rcfile']}") || is_link("{$prefix}{$service['rcfile']}")) { |
|
106 |
if (file_exists("{$prefix}{$service['rcfile']}") || is_link("{$prefix}{$service['rcfile']}")) {
|
|
105 | 107 |
mwexec_bg("{$prefix}{$service['rcfile']} start"); |
106 | 108 |
} |
107 | 109 |
} |
108 |
if (!empty($service['startcmd'])) |
|
110 |
if (!empty($service['startcmd'])) {
|
|
109 | 111 |
eval($service['startcmd']); |
112 |
} |
|
110 | 113 |
break; |
111 | 114 |
} |
112 | 115 |
} |
... | ... | |
116 | 119 |
function stop_service($name) { |
117 | 120 |
global $config; |
118 | 121 |
|
119 |
if (empty($name)) |
|
122 |
if (empty($name)) {
|
|
120 | 123 |
return; |
124 |
} |
|
121 | 125 |
|
122 | 126 |
if (is_array($config['installedpackages']) && is_array($config['installedpackages']['service'])) { |
123 |
foreach($config['installedpackages']['service'] as $service) { |
|
124 |
if(strtolower($service['name']) == strtolower($name)) { |
|
125 |
if($service['rcfile']) { |
|
127 |
foreach ($config['installedpackages']['service'] as $service) {
|
|
128 |
if (strtolower($service['name']) == strtolower($name)) {
|
|
129 |
if ($service['rcfile']) {
|
|
126 | 130 |
$prefix = RCFILEPREFIX; |
127 |
if(!empty($service['prefix'])) { |
|
131 |
if (!empty($service['prefix'])) {
|
|
128 | 132 |
$prefix =& $service['prefix']; |
129 | 133 |
} |
130 |
if(file_exists("{$prefix}{$service['rcfile']}") || is_link("{$prefix}{$service['rcfile']}")) { |
|
134 |
if (file_exists("{$prefix}{$service['rcfile']}") || is_link("{$prefix}{$service['rcfile']}")) {
|
|
131 | 135 |
mwexec("{$prefix}{$service['rcfile']} stop"); |
132 | 136 |
} |
133 | 137 |
return; |
134 | 138 |
} |
135 |
if (!empty($service['stopcmd'])) |
|
139 |
if (!empty($service['stopcmd'])) {
|
|
136 | 140 |
eval($service['stopcmd']); |
141 |
} |
|
137 | 142 |
|
138 | 143 |
break; |
139 | 144 |
} |
... | ... | |
144 | 149 |
function restart_service($name) { |
145 | 150 |
global $config; |
146 | 151 |
|
147 |
if (empty($name)) |
|
152 |
if (empty($name)) {
|
|
148 | 153 |
return; |
154 |
} |
|
149 | 155 |
|
150 | 156 |
stop_service($name); |
151 | 157 |
start_service($name); |
152 | 158 |
|
153 | 159 |
if (is_array($config['installedpackages']) && is_array($config['installedpackages']['service'])) { |
154 |
foreach($config['installedpackages']['service'] as $service) { |
|
155 |
if(strtolower($service['name']) == strtolower($name)) { |
|
156 |
if($service['restartcmd']) { |
|
160 |
foreach ($config['installedpackages']['service'] as $service) {
|
|
161 |
if (strtolower($service['name']) == strtolower($name)) {
|
|
162 |
if ($service['restartcmd']) {
|
|
157 | 163 |
eval($service['restartcmd']); |
158 | 164 |
} |
159 | 165 |
break; |
... | ... | |
163 | 169 |
} |
164 | 170 |
|
165 | 171 |
function is_pid_running($pidfile) { |
166 |
if (!file_exists($pidfile)) |
|
172 |
if (!file_exists($pidfile)) {
|
|
167 | 173 |
return false; |
174 |
} |
|
168 | 175 |
|
169 | 176 |
return (isvalidpid($pidfile)); |
170 | 177 |
} |
171 | 178 |
|
172 | 179 |
function is_dhcp_running($interface) { |
173 | 180 |
$status = find_dhclient_process($interface); |
174 |
if($status != 0)
|
|
181 |
if ($status != 0) {
|
|
175 | 182 |
return true; |
183 |
} |
|
176 | 184 |
return false; |
177 | 185 |
} |
178 | 186 |
|
179 | 187 |
function restart_service_if_running($service) { |
180 | 188 |
global $config; |
181 |
if(is_service_running($service))
|
|
189 |
if (is_service_running($service)) {
|
|
182 | 190 |
restart_service($service); |
191 |
} |
|
183 | 192 |
return; |
184 | 193 |
} |
185 | 194 |
|
186 | 195 |
function is_service_enabled($service_name) { |
187 | 196 |
global $config; |
188 |
if ($service_name == "") |
|
197 |
if ($service_name == "") {
|
|
189 | 198 |
return false; |
199 |
} |
|
190 | 200 |
if (is_array($config['installedpackages'])) { |
191 | 201 |
if (isset($config['installedpackages'][$service_name]['config'][0]['enable']) && |
192 |
((empty($config['installedpackages'][$service_name]['config'][0]['enable'])) ||
|
|
193 |
($config['installedpackages'][$service_name]['config'][0]['enable'] === 'off'))) {
|
|
202 |
((empty($config['installedpackages'][$service_name]['config'][0]['enable'])) ||
|
|
203 |
($config['installedpackages'][$service_name]['config'][0]['enable'] === 'off'))) {
|
|
194 | 204 |
return false; |
195 | 205 |
} |
196 | 206 |
} |
... | ... | |
200 | 210 |
function is_service_running($service, $ps = "") { |
201 | 211 |
global $config; |
202 | 212 |
|
203 |
if(is_array($config['installedpackages']['service'])) { |
|
204 |
foreach($config['installedpackages']['service'] as $aservice) { |
|
205 |
if(strtolower($service) == strtolower($aservice['name'])) { |
|
213 |
if (is_array($config['installedpackages']['service'])) {
|
|
214 |
foreach ($config['installedpackages']['service'] as $aservice) {
|
|
215 |
if (strtolower($service) == strtolower($aservice['name'])) {
|
|
206 | 216 |
if ($aservice['custom_php_service_status_command'] <> "") { |
207 | 217 |
eval("\$rc={$aservice['custom_php_service_status_command']};"); |
208 | 218 |
return $rc; |
209 | 219 |
} |
210 |
if(empty($aservice['executable']))
|
|
220 |
if (empty($aservice['executable'])) {
|
|
211 | 221 |
return false; |
212 |
if (is_process_running($aservice['executable'])) |
|
222 |
} |
|
223 |
if (is_process_running($aservice['executable'])) { |
|
213 | 224 |
return true; |
225 |
} |
|
214 | 226 |
|
215 | 227 |
return false; |
216 | 228 |
} |
217 | 229 |
} |
218 | 230 |
} |
219 | 231 |
|
220 |
if (is_process_running($service)) |
|
232 |
if (is_process_running($service)) {
|
|
221 | 233 |
return true; |
234 |
} |
|
222 | 235 |
|
223 | 236 |
return false; |
224 | 237 |
} |
225 | 238 |
|
226 | 239 |
function get_services() { |
227 | 240 |
global $config; |
228 |
if (is_array($config['installedpackages']['service'])) |
|
241 |
if (is_array($config['installedpackages']['service'])) {
|
|
229 | 242 |
$services = $config['installedpackages']['service']; |
230 |
else
|
|
243 |
} else {
|
|
231 | 244 |
$services = array(); |
245 |
} |
|
232 | 246 |
|
233 |
/* Add services that are in the base.
|
|
234 |
* |
|
247 |
/* |
|
248 |
* Add services that are in the base.
|
|
235 | 249 |
*/ |
236 | 250 |
if (is_radvd_enabled()) { |
237 | 251 |
$pconfig = array(); |
... | ... | |
275 | 289 |
$ifdescrs = get_configured_interface_list(); |
276 | 290 |
foreach ($ifdescrs as $if) { |
277 | 291 |
$oc = $config['interfaces'][$if]; |
278 |
if ($oc['if'] && (!link_interface_to_bridge($if))) |
|
292 |
if ($oc['if'] && (!link_interface_to_bridge($if))) {
|
|
279 | 293 |
$iflist[$if] = $if; |
294 |
} |
|
280 | 295 |
} |
281 | 296 |
|
282 | 297 |
if (isset($config['dhcrelay']['enable'])) { |
... | ... | |
377 | 392 |
|
378 | 393 |
function find_service_by_name($name) { |
379 | 394 |
$services = get_services(); |
380 |
foreach ($services as $service) |
|
381 |
if ($service["name"] == $name) |
|
395 |
foreach ($services as $service) {
|
|
396 |
if ($service["name"] == $name) {
|
|
382 | 397 |
return $service; |
398 |
} |
|
399 |
} |
|
383 | 400 |
return array(); |
384 | 401 |
} |
385 | 402 |
|
386 | 403 |
function find_service_by_openvpn_vpnid($vpnid) { |
387 | 404 |
$services = get_services(); |
388 |
foreach ($services as $service) |
|
389 |
if (($service["name"] == "openvpn") && isset($service["vpnid"]) && ($service["vpnid"] == $vpnid)) |
|
405 |
foreach ($services as $service) {
|
|
406 |
if (($service["name"] == "openvpn") && isset($service["vpnid"]) && ($service["vpnid"] == $vpnid)) {
|
|
390 | 407 |
return $service; |
408 |
} |
|
409 |
} |
|
391 | 410 |
return array(); |
392 | 411 |
} |
393 | 412 |
|
394 | 413 |
function find_service_by_cp_zone($zone) { |
395 | 414 |
$services = get_services(); |
396 |
foreach ($services as $service) |
|
397 |
if (($service["name"] == "captiveportal") && isset($service["zone"]) && ($service["zone"] == $zone)) |
|
415 |
foreach ($services as $service) {
|
|
416 |
if (($service["name"] == "captiveportal") && isset($service["zone"]) && ($service["zone"] == $zone)) {
|
|
398 | 417 |
return $service; |
418 |
} |
|
419 |
} |
|
399 | 420 |
return array(); |
400 | 421 |
} |
401 | 422 |
|
402 | 423 |
function service_name_compare($a, $b) { |
403 |
if (strtolower($a['name']) == strtolower($b['name'])) |
|
424 |
if (strtolower($a['name']) == strtolower($b['name'])) {
|
|
404 | 425 |
return 0; |
426 |
} |
|
405 | 427 |
return (strtolower($a['name']) < strtolower($b['name'])) ? -1 : 1; |
406 | 428 |
} |
407 | 429 |
|
408 | 430 |
function get_pkg_descr($package_name) { |
409 | 431 |
global $config; |
410 | 432 |
if (is_array($config['installedpackages']['package'])) { |
411 |
foreach($config['installedpackages']['package'] as $pkg) { |
|
412 |
if($pkg['name'] == $package_name)
|
|
433 |
foreach ($config['installedpackages']['package'] as $pkg) {
|
|
434 |
if ($pkg['name'] == $package_name) {
|
|
413 | 435 |
return $pkg['descr']; |
436 |
} |
|
414 | 437 |
} |
415 | 438 |
} |
416 | 439 |
return gettext("Not available."); |
... | ... | |
424 | 447 |
break; |
425 | 448 |
case "captiveportal": |
426 | 449 |
$running = is_pid_running("{$g['varrun_path']}/lighty-{$service['zone']}-CaptivePortal.pid"); |
427 |
if (isset($config['captiveportal'][$service['zone']]['httpslogin'])) |
|
450 |
if (isset($config['captiveportal'][$service['zone']]['httpslogin'])) {
|
|
428 | 451 |
$running = $running && is_pid_running("{$g['varrun_path']}/lighty-{$service['zone']}-CaptivePortal-SSL.pid"); |
452 |
} |
|
429 | 453 |
break; |
430 | 454 |
case "vhosts-http": |
431 | 455 |
$running = is_pid_running("{$g['varrun_path']}/vhosts-http.pid"); |
... | ... | |
445 | 469 |
function get_service_status_icon($service, $withtext = true, $smallicon = false) { |
446 | 470 |
global $g; |
447 | 471 |
$output = ""; |
448 |
if(get_service_status($service)) { |
|
472 |
if (get_service_status($service)) {
|
|
449 | 473 |
$statustext = gettext("Running"); |
450 | 474 |
$output .= "<img style=\"vertical-align:middle\" title=\"" . sprintf(gettext("%s Service is"),$service["name"]) . " {$statustext}\" src=\"/themes/" . $g["theme"] . "/images/icons/"; |
451 | 475 |
$output .= ($smallicon) ? "icon_pass.gif" : "icon_service_running.gif"; |
452 | 476 |
$output .= "\" alt=\"status\" /> "; |
453 |
if ($withtext) |
|
477 |
if ($withtext) {
|
|
454 | 478 |
$output .= " " . $statustext; |
479 |
} |
|
455 | 480 |
} else { |
456 | 481 |
$service_enabled = is_service_enabled($service['name']); |
457 | 482 |
$statustext = ($service_enabled) ? gettext("Stopped") : gettext("Disabled"); |
458 | 483 |
$output .= "<img style=\"vertical-align:middle\" title=\"" . sprintf(gettext("%s Service is"),$service["name"]) . " {$statustext}\" src=\"/themes/" . $g["theme"] . "/images/icons/"; |
459 | 484 |
$output .= ($smallicon) ? "icon_block.gif" : "icon_service_stopped.gif"; |
460 | 485 |
$output .= "\" alt=\"status\" /> "; |
461 |
if ($withtext) |
|
486 |
if ($withtext) {
|
|
462 | 487 |
$output .= " <font color=\"white\">{$statustext}</font>"; |
488 |
} |
|
463 | 489 |
} |
464 | 490 |
return $output; |
465 | 491 |
} |
... | ... | |
468 | 494 |
global $g; |
469 | 495 |
$output = ""; |
470 | 496 |
$stitle = ($addname) ? $service['name'] . " " : ""; |
471 |
if(get_service_status($service)) { |
|
497 |
if (get_service_status($service)) {
|
|
472 | 498 |
switch ($service['name']) { |
473 | 499 |
case "openvpn": |
474 | 500 |
$output .= "<a href='status_services.php?mode=restartservice&service={$service['name']}&vpnmode={$service['mode']}&id={$service['vpnid']}'>"; |
... | ... | |
502 | 528 |
$output .= "<a href='status_services.php?mode=startservice&service={$service['name']}&zone={$service['zone']}'>"; |
503 | 529 |
break; |
504 | 530 |
default: |
505 |
if ($service_enabled) |
|
531 |
if ($service_enabled) {
|
|
506 | 532 |
$output .= "<a href='status_services.php?mode=startservice&service={$service['name']}'>"; |
533 |
} |
|
507 | 534 |
} |
508 |
if ($service_enabled) |
|
535 |
if ($service_enabled) {
|
|
509 | 536 |
$output .= "<img style=\"vertical-align:middle\" title='" . sprintf(gettext("Start %sService"),$stitle) . "' border='0' src='./themes/".$g['theme']."/images/icons/icon_service_start.gif' alt='start' /></a>\n"; |
537 |
} |
|
510 | 538 |
} |
511 | 539 |
return $output; |
512 | 540 |
} |
513 | 541 |
|
514 | 542 |
function service_control_start($name, $extras) { |
515 | 543 |
global $g; |
516 |
switch($name) { |
|
544 |
switch ($name) {
|
|
517 | 545 |
case 'radvd': |
518 | 546 |
services_radvd_configure(); |
519 | 547 |
break; |
... | ... | |
563 | 591 |
if (($vpnmode == "server") || ($vpnmode == "client")) { |
564 | 592 |
$id = isset($extras['vpnid']) ? htmlspecialchars($extras['vpnid']) : htmlspecialchars($extras['id']); |
565 | 593 |
$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf"; |
566 |
if (file_exists($configfile)) |
|
594 |
if (file_exists($configfile)) {
|
|
567 | 595 |
openvpn_restart_by_vpnid($vpnmode, $id); |
596 |
} |
|
568 | 597 |
} |
569 | 598 |
break; |
570 | 599 |
case 'relayd': |
... | ... | |
578 | 607 |
} |
579 | 608 |
function service_control_stop($name, $extras) { |
580 | 609 |
global $g; |
581 |
switch($name) { |
|
610 |
switch ($name) {
|
|
582 | 611 |
case 'radvd': |
583 | 612 |
killbypid("{$g['varrun_path']}/radvd.pid"); |
584 | 613 |
break; |
... | ... | |
649 | 678 |
|
650 | 679 |
function service_control_restart($name, $extras) { |
651 | 680 |
global $g; |
652 |
switch($name) { |
|
681 |
switch ($name) {
|
|
653 | 682 |
case 'radvd': |
654 | 683 |
services_radvd_configure(); |
655 | 684 |
break; |
... | ... | |
702 | 731 |
if ($vpnmode == "server" || $vpnmode == "client") { |
703 | 732 |
$id = htmlspecialchars($extras['id']); |
704 | 733 |
$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf"; |
705 |
if (file_exists($configfile)) |
|
734 |
if (file_exists($configfile)) {
|
|
706 | 735 |
openvpn_restart_by_vpnid($vpnmode, $id); |
736 |
} |
|
707 | 737 |
} |
708 | 738 |
break; |
709 | 739 |
case 'relayd': |
etc/inc/services.inc | ||
---|---|---|
44 | 44 |
/* implement ipv6 route advertising daemon */ |
45 | 45 |
function services_radvd_configure($blacklist = array()) { |
46 | 46 |
global $config, $g; |
47 |
|
|
48 |
if ($g['platform'] == 'jail') |
|
47 |
|
|
48 |
if ($g['platform'] == 'jail') {
|
|
49 | 49 |
return; |
50 |
} |
|
50 | 51 |
|
51 |
if(isset($config['system']['developerspew'])) { |
|
52 |
if (isset($config['system']['developerspew'])) {
|
|
52 | 53 |
$mt = microtime(); |
53 | 54 |
echo "services_radvd_configure() being called $mt\n"; |
54 | 55 |
} |
55 | 56 |
|
56 |
if (!is_array($config['dhcpdv6'])) |
|
57 |
if (!is_array($config['dhcpdv6'])) {
|
|
57 | 58 |
$config['dhcpdv6'] = array(); |
59 |
} |
|
58 | 60 |
|
59 | 61 |
$Iflist = get_configured_interface_list(); |
60 | 62 |
$Iflist = array_merge($Iflist, get_configured_pppoe_server_interfaces()); |
... | ... | |
67 | 69 |
|
68 | 70 |
/* handle manually configured DHCP6 server settings first */ |
69 | 71 |
foreach ($config['dhcpdv6'] as $dhcpv6if => $dhcpv6ifconf) { |
70 |
if (!is_array($config['interfaces'][$dhcpv6if])) |
|
72 |
if (!is_array($config['interfaces'][$dhcpv6if])) {
|
|
71 | 73 |
continue; |
72 |
if (!isset($config['interfaces'][$dhcpv6if]['enable'])) |
|
74 |
} |
|
75 |
if (!isset($config['interfaces'][$dhcpv6if]['enable'])) { |
|
73 | 76 |
continue; |
77 |
} |
|
74 | 78 |
|
75 | 79 |
/* Do not put in the config an interface which is down */ |
76 |
if (isset($blacklist[$dhcpv6if])) |
|
80 |
if (isset($blacklist[$dhcpv6if])) {
|
|
77 | 81 |
continue; |
78 |
if (!isset($dhcpv6ifconf['ramode'])) |
|
82 |
} |
|
83 |
if (!isset($dhcpv6ifconf['ramode'])) { |
|
79 | 84 |
$dhcpv6ifconf['ramode'] = $dhcpv6ifconf['mode']; |
85 |
} |
|
80 | 86 |
|
81 | 87 |
/* are router advertisements enabled? */ |
82 |
if ($dhcpv6ifconf['ramode'] == "disabled") |
|
88 |
if ($dhcpv6ifconf['ramode'] == "disabled") {
|
|
83 | 89 |
continue; |
90 |
} |
|
84 | 91 |
|
85 |
if (!isset($dhcpv6ifconf['rapriority'])) |
|
92 |
if (!isset($dhcpv6ifconf['rapriority'])) {
|
|
86 | 93 |
$dhcpv6ifconf['rapriority'] = "medium"; |
94 |
} |
|
87 | 95 |
|
88 | 96 |
/* always start with the real parent, we override with the carp if later */ |
89 | 97 |
$carpif = false; |
... | ... | |
97 | 105 |
|
98 | 106 |
if (strstr($dhcpv6if, "_vip")) { |
99 | 107 |
// CARP IP, check if it's enabled and find parent |
100 |
if (!get_carp_status() || get_carp_interface_status($dhcpv6if) != "MASTER") |
|
108 |
if (!get_carp_status() || get_carp_interface_status($dhcpv6if) != "MASTER") {
|
|
101 | 109 |
continue; |
110 |
} |
|
102 | 111 |
$ifparent = link_carp_interface_to_parent($dhcpv6if); |
103 | 112 |
$realif = convert_friendly_interface_to_real_interface_name($ifparent); |
104 | 113 |
} else { |
105 | 114 |
$realif = get_real_interface($dhcpv6if, "inet6"); |
106 | 115 |
} |
107 |
|
|
108 |
if (isset($radvdifs[$realif])) |
|
116 |
|
|
117 |
if (isset($radvdifs[$realif])) {
|
|
109 | 118 |
continue; |
119 |
} |
|
110 | 120 |
|
111 | 121 |
$ifcfgipv6 = get_interface_ipv6($dhcpv6if); |
112 |
if (!is_ipaddrv6($ifcfgipv6)) |
|
122 |
if (!is_ipaddrv6($ifcfgipv6)) {
|
|
113 | 123 |
continue; |
124 |
} |
|
114 | 125 |
|
115 | 126 |
$ifcfgsnv6 = get_interface_subnetv6($dhcpv6if); |
116 | 127 |
$subnetv6 = gen_subnetv6($ifcfgipv6, $ifcfgsnv6); |
... | ... | |
122 | 133 |
$radvdconf .= "\tMinRtrAdvInterval 5;\n"; |
123 | 134 |
$radvdconf .= "\tMaxRtrAdvInterval 20;\n"; |
124 | 135 |
$mtu = get_interface_mtu($realif); |
125 |
if (is_numeric($mtu)) |
|
136 |
if (is_numeric($mtu)) {
|
|
126 | 137 |
$radvdconf .= "\tAdvLinkMTU {$mtu};\n"; |
127 |
else
|
|
138 |
} else {
|
|
128 | 139 |
$radvdconf .= "\tAdvLinkMTU 1280;\n"; |
140 |
} |
|
129 | 141 |
// $radvdconf .= "\tDeprecatePrefix on;\n"; |
130 |
switch($dhcpv6ifconf['rapriority']) { |
|
142 |
switch ($dhcpv6ifconf['rapriority']) {
|
|
131 | 143 |
case "low": |
132 | 144 |
$radvdconf .= "\tAdvDefaultPreference low;\n"; |
133 | 145 |
break; |
... | ... | |
138 | 150 |
$radvdconf .= "\tAdvDefaultPreference medium;\n"; |
139 | 151 |
break; |
140 | 152 |
} |
141 |
switch($dhcpv6ifconf['ramode']) { |
|
153 |
switch ($dhcpv6ifconf['ramode']) {
|
|
142 | 154 |
case "managed": |
143 | 155 |
case "assist": |
144 | 156 |
$radvdconf .= "\tAdvManagedFlag on;\n"; |
... | ... | |
146 | 158 |
break; |
147 | 159 |
} |
148 | 160 |
$radvdconf .= "\tprefix {$subnetv6}/{$ifcfgsnv6} {\n"; |
149 |
if($carpif == true) { |
|
161 |
if ($carpif == true) {
|
|
150 | 162 |
$radvdconf .= "\t\tDeprecatePrefix off;\n"; |
151 | 163 |
} else { |
152 | 164 |
$radvdconf .= "\t\tDeprecatePrefix on;\n"; |
153 | 165 |
} |
154 |
switch($dhcpv6ifconf['ramode']) { |
|
166 |
switch ($dhcpv6ifconf['ramode']) {
|
|
155 | 167 |
case "managed": |
156 | 168 |
$radvdconf .= "\t\tAdvOnLink on;\n"; |
157 | 169 |
$radvdconf .= "\t\tAdvAutonomous off;\n"; |
... | ... | |
171 | 183 |
$radvdconf .= "\t\tAdvOnLink on;\n"; |
172 | 184 |
$radvdconf .= "\t\tAdvAutonomous on;\n"; |
173 | 185 |
$radvdconf .= "\t\tAdvRouterAddr on;\n"; |
174 |
break;
|
|
186 |
break; |
|
175 | 187 |
} |
176 | 188 |
$radvdconf .= "\t};\n"; |
177 | 189 |
|
178 |
if($carpif === true) { |
|
190 |
if ($carpif === true) {
|
|
179 | 191 |
$radvdconf .= "\troute ::/0 {\n"; |
180 | 192 |
$radvdconf .= "\t\tRemoveRoute off;\n"; |
181 | 193 |
$radvdconf .= "\t};\n"; |
... | ... | |
188 | 200 |
/* add DNS servers */ |
189 | 201 |
$dnslist = array(); |
190 | 202 |
if (isset($dhcpv6ifconf['rasamednsasdhcp6']) && is_array($dhcpv6ifconf['dnsserver']) && !empty($dhcpv6ifconf['dnsserver'])) { |
191 |
foreach($dhcpv6ifconf['dnsserver'] as $server)
|
|
192 |
if (is_ipaddrv6($server)) |
|
203 |
foreach ($dhcpv6ifconf['dnsserver'] as $server) {
|
|
204 |
if (is_ipaddrv6($server)) {
|
|
193 | 205 |
$dnslist[] = $server; |
206 |
} |
|
207 |
} |
|
194 | 208 |
} elseif (!isset($dhcpv6ifconf['rasamednsasdhcp6']) && isset($dhcpv6ifconf['radnsserver']) && is_array($dhcpv6ifconf['radnsserver'])) { |
195 |
foreach($dhcpv6ifconf['radnsserver'] as $server)
|
|
196 |
if (is_ipaddrv6($server)) |
|
209 |
foreach ($dhcpv6ifconf['radnsserver'] as $server) {
|
|
210 |
if (is_ipaddrv6($server)) {
|
|
197 | 211 |
$dnslist[] = $server; |
212 |
} |
|
213 |
} |
|
198 | 214 |
} elseif (isset($config['dnsmasq']['enable']) || isset($config['unbound']['enable'])) { |
199 | 215 |
$dnslist[] = get_interface_ipv6($realif); |
200 | 216 |
} elseif (is_array($config['system']['dnsserver']) && !empty($config['system']['dnsserver'])) { |
201 |
foreach($config['system']['dnsserver'] as $server) { |
|
202 |
if (is_ipaddrv6($server)) |
|
217 |
foreach ($config['system']['dnsserver'] as $server) {
|
|
218 |
if (is_ipaddrv6($server)) {
|
|
203 | 219 |
$dnslist[] = $server; |
220 |
} |
|
204 | 221 |
} |
205 | 222 |
} |
206 | 223 |
if (count($dnslist) > 0) { |
207 | 224 |
$dnsstring = implode(" ", $dnslist); |
208 |
if ($dnsstring <> "") |
|
225 |
if ($dnsstring <> "") {
|
|
209 | 226 |
$radvdconf .= "\tRDNSS {$dnsstring} { };\n"; |
227 |
} |
|
210 | 228 |
} |
211 | 229 |
if (!empty($dhcpv6ifconf['domain'])) { |
212 | 230 |
$radvdconf .= "\tDNSSL {$dhcpv6ifconf['domain']} { };\n"; |
... | ... | |
218 | 236 |
|
219 | 237 |
/* handle DHCP-PD prefixes and 6RD dynamic interfaces */ |
220 | 238 |
foreach ($Iflist as $if => $ifdescr) { |
221 |
if(!isset($config['interfaces'][$if]['track6-interface']))
|
|
239 |
if (!isset($config['interfaces'][$if]['track6-interface'])) {
|
|
222 | 240 |
continue; |
223 |
if(!isset($config['interfaces'][$if]['enable'])) |
|
241 |
} |
|
242 |
if (!isset($config['interfaces'][$if]['enable'])) { |
|
224 | 243 |
continue; |
244 |
} |
|
225 | 245 |
/* Do not put in the config an interface which is down */ |
226 |
if (isset($blacklist[$if])) |
|
246 |
if (isset($blacklist[$if])) {
|
|
227 | 247 |
continue; |
248 |
} |
|
228 | 249 |
$trackif = $config['interfaces'][$if]['track6-interface']; |
Also available in: Unified diff
Code style etc in r s