forked from extern/shorewall_code
Compare commits
623 Commits
4.4.2.2
...
4.4.8-base
Author | SHA1 | Date | |
---|---|---|---|
|
34e59b066e | ||
|
e158509421 | ||
|
9efb7bed29 | ||
|
c1477fd719 | ||
|
acdd361540 | ||
|
41b666449e | ||
|
fab2ce3d74 | ||
|
9bb1caa4bc | ||
|
f363825261 | ||
|
9a88156769 | ||
|
fae29bcf6f | ||
|
508475d80b | ||
|
b22b279bd1 | ||
|
a71f5df64f | ||
|
f44dbcf20b | ||
|
91bc3b3293 | ||
|
1177540fd8 | ||
|
66c883de2c | ||
|
b2a56cd542 | ||
|
a01fa345b7 | ||
|
5ac2b16936 | ||
|
16bbe780c7 | ||
|
787cec4fe7 | ||
|
472425cc62 | ||
|
a2ac726ce9 | ||
|
196cd5417f | ||
|
57dc5731b2 | ||
|
249f9412f6 | ||
|
4f32be03d7 | ||
|
0fb9333346 | ||
|
93494c6ae3 | ||
|
fb4f7ebd67 | ||
|
07cba9e066 | ||
|
efed2286b0 | ||
|
696f7d6b2b | ||
|
ce8d1cbc59 | ||
|
f246f728e7 | ||
|
7ee96c41e0 | ||
|
1c293d17dc | ||
|
9b1483d93e | ||
|
4e18414fd7 | ||
|
5671a7ae2f | ||
|
88447bfc7d | ||
|
2d458b46b4 | ||
|
928b162d3c | ||
|
7557b4b5fb | ||
|
fe089ddc36 | ||
|
e9dffbace2 | ||
|
bcfa98bf4d | ||
|
117d79ec02 | ||
|
c8d8d75cae | ||
|
707ec67430 | ||
|
35974535b2 | ||
|
f8c7a284a5 | ||
|
8e5114859c | ||
|
b4d4cedef9 | ||
|
a0ea84a8c6 | ||
|
f06bb65ffb | ||
|
abb943bfb7 | ||
|
50330f71f6 | ||
|
3e4d9b3118 | ||
|
7757c0bc20 | ||
|
41d709b043 | ||
|
7b52d812ae | ||
|
24432a5f76 | ||
|
4c081e5998 | ||
|
5d87983803 | ||
|
1d52683af8 | ||
|
a963c8f955 | ||
|
a4414a9695 | ||
|
3f73b3c408 | ||
|
49c1350aa0 | ||
|
c6981de0e5 | ||
|
ee74696747 | ||
|
234e4fa754 | ||
|
7457f643ee | ||
|
70296b4bd6 | ||
|
78a39ccad5 | ||
|
cce4bf277a | ||
|
2656a9b0c7 | ||
|
5613d0105a | ||
|
68f5215f07 | ||
|
82bb80cbba | ||
|
55e1124bbe | ||
|
3ea6f6792f | ||
|
5fc6d58e19 | ||
|
d4936f4bad | ||
|
9ec5f36549 | ||
|
169f97d76b | ||
|
8cfcacc862 | ||
|
f11bfd3890 | ||
|
cfa09dce22 | ||
|
3ba797cb14 | ||
|
53c73bc8e9 | ||
|
14f83759ae | ||
|
5d840e336a | ||
|
546a48543d | ||
|
f98e772c96 | ||
|
39883aa690 | ||
|
fb55d63eaf | ||
|
333ac21c2f | ||
|
83ed0a401b | ||
|
585711caa8 | ||
|
693d0e5d4c | ||
|
91a14b4e82 | ||
|
d2992c21f4 | ||
|
c9c957c5b8 | ||
|
8fadaa8f2c | ||
|
f0dc720740 | ||
|
3c4b41fbe0 | ||
|
643d4831ab | ||
|
061d850c16 | ||
|
c1ac19a81e | ||
|
8aaddf368b | ||
|
e66b8759d6 | ||
|
abbcf8eba4 | ||
|
7fe7ebc891 | ||
|
4059fe6956 | ||
|
dd004bacb9 | ||
|
4dedc26d9e | ||
|
cd2056f0aa | ||
|
4415050fd2 | ||
|
bffb1793d7 | ||
|
570497766b | ||
|
70a246501e | ||
|
4320ebb8b0 | ||
|
b2350829b9 | ||
|
3fc10cd94b | ||
|
efa41d1801 | ||
|
88d29d2e35 | ||
|
20ca22d437 | ||
|
55c9cf3e99 | ||
|
6165a50e49 | ||
|
56bcb5ebc4 | ||
|
8bc6f2144a | ||
|
8c3bb22511 | ||
|
2a965d42b9 | ||
|
70242c0d00 | ||
|
3a9416fb87 | ||
|
e690303937 | ||
|
8baa4e60c9 | ||
|
6a3b2b0dee | ||
|
6307653a01 | ||
|
5696742ef3 | ||
|
a83663bf25 | ||
|
edaf541850 | ||
|
c030bc900c | ||
|
ceff8adc78 | ||
|
3a2173ddb4 | ||
|
ea8be87720 | ||
|
4e0225a4c3 | ||
|
ea8a6c837f | ||
|
00b0490cd7 | ||
|
625963a4f0 | ||
|
41bb0782a3 | ||
|
5649dbf9a8 | ||
|
115ce7b87d | ||
|
eaafeb8c2b | ||
|
375160d733 | ||
|
167b29c2c5 | ||
|
8aaf4aab3a | ||
|
4546394531 | ||
|
5d08d51fe5 | ||
|
12d3420a5d | ||
|
ba01cecbcd | ||
|
0624451537 | ||
|
5e9ecf1491 | ||
|
50d246c8be | ||
|
ec95e5b32c | ||
|
1258149e0e | ||
|
ea5a6c79bc | ||
|
5a96771e07 | ||
|
757fea7467 | ||
|
b35f20b403 | ||
|
b8c195f570 | ||
|
b1c64913b4 | ||
|
433fc385bc | ||
|
add302d02a | ||
|
76f053246a | ||
|
01521e4941 | ||
|
21d4c8ba21 | ||
|
1f86f54a8e | ||
|
46e2afcf16 | ||
|
b45a70f98a | ||
|
6239218db5 | ||
|
18d03a61f5 | ||
|
28b1139ef7 | ||
|
b449d8168e | ||
|
11a2ec9f7c | ||
|
e64af57cae | ||
|
f4e175f149 | ||
|
97f3e5b8de | ||
|
52880a8822 | ||
|
9d288241da | ||
|
096fb29203 | ||
|
1d8a7ad09f | ||
|
e788b4c0f6 | ||
|
753eb97667 | ||
|
ede17e2da0 | ||
|
dd60f04a9f | ||
|
58f6e57286 | ||
|
d354560863 | ||
|
f0d101605b | ||
|
193fdc85f0 | ||
|
1981372c94 | ||
|
f2709dd525 | ||
|
3d39a47582 | ||
|
659f774451 | ||
|
9d2decd26d | ||
|
b8ec2be516 | ||
|
ecc7861115 | ||
|
ebd847ef70 | ||
|
05f2bb4b3a | ||
|
103a1660bc | ||
|
9d25318d80 | ||
|
be117f6638 | ||
|
2069855e44 | ||
|
846715b009 | ||
|
54456de888 | ||
|
c05c1a6f50 | ||
|
17fa381409 | ||
|
1556002b54 | ||
|
fb007bc1c7 | ||
|
9408a114c6 | ||
|
d933aa602b | ||
|
90b68a05de | ||
|
c5f64848f6 | ||
|
bb1f2993cc | ||
|
bfdc6719c1 | ||
|
83565f7a22 | ||
|
e14d48c2cf | ||
|
0d63182ab4 | ||
|
8dd835be2b | ||
|
5d5bdfc996 | ||
|
f283c37b1c | ||
|
199a50e1c7 | ||
|
f74771a118 | ||
|
8def4d03c3 | ||
|
8f85c75264 | ||
|
efc43b1b24 | ||
|
a248acb4d4 | ||
|
4303ad0a3e | ||
|
10fe25050f | ||
|
a7d4207bf5 | ||
|
61a0e85410 | ||
|
8b50966f80 | ||
|
f731e04388 | ||
|
6b9afd6a82 | ||
|
188bd64242 | ||
|
9788e057bf | ||
|
1716995d75 | ||
|
5cc2edf15a | ||
|
8798d3cdb4 | ||
|
4453bb7dc8 | ||
|
eb790c6d89 | ||
|
e119037dea | ||
|
f072c10b18 | ||
|
957de4b057 | ||
|
146a738e4c | ||
|
f4102417ff | ||
|
07cdb8ca82 | ||
|
47007c5dbd | ||
|
aad8ea837a | ||
|
5ec7759d81 | ||
|
5ae3e239e6 | ||
|
fddb85189e | ||
|
4bf0b8e1dd | ||
|
c39f3c12c9 | ||
|
d5cc302ad9 | ||
|
25d433b36f | ||
|
45d975cb45 | ||
|
81a5723009 | ||
|
6e998edd48 | ||
|
ce96bb003e | ||
|
ebf1e55609 | ||
|
1f1812b786 | ||
|
bffe8ce4c6 | ||
|
79f8031267 | ||
|
b8b7555ff9 | ||
|
880cd269c7 | ||
|
72de96760f | ||
|
890cbfbd5d | ||
|
10c5630786 | ||
|
555133fa3c | ||
|
505a2bac22 | ||
|
b4b6dce7c8 | ||
|
4821d5e8b7 | ||
|
ed3d3855f2 | ||
|
55e41483de | ||
|
38b8a8a7fd | ||
|
db2a1fe749 | ||
|
2b39d7f522 | ||
|
416f600181 | ||
|
f69a741691 | ||
|
7e183e8eb4 | ||
|
57672d096c | ||
|
ae31a09e8b | ||
|
4420eed8d7 | ||
|
271e472d3d | ||
|
818dfb6295 | ||
|
cab1f8548a | ||
|
5bd050f8b6 | ||
|
6c62f14749 | ||
|
d164880381 | ||
|
3822fe98c2 | ||
|
4be3cbe97b | ||
|
341617b5b8 | ||
|
4464094773 | ||
|
b6a7723c05 | ||
|
baa893773d | ||
|
6b085b7897 | ||
|
5b4e9eb8e6 | ||
|
0b549c7a15 | ||
|
fc8bfdcbf9 | ||
|
1a74dbf93e | ||
|
01293427f5 | ||
|
4f5bb5e90b | ||
|
d2d2912534 | ||
|
ab86994d68 | ||
|
4e50ea14ea | ||
|
b0feeb805d | ||
|
a1e46b68f0 | ||
|
54b21365c2 | ||
|
e6c0c8f6b7 | ||
|
a2efc8e827 | ||
|
bbce309791 | ||
|
83c2473d78 | ||
|
ca4eee3ae4 | ||
|
db819b1d3f | ||
|
314536dd74 | ||
|
605da92eca | ||
|
d362af9fb6 | ||
|
ab1dc03986 | ||
|
556170c990 | ||
|
1f49d49464 | ||
|
4d3887c4f6 | ||
|
0c92e05509 | ||
|
1175fa23b8 | ||
|
d6123a8fbc | ||
|
84051ca19a | ||
|
559e22706b | ||
|
4e0f9b2ef3 | ||
|
e3c75dcfcc | ||
|
91b65125aa | ||
|
1aa55779e2 | ||
|
b491eae3c0 | ||
|
a1fd3aa7e3 | ||
|
f306018159 | ||
|
cf8239e1d9 | ||
|
5ecf0e826a | ||
|
55e874b23f | ||
|
65c282af8b | ||
|
ea2ab6e4b6 | ||
|
c19e7715c4 | ||
|
f568f3df9e | ||
|
738a6de11b | ||
|
167d86746c | ||
|
f933816735 | ||
|
a7865e7e0e | ||
|
7e3675fb30 | ||
|
3bd3defd8e | ||
|
d62f3a4fed | ||
|
d5c695258a | ||
|
f233b86278 | ||
|
58977a1905 | ||
|
e38df7efcb | ||
|
e37cf0a370 | ||
|
d87d0893d2 | ||
|
8eb6d136ae | ||
|
d45dd5387a | ||
|
61b2ed7b57 | ||
|
15a1b39822 | ||
|
436169f0b2 | ||
|
9cf75a4253 | ||
|
7be7ef6685 | ||
|
d5914addd1 | ||
|
19af1a081c | ||
|
4f4d77be48 | ||
|
24ddacb4a7 | ||
|
508e1123bb | ||
|
10ae98571b | ||
|
4bbbcc20dd | ||
|
182ed24b02 | ||
|
576cd76842 | ||
|
e9d12cfc11 | ||
|
c8e185554f | ||
|
c8c523622b | ||
|
0e19ad5ea0 | ||
|
17802a4555 | ||
|
43c45a064c | ||
|
c56ff69c8f | ||
|
f938e9789e | ||
|
beb7634ca6 | ||
|
c40f8e3742 | ||
|
232423edf8 | ||
|
6a62ced2c6 | ||
|
9988cfb619 | ||
|
a150ed1a72 | ||
|
3214b14197 | ||
|
79ce532b69 | ||
|
a321ec6225 | ||
|
4076a6bca7 | ||
|
5e1f550b69 | ||
|
7a6ad80c8a | ||
|
c8616d4c67 | ||
|
acaa9ccc55 | ||
|
0e5293ffc5 | ||
|
01ed97ad94 | ||
|
acc985a290 | ||
|
e18238c665 | ||
|
12279e57ed | ||
|
083debb34e | ||
|
0e71ed18c0 | ||
|
ee2195e745 | ||
|
486f1a3493 | ||
|
a188fec942 | ||
|
4bf55883ee | ||
|
4c7731fee6 | ||
|
768da64869 | ||
|
117d4f9f2a | ||
|
8d2408a8d6 | ||
|
66d07955b0 | ||
|
add564e07a | ||
|
4494272dcd | ||
|
8c033de049 | ||
|
8b2c6853f3 | ||
|
e582f222ad | ||
|
e5106f10bc | ||
|
4e8d753682 | ||
|
d1812b4174 | ||
|
038b84e775 | ||
|
f21c71d7a6 | ||
|
0b1621027b | ||
|
f5378e7652 | ||
|
ea2c55a993 | ||
|
f5bf3c9b43 | ||
|
7352771c5d | ||
|
8297db4c59 | ||
|
543af8bccb | ||
|
7f16e96167 | ||
|
a37e56d823 | ||
|
18eedf7e34 | ||
|
1699d8e941 | ||
|
251d7116c8 | ||
|
22991ac9dd | ||
|
222c8cf88f | ||
|
8ff4d004c0 | ||
|
8263ea1312 | ||
|
d189c08533 | ||
|
a2cd4bd1f4 | ||
|
4c40b205f8 | ||
|
10056a03d9 | ||
|
cd84efea94 | ||
|
deb45c5a27 | ||
|
bdb673a642 | ||
|
1710f9ce7c | ||
|
9d85d0ff7a | ||
|
d3d21d4d18 | ||
|
f186c436d4 | ||
|
5610f78a48 | ||
|
cc809eaf78 | ||
|
c17ac8f23f | ||
|
532105ec39 | ||
|
b30cae89e3 | ||
|
99a35c1bf0 | ||
|
2eaf396f5a | ||
|
fedb26fe1e | ||
|
1150ef72d3 | ||
|
ba4db1dd41 | ||
|
c1001d7cc9 | ||
|
617fddf1bd | ||
|
d43ba935d1 | ||
|
5b02ef68a5 | ||
|
90170d6018 | ||
|
d4ff629fd8 | ||
|
720442b400 | ||
|
bd9c0ac285 | ||
|
76e7dea858 | ||
|
6e9d9e239d | ||
|
c8209f4ce2 | ||
|
4aeee6fd8b | ||
|
c7de19cf39 | ||
|
cbe944c354 | ||
|
ecf6a0ec4a | ||
|
bce4d51a18 | ||
|
c5bb493b29 | ||
|
0df84cf8b5 | ||
|
a23632f45e | ||
|
de9c088972 | ||
|
c26fe6b15e | ||
|
c39a9fb5eb | ||
|
d7c084c9c6 | ||
|
4579a71574 | ||
|
831611e792 | ||
|
5f70b261b6 | ||
|
c4bfab29a5 | ||
|
9d5dd2ad3a | ||
|
5ec4f8d82c | ||
|
2a910ebddf | ||
|
31f01fe765 | ||
|
016537f631 | ||
|
dd543a2934 | ||
|
f5a019becc | ||
|
20ef4e584b | ||
|
1c1f16661f | ||
|
cb67513160 | ||
|
b662718eec | ||
|
10affb1cde | ||
|
fa3bdde214 | ||
|
9d57ff050a | ||
|
0e6c9abb5b | ||
|
f904866336 | ||
|
2d53f8cb0c | ||
|
e748341afd | ||
|
b943f09e37 | ||
|
8ddc2e804d | ||
|
4e6b8f8f42 | ||
|
0f078e7440 | ||
|
a4eb581d44 | ||
|
06d3b2c692 | ||
|
6987cd15c5 | ||
|
ba8ad6346a | ||
|
893a847c87 | ||
|
1735e168b1 | ||
|
bd9c651961 | ||
|
bf8c38e054 | ||
|
7120a73f0e | ||
|
c9e57c93a2 | ||
|
4e2f2923b6 | ||
|
79b5cb49df | ||
|
893a0c9d42 | ||
|
9b127e6e06 | ||
|
92208251b7 | ||
|
dda6f06883 | ||
|
4d977306f9 | ||
|
83621ff416 | ||
|
09f1b6501c | ||
|
ca1dd1416d | ||
|
1238b771a2 | ||
|
b1706e10e3 | ||
|
bcd4887d84 | ||
|
7f54a6fea9 | ||
|
496cfc391e | ||
|
b491745f1c | ||
|
4ef45ff665 | ||
|
73eab1fa55 | ||
|
d73ebb8a6a | ||
|
7014bd3ea0 | ||
|
89bdcf9a3d | ||
|
a98195e156 | ||
|
fb3477b8b5 | ||
|
c1898d1c80 | ||
|
7e21488aec | ||
|
b4199fd068 | ||
|
28b660c853 | ||
|
3cc9ee7be5 | ||
|
4548db58da | ||
|
4f5c602d5f | ||
|
25549b176c | ||
|
306549119a | ||
|
5a525134ea | ||
|
f2f91ce7dd | ||
|
c893ba6ffa | ||
|
1892160ed5 | ||
|
45653ffe79 | ||
|
f97e0c5989 | ||
|
11ddfa92e9 | ||
|
23d0806da2 | ||
|
99c77d2611 | ||
|
4c3b0c7571 | ||
|
59d01ccf97 | ||
|
105754823a | ||
|
f0b4b1f42e | ||
|
cc0adc218f | ||
|
8251948d2a | ||
|
b3571261dd | ||
|
c922afaf23 | ||
|
3e2cf982a3 | ||
|
86df82a29a | ||
|
46896e7dce | ||
|
445527d27e | ||
|
58ef1d3b63 | ||
|
d0cda6b6ea | ||
|
49f361124e | ||
|
c4af105ee4 | ||
|
7adb9b12bb | ||
|
a0482132c6 | ||
|
abc9ab061a | ||
|
65e4a5ff66 | ||
|
0a74320bc2 | ||
|
31bbec0fdd | ||
|
30dbfdc949 | ||
|
f3043f1453 | ||
|
e6755b7172 | ||
|
f6913953fe | ||
|
a61c9a9e06 | ||
|
62c7ad7fbb | ||
|
b38841798e | ||
|
44c5ebcfa4 | ||
|
6e6063f193 | ||
|
e2f64af187 | ||
|
19a90db09f | ||
|
94d039bf56 | ||
|
b24544306c | ||
|
990a9f0fdc | ||
|
1b0a3e4417 | ||
|
80f41779f8 | ||
|
fe3b8be029 | ||
|
f1d014dfe4 | ||
|
7064b8dd08 | ||
|
7612c895e5 | ||
|
3f7a1f9574 | ||
|
28b0e99492 | ||
|
83a9d8dd1b | ||
|
dc643c67e9 | ||
|
ab4e7cffcf | ||
|
8089ef1599 | ||
|
8915145607 | ||
|
beac09e45f | ||
|
de933ba912 | ||
|
964cba79a9 | ||
|
065808be16 | ||
|
3171d3bfc2 |
@@ -10,10 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-interfaces"
|
||||
#
|
||||
# For additional information, see
|
||||
# http://shorewall.net/Documentation.htm#Interfaces
|
||||
#
|
||||
###############################################################################
|
||||
#ZONE INTERFACE BROADCAST OPTIONS
|
||||
net eth0 detect dhcp,tcpflags,logmartians,nosmurfs
|
||||
|
@@ -10,9 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#-----------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-policy"
|
||||
#
|
||||
# See http://shorewall.net/Documentation.htm#Policy for additional information.
|
||||
#
|
||||
###############################################################################
|
||||
#SOURCE DEST POLICY LOG LEVEL LIMIT:BURST
|
||||
$FW net ACCEPT
|
||||
|
@@ -10,9 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------------------------------------
|
||||
# For information on entries in this file, type "man shorewall-rules"
|
||||
#
|
||||
# For more information, see http://www.shorewall.net/Documentation.htm#Zones
|
||||
#
|
||||
#############################################################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK
|
||||
# PORT PORT(S) DEST LIMIT GROUP
|
||||
|
@@ -34,9 +34,9 @@ VERBOSITY=1
|
||||
|
||||
LOGFILE=/var/log/messages
|
||||
|
||||
STARTUP_LOG=
|
||||
STARTUP_LOG=/var/log/shorewall-init.log
|
||||
|
||||
LOG_VERBOSITY=
|
||||
LOG_VERBOSITY=2
|
||||
|
||||
LOGFORMAT="Shorewall:%s:%s:"
|
||||
|
||||
@@ -109,7 +109,7 @@ RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
|
||||
|
||||
IP_FORWARDING=Off
|
||||
|
||||
ADD_IP_ALIASES=Yes
|
||||
ADD_IP_ALIASES=No
|
||||
|
||||
ADD_SNAT_ALIASES=No
|
||||
|
||||
@@ -119,6 +119,8 @@ TC_ENABLED=Internal
|
||||
|
||||
TC_EXPERT=No
|
||||
|
||||
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
|
||||
|
||||
CLEAR_TC=Yes
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
@@ -137,7 +139,7 @@ BLACKLISTNEWONLY=Yes
|
||||
|
||||
DELAYBLACKLISTLOAD=No
|
||||
|
||||
MODULE_SUFFIX=
|
||||
MODULE_SUFFIX=ko
|
||||
|
||||
DISABLE_IPV6=No
|
||||
|
||||
@@ -191,6 +193,18 @@ AUTOMAKE=No
|
||||
|
||||
WIDE_TC_MARKS=Yes
|
||||
|
||||
TRACK_PROVIDERS=Yes
|
||||
|
||||
ZONE2ZONE=2
|
||||
|
||||
ACCOUNTING=Yes
|
||||
|
||||
DYNAMIC_BLACKLIST=Yes
|
||||
|
||||
OPTIMIZE_ACCOUNTING=No
|
||||
|
||||
LOAD_HELPERS_ONLY=Yes
|
||||
|
||||
###############################################################################
|
||||
# P A C K E T D I S P O S I T I O N
|
||||
###############################################################################
|
||||
|
@@ -10,9 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#-----------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-zones"
|
||||
#
|
||||
# For more information, see http://www.shorewall.net/Documentation.htm#Zones
|
||||
#
|
||||
###############################################################################
|
||||
#ZONE TYPE OPTIONS IN OUT
|
||||
# OPTIONS OPTIONS
|
||||
|
@@ -10,10 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-interfaces"
|
||||
#
|
||||
# For additional information, see
|
||||
# http://shorewall.net/Documentation.htm#Interfaces
|
||||
#
|
||||
###############################################################################
|
||||
#ZONE INTERFACE BROADCAST OPTIONS
|
||||
net eth0 detect tcpflags,dhcp,nosmurfs,routefilter,logmartians
|
||||
|
@@ -10,9 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-masq"
|
||||
#
|
||||
# For additional information, see http://shorewall.net/Documentation.htm#Masq
|
||||
#
|
||||
##############################################################################
|
||||
#INTERFACE SOURCE ADDRESS PROTO PORT(S) IPSEC MARK
|
||||
eth0 10.0.0.0/8,\
|
||||
|
@@ -10,9 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-policy"
|
||||
#
|
||||
# See http://shorewall.net/Documentation.htm#Policy for additional information.
|
||||
#
|
||||
###############################################################################
|
||||
#SOURCE DEST POLICY LOG LEVEL LIMIT:BURST
|
||||
|
||||
|
@@ -10,11 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-routestopped"
|
||||
#
|
||||
# See http://shorewall.net/Documentation.htm#Routestopped and
|
||||
# http://shorewall.net/starting_and_stopping_shorewall.htm for additional
|
||||
# information.
|
||||
#
|
||||
##############################################################################
|
||||
#INTERFACE HOST(S)
|
||||
eth1 -
|
||||
|
@@ -10,9 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-rules"
|
||||
#
|
||||
# For additional information, see http://shorewall.net/Documentation.htm#Rules
|
||||
#
|
||||
#############################################################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK
|
||||
# PORT PORT(S) DEST LIMIT GROUP
|
||||
|
@@ -34,9 +34,9 @@ VERBOSITY=1
|
||||
|
||||
LOGFILE=/var/log/messages
|
||||
|
||||
STARTUP_LOG=
|
||||
STARTUP_LOG=/var/log/shorewall-init.log
|
||||
|
||||
LOG_VERBOSITY=
|
||||
LOG_VERBOSITY=2
|
||||
|
||||
LOGFORMAT="Shorewall:%s:%s:"
|
||||
|
||||
@@ -109,7 +109,7 @@ RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
|
||||
|
||||
IP_FORWARDING=On
|
||||
|
||||
ADD_IP_ALIASES=Yes
|
||||
ADD_IP_ALIASES=No
|
||||
|
||||
ADD_SNAT_ALIASES=No
|
||||
|
||||
@@ -119,6 +119,8 @@ TC_ENABLED=Internal
|
||||
|
||||
TC_EXPERT=No
|
||||
|
||||
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
|
||||
|
||||
CLEAR_TC=Yes
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
@@ -137,7 +139,7 @@ BLACKLISTNEWONLY=Yes
|
||||
|
||||
DELAYBLACKLISTLOAD=No
|
||||
|
||||
MODULE_SUFFIX=
|
||||
MODULE_SUFFIX=ko
|
||||
|
||||
DISABLE_IPV6=No
|
||||
|
||||
@@ -191,6 +193,18 @@ AUTOMAKE=No
|
||||
|
||||
WIDE_TC_MARKS=Yes
|
||||
|
||||
TRACK_PROVIDERS=Yes
|
||||
|
||||
ZONE2ZONE=2
|
||||
|
||||
ACCOUNTING=Yes
|
||||
|
||||
DYNAMIC_BLACKLIST=Yes
|
||||
|
||||
OPTIMIZE_ACCOUNTING=No
|
||||
|
||||
LOAD_HELPERS_ONLY=Yes
|
||||
|
||||
###############################################################################
|
||||
# P A C K E T D I S P O S I T I O N
|
||||
###############################################################################
|
||||
|
@@ -10,9 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-zones"
|
||||
#
|
||||
# For more information, see http://www.shorewall.net/Documentation.htm#Zones
|
||||
#
|
||||
###############################################################################
|
||||
#ZONE TYPE OPTIONS IN OUT
|
||||
# OPTIONS OPTIONS
|
||||
|
@@ -10,10 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-interfaces"
|
||||
#
|
||||
# For additional information, see
|
||||
# http://shorewall.net/Documentation.htm#Interfaces
|
||||
#
|
||||
###############################################################################
|
||||
#ZONE INTERFACE BROADCAST OPTIONS
|
||||
net eth0 detect dhcp,tcpflags,nosmurfs,routefilter,logmartians
|
||||
|
@@ -10,9 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-masq"
|
||||
#
|
||||
# For additional information, see http://shorewall.net/Documentation.htm#Masq
|
||||
#
|
||||
###############################################################################
|
||||
#INTERFACE SOURCE ADDRESS PROTO PORT(S) IPSEC MARK
|
||||
eth0 10.0.0.0/8,\
|
||||
|
@@ -10,9 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-policy"
|
||||
#
|
||||
# See http://shorewall.net/Documentation.htm#Policy for additional information.
|
||||
#
|
||||
###############################################################################
|
||||
#SOURCE DEST POLICY LOG LEVEL LIMIT:BURST
|
||||
|
||||
|
@@ -10,11 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-routestopped"
|
||||
#
|
||||
# See http://shorewall.net/Documentation.htm#Routestopped and
|
||||
# http://shorewall.net/starting_and_stopping_shorewall.htm for additional
|
||||
# information.
|
||||
#
|
||||
##############################################################################
|
||||
#INTERFACE HOST(S) OPTIONS
|
||||
eth1 -
|
||||
|
@@ -10,9 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-rules"
|
||||
#
|
||||
# For more information, see http://www.shorewall.net/Documentation.htm#Rules
|
||||
#
|
||||
#############################################################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK
|
||||
# PORT PORT(S) DEST LIMIT GROUP
|
||||
|
@@ -41,9 +41,9 @@ SHOREWALL_COMPILER=
|
||||
|
||||
LOGFILE=/var/log/messages
|
||||
|
||||
STARTUP_LOG=
|
||||
STARTUP_LOG=/var/log/shorewall-init.log
|
||||
|
||||
LOG_VERBOSITY=
|
||||
LOG_VERBOSITY=2
|
||||
|
||||
LOGFORMAT="Shorewall:%s:%s:"
|
||||
|
||||
@@ -116,7 +116,7 @@ RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
|
||||
|
||||
IP_FORWARDING=On
|
||||
|
||||
ADD_IP_ALIASES=Yes
|
||||
ADD_IP_ALIASES=No
|
||||
|
||||
ADD_SNAT_ALIASES=No
|
||||
|
||||
@@ -126,6 +126,8 @@ TC_ENABLED=Internal
|
||||
|
||||
TC_EXPERT=No
|
||||
|
||||
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
|
||||
|
||||
CLEAR_TC=Yes
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
@@ -144,7 +146,7 @@ BLACKLISTNEWONLY=Yes
|
||||
|
||||
DELAYBLACKLISTLOAD=No
|
||||
|
||||
MODULE_SUFFIX=
|
||||
MODULE_SUFFIX=ko
|
||||
|
||||
DISABLE_IPV6=No
|
||||
|
||||
@@ -198,6 +200,18 @@ AUTOMAKE=No
|
||||
|
||||
WIDE_TC_MARKS=Yes
|
||||
|
||||
TRACK_PROVIDERS=Yes
|
||||
|
||||
ZONE2ZONE=2
|
||||
|
||||
ACCOUNTING=Yes
|
||||
|
||||
DYNAMIC_BLACKLIST=Yes
|
||||
|
||||
OPTIMIZE_ACCOUNTING=No
|
||||
|
||||
LOAD_HELPERS_ONLY=Yes
|
||||
|
||||
###############################################################################
|
||||
# P A C K E T D I S P O S I T I O N
|
||||
###############################################################################
|
||||
|
@@ -10,9 +10,6 @@
|
||||
# See the file README.txt for further details.
|
||||
#------------------------------------------------------------------------------
|
||||
# For information about entries in this file, type "man shorewall-zones"
|
||||
#
|
||||
# For more information, see http://www.shorewall.net/Documentation.htm#Zones
|
||||
#
|
||||
###############################################################################
|
||||
#ZONE TYPE OPTIONS IN OUT
|
||||
# OPTIONS OPTIONS
|
||||
|
@@ -32,9 +32,9 @@ VERBOSITY=1
|
||||
|
||||
LOGFILE=/var/log/messages
|
||||
|
||||
STARTUP_LOG=
|
||||
STARTUP_LOG=/var/log/shorewall6-init.log
|
||||
|
||||
LOG_VERBOSITY=
|
||||
LOG_VERBOSITY=2
|
||||
|
||||
LOGFORMAT="Shorewall:%s:%s:"
|
||||
|
||||
@@ -99,6 +99,8 @@ TC_ENABLED=No
|
||||
|
||||
TC_EXPERT=No
|
||||
|
||||
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
|
||||
|
||||
CLEAR_TC=Yes
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
@@ -111,7 +113,7 @@ ADMINISABSENTMINDED=Yes
|
||||
|
||||
BLACKLISTNEWONLY=Yes
|
||||
|
||||
MODULE_SUFFIX=
|
||||
MODULE_SUFFIX=ko
|
||||
|
||||
FASTACCEPT=No
|
||||
|
||||
@@ -139,7 +141,19 @@ AUTOMAKE=No
|
||||
|
||||
WIDE_TC_MARKS=Yes
|
||||
|
||||
###############################################################################
|
||||
TRACK_PROVIDERS=Yes
|
||||
|
||||
ZONE2ZONE=2
|
||||
|
||||
ACCOUNTING=Yes
|
||||
|
||||
DYNAMIC_BLACKLIST=Yes
|
||||
|
||||
OPTIMIZE_ACCOUNTING=No
|
||||
|
||||
LOAD_HELPERS_ONLY=Yes
|
||||
|
||||
##############################################################################
|
||||
# P A C K E T D I S P O S I T I O N
|
||||
###############################################################################
|
||||
|
||||
|
@@ -32,9 +32,9 @@ VERBOSITY=1
|
||||
|
||||
LOGFILE=/var/log/messages
|
||||
|
||||
STARTUP_LOG=
|
||||
STARTUP_LOG=/var/log/shorewall6-init.log
|
||||
|
||||
LOG_VERBOSITY=
|
||||
LOG_VERBOSITY=2
|
||||
|
||||
LOGFORMAT="Shorewall:%s:%s:"
|
||||
|
||||
@@ -99,6 +99,8 @@ TC_ENABLED=No
|
||||
|
||||
TC_EXPERT=No
|
||||
|
||||
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
|
||||
|
||||
CLEAR_TC=Yes
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
@@ -111,7 +113,7 @@ ADMINISABSENTMINDED=Yes
|
||||
|
||||
BLACKLISTNEWONLY=Yes
|
||||
|
||||
MODULE_SUFFIX=
|
||||
MODULE_SUFFIX=ko
|
||||
|
||||
FASTACCEPT=No
|
||||
|
||||
@@ -139,6 +141,18 @@ AUTOMAKE=No
|
||||
|
||||
WIDE_TC_MARKS=Yes
|
||||
|
||||
TRACK_PROVIDERS=Yes
|
||||
|
||||
ZONE2ZONE=2
|
||||
|
||||
ACCOUNTING=Yes
|
||||
|
||||
DYNAMIC_BLACKLIST=Yes
|
||||
|
||||
OPTIMIZE_ACCOUNTING=No
|
||||
|
||||
LOAD_HELPERS_ONLY=Yes
|
||||
|
||||
###############################################################################
|
||||
# P A C K E T D I S P O S I T I O N
|
||||
###############################################################################
|
||||
|
@@ -32,9 +32,9 @@ VERBOSITY=1
|
||||
|
||||
LOGFILE=/var/log/messages
|
||||
|
||||
STARTUP_LOG=
|
||||
STARTUP_LOG=/var/log/shorewall6-init.log
|
||||
|
||||
LOG_VERBOSITY=
|
||||
LOG_VERBOSITY=2
|
||||
|
||||
LOGFORMAT="Shorewall:%s:%s:"
|
||||
|
||||
@@ -99,6 +99,8 @@ TC_ENABLED=No
|
||||
|
||||
TC_EXPERT=No
|
||||
|
||||
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
|
||||
|
||||
CLEAR_TC=Yes
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
@@ -111,7 +113,7 @@ ADMINISABSENTMINDED=Yes
|
||||
|
||||
BLACKLISTNEWONLY=Yes
|
||||
|
||||
MODULE_SUFFIX=
|
||||
MODULE_SUFFIX=ko
|
||||
|
||||
FASTACCEPT=No
|
||||
|
||||
@@ -139,6 +141,18 @@ AUTOMAKE=No
|
||||
|
||||
WIDE_TC_MARKS=Yes
|
||||
|
||||
TRACK_PROVIDERS=Yes
|
||||
|
||||
ZONE2ZONE=2
|
||||
|
||||
ACCOUNTING=Yes
|
||||
|
||||
DYNAMIC_BLACKLIST=Yes
|
||||
|
||||
OPTIMIZE_ACCOUNTING=No
|
||||
|
||||
LOAD_HELPERS_ONLY=Yes
|
||||
|
||||
###############################################################################
|
||||
# P A C K E T D I S P O S I T I O N
|
||||
###############################################################################
|
||||
|
@@ -1 +1 @@
|
||||
This is the Shorewall-lite development 4.3 branch of SVN.
|
||||
This is the Shorewall-lite stable 4.4 branch of Git.
|
||||
|
@@ -21,4 +21,9 @@ startup=0
|
||||
|
||||
OPTIONS=""
|
||||
|
||||
#
|
||||
# Init Log -- if /dev/null, use the STARTUP_LOG defined in shorewall.conf
|
||||
#
|
||||
INITLOG=/dev/null
|
||||
|
||||
# EOF
|
||||
|
@@ -28,7 +28,7 @@
|
||||
# shown below. Simply run this script to revert to your prior version of
|
||||
# Shoreline Firewall.
|
||||
|
||||
VERSION=4.4.2.2
|
||||
VERSION=4.4.8
|
||||
|
||||
usage() # $1 = exit status
|
||||
{
|
||||
|
@@ -2,8 +2,8 @@
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: shorewall-lite
|
||||
# Required-Start: $network
|
||||
# Required-Stop: $network
|
||||
# Required-Start: $network $remote_fs
|
||||
# Required-Stop: $network $remote_fs
|
||||
# Default-Start: S
|
||||
# Default-Stop: 0 6
|
||||
# Short-Description: Configure the firewall at boot time
|
||||
@@ -15,9 +15,7 @@
|
||||
|
||||
SRWL=/sbin/shorewall-lite
|
||||
SRWL_OPTS="-tvv"
|
||||
# Note, set INITLOG to /dev/null if you do not want to
|
||||
# keep logs of the firewall (not recommended)
|
||||
INITLOG=/var/log/shorewall-lite-init.log
|
||||
test -n ${INITLOG:=/var/log/shorewall-lite-init.log}
|
||||
|
||||
[ "$INITLOG" eq "/dev/null" && SHOREWALL_INIT_SCRIPT=1 || SHOREWALL_INIT_SCRIPT=0
|
||||
|
||||
@@ -25,7 +23,7 @@ export SHOREWALL_INIT_SCRIPT
|
||||
|
||||
test -x $SRWL || exit 0
|
||||
test -x $WAIT_FOR_IFUP || exit 0
|
||||
test -n $INITLOG || {
|
||||
test -n "$INITLOG" || {
|
||||
echo "INITLOG cannot be empty, please configure $0" ;
|
||||
exit 1;
|
||||
}
|
||||
@@ -44,6 +42,7 @@ echo_notdone () {
|
||||
echo "not done (check $INITLOG)."
|
||||
fi
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
not_configured () {
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2000,2001,2002,2003,2004,2005,2006,2007 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Shorewall documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -22,7 +22,7 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
VERSION=4.4.2.2
|
||||
VERSION=4.4.8
|
||||
|
||||
usage() # $1 = exit status
|
||||
{
|
||||
@@ -220,6 +220,11 @@ mkdir -p ${PREFIX}/var/lib/shorewall-lite
|
||||
chmod 755 ${PREFIX}/etc/shorewall-lite
|
||||
chmod 755 ${PREFIX}/usr/share/shorewall-lite
|
||||
|
||||
if [ -n "$PREFIX" ]; then
|
||||
mkdir -p ${PREFIX}/etc/logrotate.d
|
||||
chmod 755 ${PREFIX}/etc/logrotate.d
|
||||
fi
|
||||
|
||||
#
|
||||
# Install the config file
|
||||
#
|
||||
@@ -304,6 +309,12 @@ cd ..
|
||||
|
||||
echo "Man Pages Installed"
|
||||
|
||||
if [ -d ${PREFIX}/etc/logrotate.d ]; then
|
||||
run_install $OWNERSHIP -m 0644 logrotate ${PREFIX}/etc/logrotate.d/shorewall-lite
|
||||
echo "Logrotate file installed as ${PREFIX}/etc/logrotate.d/shorewall-lite"
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Create the version file
|
||||
#
|
||||
|
5
Shorewall-lite/logrotate
Normal file
5
Shorewall-lite/logrotate
Normal file
@@ -0,0 +1,5 @@
|
||||
/var/log/shorewall-init.log {
|
||||
missingok
|
||||
notifempty
|
||||
create 0600 root root
|
||||
}
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2006,2007 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# This file should be placed in /sbin/shorewall.
|
||||
#
|
||||
@@ -48,18 +48,19 @@
|
||||
SHAREDIR=/usr/share/shorewall-lite
|
||||
VARDIR=/var/lib/shorewall-lite
|
||||
CONFDIR=/etc/shorewall-lite
|
||||
PRODUCT="Shorewall Lite"
|
||||
g_product="Shorewall Lite"
|
||||
|
||||
. /usr/share/shorewall-lite/lib.base
|
||||
. /usr/share/shorewall-lite/lib.cli
|
||||
. /usr/share/shorewall-lite/configpath
|
||||
|
||||
[ -n "$PATH" ] || PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
||||
|
||||
VERSION=$(cat /usr/share/shorewall-lite/version)
|
||||
SHOREWALL_VERSION=$(cat /usr/share/shorewall-lite/version)
|
||||
|
||||
[ -n "$IPTABLES" ] || IPTABLES=$(mywhich iptables)
|
||||
|
||||
VERBOSE=0
|
||||
VERBOSITY=0
|
||||
load_kernel_modules No
|
||||
determine_capabilities
|
||||
report_capabilities1
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2006 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# This file should be placed in /sbin/shorewall-lite.
|
||||
#
|
||||
@@ -95,7 +95,7 @@ get_config() {
|
||||
|
||||
if ( ps ax 2> /dev/null | grep -v grep | qt grep 'syslogd.*-C' ) ; then
|
||||
LOGREAD="logread | tac"
|
||||
elif [ -f $LOGFILE ]; then
|
||||
elif [ -r $LOGFILE ]; then
|
||||
LOGREAD="tac $LOGFILE"
|
||||
else
|
||||
echo "LOGFILE ($LOGFILE) does not exist!" >&2
|
||||
@@ -117,8 +117,6 @@ get_config() {
|
||||
|
||||
[ -n "$LOGFORMAT" ] || LOGFORMAT="Shorewall:"
|
||||
|
||||
export LOGFORMAT
|
||||
|
||||
if [ -n "$IPTABLES" ]; then
|
||||
if [ ! -x "$IPTABLES" ]; then
|
||||
echo " ERROR: The program specified in IPTABLES does not exist or is not executable" >&2
|
||||
@@ -132,8 +130,6 @@ get_config() {
|
||||
fi
|
||||
fi
|
||||
|
||||
export IPTABLES
|
||||
|
||||
if [ -n "$SHOREWALL_SHELL" ]; then
|
||||
if [ ! -x "$SHOREWALL_SHELL" ]; then
|
||||
echo " WARNING: The program specified in SHOREWALL_SHELL does not exist or is not executable; falling back to /bin/sh" >&2
|
||||
@@ -145,15 +141,20 @@ get_config() {
|
||||
|
||||
validate_restorefile RESTOREFILE
|
||||
|
||||
export RESTOREFILE
|
||||
|
||||
[ -n "${VERBOSITY:=2}" ]
|
||||
|
||||
[ -n "$USE_VERBOSITY" ] && VERBOSE=$USE_VERBOSITY || VERBOSE=$(($VERBOSE_OFFSET + $VERBOSITY))
|
||||
[ -n "$g_use_verbosity" ] && VERBOSITY=$g_use_verbosity || VERBOSITY=$(($g_verbose_offset + $VERBOSITY))
|
||||
|
||||
export VERBOSE
|
||||
g_hostname=$(hostname 2> /dev/null)
|
||||
|
||||
[ -n "${HOSTNAME:=$(hostname)}" ]
|
||||
IP=$(mywhich ip 2> /dev/null)
|
||||
if [ -z "$IP" ] ; then
|
||||
echo " ERROR: Can't find ip executable" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
IPSET=ipset
|
||||
TC=tc
|
||||
|
||||
}
|
||||
|
||||
@@ -161,13 +162,13 @@ get_config() {
|
||||
# Verify that we have a compiled firewall script
|
||||
#
|
||||
verify_firewall_script() {
|
||||
if [ ! -f $FIREWALL ]; then
|
||||
if [ ! -f $g_firewall ]; then
|
||||
echo " ERROR: Shorewall Lite is not properly installed" >&2
|
||||
if [ -L $FIREWALL ]; then
|
||||
echo " $FIREWALL is a symbolic link to a" >&2
|
||||
if [ -L $g_firewall ]; then
|
||||
echo " $g_firewall is a symbolic link to a" >&2
|
||||
echo " non-existant file" >&2
|
||||
else
|
||||
echo " The file $FIREWALL does not exist" >&2
|
||||
echo " The file $g_firewall does not exist" >&2
|
||||
fi
|
||||
|
||||
exit 2
|
||||
@@ -187,7 +188,7 @@ start_command() {
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
|
||||
if [ -x ${LITEDIR}/firewall ]; then
|
||||
${LITEDIR}/firewall $debugging start
|
||||
run_it ${LITEDIR}/firewall $debugging start
|
||||
rc=$?
|
||||
else
|
||||
error_message "${LITEDIR}/firewall is missing or is not executable"
|
||||
@@ -219,12 +220,12 @@ start_command() {
|
||||
option=
|
||||
;;
|
||||
f*)
|
||||
FAST=Yes
|
||||
g_fast=Yes
|
||||
option=${option#f}
|
||||
;;
|
||||
p*)
|
||||
[ -n "$(which conntrack)" ] || fatal_error "The '-p' option requires the conntrack utility which does not appear to be installed on this system"
|
||||
PURGE=Yes
|
||||
g_purge=Yes
|
||||
option=${option%p}
|
||||
;;
|
||||
*)
|
||||
@@ -248,36 +249,21 @@ start_command() {
|
||||
;;
|
||||
esac
|
||||
|
||||
export NOROUTES
|
||||
|
||||
if [ -n "$FAST" ]; then
|
||||
if [ -n "$g_fast" ]; then
|
||||
if qt mywhich make; then
|
||||
#
|
||||
# RESTOREFILE is exported by get_config()
|
||||
#
|
||||
make -qf ${CONFDIR}/Makefile || FAST=
|
||||
export RESTOREFILE
|
||||
make -qf ${CONFDIR}/Makefile || g_fast=
|
||||
fi
|
||||
|
||||
if [ -n "$FAST" ]; then
|
||||
if [ -n "$g_fast" ]; then
|
||||
|
||||
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
||||
|
||||
if [ -x $RESTOREPATH ]; then
|
||||
if [ -x ${RESTOREPATH}-ipsets ]; then
|
||||
echo Restoring Ipsets...
|
||||
#
|
||||
# We must purge iptables to be sure that there are no
|
||||
# references to ipsets
|
||||
#
|
||||
iptables -F
|
||||
iptables -X
|
||||
$SHOREWALL_SHELL ${RESTOREPATH}-ipsets
|
||||
fi
|
||||
g_restorepath=${VARDIR}/$RESTOREFILE
|
||||
|
||||
if [ -x $g_restorepath ]; then
|
||||
echo Restoring Shorewall Lite...
|
||||
$SHOREWALL_SHELL $RESTOREPATH restore
|
||||
run_it $g_restorepath restore
|
||||
date > ${VARDIR}/restarted
|
||||
progress_message3 Shorewall Lite restored from $RESTOREPATH
|
||||
progress_message3 Shorewall Lite restored from $g_restorepath
|
||||
else
|
||||
do_it
|
||||
fi
|
||||
@@ -313,12 +299,12 @@ restart_command() {
|
||||
option=
|
||||
;;
|
||||
n*)
|
||||
NOROUTES=Yes
|
||||
g_noroutes=Yes
|
||||
option=${option#n}
|
||||
;;
|
||||
p*)
|
||||
[ -n "$(which conntrack)" ] || fatal_error "The '-p' option requires the conntrack utility which does not appear to be installed on this system"
|
||||
PURGE=Yes
|
||||
g_purge=Yes
|
||||
option=${option%p}
|
||||
;;
|
||||
*)
|
||||
@@ -342,12 +328,10 @@ restart_command() {
|
||||
;;
|
||||
esac
|
||||
|
||||
export NOROUTES
|
||||
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
|
||||
if [ -x ${LITEDIR}/firewall ]; then
|
||||
$SHOREWALL_SHELL ${LITEDIR}/firewall $debugging restart
|
||||
run_it ${LITEDIR}/firewall $debugging restart
|
||||
rc=$?
|
||||
else
|
||||
error_message "${LITEDIR}/firewall is missing or is not executable"
|
||||
@@ -366,13 +350,14 @@ usage() # $1 = exit status
|
||||
{
|
||||
echo "Usage: $(basename $0) [debug|trace] [nolock] [ -q ] [ -v[-1|{0-2}] ] [ -t ] <command>"
|
||||
echo "where <command> is one of:"
|
||||
echo " add <interface>[:<host-list>] ... <zone>"
|
||||
echo " allow <address> ..."
|
||||
echo " clear"
|
||||
echo " clear [ -f ]"
|
||||
echo " delete <interface>[:<host-list>] ... <zone>"
|
||||
echo " drop <address> ..."
|
||||
echo " dump [ -x ]"
|
||||
echo " forget [ <file name> ]"
|
||||
echo " help"
|
||||
echo " hits [ -t ]"
|
||||
echo " ipcalc { <address>/<vlsm> | <address> <netmask> }"
|
||||
echo " ipdecimal { <address> | <integer> }"
|
||||
echo " iprange <address>-<address>"
|
||||
@@ -381,7 +366,7 @@ usage() # $1 = exit status
|
||||
echo " logwatch [<refresh interval>]"
|
||||
echo " reject <address> ..."
|
||||
echo " reset [ <chain> ... ]"
|
||||
echo " restart [ -n ] [ -p ]"
|
||||
echo " restart [ -n ] [ -p ] [ -f ] [ <directory> ]"
|
||||
echo " restore [ -n ] [ <file name> ]"
|
||||
echo " save [ <file name> ]"
|
||||
echo " show [ -x ] [ -t {filter|mangle|nat} ] [ {chain [<chain> [ <chain> ... ]"
|
||||
@@ -389,19 +374,18 @@ usage() # $1 = exit status
|
||||
echo " show classifiers"
|
||||
echo " show config"
|
||||
echo " show connections"
|
||||
echo " show dynamic <zone>"
|
||||
echo " show filter"
|
||||
echo " show filters"
|
||||
echo " show ip"
|
||||
echo " show [ -m ] log"
|
||||
echo " show [ -x ] mangle|nat|raw"
|
||||
echo " show routing"
|
||||
echo " show tc"
|
||||
echo " show [ -x ] mangle|nat|raw|routing"
|
||||
echo " show policies"
|
||||
echo " show tc [ device ]"
|
||||
echo " show vardir"
|
||||
echo " show zones"
|
||||
echo " start [ -n ] [ -p ]"
|
||||
echo " stop"
|
||||
echo " start [ -f ] [ -p ] [ <directory> ]"
|
||||
echo " stop [ -f ]"
|
||||
echo " status"
|
||||
echo " version"
|
||||
echo " version [ -a ]"
|
||||
echo
|
||||
exit $1
|
||||
}
|
||||
@@ -423,14 +407,13 @@ if [ $# -gt 0 ] && [ "$1" = "nolock" ]; then
|
||||
shift
|
||||
fi
|
||||
|
||||
IPT_OPTIONS="-nv"
|
||||
FAST=
|
||||
VERBOSE_OFFSET=0
|
||||
USE_VERBOSITY=
|
||||
NOROUTES=
|
||||
EXPORT=
|
||||
export TIMESTAMP=
|
||||
noroutes=
|
||||
g_ipt_options="-nv"
|
||||
g_fast=
|
||||
g_verbose_offset=0
|
||||
g_use_verbosity=
|
||||
g_noroutes=
|
||||
g_timestamp=
|
||||
g_recovering=
|
||||
|
||||
finished=0
|
||||
|
||||
@@ -449,48 +432,48 @@ while [ $finished -eq 0 ]; do
|
||||
while [ -n "$option" ]; do
|
||||
case $option in
|
||||
x*)
|
||||
IPT_OPTIONS="-xnv"
|
||||
g_ipt_options="-xnv"
|
||||
option=${option#x}
|
||||
;;
|
||||
q*)
|
||||
VERBOSE_OFFSET=$(($VERBOSE_OFFSET - 1 ))
|
||||
g_verbose_offset=$(($g_verbose_offset - 1 ))
|
||||
option=${option#q}
|
||||
;;
|
||||
f*)
|
||||
FAST=Yes
|
||||
g_fast=Yes
|
||||
option=${option#f}
|
||||
;;
|
||||
v*)
|
||||
option=${option#v}
|
||||
case $option in
|
||||
-1*)
|
||||
USE_VERBOSITY=-1
|
||||
g_use_verbosity=-1
|
||||
option=${option#-1}
|
||||
;;
|
||||
0*)
|
||||
USE_VERBOSITY=0
|
||||
g_use_verbosity=0
|
||||
option=${option#0}
|
||||
;;
|
||||
1*)
|
||||
USE_VERBOSITY=1
|
||||
g_use_verbosity=1
|
||||
option=${option#1}
|
||||
;;
|
||||
2*)
|
||||
USE_VERBOSITY=2
|
||||
g_use_verbosity=2
|
||||
option=${option#2}
|
||||
;;
|
||||
*)
|
||||
VERBOSE_OFFSET=$(($VERBOSE_OFFSET + 1 ))
|
||||
USE_VERBOSITY=
|
||||
g_verbose_offset=$(($g_verbose_offset + 1 ))
|
||||
g_use_verbosity=
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
n*)
|
||||
NOROUTES=Yes
|
||||
g_noroutes=Yes
|
||||
option=${option#n}
|
||||
;;
|
||||
t*)
|
||||
TIMESTAMP=Yes
|
||||
g_timestamp=Yes
|
||||
option=${option#t}
|
||||
;;
|
||||
-)
|
||||
@@ -515,12 +498,11 @@ if [ $# -eq 0 ]; then
|
||||
fi
|
||||
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
||||
export PATH
|
||||
MUTEX_TIMEOUT=
|
||||
|
||||
SHAREDIR=/usr/share/shorewall-lite
|
||||
CONFDIR=/etc/shorewall-lite
|
||||
export PRODUCT="Shorewall Lite"
|
||||
g_product="Shorewall Lite"
|
||||
|
||||
[ -f ${CONFDIR}/vardir ] && . ${CONFDIR}/vardir ]
|
||||
|
||||
@@ -528,17 +510,10 @@ export PRODUCT="Shorewall Lite"
|
||||
|
||||
[ -d $VARDIR ] || mkdir -p $VARDIR || fatal_error "Unable to create $VARDIR"
|
||||
|
||||
LIBRARIES="$SHAREDIR/lib.base $SHAREDIR/lib.cli"
|
||||
VERSION_FILE=$SHAREDIR/version
|
||||
HELP=$SHAREDIR/help
|
||||
version_file=$SHAREDIR/version
|
||||
|
||||
for library in $LIBRARIES; do
|
||||
if [ -f $library ]; then
|
||||
. $library
|
||||
else
|
||||
echo "Installation error: $library does not exist!" >&2
|
||||
exit 2
|
||||
fi
|
||||
for library in base cli; do
|
||||
. ${SHAREDIR}/lib.$library
|
||||
done
|
||||
|
||||
ensure_config_path
|
||||
@@ -558,7 +533,6 @@ else
|
||||
fi
|
||||
|
||||
ensure_config_path
|
||||
export CONFIG_PATH
|
||||
|
||||
LITEDIR=${VARDIR}
|
||||
|
||||
@@ -566,17 +540,17 @@ LITEDIR=${VARDIR}
|
||||
|
||||
get_config
|
||||
|
||||
FIREWALL=$LITEDIR/firewall
|
||||
g_firewall=$LITEDIR/firewall
|
||||
|
||||
if [ -f $VERSION_FILE ]; then
|
||||
version=$(cat $VERSION_FILE)
|
||||
if [ -f $version_file ]; then
|
||||
SHOREWALL_VERSION=$(cat $version_file)
|
||||
else
|
||||
echo " ERROR: Shorewall Lite is not properly installed" >&2
|
||||
echo " The file $VERSION_FILE does not exist" >&2
|
||||
echo " The file $version_file does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
banner="Shorewall Lite $version Status at $HOSTNAME -"
|
||||
banner="Shorewall Lite $SHOREWALL_VERSION Status at $g_hostname -"
|
||||
|
||||
case $(echo -e) in
|
||||
-e*)
|
||||
@@ -608,12 +582,11 @@ case "$COMMAND" in
|
||||
stop|clear)
|
||||
[ $# -ne 1 ] && usage 1
|
||||
verify_firewall_script
|
||||
export NOROUTES
|
||||
exec $SHOREWALL_SHELL $FIREWALL $debugging $nolock $COMMAND
|
||||
run_it $g_firewall $debugging $nolock $COMMAND
|
||||
;;
|
||||
reset)
|
||||
verify_firewall_script
|
||||
exec $SHOREWALL_SHELL $FIREWALL $debugging $nolock $@
|
||||
run_it $SHOREWALL_SHELL $g_firewall $debugging $nolock $@
|
||||
;;
|
||||
restart)
|
||||
shift
|
||||
@@ -626,7 +599,7 @@ case "$COMMAND" in
|
||||
status)
|
||||
[ $# -eq 1 ] || usage 1
|
||||
[ "$(id -u)" != 0 ] && fatal_error "ERROR: The status command may only be run by root"
|
||||
echo "Shorewall Lite $version Status at $HOSTNAME - $(date)"
|
||||
echo "Shorewall Lite $SHOREWALL_VERSION Status at $g_hostname - $(date)"
|
||||
echo
|
||||
if shorewall_is_started ; then
|
||||
echo "Shorewall Lite is running"
|
||||
@@ -660,7 +633,7 @@ case "$COMMAND" in
|
||||
hits_command $@
|
||||
;;
|
||||
version)
|
||||
echo $version Lite
|
||||
echo $SHOREWALL_VERSION Lite
|
||||
;;
|
||||
logwatch)
|
||||
logwatch_command $@
|
||||
@@ -729,7 +702,7 @@ case "$COMMAND" in
|
||||
;;
|
||||
esac
|
||||
|
||||
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
||||
g_restorepath=${VARDIR}/$RESTOREFILE
|
||||
|
||||
[ "$nolock" ] || mutex_on
|
||||
|
||||
@@ -751,20 +724,20 @@ case "$COMMAND" in
|
||||
esac
|
||||
|
||||
|
||||
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
||||
g_restorepath=${VARDIR}/$RESTOREFILE
|
||||
|
||||
if [ -x $RESTOREPATH ]; then
|
||||
if [ -x $g_restorepath ]; then
|
||||
|
||||
if [ -x ${RESTOREPATH}-ipsets ]; then
|
||||
rm -f ${RESTOREPATH}-ipsets
|
||||
echo " ${RESTOREPATH}-ipsets removed"
|
||||
if [ -x ${g_restorepath}-ipsets ]; then
|
||||
rm -f ${g_restorepath}-ipsets
|
||||
echo " ${g_restorepath}-ipsets removed"
|
||||
fi
|
||||
|
||||
rm -f $RESTOREPATH
|
||||
rm -f ${RESTOREPATH}-iptables
|
||||
echo " $RESTOREPATH removed"
|
||||
elif [ -f $RESTOREPATH ]; then
|
||||
echo " $RESTOREPATH exists and is not a saved Shorewall configuration"
|
||||
rm -f $g_restorepath
|
||||
rm -f ${g_restorepath}-iptables
|
||||
echo " $g_restorepath removed"
|
||||
elif [ -f $g_restorepath ]; then
|
||||
echo " $g_restorepath exists and is not a saved Shorewall configuration"
|
||||
fi
|
||||
rm -f ${VARDIR}/save
|
||||
;;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
%define name shorewall-lite
|
||||
%define version 4.4.2
|
||||
%define release 2
|
||||
%define version 4.4.8
|
||||
%define release 0base
|
||||
|
||||
Summary: Shoreline Firewall Lite is an iptables-based firewall for Linux systems.
|
||||
Name: %{name}
|
||||
@@ -79,6 +79,8 @@ fi
|
||||
%attr(0755,root,root) %dir /usr/share/shorewall-lite
|
||||
%attr(0700,root,root) %dir /var/lib/shorewall-lite
|
||||
|
||||
%attr(0644,root,root) /etc/logrotate.d/shorewall-lite
|
||||
|
||||
%attr(0755,root,root) /sbin/shorewall-lite
|
||||
|
||||
%attr(0644,root,root) /usr/share/shorewall-lite/version
|
||||
@@ -86,6 +88,7 @@ fi
|
||||
%attr(- ,root,root) /usr/share/shorewall-lite/functions
|
||||
%attr(0644,root,root) /usr/share/shorewall-lite/lib.base
|
||||
%attr(0644,root,root) /usr/share/shorewall-lite/lib.cli
|
||||
%attr(0644,root,root) /usr/share/shorewall-lite/lib.common
|
||||
%attr(0644,root,root) /usr/share/shorewall-lite/modules
|
||||
%attr(0544,root,root) /usr/share/shorewall-lite/shorecap
|
||||
%attr(0755,root,root) /usr/share/shorewall-lite/wait4ifup
|
||||
@@ -98,10 +101,44 @@ fi
|
||||
%doc COPYING changelog.txt releasenotes.txt
|
||||
|
||||
%changelog
|
||||
* Sat Oct 03 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.2-2
|
||||
* Fri Oct 02 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.2-1
|
||||
* Fri Mar 19 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0base
|
||||
* Tue Mar 16 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0RC2
|
||||
* Mon Mar 08 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0RC1
|
||||
* Sun Feb 28 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0Beta2
|
||||
* Thu Feb 11 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0Beta1
|
||||
* Fri Feb 05 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0base
|
||||
* Tue Feb 02 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0RC2
|
||||
* Wed Jan 27 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0RC1
|
||||
* Mon Jan 25 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0Beta4
|
||||
* Fri Jan 22 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0Beta3
|
||||
* Fri Jan 22 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0Beta2
|
||||
* Sun Jan 17 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0Beta1
|
||||
* Wed Jan 13 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.6-0base
|
||||
* Tue Jan 12 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.6-0Beta1
|
||||
* Thu Dec 24 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.5-0base
|
||||
* Sat Nov 21 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.4-0base
|
||||
* Fri Nov 13 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.4-0Beta2
|
||||
* Wed Nov 11 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.4-0Beta1
|
||||
* Tue Nov 03 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.3-0base
|
||||
* Sun Sep 06 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.2-0base
|
||||
* Fri Sep 04 2009 Tom Eastep tom@shorewall.net
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2000,2001,2002,2003,2004,2005,2006,2007 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Shorewall documentation is available at http://shorewall.sourceforge.net
|
||||
#
|
||||
@@ -26,7 +26,7 @@
|
||||
# You may only use this script to uninstall the version
|
||||
# shown below. Simply run this script to remove Shorewall Firewall
|
||||
|
||||
VERSION=4.4.2.2
|
||||
VERSION=4.4.8
|
||||
|
||||
usage() # $1 = exit status
|
||||
{
|
||||
@@ -106,6 +106,7 @@ rm -rf /var/lib/shorewall-lite
|
||||
rm -rf /var/lib/shorewall-lite-*.bkout
|
||||
rm -rf /usr/share/shorewall-lite
|
||||
rm -rf /usr/share/shorewall-lite-*.bkout
|
||||
rm -f /etc/logrotate.d/shorewall-lite
|
||||
|
||||
echo "Shorewall Uninstalled"
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Shorewall WAN Interface monitor - V4.2
|
||||
# Shorewall WAN Interface monitor - V4.4
|
||||
#
|
||||
# Inspired by Angsuman Chakraborty's gwping script.
|
||||
#
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# Shorewall WAN Interface monitor - V4.2
|
||||
# Shorewall WAN Interface monitor - V4.4
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
|
@@ -3,9 +3,9 @@
|
||||
#
|
||||
# /usr/share/shorewall/macro.BGP
|
||||
#
|
||||
# This macro handles BGP4 traffic.
|
||||
# This macro handles BGP4 traffic.
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
# PORT(S) PORT(S) LIMIT GROUP
|
||||
PARAM - - tcp 179 # BGP4
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
# PORT(S) PORT(S) LIMIT GROUP
|
||||
PARAM - - tcp 179 # BGP4
|
||||
|
@@ -3,11 +3,12 @@
|
||||
#
|
||||
# /usr/share/shorewall/macro.Citrix
|
||||
#
|
||||
# This macro handles Citrix/ICA traffic (ICA, ICA Browser, CGP a.k.a. ICA Session Reliability)
|
||||
# This macro handles Citrix/ICA traffic (ICA, ICA Browser, CGP a.k.a.
|
||||
# ICA Session Reliability)
|
||||
#
|
||||
####################################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
# PORT(S) PORT(S) LIMIT GROUP
|
||||
PARAM - - tcp 1494 # ICA
|
||||
PARAM - - udp 1604 # ICA Browser
|
||||
PARAM - - tcp 2598 # CGP Session Reliabilty
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
# PORT(S) PORT(S) LIMIT GROUP
|
||||
PARAM - - tcp 1494 # ICA
|
||||
PARAM - - udp 1604 # ICA Browser
|
||||
PARAM - - tcp 2598 # CGP Session Reliabilty
|
||||
|
12
Shorewall/Macros/macro.DHCPfwd
Normal file
12
Shorewall/Macros/macro.DHCPfwd
Normal file
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# Shorewall version 4 - DHCPfwd Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.DHCPfwd
|
||||
#
|
||||
# This macro (bidirectional) handles forwarded DHCP traffic
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
# PORT(S) PORT(S) LIMIT GROUP
|
||||
PARAM - - udp 67:68 67:68 # DHCP
|
||||
PARAM DEST SOURCE udp 67:68 67:68 # DHCP
|
11
Shorewall/Macros/macro.HKP
Normal file
11
Shorewall/Macros/macro.HKP
Normal file
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Shorewall version 4 - HKP Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.HKP
|
||||
#
|
||||
# This macro handles OpenPGP HTTP keyserver protocol traffic.
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
# PORT(S) PORT(S) LIMIT GROUP
|
||||
PARAM - - tcp 11371
|
@@ -3,9 +3,9 @@
|
||||
#
|
||||
# /usr/share/shorewall/macro.OSPF
|
||||
#
|
||||
# This macro handles OSPF multicast traffic
|
||||
# This macro handles OSPF multicast traffic
|
||||
#
|
||||
#######################################################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ ORIGINAL
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP DEST
|
||||
PARAM - - 89 - # OSPF
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
# PORT(S) PORT(S) LIMIT GROUP
|
||||
PARAM - - 89 # OSPF
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# /usr/share/shorewall/macro.Razor
|
||||
#
|
||||
# This macro handles traffic for the Razor Antispam System
|
||||
# This macro handles traffic for the Razor Antispam System
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
|
@@ -1,12 +1,14 @@
|
||||
#
|
||||
# Shorewall version 4 - Multicast DNS Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.DNS
|
||||
# /usr/share/shorewall/macro.mDNS
|
||||
#
|
||||
# This macro handles multicast DNS traffic.
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
# PORT(S) PORT(S) LIMIT GROUP
|
||||
PARAM - - udp 5353
|
||||
PARAM DEST SOURCE udp 5353
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
# PORT(S) PORT(S) LIMIT GROUP
|
||||
PARAM - 224.0.0.251 udp 5353
|
||||
PARAM - 224.0.0.251 2
|
||||
PARAM DEST SOURCE:224.0.0.251 udp 5353
|
||||
PARAM DEST SOURCE:224.0.0.251 2
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007,2008 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -35,7 +35,7 @@ use strict;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw( setup_accounting );
|
||||
our @EXPORT_OK = qw( );
|
||||
our $VERSION = '4.4_1';
|
||||
our $VERSION = '4.4.7';
|
||||
|
||||
#
|
||||
# Called by the compiler to [re-]initialize this module's state
|
||||
@@ -84,7 +84,7 @@ sub process_accounting_rule( ) {
|
||||
$ports = '' if $ports eq 'any' || $ports eq 'all';
|
||||
$sports = '' if $sports eq 'any' || $sports eq 'all';
|
||||
|
||||
my $rule = do_proto( $proto, $ports, $sports ) . do_user ( $user ) . do_test ( $mark, 0xFF );
|
||||
my $rule = do_proto( $proto, $ports, $sports ) . do_user ( $user ) . do_test ( $mark, $globals{TC_MASK} );
|
||||
my $rule2 = 0;
|
||||
|
||||
unless ( $action eq 'COUNT' ) {
|
||||
@@ -185,17 +185,17 @@ sub setup_accounting() {
|
||||
if ( have_bridges ) {
|
||||
if ( $filter_table->{accounting} ) {
|
||||
for my $chain ( qw/INPUT FORWARD/ ) {
|
||||
insert_rule1 $filter_table->{$chain}, 0, '-j accounting';
|
||||
add_jump( $filter_table->{$chain}, 'accounting', 0, '', 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $filter_table->{accountout} ) {
|
||||
insert_rule1 $filter_table->{OUTPUT}, 0, '-j accountout';
|
||||
add_jump( $filter_table->{OUTPUT}, 'accountout', 0, '', 0, 0 );
|
||||
}
|
||||
} else {
|
||||
if ( $filter_table->{accounting} ) {
|
||||
for my $chain ( qw/INPUT FORWARD OUTPUT/ ) {
|
||||
insert_rule1 $filter_table->{$chain}, 0, '-j accounting';
|
||||
add_jump( $filter_table->{$chain}, 'accounting', 0, '', 0, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007,2008 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -57,7 +57,7 @@ our @EXPORT = qw( merge_levels
|
||||
$macro_commands
|
||||
);
|
||||
our @EXPORT_OK = qw( initialize );
|
||||
our $VERSION = '4.4_2';
|
||||
our $VERSION = '4.4_7';
|
||||
|
||||
#
|
||||
# Used Actions. Each action that is actually used has an entry with value 1.
|
||||
@@ -213,7 +213,7 @@ sub merge_macro_source_dest( $$ ) {
|
||||
if ( $invocation ) {
|
||||
if ( $body ) {
|
||||
return $body if $invocation eq '-';
|
||||
return "$body:$invocation" if $invocation =~ /.*?\.*?\.|^\+|^~|^!~/;
|
||||
return "$body:$invocation" if $invocation =~ /.*?\.*?\.|^\+|^!+|^~|^!~|~<|~\[/;
|
||||
return "$invocation:$body";
|
||||
}
|
||||
|
||||
@@ -305,10 +305,10 @@ sub map_old_actions( $ ) {
|
||||
# Create and record a log action chain -- Log action chains have names
|
||||
# that are formed from the action name by prepending a "%" and appending
|
||||
# a 1- or 2-digit sequence number. In the functions that follow,
|
||||
# the CHAIN, LEVEL and TAG variable serves as arguments to the user's
|
||||
# the $chain, $level and $tag variable serves as arguments to the user's
|
||||
# exit. We call the exit corresponding to the name of the action but we
|
||||
# set CHAIN to the name of the iptables chain where rules are to be added.
|
||||
# Similarly, LEVEL and TAG contain the log level and log tag respectively.
|
||||
# set $chain to the name of the iptables chain where rules are to be added.
|
||||
# Similarly, $level and $tag contain the log level and log tag respectively.
|
||||
#
|
||||
# The maximum length of a chain name is 30 characters -- since the log
|
||||
# action chain name is 2-3 characters longer than the base chain name,
|
||||
@@ -341,6 +341,8 @@ sub createlogactionchain( $$ ) {
|
||||
|
||||
unless ( $targets{$action} & BUILTIN ) {
|
||||
|
||||
dont_optimize $chainref;
|
||||
|
||||
my $file = find_file $chain;
|
||||
|
||||
if ( -f $file ) {
|
||||
@@ -367,6 +369,8 @@ sub createsimpleactionchain( $ ) {
|
||||
|
||||
unless ( $targets{$action} & BUILTIN ) {
|
||||
|
||||
dont_optimize $chainref;
|
||||
|
||||
my $file = find_file $action;
|
||||
|
||||
if ( -f $file ) {
|
||||
@@ -384,7 +388,7 @@ sub createsimpleactionchain( $ ) {
|
||||
}
|
||||
|
||||
#
|
||||
# Create an action chain and run it's associated user exit
|
||||
# Create an action chain and run its associated user exit
|
||||
#
|
||||
sub createactionchain( $ ) {
|
||||
my ( $action , $level ) = split_action $_[0];
|
||||
@@ -574,7 +578,7 @@ sub process_actions2 () {
|
||||
for my $target (keys %usedactions) {
|
||||
my ($action, $level) = split_action $target;
|
||||
my $actionref = $actions{$action};
|
||||
fatal_error "Null Action Reference in process_actions2" unless $actionref;
|
||||
assert( $actionref );
|
||||
for my $action1 ( keys %{$actionref->{requires}} ) {
|
||||
my $action2 = merge_levels $target, $action1;
|
||||
unless ( $usedactions{ $action2 } ) {
|
||||
@@ -609,7 +613,7 @@ sub process_action( $$$$$$$$$$$ ) {
|
||||
|
||||
expand_rule ( $chainref ,
|
||||
NO_RESTRICT ,
|
||||
do_proto( $proto, $ports, $sports ) . do_ratelimit( $rate, $action ) . do_user $user . do_test( $mark, 0xFF ) ,
|
||||
do_proto( $proto, $ports, $sports ) . do_ratelimit( $rate, $action ) . do_user $user . do_test( $mark, $globals{TC_MASK} ) ,
|
||||
$source ,
|
||||
$dest ,
|
||||
'', #Original Dest
|
||||
@@ -766,10 +770,14 @@ sub process_action3( $$$$$ ) {
|
||||
sub dropBcast( $$$ ) {
|
||||
my ($chainref, $level, $tag) = @_;
|
||||
|
||||
if ( $capabilities{ADDRTYPE} ) {
|
||||
if ( have_capability( 'ADDRTYPE' ) ) {
|
||||
if ( $level ne '' ) {
|
||||
log_rule_limit $level, $chainref, 'dropBcast' , 'DROP', '', $tag, 'add', ' -m addrtype --dst-type BROADCAST ';
|
||||
log_rule_limit $level, $chainref, 'dropBcast' , 'DROP', '', $tag, 'add', ' -d 224.0.0.0/4 ';
|
||||
if ( $family == F_IPV4 ) {
|
||||
log_rule_limit $level, $chainref, 'dropBcast' , 'DROP', '', $tag, 'add', ' -d 224.0.0.0/4 ';
|
||||
} else {
|
||||
log_rule_limit $level, $chainref, 'dropBcast' , 'DROP', '', $tag, 'add', ' -d ff00::/10 -j DROP ';
|
||||
}
|
||||
}
|
||||
|
||||
add_rule $chainref, '-m addrtype --dst-type BROADCAST -j DROP';
|
||||
@@ -800,7 +808,7 @@ sub dropBcast( $$$ ) {
|
||||
sub allowBcast( $$$ ) {
|
||||
my ($chainref, $level, $tag) = @_;
|
||||
|
||||
if ( $family == F_IPV4 && $capabilities{ADDRTYPE} ) {
|
||||
if ( $family == F_IPV4 && have_capability( 'ADDRTYPE' ) ) {
|
||||
if ( $level ne '' ) {
|
||||
log_rule_limit $level, $chainref, 'allowBcast' , 'ACCEPT', '', $tag, 'add', ' -m addrtype --dst-type BROADCAST ';
|
||||
log_rule_limit $level, $chainref, 'allowBcast' , 'ACCEPT', '', $tag, 'add', ' -d 224.0.0.0/4 ';
|
||||
@@ -834,15 +842,15 @@ sub allowBcast( $$$ ) {
|
||||
sub dropNotSyn ( $$$ ) {
|
||||
my ($chainref, $level, $tag) = @_;
|
||||
|
||||
log_rule_limit $level, $chainref, 'dropNotSyn' , 'DROP', '', $tag, 'add', '-p tcp ! --syn ' if $level ne '';
|
||||
add_rule $chainref , '-p tcp ! --syn -j DROP';
|
||||
log_rule_limit $level, $chainref, 'dropNotSyn' , 'DROP', '', $tag, 'add', '-p 6 ! --syn ' if $level ne '';
|
||||
add_rule $chainref , '-p 6 ! --syn -j DROP';
|
||||
}
|
||||
|
||||
sub rejNotSyn ( $$$ ) {
|
||||
my ($chainref, $level, $tag) = @_;
|
||||
|
||||
log_rule_limit $level, $chainref, 'rejNotSyn' , 'REJECT', '', $tag, 'add', '-p tcp ! --syn ' if $level ne '';
|
||||
add_rule $chainref , '-p tcp ! --syn -j REJECT --reject-with tcp-reset';
|
||||
log_rule_limit $level, $chainref, 'rejNotSyn' , 'REJECT', '', $tag, 'add', '-p 6 ! --syn ' if $level ne '';
|
||||
add_rule $chainref , '-p 6 ! --syn -j REJECT --reject-with tcp-reset';
|
||||
}
|
||||
|
||||
sub dropInvalid ( $$$ ) {
|
||||
@@ -860,18 +868,19 @@ sub allowInvalid ( $$$ ) {
|
||||
}
|
||||
|
||||
sub forwardUPnP ( $$$ ) {
|
||||
dont_optimize 'forwardUPnP';
|
||||
}
|
||||
|
||||
sub allowinUPnP ( $$$ ) {
|
||||
my ($chainref, $level, $tag) = @_;
|
||||
|
||||
if ( $level ne '' ) {
|
||||
log_rule_limit $level, $chainref, 'allowinUPnP' , 'ACCEPT', '', $tag, 'add', '-p udp --dport 1900 ';
|
||||
log_rule_limit $level, $chainref, 'allowinUPnP' , 'ACCEPT', '', $tag, 'add', '-p tcp --dport 49152 ';
|
||||
log_rule_limit $level, $chainref, 'allowinUPnP' , 'ACCEPT', '', $tag, 'add', '-p 17 --dport 1900 ';
|
||||
log_rule_limit $level, $chainref, 'allowinUPnP' , 'ACCEPT', '', $tag, 'add', '-p 6 --dport 49152 ';
|
||||
}
|
||||
|
||||
add_rule $chainref, '-p udp --dport 1900 -j ACCEPT';
|
||||
add_rule $chainref, '-p tcp --dport 49152 -j ACCEPT';
|
||||
add_rule $chainref, '-p 17 --dport 1900 -j ACCEPT';
|
||||
add_rule $chainref, '-p 6 --dport 49152 -j ACCEPT';
|
||||
}
|
||||
|
||||
sub Limit( $$$ ) {
|
||||
@@ -897,7 +906,7 @@ sub Limit( $$$ ) {
|
||||
my $xchainref = new_chain 'filter' , "$chainref->{name}%";
|
||||
log_rule_limit $level, $xchainref, $tag[0], 'DROP', '', '', 'add', '';
|
||||
add_rule $xchainref, '-j DROP';
|
||||
add_rule $chainref, "-m recent --name $set --update --seconds $tag[2] --hitcount $count -j $xchainref->{name}";
|
||||
add_jump $chainref, $xchainref, 0, "-m recent --name $set --update --seconds $tag[2] --hitcount $count ";
|
||||
} else {
|
||||
add_rule $chainref, "-m recent --update --name $set --seconds $tag[2] --hitcount $count -j DROP";
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007,2008,2009 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -41,9 +41,9 @@ use Shorewall::IPAddrs;
|
||||
use Shorewall::Raw;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw( compiler EXPORT TIMESTAMP DEBUG );
|
||||
our @EXPORT = qw( compiler );
|
||||
our @EXPORT_OK = qw( $export );
|
||||
our $VERSION = '4.4_2';
|
||||
our $VERSION = '4.4_8';
|
||||
|
||||
our $export;
|
||||
|
||||
@@ -72,9 +72,12 @@ sub initialize_package_globals() {
|
||||
#
|
||||
# First stage of script generation.
|
||||
#
|
||||
# Copy prog.header to the generated script.
|
||||
# Copy prog.header and lib.common to the generated script.
|
||||
# Generate the various user-exit jacket functions.
|
||||
#
|
||||
# Note: This function is not called when $command eq 'check'. So it must have no side effects other
|
||||
# than those related to writing to the output script file.
|
||||
#
|
||||
sub generate_script_1() {
|
||||
|
||||
if ( $test ) {
|
||||
@@ -83,21 +86,25 @@ sub generate_script_1() {
|
||||
my $date = localtime;
|
||||
|
||||
emit "#!/bin/sh\n#\n# Compiled firewall script generated by Shorewall $globals{VERSION} - $date\n#";
|
||||
|
||||
if ( $family == F_IPV4 ) {
|
||||
copy $globals{SHAREDIRPL} . 'prog.header';
|
||||
} else {
|
||||
copy $globals{SHAREDIRPL} . 'prog.header6';
|
||||
}
|
||||
|
||||
copy2 $globals{SHAREDIR} . '/lib.common';
|
||||
}
|
||||
|
||||
my $lib = find_file 'lib.private';
|
||||
|
||||
copy2 $lib if -f $lib;
|
||||
|
||||
emit <<'EOF';
|
||||
################################################################################
|
||||
# Functions to execute the various user exits (extension scripts)
|
||||
################################################################################
|
||||
EOF
|
||||
my $lib = find_file 'lib.private';
|
||||
|
||||
copy1 $lib, emit "\n" if -f $lib;
|
||||
|
||||
for my $exit qw/init start tcclear started stop stopped clear refresh refreshed restored/ {
|
||||
emit "\nrun_${exit}_exit() {";
|
||||
@@ -129,7 +136,7 @@ EOF
|
||||
# Generate the 'initialize()' function.
|
||||
#
|
||||
# Note: This function is not called when $command eq 'check'. So it must have no side effects other
|
||||
# than those related to writing to the object file.
|
||||
# than those related to writing to the output script file.
|
||||
|
||||
sub generate_script_2() {
|
||||
|
||||
@@ -154,24 +161,24 @@ sub generate_script_2() {
|
||||
if ( $export ) {
|
||||
emit ( 'SHAREDIR=/usr/share/shorewall-lite',
|
||||
'CONFDIR=/etc/shorewall-lite',
|
||||
'PRODUCT="Shorewall Lite"'
|
||||
'g_product="Shorewall Lite"'
|
||||
);
|
||||
} else {
|
||||
emit ( 'SHAREDIR=/usr/share/shorewall',
|
||||
'CONFDIR=/etc/shorewall',
|
||||
'PRODUCT=\'Shorewall\'',
|
||||
'g_product=\'Shorewall\'',
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if ( $export ) {
|
||||
emit ( 'SHAREDIR=/usr/share/shorewall6-lite',
|
||||
'CONFDIR=/etc/shorewall6-lite',
|
||||
'PRODUCT="Shorewall6 Lite"'
|
||||
'g_product="Shorewall6 Lite"'
|
||||
);
|
||||
} else {
|
||||
emit ( 'SHAREDIR=/usr/share/shorewall6',
|
||||
'CONFDIR=/etc/shorewall6',
|
||||
'PRODUCT=\'Shorewall6\'',
|
||||
'g_product=\'Shorewall6\'',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -203,17 +210,15 @@ sub generate_script_2() {
|
||||
my @dont_load = split_list $config{DONT_LOAD}, 'module';
|
||||
|
||||
emit ( '[ -n "${COMMAND:=restart}" ]',
|
||||
'[ -n "${VERBOSE:=0}" ]',
|
||||
qq([ -n "\${RESTOREFILE:=$config{RESTOREFILE}}" ]),
|
||||
'[ -n "$LOGFORMAT" ] || LOGFORMAT="Shorewall:%s:%s:"' );
|
||||
'[ -n "${VERBOSITY:=0}" ]',
|
||||
qq([ -n "\${RESTOREFILE:=$config{RESTOREFILE}}" ]) );
|
||||
|
||||
emit ( qq(VERSION="$globals{VERSION}") ) unless $test;
|
||||
emit ( qq(SHOREWALL_VERSION="$globals{VERSION}") ) unless $test;
|
||||
|
||||
emit ( qq(PATH="$config{PATH}") ,
|
||||
'TERMINATOR=fatal_error' ,
|
||||
qq(DONT_LOAD="@dont_load") ,
|
||||
qq(STARTUP_LOG="$config{STARTUP_LOG}") ,
|
||||
"LOG_VERBOSE=$config{LOG_VERBOSITY}" ,
|
||||
''
|
||||
);
|
||||
|
||||
@@ -222,7 +227,7 @@ sub generate_script_2() {
|
||||
append_file 'params' if $config{EXPORTPARAMS};
|
||||
|
||||
emit ( '',
|
||||
"STOPPING=",
|
||||
"g_stopping=",
|
||||
'',
|
||||
'#',
|
||||
'# The library requires that ${VARDIR} exist',
|
||||
@@ -230,14 +235,24 @@ sub generate_script_2() {
|
||||
'[ -d ${VARDIR} ] || mkdir -p ${VARDIR}'
|
||||
);
|
||||
|
||||
pop_indent;
|
||||
|
||||
emit "\n}\n"; # End of initialize()
|
||||
|
||||
emit( '' ,
|
||||
'#' ,
|
||||
'# Set global variables holding detected IP information' ,
|
||||
'#' ,
|
||||
'detect_configuration()',
|
||||
'{' );
|
||||
|
||||
my $global_variables = have_global_variables;
|
||||
|
||||
push_indent;
|
||||
|
||||
if ( $global_variables ) {
|
||||
emit( '' ,
|
||||
'#' ,
|
||||
'# Set global variables holding detected IP information' ,
|
||||
'#' ,
|
||||
'case $COMMAND in' );
|
||||
|
||||
emit( 'case $COMMAND in' );
|
||||
|
||||
push_indent;
|
||||
|
||||
@@ -273,11 +288,13 @@ sub generate_script_2() {
|
||||
pop_indent;
|
||||
|
||||
emit ( 'esac' ) ,
|
||||
} else {
|
||||
emit( 'true' ) unless handle_optional_interfaces;
|
||||
}
|
||||
|
||||
pop_indent;
|
||||
|
||||
emit "\n}\n"; # End of initialize()
|
||||
emit "\n}\n"; # End of detect_configuration()
|
||||
|
||||
}
|
||||
|
||||
@@ -291,7 +308,7 @@ sub generate_script_2() {
|
||||
# Generate the 'define_firewall()' function.
|
||||
#
|
||||
# Note: This function is not called when $command eq 'check'. So it must have no side effects other
|
||||
# than those related to writing to the object file.
|
||||
# than those related to writing to the output script file.
|
||||
#
|
||||
sub generate_script_3($) {
|
||||
|
||||
@@ -313,9 +330,9 @@ sub generate_script_3($) {
|
||||
save_progress_message 'Initializing...';
|
||||
|
||||
if ( $export ) {
|
||||
my $fn = find_file 'modules';
|
||||
my $fn = find_file $config{LOAD_HELPERS_ONLY} ? 'helpers' : 'modules';
|
||||
|
||||
if ( $fn ne "$globals{SHAREDIR}/modules" && -f $fn ) {
|
||||
if ( -f $fn && ! $fn =~ "^$globals{SHAREDIR}/" ) {
|
||||
emit 'echo MODULESDIR="$MODULESDIR" > ${VARDIR}/.modulesdir';
|
||||
emit 'cat > ${VARDIR}/.modules << EOF';
|
||||
open_file $fn;
|
||||
@@ -334,15 +351,17 @@ sub generate_script_3($) {
|
||||
if ( $family == F_IPV4 ) {
|
||||
my @ipsets = all_ipsets;
|
||||
|
||||
if ( @ipsets ) {
|
||||
if ( @ipsets || $config{SAVE_IPSETS} ) {
|
||||
emit ( '',
|
||||
'local hack',
|
||||
'',
|
||||
'case $IPSET in',
|
||||
' */*)',
|
||||
' [ -x "$IPSET" ] || fatal_error "IPSET=$IPSET does not exist or is not executable"',
|
||||
' [ -x "$IPSET" ] || startup_error "IPSET=$IPSET does not exist or is not executable"',
|
||||
' ;;',
|
||||
' *)',
|
||||
' IPSET="$(mywhich $IPSET)"',
|
||||
' [ -n "$IPSET" ] || fatal_error "The ipset utility cannot be located"' ,
|
||||
' [ -n "$IPSET" ] || startup_error "The ipset utility cannot be located"' ,
|
||||
' ;;',
|
||||
'esac',
|
||||
'',
|
||||
@@ -352,20 +371,44 @@ sub generate_script_3($) {
|
||||
' $IPSET -X' ,
|
||||
' $IPSET -R < ${VARDIR}/ipsets.save' ,
|
||||
' fi' ,
|
||||
'' );
|
||||
'elif [ "$COMMAND" = restore -a -z "$g_recovering" ]; then' ,
|
||||
' if [ -f $(my_pathname)-ipsets ]; then' ,
|
||||
' if chain_exists shorewall; then' ,
|
||||
' startup_error "Cannot restore $(my_pathname)-ipsets with Shorewall running"' ,
|
||||
' else' ,
|
||||
' $IPSET -F' ,
|
||||
' $IPSET -X' ,
|
||||
' $IPSET -R < $(my_pathname)-ipsets' ,
|
||||
' fi' ,
|
||||
' fi' ,
|
||||
);
|
||||
|
||||
emit ( " qt \$IPSET -L $_ -n || \$IPSET -N $_ iphash" ) for @ipsets;
|
||||
if ( @ipsets ) {
|
||||
emit '';
|
||||
|
||||
emit ( '' ,
|
||||
'elif [ "$COMMAND" = restart ]; then' ,
|
||||
'' );
|
||||
emit ( " qt \$IPSET -L $_ -n || \$IPSET -N $_ iphash" ) for @ipsets;
|
||||
|
||||
emit ( " qt \$IPSET -L $_ -n || \$IPSET -N $_ iphash" ) for @ipsets;
|
||||
emit ( '' ,
|
||||
'elif [ "$COMMAND" = restart ]; then' ,
|
||||
'' );
|
||||
|
||||
emit ( " qt \$IPSET -L $_ -n || \$IPSET -N $_ iphash" ) for @ipsets;
|
||||
|
||||
emit ( '' ,
|
||||
' if [ -f /etc/debian_version ] && [ $(cat /etc/debian_version) = 5.0.3 ]; then' ,
|
||||
' #',
|
||||
' # The \'grep -v\' is a hack for a bug in ipset\'s nethash implementation when xtables-addons is applied to Lenny' ,
|
||||
' #',
|
||||
' hack=\'| grep -v /31\'' ,
|
||||
' else' ,
|
||||
' hack=' ,
|
||||
' fi' ,
|
||||
'',
|
||||
' if eval $IPSET -S $hack > ${VARDIR}/ipsets.tmp; then' ,
|
||||
' grep -q "^-N" ${VARDIR}/ipsets.tmp && mv -f ${VARDIR}/ipsets.tmp ${VARDIR}/ipsets.save' ,
|
||||
' fi' );
|
||||
}
|
||||
|
||||
emit ( '' ,
|
||||
' if $IPSET -S > ${VARDIR}/ipsets.tmp; then' ,
|
||||
' grep -q "^-N" ${VARDIR}/ipsets.tmp && mv -f ${VARDIR}/ipsets.tmp ${VARDIR}/ipsets.save' ,
|
||||
' fi' );
|
||||
emit ( 'fi',
|
||||
'' );
|
||||
}
|
||||
@@ -387,7 +430,7 @@ sub generate_script_3($) {
|
||||
''
|
||||
);
|
||||
|
||||
if ( $capabilities{NAT_ENABLED} ) {
|
||||
if ( have_capability( 'NAT_ENABLED' ) ) {
|
||||
emit( 'if [ -f ${VARDIR}/nat ]; then',
|
||||
' while read external interface; do',
|
||||
' del_ip_addr $external $interface',
|
||||
@@ -400,23 +443,10 @@ sub generate_script_3($) {
|
||||
emit "disable_ipv6\n" if $config{DISABLE_IPV6};
|
||||
|
||||
} else {
|
||||
emit ( '#',
|
||||
'# Recent kernels are difficult to configure -- we see state match omitted a lot so we check for it here',
|
||||
'#',
|
||||
'qt1 $IP6TABLES -N foox1234',
|
||||
'qt1 $IP6TABLES -A foox1234 -m state --state ESTABLISHED,RELATED -j ACCEPT',
|
||||
'result=$?',
|
||||
'qt1 $IP6TABLES -F foox1234',
|
||||
'qt1 $IP6TABLES -X foox1234',
|
||||
'[ $result = 0 ] || startup_error "Your kernel/ip6tables do not include state match support. No version of Shorewall6 will run on this system"',
|
||||
'' );
|
||||
|
||||
emit ( '[ "$COMMAND" = refresh ] && run_refresh_exit || run_init_exit',
|
||||
'',
|
||||
'qt1 $IP6TABLES -L shorewall -n && qt1 $IP6TABLES -F shorewall && qt1 $IP6TABLES -X shorewall',
|
||||
''
|
||||
);
|
||||
|
||||
'' );
|
||||
mark_firewall_not_started;
|
||||
emit '';
|
||||
}
|
||||
|
||||
emit qq(delete_tc1\n) if $config{CLEAR_TC};
|
||||
@@ -438,6 +468,10 @@ sub generate_script_3($) {
|
||||
dump_zone_contents;
|
||||
emit_unindented '__EOF__';
|
||||
|
||||
emit 'cat > ${VARDIR}/policies << __EOF__';
|
||||
save_policies;
|
||||
emit_unindented '__EOF__';
|
||||
|
||||
pop_indent;
|
||||
|
||||
emit "fi\n";
|
||||
@@ -465,6 +499,7 @@ EOF
|
||||
pop_indent;
|
||||
setup_forwarding( $family , 1 );
|
||||
push_indent;
|
||||
|
||||
emit<<'EOF';
|
||||
set_state "Started"
|
||||
run_restored_exit
|
||||
@@ -473,6 +508,7 @@ else
|
||||
chainlist_reload
|
||||
EOF
|
||||
setup_forwarding( $family , 0 );
|
||||
|
||||
emit<<'EOF';
|
||||
run_refreshed_exit
|
||||
do_iptables -N shorewall
|
||||
@@ -483,6 +519,7 @@ EOF
|
||||
conditionally_flush_conntrack
|
||||
EOF
|
||||
setup_forwarding( $family , 0 );
|
||||
|
||||
emit<<'EOF';
|
||||
run_start_exit
|
||||
do_iptables -N shorewall
|
||||
@@ -497,16 +534,16 @@ date > ${VARDIR}/restarted
|
||||
|
||||
case $COMMAND in
|
||||
start)
|
||||
logger -p kern.info "$PRODUCT started"
|
||||
logger -p kern.info "$g_product started"
|
||||
;;
|
||||
restart)
|
||||
logger -p kern.info "$PRODUCT restarted"
|
||||
logger -p kern.info "$g_product restarted"
|
||||
;;
|
||||
refresh)
|
||||
logger -p kern.info "$PRODUCT refreshed"
|
||||
logger -p kern.info "$g_product refreshed"
|
||||
;;
|
||||
restore)
|
||||
logger -p kern.info "$PRODUCT restored"
|
||||
logger -p kern.info "$g_product restored"
|
||||
;;
|
||||
esac
|
||||
EOF
|
||||
@@ -524,8 +561,8 @@ EOF
|
||||
#
|
||||
sub compiler {
|
||||
|
||||
my ( $objectfile, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity ) =
|
||||
( '', '', -1, '', 0, '', '', -1 );
|
||||
my ( $scriptfilename, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity, $preview ) =
|
||||
( '', '', -1, '', 0, '', '', -1, 0 );
|
||||
|
||||
$export = 0;
|
||||
$test = 0;
|
||||
@@ -545,7 +582,8 @@ sub compiler {
|
||||
defined($val) && ($val == F_IPV4 || $val == F_IPV6);
|
||||
}
|
||||
|
||||
my %parms = ( object => { store => \$objectfile },
|
||||
my %parms = ( object => { store => \$scriptfilename }, #Deprecated
|
||||
script => { store => \$scriptfilename },
|
||||
directory => { store => \$directory },
|
||||
family => { store => \$family , validate => \&validate_family } ,
|
||||
verbosity => { store => \$verbosity , validate => \&validate_verbosity } ,
|
||||
@@ -556,6 +594,7 @@ sub compiler {
|
||||
log => { store => \$log },
|
||||
log_verbosity => { store => \$log_verbosity, validate => \&validate_verbosity } ,
|
||||
test => { store => \$test },
|
||||
preview => { store => \$preview },
|
||||
);
|
||||
#
|
||||
# P A R A M E T E R P R O C E S S I N G
|
||||
@@ -589,16 +628,16 @@ sub compiler {
|
||||
#
|
||||
get_configuration( $export );
|
||||
|
||||
report_capabilities;
|
||||
report_capabilities unless $config{LOAD_HELPERS_ONLY};
|
||||
|
||||
require_capability( 'MULTIPORT' , "Shorewall $globals{VERSION}" , 's' );
|
||||
require_capability( 'RECENT_MATCH' , 'MACLIST_TTL' , 's' ) if $config{MACLIST_TTL};
|
||||
require_capability( 'XCONNMARK' , 'HIGH_ROUTE_MARKS=Yes' , 's' ) if $config{HIGH_ROUTE_MARKS};
|
||||
require_capability( 'XCONNMARK' , 'HIGH_ROUTE_MARKS=Yes' , 's' ) if $config{PROVIDER_OFFSET} > 0;
|
||||
require_capability( 'MANGLE_ENABLED' , 'Traffic Shaping' , 's' ) if $config{TC_ENABLED};
|
||||
|
||||
if ( $objectfile ) {
|
||||
if ( $scriptfilename ) {
|
||||
set_command( 'compile', 'Compiling', 'Compiled' );
|
||||
create_temp_object( $objectfile , $export );
|
||||
create_temp_script( $scriptfilename , $export );
|
||||
} else {
|
||||
set_command( 'check', 'Checking', 'Checked' );
|
||||
}
|
||||
@@ -644,11 +683,11 @@ sub compiler {
|
||||
#
|
||||
setup_notrack;
|
||||
|
||||
enable_object;
|
||||
enable_script;
|
||||
|
||||
if ( $objectfile ) {
|
||||
if ( $scriptfilename ) {
|
||||
#
|
||||
# Place Header in the object
|
||||
# Place Header in the script
|
||||
#
|
||||
generate_script_1;
|
||||
#
|
||||
@@ -664,11 +703,11 @@ sub compiler {
|
||||
push_indent;
|
||||
}
|
||||
#
|
||||
# Do all of the zone-independent stuff
|
||||
# Do all of the zone-independent stuff (mostly /proc)
|
||||
#
|
||||
add_common_rules;
|
||||
#
|
||||
# /proc stuff
|
||||
# More /proc
|
||||
#
|
||||
if ( $family == F_IPV4 ) {
|
||||
setup_arp_filtering;
|
||||
@@ -682,24 +721,24 @@ sub compiler {
|
||||
#
|
||||
setup_proxy_arp;
|
||||
#
|
||||
# Handle MSS setings in the zones file
|
||||
# Handle MSS settings in the zones file
|
||||
#
|
||||
setup_zone_mss;
|
||||
|
||||
if ( $objectfile ) {
|
||||
if ( $scriptfilename ) {
|
||||
emit 'return 0';
|
||||
pop_indent;
|
||||
emit '}';
|
||||
}
|
||||
|
||||
disable_object;
|
||||
disable_script;
|
||||
#
|
||||
# R O U T I N G _ A N D _ T R A F F I C _ S H A P I N G
|
||||
# (Writes the setup_routing_and_traffic_shaping() function to the compiled script)
|
||||
#
|
||||
enable_object;
|
||||
enable_script;
|
||||
|
||||
if ( $objectfile ) {
|
||||
if ( $scriptfilename ) {
|
||||
emit( "\n#",
|
||||
'# Setup routing and traffic shaping',
|
||||
'#',
|
||||
@@ -717,12 +756,12 @@ sub compiler {
|
||||
#
|
||||
setup_tc;
|
||||
|
||||
if ( $objectfile ) {
|
||||
if ( $scriptfilename ) {
|
||||
pop_indent;
|
||||
emit "}\n";
|
||||
}
|
||||
|
||||
disable_object;
|
||||
disable_script;
|
||||
#
|
||||
# N E T F I L T E R
|
||||
# (Produces no output to the compiled script -- rules are stored in the chain table)
|
||||
@@ -733,7 +772,7 @@ sub compiler {
|
||||
#
|
||||
# ECN
|
||||
#
|
||||
setup_ecn if $capabilities{MANGLE_ENABLED} && $config{MANGLE_ENABLED};
|
||||
setup_ecn if have_capability( 'MANGLE_ENABLED' ) && $config{MANGLE_ENABLED};
|
||||
#
|
||||
# Setup Masquerading/SNAT
|
||||
#
|
||||
@@ -776,15 +815,27 @@ sub compiler {
|
||||
#
|
||||
# Accounting.
|
||||
#
|
||||
setup_accounting;
|
||||
setup_accounting if $config{ACCOUNTING};
|
||||
|
||||
if ( $objectfile ) {
|
||||
if ( $scriptfilename ) {
|
||||
#
|
||||
# Generate the zone by zone matrix
|
||||
# Compiling a script - generate the zone by zone matrix
|
||||
#
|
||||
generate_matrix;
|
||||
|
||||
enable_object;
|
||||
if ( $config{OPTIMIZE} & 6 ) {
|
||||
progress_message2 'Optimizing Ruleset...';
|
||||
#
|
||||
# Optimize Policy Chains
|
||||
#
|
||||
optimize_policy_chains if $config{OPTIMIZE} & 2;
|
||||
#
|
||||
# More Optimization
|
||||
#
|
||||
optimize_ruleset if $config{OPTIMIZE} & 4;
|
||||
}
|
||||
|
||||
enable_script;
|
||||
#
|
||||
# I N I T I A L I Z E
|
||||
# (Writes the initialize() function to the compiled script)
|
||||
@@ -805,9 +856,9 @@ sub compiler {
|
||||
# S T O P _ F I R E W A L L
|
||||
# (Writes the stop_firewall() function to the compiled script)
|
||||
#
|
||||
compile_stop_firewall( $test );
|
||||
compile_stop_firewall( $test, $export );
|
||||
#
|
||||
# Copy the footer to the object
|
||||
# Copy the footer to the script
|
||||
#
|
||||
unless ( $test ) {
|
||||
if ( $family == F_IPV4 ) {
|
||||
@@ -817,16 +868,39 @@ sub compiler {
|
||||
}
|
||||
}
|
||||
|
||||
disable_object;
|
||||
disable_script;
|
||||
#
|
||||
# Close, rename and secure the object
|
||||
# Close, rename and secure the script
|
||||
#
|
||||
finalize_object ( $export );
|
||||
finalize_script ( $export );
|
||||
#
|
||||
# And generate the auxilary config file
|
||||
#
|
||||
enable_object, generate_aux_config if $export;
|
||||
enable_script, generate_aux_config if $export;
|
||||
} else {
|
||||
#
|
||||
# Just checking the configuration
|
||||
#
|
||||
if ( $preview ) {
|
||||
#
|
||||
# User wishes to preview the ruleset -- generate the rule matrix
|
||||
#
|
||||
generate_matrix;
|
||||
|
||||
if ( $config{OPTIMIZE} & 6 ) {
|
||||
progress_message2 'Optimizing Ruleset...';
|
||||
#
|
||||
# Optimize Policy Chains
|
||||
#
|
||||
optimize_policy_chains if $config{OPTIMIZE} & 2;
|
||||
#
|
||||
# Ruleset Optimization
|
||||
#
|
||||
optimize_ruleset if $config{OPTIMIZE} & 4;
|
||||
}
|
||||
|
||||
preview_netfilter_load;
|
||||
}
|
||||
#
|
||||
# Re-initialize the chain table so that process_routestopped() has the same
|
||||
# environment that it would when called by compile_stop_firewall().
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007,2008,2009 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -26,7 +26,7 @@
|
||||
#
|
||||
package Shorewall::IPAddrs;
|
||||
require Exporter;
|
||||
use Shorewall::Config qw( :DEFAULT split_list require_capability in_hex8 F_IPV4 F_IPV6 );
|
||||
use Shorewall::Config qw( :DEFAULT split_list require_capability in_hex8 numeric_value F_IPV4 F_IPV6 );
|
||||
use Socket;
|
||||
|
||||
use strict;
|
||||
@@ -47,6 +47,7 @@ our @EXPORT = qw( ALLIPv4
|
||||
ALL
|
||||
TCP
|
||||
UDP
|
||||
UDPLITE
|
||||
ICMP
|
||||
DCCP
|
||||
IPv6_ICMP
|
||||
@@ -72,7 +73,7 @@ our @EXPORT = qw( ALLIPv4
|
||||
validate_icmp6
|
||||
);
|
||||
our @EXPORT_OK = qw( );
|
||||
our $VERSION = '4.4_1';
|
||||
our $VERSION = '4.4_7';
|
||||
|
||||
#
|
||||
# Some IPv4/6 useful stuff
|
||||
@@ -103,11 +104,11 @@ use constant { ALLIPv4 => '0.0.0.0/0' ,
|
||||
UDP => 17,
|
||||
DCCP => 33,
|
||||
IPv6_ICMP => 58,
|
||||
SCTP => 132 };
|
||||
SCTP => 132,
|
||||
UDPLITE => 136 };
|
||||
|
||||
our @rfc1918_networks = ( "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16" );
|
||||
|
||||
|
||||
#
|
||||
# Note: initialize() is declared at the bottom of the file
|
||||
#
|
||||
@@ -287,7 +288,12 @@ sub resolve_proto( $ ) {
|
||||
my $proto = $_[0];
|
||||
my $number;
|
||||
|
||||
$proto =~ /^(\d+)$/ ? $proto <= 65535 ? $proto : undef : defined( $number = $nametoproto{$proto} ) ? $number : scalar getprotobyname $proto;
|
||||
if ( $proto =~ /^\d+$/ || $proto =~ /^0x/ ) {
|
||||
$number = numeric_value ( $proto );
|
||||
defined $number && $number <= 65535 ? $number : undef;
|
||||
} else {
|
||||
defined( $number = $nametoproto{$proto} ) ? $number : scalar getprotobyname $proto;
|
||||
}
|
||||
}
|
||||
|
||||
sub proto_name( $ ) {
|
||||
@@ -301,16 +307,19 @@ sub validate_port( $$ ) {
|
||||
|
||||
my $value;
|
||||
|
||||
if ( $port =~ /^(\d+)$/ ) {
|
||||
return $port if $port <= 65535;
|
||||
if ( $port =~ /^(\d+)$/ || $port =~ /^0x/ ) {
|
||||
$port = numeric_value $port;
|
||||
return $port if defined $port && $port && $port <= 65535;
|
||||
} else {
|
||||
$proto = proto_name $proto if $proto =~ /^(\d+)$/;
|
||||
$value = getservbyname( $port, $proto );
|
||||
}
|
||||
|
||||
fatal_error "Invalid/Unknown $proto port/service ($port)" unless defined $value;
|
||||
return $value if defined $value;
|
||||
|
||||
$value;
|
||||
fatal_error "The separator for a port range is ':', not '-' ($port)" if $port =~ /^\d+-\d+$/;
|
||||
|
||||
fatal_error "Invalid/Unknown $proto port/service ($_[1])" unless defined $value;
|
||||
}
|
||||
|
||||
sub validate_portpair( $$ ) {
|
||||
@@ -476,6 +485,7 @@ sub valid_6address( $ ) {
|
||||
return 0 unless valid_4address pop @address;
|
||||
$max = 6;
|
||||
$address = join ':', @address;
|
||||
return 1 if @address eq ':';
|
||||
} else {
|
||||
$max = 8;
|
||||
}
|
||||
@@ -484,16 +494,16 @@ sub valid_6address( $ ) {
|
||||
return 0 unless ( @address == $max ) || $address =~ /::/;
|
||||
return 0 if $address =~ /:::/ || $address =~ /::.*::/;
|
||||
|
||||
if ( $address =~ /^:/ ) {
|
||||
unless ( $address eq '::' ) {
|
||||
return 0 if $address =~ /:$/ || $address =~ /^:.*::/;
|
||||
}
|
||||
} elsif ( $address =~ /:$/ ) {
|
||||
return 0 if $address =~ /::.*:$/;
|
||||
unless ( $address =~ /^::/ ) {
|
||||
return 0 if $address =~ /^:/;
|
||||
}
|
||||
|
||||
unless ( $address =~ /::$/ ) {
|
||||
return 0 if $address =~ /:$/;
|
||||
}
|
||||
|
||||
for my $a ( @address ) {
|
||||
return 0 unless $a eq '' || ( $a =~ /^[a-fA-f\d]+$/ && oct "0x$a" < 65536 );
|
||||
return 0 unless $a eq '' || ( $a =~ /^[a-fA-f\d]+$/ && length $a < 5 );
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -542,13 +552,27 @@ sub validate_6net( $$ ) {
|
||||
sub normalize_6addr( $ ) {
|
||||
my $addr = shift;
|
||||
|
||||
while ( $addr =~ tr/:/:/ < 6 ) {
|
||||
$addr =~ s/::/:0::/;
|
||||
if ( $addr eq '::' ) {
|
||||
'0:0:0:0:0:0:0:0';
|
||||
} else {
|
||||
#
|
||||
# Suppress leading zeros
|
||||
#
|
||||
$addr =~ s/^0+//;
|
||||
$addr =~ s/:0+/:/g;
|
||||
$addr =~ s/^:/0:/;
|
||||
$addr =~ s/:$/:0/;
|
||||
|
||||
$addr =~ s/::/:0::/ while $addr =~ tr/:/:/ < 7;
|
||||
#
|
||||
# Note: "s/::/:0:/g" doesn't work here
|
||||
#
|
||||
1 while $addr =~ s/::/:0:/;
|
||||
|
||||
$addr =~ s/^0+:/0:/;
|
||||
|
||||
$addr;
|
||||
}
|
||||
|
||||
$addr =~ s/::/:0:/;
|
||||
|
||||
$addr;
|
||||
}
|
||||
|
||||
sub validate_6range( $$ ) {
|
||||
@@ -572,7 +596,7 @@ sub validate_6range( $$ ) {
|
||||
}
|
||||
|
||||
sub validate_6host( $$ ) {
|
||||
my ( $host, $allow_name ) = $_[0];
|
||||
my ( $host, $allow_name ) = @_;
|
||||
|
||||
if ( $host =~ /^(.*:.*)-(.*:.*)$/ ) {
|
||||
validate_6range $1, $2;
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007,2008,2009 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -36,7 +36,7 @@ use strict;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw( setup_masq setup_nat setup_netmap add_addresses );
|
||||
our @EXPORT_OK = ();
|
||||
our $VERSION = '4.4_2';
|
||||
our $VERSION = '4.4_6';
|
||||
|
||||
our @addresses_to_add;
|
||||
our %addresses_to_add;
|
||||
@@ -150,7 +150,7 @@ sub process_one_masq( )
|
||||
# Handle IPSEC options, if any
|
||||
#
|
||||
if ( $ipsec ne '-' ) {
|
||||
fatal_error "Non-empty IPSEC column requires policy match support in your kernel and iptables" unless $globals{ORIGINAL_POLICY_MATCH};
|
||||
fatal_error "Non-empty IPSEC column requires policy match support in your kernel and iptables" unless have_capability( 'POLICY_MATCH' );
|
||||
|
||||
if ( $ipsec =~ /^yes$/i ) {
|
||||
$baserule .= '-m policy --pol ipsec --dir out ';
|
||||
@@ -159,7 +159,7 @@ sub process_one_masq( )
|
||||
} else {
|
||||
$baserule .= do_ipsec_options $ipsec;
|
||||
}
|
||||
} elsif ( $capabilities{POLICY_MATCH} ) {
|
||||
} elsif ( have_ipsec ) {
|
||||
$baserule .= '-m policy --pol none --dir out ';
|
||||
}
|
||||
|
||||
@@ -170,8 +170,8 @@ sub process_one_masq( )
|
||||
#
|
||||
# Handle Mark
|
||||
#
|
||||
$baserule .= do_test( $mark, 0xFF) if $mark ne '-';
|
||||
$baserule .= do_user( $user ) if $user ne '-';
|
||||
$baserule .= do_test( $mark, $globals{TC_MASK} ) if $mark ne '-';
|
||||
$baserule .= do_user( $user ) if $user ne '-';
|
||||
|
||||
for my $fullinterface (split_list $interfacelist, 'interface' ) {
|
||||
my $rule = '';
|
||||
@@ -195,7 +195,7 @@ sub process_one_masq( )
|
||||
fatal_error "Unknown interface ($interface)" unless my $interfaceref = known_interface( $interface );
|
||||
|
||||
unless ( $interfaceref->{root} ) {
|
||||
$rule .= "-o $interface ";
|
||||
$rule .= match_dest_dev( $interface );
|
||||
$interface = $interfaceref->{name};
|
||||
}
|
||||
|
||||
@@ -290,7 +290,6 @@ sub process_one_masq( )
|
||||
next if $addrs eq 'detect';
|
||||
for my $addr ( ip_range_explicit $addrs ) {
|
||||
unless ( $addresses_to_add{$addr} ) {
|
||||
emit "del_ip_addr $addr $interface" unless $config{RETAIN_ALIASES};
|
||||
$addresses_to_add{$addr} = 1;
|
||||
if ( defined $alias ) {
|
||||
push @addresses_to_add, $addr, "$interface:$alias";
|
||||
@@ -368,12 +367,12 @@ sub do_one_nat( $$$$$ )
|
||||
fatal_error "Unknown interface ($interface)" unless my $interfaceref = known_interface( $interface );
|
||||
|
||||
unless ( $interfaceref->{root} ) {
|
||||
$rulein = "-i $interface ";
|
||||
$ruleout = "-o $interface ";
|
||||
$rulein = match_source_dev $interface;
|
||||
$ruleout = match_dest_dev $interface;
|
||||
$interface = $interfaceref->{name};
|
||||
}
|
||||
|
||||
if ( $capabilities{POLICY_MATCH} ) {
|
||||
if ( have_ipsec ) {
|
||||
$policyin = ' -m policy --pol none --dir in';
|
||||
$policyout = '-m policy --pol none --dir out';
|
||||
}
|
||||
@@ -403,7 +402,6 @@ sub do_one_nat( $$$$$ )
|
||||
push @addresses_to_add, ( $external , $fullinterface );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
@@ -461,8 +459,8 @@ sub setup_netmap() {
|
||||
fatal_error "Unknown interface ($interface)" unless my $interfaceref = find_interface( $interface );
|
||||
|
||||
unless ( $interfaceref->{root} ) {
|
||||
$rulein = "-i $interface ";
|
||||
$ruleout = "-o $interface ";
|
||||
$rulein = match_source_dev $interface;
|
||||
$ruleout = match_dest_dev $interface;
|
||||
$interface = $interfaceref->{name};
|
||||
}
|
||||
|
||||
@@ -482,12 +480,13 @@ sub setup_netmap() {
|
||||
|
||||
sub add_addresses () {
|
||||
if ( @addresses_to_add ) {
|
||||
my @addrs = @addresses_to_add;
|
||||
my $arg = '';
|
||||
my $addresses = 0;
|
||||
|
||||
while ( @addresses_to_add ) {
|
||||
my $addr = shift @addresses_to_add;
|
||||
my $interface = shift @addresses_to_add;
|
||||
while ( @addrs ) {
|
||||
my $addr = shift @addrs;
|
||||
my $interface = shift @addrs;
|
||||
$arg = "$arg $addr $interface";
|
||||
unless ( $config{RETAIN_ALIASES} ) {
|
||||
emit '' unless $addresses++;
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007,2008,2009 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -32,9 +32,9 @@ use Shorewall::Actions;
|
||||
use strict;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw( validate_policy apply_policy_rules complete_standard_chain setup_syn_flood_chains );
|
||||
our @EXPORT = qw( validate_policy apply_policy_rules complete_standard_chain setup_syn_flood_chains save_policies optimize_policy_chains);
|
||||
our @EXPORT_OK = qw( );
|
||||
our $VERSION = '4.4_1';
|
||||
our $VERSION = '4.4_7';
|
||||
|
||||
# @policy_chains is a list of references to policy chains in the filter table
|
||||
|
||||
@@ -68,7 +68,7 @@ sub new_policy_chain($$$$)
|
||||
{
|
||||
my ($source, $dest, $policy, $optional) = @_;
|
||||
|
||||
my $chainref = new_chain( 'filter', "${source}2${dest}" );
|
||||
my $chainref = new_chain( 'filter', rules_chain( ${source}, ${dest} ) );
|
||||
|
||||
convert_to_policy_chain( $chainref, $source, $dest, $policy, $optional );
|
||||
|
||||
@@ -119,7 +119,7 @@ use constant { OPTIONAL => 1 };
|
||||
|
||||
sub add_or_modify_policy_chain( $$ ) {
|
||||
my ( $zone, $zone1 ) = @_;
|
||||
my $chain = "${zone}2${zone1}";
|
||||
my $chain = rules_chain( ${zone}, ${zone1} );
|
||||
my $chainref = $filter_table->{$chain};
|
||||
|
||||
if ( $chainref ) {
|
||||
@@ -211,7 +211,7 @@ sub process_a_policy() {
|
||||
}
|
||||
}
|
||||
|
||||
my $chain = "${client}2${server}";
|
||||
my $chain = rules_chain( ${client}, ${server} );
|
||||
my $chainref;
|
||||
|
||||
if ( defined $filter_table->{$chain} ) {
|
||||
@@ -252,19 +252,19 @@ sub process_a_policy() {
|
||||
if ( $serverwild ) {
|
||||
for my $zone ( @zonelist ) {
|
||||
for my $zone1 ( @zonelist ) {
|
||||
set_policy_chain $client, $server, "${zone}2${zone1}", $chainref, $policy;
|
||||
set_policy_chain $client, $server, rules_chain( ${zone}, ${zone1} ), $chainref, $policy;
|
||||
print_policy $zone, $zone1, $policy, $chain;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for my $zone ( all_zones ) {
|
||||
set_policy_chain $client, $server, "${zone}2${server}", $chainref, $policy;
|
||||
set_policy_chain $client, $server, rules_chain( ${zone}, ${server} ), $chainref, $policy;
|
||||
print_policy $zone, $server, $policy, $chain;
|
||||
}
|
||||
}
|
||||
} elsif ( $serverwild ) {
|
||||
for my $zone ( @zonelist ) {
|
||||
set_policy_chain $client, $server, "${client}2${zone}", $chainref, $policy;
|
||||
set_policy_chain $client, $server, rules_chain( ${client}, ${zone} ), $chainref, $policy;
|
||||
print_policy $client, $zone, $policy, $chain;
|
||||
}
|
||||
|
||||
@@ -273,6 +273,21 @@ sub process_a_policy() {
|
||||
}
|
||||
}
|
||||
|
||||
sub save_policies() {
|
||||
for my $zone1 ( all_zones ) {
|
||||
for my $zone2 ( all_zones ) {
|
||||
my $chainref = $filter_table->{ rules_chain( $zone1, $zone2 ) };
|
||||
my $policyref = $filter_table->{ $chainref->{policychain} };
|
||||
|
||||
if ( $policyref->{referenced} ) {
|
||||
emit_unindented "$zone1 \t=>\t$zone2\t" . $policyref->{policy} . ' using chain ' . $policyref->{name};
|
||||
} elsif ( $zone1 ne $zone2 ) {
|
||||
emit_unindented "$zone1 \t=>\t$zone2\t" . $policyref->{policy};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub validate_policy()
|
||||
{
|
||||
our %validpolicies = (
|
||||
@@ -334,7 +349,7 @@ sub validate_policy()
|
||||
|
||||
for $zone ( all_zones ) {
|
||||
for my $zone1 ( all_zones ) {
|
||||
fatal_error "No policy defined from zone $zone to zone $zone1" unless $filter_table->{"${zone}2${zone1}"}{policy};
|
||||
fatal_error "No policy defined from zone $zone to zone $zone1" unless $filter_table->{rules_chain( ${zone}, ${zone1} )}{policy};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,7 +362,7 @@ sub policy_rules( $$$$$ ) {
|
||||
|
||||
unless ( $target eq 'NONE' ) {
|
||||
add_rule $chainref, "-d 224.0.0.0/4 -j RETURN" if $dropmulticast && $target ne 'CONTINUE' && $target ne 'ACCEPT';
|
||||
add_rule $chainref, "-j $default" if $default && $default ne 'none';
|
||||
add_jump $chainref, $default, 0 if $default && $default ne 'none';
|
||||
log_rule $loglevel , $chainref , $target , '' if $loglevel ne '';
|
||||
fatal_error "Null target in policy_rules()" unless $target;
|
||||
|
||||
@@ -403,13 +418,24 @@ sub apply_policy_rules() {
|
||||
my $provisional = $chainref->{provisional};
|
||||
my $default = $chainref->{default};
|
||||
my $name = $chainref->{name};
|
||||
my $synparms = $chainref->{synparms};
|
||||
|
||||
if ( $policy ne 'NONE' ) {
|
||||
if ( ! $chainref->{referenced} && ( ! $provisional && $policy ne 'CONTINUE' ) ) {
|
||||
ensure_filter_chain $name, 1;
|
||||
unless ( $chainref->{referenced} || $provisional || $policy eq 'CONTINUE' ) {
|
||||
if ( $config{OPTIMIZE} & 2 ) {
|
||||
#
|
||||
# This policy chain is empty and the only thing that we would put in it is
|
||||
# the policy-related stuff. Don't create it if all we are going to put in it
|
||||
# is a single jump. Generate_matrix() will just use the policy target when
|
||||
# needed.
|
||||
#
|
||||
ensure_filter_chain $name, 1 if $default ne 'none' || $loglevel || $synparms || $config{MULTICAST} || ! ( $policy eq 'ACCEPT' || $config{FASTACCEPT} );
|
||||
} else {
|
||||
ensure_filter_chain $name, 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $name =~ /^all2|2all$/ ) {
|
||||
if ( $name =~ /^all[-2]|[-2]all$/ ) {
|
||||
run_user_exit $chainref;
|
||||
policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
|
||||
}
|
||||
@@ -418,7 +444,7 @@ sub apply_policy_rules() {
|
||||
|
||||
for my $zone ( all_zones ) {
|
||||
for my $zone1 ( all_zones ) {
|
||||
my $chainref = $filter_table->{"${zone}2${zone1}"};
|
||||
my $chainref = $filter_table->{rules_chain( ${zone}, ${zone1} )};
|
||||
|
||||
if ( $chainref->{referenced} ) {
|
||||
run_user_exit $chainref;
|
||||
@@ -444,7 +470,7 @@ sub complete_standard_chain ( $$$$ ) {
|
||||
|
||||
run_user_exit $stdchainref;
|
||||
|
||||
my $ruleschainref = $filter_table->{"${zone}2${zone2}"} || $filter_table->{all2all};
|
||||
my $ruleschainref = $filter_table->{rules_chain( ${zone}, ${zone2} ) } || $filter_table->{rules_chain( 'all', 'all' ) };
|
||||
my ( $policy, $loglevel, $defaultaction ) = ( $default , 6, $config{$default . '_DEFAULT'} );
|
||||
my $policychainref;
|
||||
|
||||
@@ -472,4 +498,24 @@ sub setup_syn_flood_chains() {
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Optimize Policy chains with ACCEPT policy
|
||||
#
|
||||
sub optimize_policy_chains() {
|
||||
for my $chainref ( grep $_->{policy} eq 'ACCEPT', @policy_chains ) {
|
||||
optimize_chain ( $chainref );
|
||||
}
|
||||
#
|
||||
# Often, fw->all has an ACCEPT policy. This code allows optimization in that case
|
||||
#
|
||||
my $outputrules = $filter_table->{OUTPUT}{rules};
|
||||
|
||||
if ( @{$outputrules} && $outputrules->[-1] =~ /-j ACCEPT/ ) {
|
||||
optimize_chain( $filter_table->{OUTPUT} );
|
||||
}
|
||||
|
||||
progress_message ' Policy chains optimized';
|
||||
progress_message '';
|
||||
}
|
||||
|
||||
1;
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007,2008,2009 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -41,7 +41,7 @@ our @EXPORT = qw(
|
||||
setup_forwarding
|
||||
);
|
||||
our @EXPORT_OK = qw( );
|
||||
our $VERSION = '4.3_12';
|
||||
our $VERSION = '4.4_7';
|
||||
|
||||
#
|
||||
# ARP Filtering
|
||||
@@ -56,27 +56,35 @@ sub setup_arp_filtering() {
|
||||
save_progress_message "Setting up ARP filtering...";
|
||||
|
||||
for my $interface ( @$interfaces ) {
|
||||
my $file = "/proc/sys/net/ipv4/conf/$interface/arp_filter";
|
||||
my $value = get_interface_option $interface, 'arp_filter';
|
||||
my $optional = interface_is_optional $interface;
|
||||
|
||||
$interface = get_physical $interface;
|
||||
|
||||
my $file = "/proc/sys/net/ipv4/conf/$interface/arp_filter";
|
||||
|
||||
emit ( '',
|
||||
"if [ -f $file ]; then",
|
||||
" echo $value > $file");
|
||||
emit ( 'else',
|
||||
" error_message \"WARNING: Cannot set ARP filtering on $interface\"" ) unless interface_is_optional( $interface );
|
||||
" error_message \"WARNING: Cannot set ARP filtering on $interface\"" ) unless $optional;
|
||||
emit "fi\n";
|
||||
}
|
||||
|
||||
for my $interface ( @$interfaces1 ) {
|
||||
my $file = "/proc/sys/net/ipv4/conf/$interface/arp_ignore";
|
||||
my $value = get_interface_option $interface, 'arp_ignore';
|
||||
my $optional = interface_is_optional $interface;
|
||||
|
||||
$interface = get_physical $interface;
|
||||
|
||||
my $file = "/proc/sys/net/ipv4/conf/$interface/arp_ignore";
|
||||
|
||||
assert( defined $value );
|
||||
|
||||
emit ( "if [ -f $file ]; then",
|
||||
" echo $value > $file");
|
||||
emit ( 'else',
|
||||
" error_message \"WARNING: Cannot set ARP filtering on $interface\"" ) unless interface_is_optional( $interface );
|
||||
" error_message \"WARNING: Cannot set ARP filtering on $interface\"" ) unless $optional;
|
||||
emit "fi\n";
|
||||
}
|
||||
}
|
||||
@@ -88,16 +96,18 @@ sub setup_arp_filtering() {
|
||||
sub setup_route_filtering() {
|
||||
|
||||
my $interfaces = find_interfaces_by_option 'routefilter';
|
||||
my $config = $config{ROUTE_FILTER};
|
||||
|
||||
if ( @$interfaces || $config{ROUTE_FILTER} ) {
|
||||
if ( @$interfaces || $config ) {
|
||||
|
||||
progress_message2 "$doing Kernel Route Filtering...";
|
||||
|
||||
save_progress_message "Setting up Route Filtering...";
|
||||
|
||||
my $val = '';
|
||||
|
||||
if ( $config{ROUTE_FILTER} ) {
|
||||
my $val = $config{ROUTE_FILTER} eq 'on' ? 1 : 0;
|
||||
if ( $config{ROUTE_FILTER} ne '' ) {
|
||||
$val = $config eq 'on' ? 1 : $config eq 'off' ? 0 : $config;
|
||||
|
||||
emit ( 'for file in /proc/sys/net/ipv4/conf/*; do',
|
||||
" [ -f \$file/rp_filter ] && echo $val > \$file/rp_filter",
|
||||
@@ -106,25 +116,29 @@ sub setup_route_filtering() {
|
||||
}
|
||||
|
||||
for my $interface ( @$interfaces ) {
|
||||
my $file = "/proc/sys/net/ipv4/conf/$interface/rp_filter";
|
||||
my $value = get_interface_option $interface, 'routefilter';
|
||||
my $optional = interface_is_optional $interface;
|
||||
|
||||
$interface = get_physical $interface;
|
||||
|
||||
my $file = "/proc/sys/net/ipv4/conf/$interface/rp_filter";
|
||||
|
||||
emit ( "if [ -f $file ]; then" ,
|
||||
" echo $value > $file" );
|
||||
emit ( 'else' ,
|
||||
" error_message \"WARNING: Cannot set route filtering on $interface\"" ) unless interface_is_optional( $interface);
|
||||
" error_message \"WARNING: Cannot set route filtering on $interface\"" ) unless $optional;
|
||||
emit "fi\n";
|
||||
}
|
||||
|
||||
emit 'echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter';
|
||||
|
||||
if ( $config{ROUTE_FILTER} eq 'on' ) {
|
||||
emit 'echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter';
|
||||
} elsif ( $config{ROUTE_FILTER} eq 'off' ) {
|
||||
emit 'echo 0 > /proc/sys/net/ipv4/conf/default/rp_filter';
|
||||
if ( have_capability( 'KERNELVERSION' ) < 20631 ) {
|
||||
emit 'echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter';
|
||||
} elsif ( $val ne '' ) {
|
||||
emit "echo $val > /proc/sys/net/ipv4/conf/all/rp_filter";
|
||||
}
|
||||
|
||||
emit "[ -n \"\$NOROUTES\" ] || \$IP -4 route flush cache";
|
||||
emit "echo $val > /proc/sys/net/ipv4/conf/default/rp_filter" if $val ne '';
|
||||
|
||||
emit "[ -n \"\$g_noroutes\" ] || \$IP -4 route flush cache";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,14 +167,18 @@ sub setup_martian_logging() {
|
||||
}
|
||||
|
||||
for my $interface ( @$interfaces ) {
|
||||
my $file = "/proc/sys/net/ipv4/conf/$interface/log_martians";
|
||||
my $value = get_interface_option $interface, 'logmartians';
|
||||
my $optional = interface_is_optional $interface;
|
||||
|
||||
$interface = get_physical $interface;
|
||||
|
||||
my $file = "/proc/sys/net/ipv4/conf/$interface/log_martians";
|
||||
|
||||
emit ( "if [ -f $file ]; then" ,
|
||||
" echo $value > $file" );
|
||||
|
||||
emit ( 'else' ,
|
||||
" error_message \"WARNING: Cannot set Martian logging on $interface\"") unless interface_is_optional( $interface);
|
||||
" error_message \"WARNING: Cannot set Martian logging on $interface\"") unless $optional;
|
||||
emit "fi\n";
|
||||
}
|
||||
}
|
||||
@@ -180,13 +198,17 @@ sub setup_source_routing( $ ) {
|
||||
save_progress_message 'Setting up Accept Source Routing...';
|
||||
|
||||
for my $interface ( @$interfaces ) {
|
||||
my $file = "/proc/sys/net/ipv$family/conf/$interface/accept_source_route";
|
||||
my $value = get_interface_option $interface, 'sourceroute';
|
||||
my $optional = interface_is_optional $interface;
|
||||
|
||||
$interface = get_physical $interface;
|
||||
|
||||
my $file = "/proc/sys/net/ipv$family/conf/$interface/accept_source_route";
|
||||
|
||||
emit ( "if [ -f $file ]; then" ,
|
||||
" echo $value > $file" );
|
||||
emit ( 'else' ,
|
||||
" error_message \"WARNING: Cannot set Accept Source Routing on $interface\"" ) unless interface_is_optional( $interface);
|
||||
" error_message \"WARNING: Cannot set Accept Source Routing on $interface\"" ) unless $optional;
|
||||
emit "fi\n";
|
||||
}
|
||||
}
|
||||
@@ -227,13 +249,17 @@ sub setup_forwarding( $$ ) {
|
||||
save_progress_message 'Setting up IPv6 Interface Forwarding...';
|
||||
|
||||
for my $interface ( @$interfaces ) {
|
||||
my $file = "/proc/sys/net/ipv6/conf/$interface/forwarding";
|
||||
my $value = get_interface_option $interface, 'forward';
|
||||
my $optional = interface_is_optional $interface;
|
||||
|
||||
$interface = get_physical $interface;
|
||||
|
||||
my $file = "/proc/sys/net/ipv6/conf/$interface/forwarding";
|
||||
|
||||
emit ( "if [ -f $file ]; then" ,
|
||||
" echo $value > $file" );
|
||||
emit ( 'else' ,
|
||||
" error_message \"WARNING: Cannot set IPv6 forwarding on $interface\"" ) unless interface_is_optional( $interface);
|
||||
" error_message \"WARNING: Cannot set IPv6 forwarding on $interface\"" ) unless $optional;
|
||||
emit "fi\n";
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007,2008,2009 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -35,7 +35,7 @@ use strict;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw( setup_providers @routemarked_interfaces handle_stickiness handle_optional_interfaces );
|
||||
our @EXPORT_OK = qw( initialize lookup_provider );
|
||||
our $VERSION = '4.4_2';
|
||||
our $VERSION = '4.4_8';
|
||||
|
||||
use constant { LOCAL_TABLE => 255,
|
||||
MAIN_TABLE => 254,
|
||||
@@ -59,6 +59,8 @@ our @providers;
|
||||
|
||||
our $family;
|
||||
|
||||
our $lastmark;
|
||||
|
||||
use constant { ROUTEMARKED_SHARED => 1, ROUTEMARKED_UNSHARED => 2 };
|
||||
|
||||
#
|
||||
@@ -94,9 +96,9 @@ sub initialize( $ ) {
|
||||
# Set up marking for 'tracked' interfaces.
|
||||
#
|
||||
sub setup_route_marking() {
|
||||
my $mask = $config{HIGH_ROUTE_MARKS} ? $config{WIDE_TC_MARKS} ? '0xFF0000' : '0xFF00' : '0xFF';
|
||||
my $mask = in_hex( $globals{PROVIDER_MASK} );
|
||||
|
||||
require_capability( $_ , 'the provider \'track\' option' , 's' ) for qw/CONNMARK_MATCH CONNMARK/;
|
||||
require_capability( $_ , q(The provider 'track' option) , 's' ) for qw/CONNMARK_MATCH CONNMARK/;
|
||||
|
||||
add_rule $mangle_table->{$_} , "-m connmark ! --mark 0/$mask -j CONNMARK --restore-mark --mask $mask" for qw/PREROUTING OUTPUT/;
|
||||
|
||||
@@ -108,33 +110,21 @@ sub setup_route_marking() {
|
||||
|
||||
for my $providerref ( @routemarked_providers ) {
|
||||
my $interface = $providerref->{interface};
|
||||
my $physical = $providerref->{physical};
|
||||
my $mark = $providerref->{mark};
|
||||
my $base = uc chain_base $interface;
|
||||
|
||||
if ( $providerref->{optional} ) {
|
||||
if ( $providerref->{shared} ) {
|
||||
add_commands( $chainref, qq(if [ interface_is_usable $interface -a -n "$providerref->{mac}" ]; then) );
|
||||
} else {
|
||||
add_commands( $chainref, qq(if [ -n "\$${base}_IS_USABLE" ]; then) );
|
||||
}
|
||||
|
||||
incr_cmd_level( $chainref );
|
||||
}
|
||||
|
||||
unless ( $marked_interfaces{$interface} ) {
|
||||
add_rule $mangle_table->{PREROUTING} , "-i $interface -m mark --mark 0/$mask -j routemark";
|
||||
add_jump $mangle_table->{PREROUTING} , $chainref1, 0, "! -i $interface -m mark --mark $mark/$mask ";
|
||||
add_jump $mangle_table->{PREROUTING} , $chainref, 0, "-i $physical -m mark --mark 0/$mask ";
|
||||
add_jump $mangle_table->{PREROUTING} , $chainref1, 0, "! -i $physical -m mark --mark $mark/$mask ";
|
||||
add_jump $mangle_table->{OUTPUT} , $chainref2, 0, "-m mark --mark $mark/$mask ";
|
||||
$marked_interfaces{$interface} = 1;
|
||||
}
|
||||
|
||||
if ( $providerref->{shared} ) {
|
||||
add_rule $chainref, " -i $interface -m mac --mac-source $providerref->{mac} -j MARK --set-mark $providerref->{mark}";
|
||||
add_rule $chainref, match_source_dev( $interface ) . "-m mac --mac-source $providerref->{mac} -j MARK --set-mark $providerref->{mark}";
|
||||
} else {
|
||||
add_rule $chainref, " -i $interface -j MARK --set-mark $providerref->{mark}";
|
||||
add_rule $chainref, match_source_dev( $interface ) . "-j MARK --set-mark $providerref->{mark}";
|
||||
}
|
||||
|
||||
decr_cmd_level( $chainref), add_commands( $chainref, "fi" ) if $providerref->{optional};
|
||||
}
|
||||
|
||||
add_rule $chainref, "-m mark ! --mark 0/$mask -j CONNMARK --save-mark --mask $mask";
|
||||
@@ -142,11 +132,15 @@ sub setup_route_marking() {
|
||||
|
||||
sub copy_table( $$$ ) {
|
||||
my ( $duplicate, $number, $realm ) = @_;
|
||||
#
|
||||
# Hack to work around problem in iproute
|
||||
#
|
||||
my $filter = $family == F_IPV6 ? q(sed 's/ via :: / /' | ) : '';
|
||||
|
||||
if ( $realm ) {
|
||||
emit ( "\$IP -$family route show table $duplicate | sed -r 's/ realm [[:alnum:]_]+//' | while read net route; do" )
|
||||
} else {
|
||||
emit ( "\$IP -$family route show table $duplicate | while read net route; do" )
|
||||
emit ( "\$IP -$family route show table $duplicate | ${filter}while read net route; do" )
|
||||
}
|
||||
|
||||
emit ( ' case $net in',
|
||||
@@ -162,11 +156,23 @@ sub copy_table( $$$ ) {
|
||||
|
||||
sub copy_and_edit_table( $$$$ ) {
|
||||
my ( $duplicate, $number, $copy, $realm) = @_;
|
||||
#
|
||||
# Hack to work around problem in iproute
|
||||
#
|
||||
my $filter = $family == F_IPV6 ? q(sed 's/ via :: / /' | ) : '';
|
||||
#
|
||||
# Map physical names in $copy to logical names
|
||||
#
|
||||
$copy = join( '|' , map( physical_name($_) , split( ',' , $copy ) ) );
|
||||
#
|
||||
# Shell and iptables use a different wildcard character
|
||||
#
|
||||
$copy =~ s/\+/*/;
|
||||
|
||||
if ( $realm ) {
|
||||
emit ( "\$IP -$family route show table $duplicate | sed -r 's/ realm [[:alnum:]_]+//' | while read net route; do" )
|
||||
emit ( "\$IP -$family route show table $duplicate | sed -r 's/ realm [[:alnum:]]+//' | while read net route; do" )
|
||||
} else {
|
||||
emit ( "\$IP -$family route show table $duplicate | while read net route; do" )
|
||||
emit ( "\$IP -$family route show table $duplicate | ${filter}while read net route; do" )
|
||||
}
|
||||
|
||||
emit ( ' case $net in',
|
||||
@@ -270,9 +276,10 @@ sub add_a_provider( ) {
|
||||
}
|
||||
|
||||
fatal_error "Unknown Interface ($interface)" unless known_interface $interface;
|
||||
fatal_error "A bridge port ($interface) may not be configured as a provider interface" if port_to_bridge $interface;
|
||||
|
||||
my $provider = chain_base $table;
|
||||
my $base = uc chain_base $interface;
|
||||
my $physical = get_physical $interface;
|
||||
my $base = uc chain_base $physical;
|
||||
my $gatewaycase = '';
|
||||
|
||||
if ( $gateway eq 'detect' ) {
|
||||
@@ -288,40 +295,15 @@ sub add_a_provider( ) {
|
||||
$gateway = '';
|
||||
}
|
||||
|
||||
my $val = 0;
|
||||
my $pref;
|
||||
|
||||
if ( $mark ne '-' ) {
|
||||
|
||||
$val = numeric_value $mark;
|
||||
|
||||
fatal_error "Invalid Mark Value ($mark)" unless defined $val;
|
||||
|
||||
verify_mark $mark;
|
||||
|
||||
if ( $val < 65535 ) {
|
||||
if ( $config{HIGH_ROUTE_MARKS} ) {
|
||||
fatal_error "Invalid Mark Value ($mark) with HIGH_ROUTE_MARKS=Yes and WIDE_TC_MARKS=Yes" if $config{WIDE_TC_MARKS};
|
||||
fatal_error "Invalid Mark Value ($mark) with HIGH_ROUTE_MARKS=Yes" if $val < 256;
|
||||
}
|
||||
} else {
|
||||
fatal_error "Invalid Mark Value ($mark)" unless $config{HIGH_ROUTE_MARKS} && $config{WIDE_TC_MARKS};
|
||||
}
|
||||
|
||||
for my $providerref ( values %providers ) {
|
||||
fatal_error "Duplicate mark value ($mark)" if numeric_value( $providerref->{mark} ) == $val;
|
||||
}
|
||||
|
||||
$pref = 10000 + $number - 1;
|
||||
|
||||
}
|
||||
|
||||
my ( $loose, $track, $balance , $default, $default_balance, $optional, $mtu ) = (0,0,0,0,$config{USE_DEFAULT_RT} ? 1 : 0,interface_is_optional( $interface ), '' );
|
||||
my ( $loose, $track, $balance , $default, $default_balance, $optional, $mtu, $local ) =
|
||||
(0, $config{TRACK_PROVIDERS}, 0 , 0, $config{USE_DEFAULT_RT} ? 1 : 0, interface_is_optional( $interface ), '' , 0 );
|
||||
|
||||
unless ( $options eq '-' ) {
|
||||
for my $option ( split_list $options, 'option' ) {
|
||||
if ( $option eq 'track' ) {
|
||||
$track = 1;
|
||||
} elsif ( $option eq 'notrack' ) {
|
||||
$track = 0;
|
||||
} elsif ( $option =~ /^balance=(\d+)$/ ) {
|
||||
fatal_error q('balance' is not available in IPv6) if $family == F_IPV6;
|
||||
$balance = $1;
|
||||
@@ -355,12 +337,43 @@ sub add_a_provider( ) {
|
||||
} else {
|
||||
$default = -1;
|
||||
}
|
||||
} elsif ( $option eq 'local' ) {
|
||||
$local = 1;
|
||||
$track = 0 if $config{TRACK_PROVIDERS};
|
||||
$default_balance = 0 if$config{USE_DEFAULT_RT};
|
||||
} else {
|
||||
fatal_error "Invalid option ($option)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $val = 0;
|
||||
my $pref;
|
||||
|
||||
$mark = ( $lastmark += ( 1 << $config{PROVIDER_OFFSET} ) ) if $mark eq '-' && $track;
|
||||
|
||||
if ( $mark ne '-' ) {
|
||||
|
||||
$val = numeric_value $mark;
|
||||
|
||||
fatal_error "Invalid Mark Value ($mark)" unless defined $val && $val;
|
||||
|
||||
verify_mark $mark;
|
||||
|
||||
fatal_error "Invalid Mark Value ($mark)" unless ( $val & $globals{PROVIDER_MASK} ) == $val;
|
||||
|
||||
fatal_error "Provider MARK may not be specified when PROVIDER_BITS=0" unless $config{PROVIDER_BITS};
|
||||
|
||||
for my $providerref ( values %providers ) {
|
||||
fatal_error "Duplicate mark value ($mark)" if numeric_value( $providerref->{mark} ) == $val;
|
||||
}
|
||||
|
||||
$pref = 10000 + $number - 1;
|
||||
|
||||
$lastmark = $val;
|
||||
|
||||
}
|
||||
|
||||
unless ( $loose ) {
|
||||
warning_message q(The 'proxyarp' option is dangerous when specified on a Provider interface) if get_interface_option( $interface, 'proxyarp' );
|
||||
warning_message q(The 'proxyndp' option is dangerous when specified on a Provider interface) if get_interface_option( $interface, 'proxyndp' );
|
||||
@@ -372,6 +385,7 @@ sub add_a_provider( ) {
|
||||
number => $number ,
|
||||
mark => $val ? in_hex($val) : $val ,
|
||||
interface => $interface ,
|
||||
physical => $physical ,
|
||||
optional => $optional ,
|
||||
gateway => $gateway ,
|
||||
gatewaycase => $gatewaycase ,
|
||||
@@ -399,19 +413,25 @@ sub add_a_provider( ) {
|
||||
if ( $shared ) {
|
||||
my $variable = $providers{$table}{mac} = get_interface_mac( $gateway, $interface , $table );
|
||||
$realm = "realm $number";
|
||||
start_provider( $table, $number, qq(if interface_is_usable $interface && [ -n "$variable" ]; then) );
|
||||
start_provider( $table, $number, qq(if interface_is_usable $physical && [ -n "$variable" ]; then) );
|
||||
} else {
|
||||
if ( $optional ) {
|
||||
start_provider( $table, $number, qq(if [ -n "\$${base}_IS_USABLE" ]; then) );
|
||||
start_provider( $table, $number, qq(if [ -n "\$SW_${base}_IS_USABLE" ]; then) );
|
||||
} elsif ( $gatewaycase eq 'detect' ) {
|
||||
start_provider( $table, $number, qq(if interface_is_usable $interface && [ -n "$gateway" ]; then) );
|
||||
start_provider( $table, $number, qq(if interface_is_usable $physical && [ -n "$gateway" ]; then) );
|
||||
} else {
|
||||
start_provider( $table, $number, "if interface_is_usable $interface; then" );
|
||||
start_provider( $table, $number, "if interface_is_usable $physical; then" );
|
||||
}
|
||||
|
||||
$provider_interfaces{$interface} = $table;
|
||||
|
||||
emit "run_ip route add default dev $interface table $number" if $gatewaycase eq 'none';
|
||||
if ( $gatewaycase eq 'none' ) {
|
||||
if ( $local ) {
|
||||
emit "run_ip route add local 0.0.0.0/0 dev $physical table $number";
|
||||
} else {
|
||||
emit "run_ip route add default dev $physical table $number";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $mark ne '-' ) {
|
||||
@@ -430,8 +450,7 @@ sub add_a_provider( ) {
|
||||
if ( $copy eq 'none' ) {
|
||||
$copy = $interface;
|
||||
} else {
|
||||
$copy =~ tr/,/|/;
|
||||
$copy = "$interface|$copy";
|
||||
$copy = "$interface,$copy";
|
||||
}
|
||||
|
||||
copy_and_edit_table( $duplicate, $number ,$copy , $realm);
|
||||
@@ -443,28 +462,33 @@ sub add_a_provider( ) {
|
||||
|
||||
if ( $gateway ) {
|
||||
$address = get_interface_address $interface unless $address;
|
||||
emit "run_ip route replace $gateway src $address dev $interface ${mtu}table $number $realm";
|
||||
emit "run_ip route add default via $gateway src $address dev $interface ${mtu}table $number $realm";
|
||||
emit "run_ip route replace $gateway src $address dev $physical ${mtu}table $number $realm";
|
||||
emit "run_ip route add default via $gateway src $address dev $physical ${mtu}table $number $realm";
|
||||
}
|
||||
|
||||
balance_default_route $balance , $gateway, $interface, $realm if $balance;
|
||||
balance_default_route $balance , $gateway, $physical, $realm if $balance;
|
||||
|
||||
if ( $default > 0 ) {
|
||||
balance_fallback_route $default , $gateway, $interface, $realm;
|
||||
balance_fallback_route $default , $gateway, $physical, $realm;
|
||||
} elsif ( $default ) {
|
||||
emit '';
|
||||
if ( $gateway ) {
|
||||
emit qq(run_ip route replace default via $gateway src $address dev $interface table ) . DEFAULT_TABLE . qq( dev $interface metric $number);
|
||||
emit qq(run_ip route replace default via $gateway src $address dev $physical table ) . DEFAULT_TABLE . qq( metric $number);
|
||||
emit qq(echo "qt \$IP -$family route del default via $gateway table ) . DEFAULT_TABLE . qq(" >> \${VARDIR}/undo_routing);
|
||||
} else {
|
||||
emit qq(run_ip route add default table ) . DEFAULT_TABLE . qq( dev $interface metric $number);
|
||||
emit qq(echo "qt \$IP -$family route del default dev $interface table ) . DEFAULT_TABLE . qq(" >> \${VARDIR}/undo_routing);
|
||||
emit qq(run_ip route add default table ) . DEFAULT_TABLE . qq( dev $physical metric $number);
|
||||
emit qq(echo "qt \$IP -$family route del default dev $physical table ) . DEFAULT_TABLE . qq(" >> \${VARDIR}/undo_routing);
|
||||
}
|
||||
}
|
||||
|
||||
if ( $loose ) {
|
||||
if ( $local ) {
|
||||
fatal_error "GATEWAY not valid with 'local' provider" unless $gatewaycase eq 'none';
|
||||
fatal_error "'track' not valid with 'local'" if $track;
|
||||
fatal_error "DUPLICATE not valid with 'local'" if $duplicate ne '-';
|
||||
fatal_error "MARK required with 'local'" unless $mark;
|
||||
} elsif ( $loose ) {
|
||||
if ( $config{DELETE_THEN_ADD} ) {
|
||||
emit ( "\nfind_interface_addresses $interface | while read address; do",
|
||||
emit ( "\nfind_interface_addresses $physical | while read address; do",
|
||||
" qt \$IP -$family rule del from \$address",
|
||||
'done'
|
||||
);
|
||||
@@ -478,7 +502,7 @@ sub add_a_provider( ) {
|
||||
|
||||
emit "\nrulenum=0\n";
|
||||
|
||||
emit ( "find_interface_addresses $interface | while read address; do" );
|
||||
emit ( "find_interface_addresses $physical | while read address; do" );
|
||||
emit ( " qt \$IP -$family rule del from \$address" ) if $config{DELETE_THEN_ADD};
|
||||
emit ( " run_ip rule add from \$address pref \$(( $rulebase + \$rulenum )) table $number",
|
||||
" echo \"qt \$IP -$family rule del from \$address\" >> \${VARDIR}/undo_routing",
|
||||
@@ -494,15 +518,15 @@ sub add_a_provider( ) {
|
||||
|
||||
if ( $optional ) {
|
||||
if ( $shared ) {
|
||||
emit ( " error_message \"WARNING: Interface $interface is not usable -- Provider $table ($number) not Added\"" );
|
||||
} else {
|
||||
emit ( " error_message \"WARNING: Gateway $gateway is not reachable -- Provider $table ($number) not Added\"" );
|
||||
} else {
|
||||
emit ( " error_message \"WARNING: Interface $physical is not usable -- Provider $table ($number) not Added\"" );
|
||||
}
|
||||
} else {
|
||||
if ( $shared ) {
|
||||
emit( " fatal_error \"Gateway $gateway is not reachable -- Provider $table ($number) Cannot be Added\"" );
|
||||
} else {
|
||||
emit( " fatal_error \"Interface $interface is not usable -- Provider $table ($number) Cannot be Added\"" );
|
||||
emit( " fatal_error \"Interface $physical is not usable -- Provider $table ($number) Cannot be Added\"" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,9 +537,32 @@ sub add_a_provider( ) {
|
||||
progress_message " Provider \"$currentline\" $done";
|
||||
}
|
||||
|
||||
#
|
||||
# Begin an 'if' statement testing whether the passed interface is available
|
||||
#
|
||||
sub start_new_if( $ ) {
|
||||
our $current_if = shift;
|
||||
|
||||
emit ( '', qq(if [ -n "\$SW_${current_if}_IS_USABLE" ]; then) );
|
||||
push_indent;
|
||||
}
|
||||
|
||||
#
|
||||
# Complete any current 'if' statement in the output script
|
||||
#
|
||||
sub finish_current_if() {
|
||||
if ( our $current_if ) {
|
||||
pop_indent;
|
||||
emit ( "fi\n" );
|
||||
$current_if = '';
|
||||
}
|
||||
}
|
||||
|
||||
sub add_an_rtrule( ) {
|
||||
my ( $source, $dest, $provider, $priority ) = split_line 4, 4, 'route_rules file';
|
||||
|
||||
our $current_if;
|
||||
|
||||
unless ( $providers{$provider} ) {
|
||||
my $found = 0;
|
||||
|
||||
@@ -550,6 +597,7 @@ sub add_an_rtrule( ) {
|
||||
( my $interface, $source , my $remainder ) = split( /:/, $source, 3 );
|
||||
fatal_error "Invalid SOURCE" if defined $remainder;
|
||||
validate_net ( $source, 0 );
|
||||
$interface = physical_name $interface;
|
||||
$source = "iif $interface from $source";
|
||||
} elsif ( $source =~ /\..*\..*/ ) {
|
||||
validate_net ( $source, 0 );
|
||||
@@ -557,9 +605,10 @@ sub add_an_rtrule( ) {
|
||||
} else {
|
||||
$source = "iif $source";
|
||||
}
|
||||
} elsif ( $source =~ /^(.+?):<(.+)>\s*$/ ) {
|
||||
} elsif ( $source =~ /^(.+?):<(.+)>\s*$/ || $source =~ /^(.+?):\[(.+)\]\s*$/ ) {
|
||||
my ($interface, $source ) = ($1, $2);
|
||||
validate_net ($source, 0);
|
||||
$interface = physical_name $interface;
|
||||
$source = "iif $interface from $source";
|
||||
} elsif ( $source =~ /:.*:/ || $source =~ /\..*\..*/ ) {
|
||||
validate_net ( $source, 0 );
|
||||
@@ -572,21 +621,21 @@ sub add_an_rtrule( ) {
|
||||
|
||||
$priority = "priority $priority";
|
||||
|
||||
emit ( "qt \$IP -$family rule del $source $dest $priority" ) if $config{DELETE_THEN_ADD};
|
||||
finish_current_if, emit ( "qt \$IP -$family rule del $source $dest $priority" ) if $config{DELETE_THEN_ADD};
|
||||
|
||||
my ( $optional, $number ) = ( $providers{$provider}{optional} , $providers{$provider}{number} );
|
||||
|
||||
if ( $optional ) {
|
||||
my $base = uc chain_base( $providers{$provider}{interface} );
|
||||
emit ( '', "if [ -n \$${base}_IS_USABLE ]; then" );
|
||||
push_indent;
|
||||
my $base = uc chain_base( $providers{$provider}{physical} );
|
||||
finish_current_if if $base ne $current_if;
|
||||
start_new_if( $base ) unless $current_if;
|
||||
} else {
|
||||
finish_current_if;
|
||||
}
|
||||
|
||||
emit ( "run_ip rule add $source $dest $priority table $number",
|
||||
"echo \"qt \$IP -$family rule del $source $dest $priority\" >> \${VARDIR}/undo_routing" );
|
||||
|
||||
pop_indent, emit ( "fi\n" ) if $optional;
|
||||
|
||||
progress_message " Routing rule \"$currentline\" $done";
|
||||
}
|
||||
|
||||
@@ -704,12 +753,14 @@ sub finish_providers() {
|
||||
sub setup_providers() {
|
||||
my $providers = 0;
|
||||
|
||||
$lastmark = 0;
|
||||
|
||||
my $fn = open_file 'providers';
|
||||
|
||||
first_entry sub() {
|
||||
emit "\nif [ -z \"\$NOROUTES\" ]; then";
|
||||
push_indent;
|
||||
progress_message2 "$doing $fn...";
|
||||
emit "\nif [ -z \"\$g_noroutes\" ]; then";
|
||||
push_indent;
|
||||
start_providers; };
|
||||
|
||||
add_a_provider, $providers++ while read_a_line;
|
||||
@@ -720,25 +771,28 @@ sub setup_providers() {
|
||||
my $fn = open_file 'route_rules';
|
||||
|
||||
if ( $fn ) {
|
||||
our $current_if = '';
|
||||
|
||||
first_entry "$doing $fn...";
|
||||
|
||||
emit '';
|
||||
|
||||
add_an_rtrule while read_a_line;
|
||||
|
||||
finish_current_if;
|
||||
}
|
||||
|
||||
setup_null_routing if $config{NULL_ROUTE_RFC1918};
|
||||
emit "\nrun_ip route flush cache";
|
||||
#
|
||||
# This completes the if block begun in the first_entry closure
|
||||
# This completes the if-block begun in the first_entry closure above
|
||||
#
|
||||
pop_indent;
|
||||
emit "fi\n";
|
||||
|
||||
setup_route_marking if @routemarked_interfaces;
|
||||
} else {
|
||||
emit "\nif [ -z \"\$NOROUTES\" ]; then";
|
||||
emit "\nif [ -z \"\$g_noroutes\" ]; then";
|
||||
|
||||
push_indent;
|
||||
|
||||
@@ -781,18 +835,21 @@ sub lookup_provider( $ ) {
|
||||
}
|
||||
|
||||
#
|
||||
# This function is called by the compiler when it is generating the initialize() function.
|
||||
# This function is called by the compiler when it is generating the detect_configuration() function.
|
||||
# The function emits code to set the ..._IS_USABLE interface variables appropriately for the
|
||||
# optional interfaces
|
||||
#
|
||||
# Returns true if there were optional interfaces
|
||||
#
|
||||
sub handle_optional_interfaces() {
|
||||
|
||||
my $interfaces = find_interfaces_by_option 'optional';
|
||||
|
||||
if ( @$interfaces ) {
|
||||
for my $interface ( @$interfaces ) {
|
||||
my $base = uc chain_base( $interface );
|
||||
my $provider = $provider_interfaces{$interface};
|
||||
my $physical = get_physical $interface;
|
||||
my $base = uc chain_base( $physical );
|
||||
|
||||
emit '';
|
||||
|
||||
@@ -803,22 +860,24 @@ sub handle_optional_interfaces() {
|
||||
my $providerref = $providers{$provider};
|
||||
|
||||
if ( $providerref->{gatewaycase} eq 'detect' ) {
|
||||
emit qq(if interface_is_usable $interface && [ -n "$providerref->{gateway}" ]; then);
|
||||
emit qq(if interface_is_usable $physical && [ -n "$providerref->{gateway}" ]; then);
|
||||
} else {
|
||||
emit qq(if interface_is_usable $interface; then);
|
||||
emit qq(if interface_is_usable $physical; then);
|
||||
}
|
||||
} else {
|
||||
#
|
||||
# Not a provider interface
|
||||
#
|
||||
emit qq(if interface_is_usable $interface; then);
|
||||
emit qq(if interface_is_usable $physical; then);
|
||||
}
|
||||
|
||||
emit( " ${base}_IS_USABLE=Yes" ,
|
||||
emit( " SW_${base}_IS_USABLE=Yes" ,
|
||||
'else' ,
|
||||
" ${base}_IS_USABLE=" ,
|
||||
" SW_${base}_IS_USABLE=" ,
|
||||
'fi' );
|
||||
}
|
||||
|
||||
1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -828,7 +887,7 @@ sub handle_optional_interfaces() {
|
||||
#
|
||||
sub handle_stickiness( $ ) {
|
||||
my $havesticky = shift;
|
||||
my $mask = $config{HIGH_ROUTE_MARKS} ? $config{WIDE_TC_MARKS} ? '0xFF0000' : '0xFF00' : '0xFF';
|
||||
my $mask = in_hex( $globals{PROVIDER_MASK} );
|
||||
my $setstickyref = $mangle_table->{setsticky};
|
||||
my $setstickoref = $mangle_table->{setsticko};
|
||||
my $tcpreref = $mangle_table->{tcpre};
|
||||
@@ -839,9 +898,8 @@ sub handle_stickiness( $ ) {
|
||||
if ( $havesticky ) {
|
||||
fatal_error "There are SAME tcrules but no 'track' providers" unless @routemarked_providers;
|
||||
|
||||
|
||||
for my $providerref ( @routemarked_providers ) {
|
||||
my $interface = $providerref->{interface};
|
||||
my $interface = $providerref->{physical};
|
||||
my $base = uc chain_base $interface;
|
||||
my $mark = $providerref->{mark};
|
||||
|
||||
@@ -851,9 +909,6 @@ sub handle_stickiness( $ ) {
|
||||
my $list = sprintf "sticky%03d" , $sticky++;
|
||||
|
||||
for my $chainref ( $stickyref, $setstickyref ) {
|
||||
|
||||
add_commands( $chainref, qq(if [ -n "\$${base}_IS_USABLE" ]; then) ), incr_cmd_level( $chainref ) if $providerref->{optional};
|
||||
|
||||
if ( $chainref->{name} eq 'sticky' ) {
|
||||
$rule1 = $_;
|
||||
$rule1 =~ s/-j sticky/-m recent --name $list --update --seconds 300 -j MARK --set-mark $mark/;
|
||||
@@ -872,9 +927,6 @@ sub handle_stickiness( $ ) {
|
||||
$rule2 =~ s/-A tcpre //;
|
||||
add_rule $chainref, $rule2;
|
||||
}
|
||||
|
||||
decr_cmd_level( $chainref), add_commands( $chainref, "fi" ) if $providerref->{optional};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -884,8 +936,6 @@ sub handle_stickiness( $ ) {
|
||||
my $stickoref = ensure_mangle_chain 'sticko';
|
||||
|
||||
for my $chainref ( $stickoref, $setstickoref ) {
|
||||
add_commands( $chainref, qq(if [ -n "\$${base}_IS_USABLE" ]; then) ), incr_cmd_level( $chainref ) if $providerref->{optional};
|
||||
|
||||
if ( $chainref->{name} eq 'sticko' ) {
|
||||
$rule1 = $_;
|
||||
$rule1 =~ s/-j sticko/-m recent --name $list --rdest --update --seconds 300 -j MARK --set-mark $mark/;
|
||||
@@ -904,8 +954,6 @@ sub handle_stickiness( $ ) {
|
||||
$rule2 =~ s/-A tcout //;
|
||||
add_rule $chainref, $rule2;
|
||||
}
|
||||
|
||||
decr_cmd_level( $chainref), add_commands( $chainref, "fi" ) if $providerref->{optional};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ our @EXPORT = qw(
|
||||
);
|
||||
|
||||
our @EXPORT_OK = qw( initialize );
|
||||
our $VERSION = '4.4_1';
|
||||
our $VERSION = '4.4_4';
|
||||
|
||||
our @proxyarp;
|
||||
|
||||
@@ -76,7 +76,7 @@ sub setup_one_proxy_arp( $$$$$ ) {
|
||||
}
|
||||
|
||||
unless ( $haveroute ) {
|
||||
emit "[ -n \"\$NOROUTES\" ] || run_ip route replace $address dev $interface";
|
||||
emit "[ -n \"\$g_noroutes\" ] || run_ip route replace $address dev $interface";
|
||||
$haveroute = 1 if $persistent;
|
||||
}
|
||||
|
||||
@@ -117,6 +117,8 @@ sub setup_proxy_arp() {
|
||||
$first_entry = 0;
|
||||
}
|
||||
|
||||
$interface = get_physical $interface;
|
||||
|
||||
$set{$interface} = 1;
|
||||
$reset{$external} = 1 unless $set{$external};
|
||||
|
||||
@@ -143,10 +145,14 @@ sub setup_proxy_arp() {
|
||||
|
||||
for my $interface ( @$interfaces ) {
|
||||
my $value = get_interface_option $interface, 'proxyarp';
|
||||
my $optional = interface_is_optional $interface;
|
||||
|
||||
$interface = get_physical $interface;
|
||||
|
||||
emit ( "if [ -f /proc/sys/net/ipv4/conf/$interface/proxy_arp ] ; then" ,
|
||||
" echo $value > /proc/sys/net/ipv4/conf/$interface/proxy_arp" );
|
||||
emit ( 'else' ,
|
||||
" error_message \"WARNING: Unable to set/reset proxy ARP on $interface\"" ) unless interface_is_optional( $interface );
|
||||
" error_message \"WARNING: Unable to set/reset proxy ARP on $interface\"" ) unless $optional;
|
||||
emit "fi\n";
|
||||
}
|
||||
}
|
||||
@@ -158,10 +164,14 @@ sub setup_proxy_arp() {
|
||||
|
||||
for my $interface ( @$interfaces ) {
|
||||
my $value = get_interface_option $interface, 'proxyndp';
|
||||
my $optional = interface_is_optional $interface;
|
||||
|
||||
$interface = get_physical $interface;
|
||||
|
||||
emit ( "if [ -f /proc/sys/net/ipv6/conf/$interface/proxy_ndp ] ; then" ,
|
||||
" echo $value > /proc/sys/net/ipv6/conf/$interface/proxy_ndp" );
|
||||
emit ( 'else' ,
|
||||
" error_message \"WARNING: Unable to set/reset Proxy NDP on $interface\"" ) unless interface_is_optional( $interface );
|
||||
" error_message \"WARNING: Unable to set/reset Proxy NDP on $interface\"" ) unless $optional;
|
||||
emit "fi\n";
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007,2008,2009 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Traffic Control is from tc4shorewall Version 0.5
|
||||
# (c) 2005 Arne Bernin <arne@ucbering.de>
|
||||
@@ -40,7 +40,7 @@ use strict;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw( setup_tc );
|
||||
our @EXPORT_OK = qw( process_tc_rule initialize );
|
||||
our $VERSION = '4.4_1';
|
||||
our $VERSION = '4.4_8';
|
||||
|
||||
our %tcs = ( T => { chain => 'tcpost',
|
||||
connmark => 0,
|
||||
@@ -79,48 +79,6 @@ use constant { NOMARK => 0 ,
|
||||
HIGHMARK => 2
|
||||
};
|
||||
|
||||
our @tccmd = ( { match => sub ( $ ) { $_[0] eq 'SAVE' } ,
|
||||
target => 'CONNMARK --save-mark --mask' ,
|
||||
mark => SMALLMARK ,
|
||||
mask => '0xFF' ,
|
||||
connmark => 1
|
||||
} ,
|
||||
{ match => sub ( $ ) { $_[0] eq 'RESTORE' },
|
||||
target => 'CONNMARK --restore-mark --mask' ,
|
||||
mark => SMALLMARK ,
|
||||
mask => '0xFF' ,
|
||||
connmark => 1
|
||||
} ,
|
||||
{ match => sub ( $ ) { $_[0] eq 'CONTINUE' },
|
||||
target => 'RETURN' ,
|
||||
mark => NOMARK ,
|
||||
mask => '' ,
|
||||
connmark => 0
|
||||
} ,
|
||||
{ match => sub ( $ ) { $_[0] eq 'SAME' },
|
||||
target => 'sticky' ,
|
||||
mark => NOMARK ,
|
||||
mask => '' ,
|
||||
connmark => 0
|
||||
} ,
|
||||
{ match => sub ( $ ) { $_[0] =~ /^IPMARK/ },
|
||||
target => 'IPMARK' ,
|
||||
mark => NOMARK,
|
||||
mask => '',
|
||||
connmark => 0
|
||||
} ,
|
||||
{ match => sub ( $ ) { $_[0] =~ '\|.*'} ,
|
||||
target => 'MARK --or-mark' ,
|
||||
mark => HIGHMARK ,
|
||||
mask => '' } ,
|
||||
{ match => sub ( $ ) { $_[0] =~ '&.*' },
|
||||
target => 'MARK --and-mark ' ,
|
||||
mark => HIGHMARK ,
|
||||
mask => '' ,
|
||||
connmark => 0
|
||||
}
|
||||
);
|
||||
|
||||
our %flow_keys = ( 'src' => 1,
|
||||
'dst' => 1,
|
||||
'proto' => 1,
|
||||
@@ -153,7 +111,7 @@ our @deferred_rules;
|
||||
#
|
||||
# TCDevices Table
|
||||
#
|
||||
# %tcdevices { <interface> -> {in_bandwidth => <value> ,
|
||||
# %tcdevices { <interface> => {in_bandwidth => <value> ,
|
||||
# out_bandwidth => <value> ,
|
||||
# number => <number>,
|
||||
# classify => 0|1
|
||||
@@ -172,7 +130,7 @@ our %tcdevices;
|
||||
our @devnums;
|
||||
our $devnum;
|
||||
our $sticky;
|
||||
|
||||
our $ipp2p;
|
||||
|
||||
#
|
||||
# TCClasses Table
|
||||
@@ -225,11 +183,14 @@ sub initialize( $ ) {
|
||||
@devnums = ();
|
||||
$devnum = 0;
|
||||
$sticky = 0;
|
||||
$ipp2p = 0;
|
||||
}
|
||||
|
||||
sub process_tc_rule( ) {
|
||||
my ( $originalmark, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper ) = split_line1 2, 12, 'tcrules file';
|
||||
|
||||
our @tccmd;
|
||||
|
||||
if ( $originalmark eq 'COMMENT' ) {
|
||||
process_comment;
|
||||
return;
|
||||
@@ -265,9 +226,9 @@ sub process_tc_rule( ) {
|
||||
fatal_error "Invalid chain designator for source $fw" unless $tcsref->{fw};
|
||||
}
|
||||
|
||||
$chain = $tcsref->{chain} if $tcsref->{chain};
|
||||
$target = $tcsref->{target} if $tcsref->{target};
|
||||
$mark = "$mark/0xFF" if $connmark = $tcsref->{connmark};
|
||||
$chain = $tcsref->{chain} if $tcsref->{chain};
|
||||
$target = $tcsref->{target} if $tcsref->{target};
|
||||
$mark = "$mark/" . in_hex( $globals{TC_MASK} ) if $connmark = $tcsref->{connmark};
|
||||
|
||||
require_capability ('CONNMARK' , "CONNMARK Rules", '' ) if $connmark;
|
||||
|
||||
@@ -285,8 +246,6 @@ sub process_tc_rule( ) {
|
||||
}
|
||||
}
|
||||
|
||||
my $mask = 0xffff;
|
||||
|
||||
my ($cmd, $rest) = split( '/', $mark, 2 );
|
||||
|
||||
$list = '';
|
||||
@@ -354,8 +313,40 @@ sub process_tc_rule( ) {
|
||||
}
|
||||
|
||||
$target = "IPMARK --addr $srcdst --and-mask $mask1 --or-mask $mask2 --shift $shift";
|
||||
} elsif ( $target eq 'TPROXY ' ) {
|
||||
require_capability( 'TPROXY_TARGET', 'Use of TPROXY', 's');
|
||||
|
||||
fatal_error "Invalid TPROXY specification( $cmd/$rest )" if $rest;
|
||||
|
||||
$chain = 'tcpre';
|
||||
|
||||
$cmd =~ /TPROXY\((.+?)\)$/;
|
||||
|
||||
my $params = $1;
|
||||
|
||||
fatal_error "Invalid TPROXY specification( $cmd )" unless defined $params;
|
||||
|
||||
( $mark, my $port, my $ip, my $bad ) = split ',', $params;
|
||||
|
||||
fatal_error "Invalid TPROXY specification( $cmd )" if defined $bad;
|
||||
|
||||
if ( $port ) {
|
||||
$port = validate_port( 'tcp', $port );
|
||||
} else {
|
||||
$port = 0;
|
||||
}
|
||||
|
||||
$target .= "--on-port $port";
|
||||
|
||||
if ( defined $ip && $ip ne '' ) {
|
||||
validate_address $ip, 1;
|
||||
$target .= " --on-ip $ip";
|
||||
}
|
||||
|
||||
$target .= ' --tproxy-mark';
|
||||
}
|
||||
|
||||
|
||||
if ( $rest ) {
|
||||
fatal_error "Invalid MARK ($originalmark)" if $marktype == NOMARK;
|
||||
|
||||
@@ -376,10 +367,10 @@ sub process_tc_rule( ) {
|
||||
|
||||
validate_mark $mark;
|
||||
|
||||
if ( $config{HIGH_ROUTE_MARKS} ) {
|
||||
if ( $config{PROVIDER_OFFSET} ) {
|
||||
my $val = numeric_value( $cmd );
|
||||
fatal_error "Invalid MARK/CLASSIFY ($cmd)" unless defined $val;
|
||||
my $limit = $config{WIDE_TC_MARKS} ? 65535 : 255;
|
||||
my $limit = $globals{TC_MASK};
|
||||
fatal_error "Marks <= $limit may not be set in the PREROUTING or OUTPUT chains when HIGH_ROUTE_MARKS=Yes"
|
||||
if $cmd && ( $chain eq 'tcpre' || $chain eq 'tcout' ) && $val <= $limit;
|
||||
}
|
||||
@@ -390,7 +381,7 @@ sub process_tc_rule( ) {
|
||||
$restrictions{$chain} ,
|
||||
do_proto( $proto, $ports, $sports) .
|
||||
do_user( $user ) .
|
||||
do_test( $testval, $mask ) .
|
||||
do_test( $testval, $globals{TC_MASK} ) .
|
||||
do_length( $length ) .
|
||||
do_tos( $tos ) .
|
||||
do_connbytes( $connbytes ) .
|
||||
@@ -451,6 +442,65 @@ sub process_flow($) {
|
||||
$flow;
|
||||
}
|
||||
|
||||
sub process_simple_device() {
|
||||
my ( $device , $type , $bandwidth ) = split_line 1, 3, 'tcinterfaces';
|
||||
|
||||
fatal_error "Duplicate INTERFACE ($device)" if $tcdevices{$device};
|
||||
fatal_error "Invalid INTERFACE name ($device)" if $device =~ /[:+]/;
|
||||
|
||||
my $number = in_hexp( $tcdevices{$device} = ++$devnum );
|
||||
|
||||
my $physical = physical_name $device;
|
||||
my $dev = chain_base( $physical );
|
||||
|
||||
if ( $type ne '-' ) {
|
||||
if ( lc $type eq 'external' ) {
|
||||
$type = 'nfct-src';
|
||||
} elsif ( lc $type eq 'internal' ) {
|
||||
$type = 'dst';
|
||||
} else {
|
||||
fatal_error "Invalid TYPE ($type)";
|
||||
}
|
||||
}
|
||||
|
||||
$bandwidth = rate_to_kbit( $bandwidth );
|
||||
|
||||
emit "if interface_is_up $physical; then";
|
||||
|
||||
push_indent;
|
||||
|
||||
emit ( "${dev}_exists=Yes",
|
||||
"qt \$TC qdisc del dev $physical root",
|
||||
"qt \$TC qdisc del dev $physical ingress\n"
|
||||
);
|
||||
|
||||
emit ( "run_tc qdisc add dev $physical handle ffff: ingress",
|
||||
"run_tc filter add dev $physical parent ffff: protocol all prio 10 u32 match ip src 0.0.0.0/0 police rate ${bandwidth}kbit burst 10k drop flowid :1\n"
|
||||
) if $bandwidth;
|
||||
|
||||
emit "run_tc qdisc add dev $physical root handle $number: prio bands 3 priomap $config{TC_PRIOMAP}";
|
||||
|
||||
for ( my $i = 1; $i <= 3; $i++ ) {
|
||||
emit "run_tc qdisc add dev $physical parent $number:$i handle ${number}${i}: sfq quantum 1875 limit 127 perturb 10";
|
||||
emit "run_tc filter add dev $physical protocol all parent $number: handle $i fw classid $number:$i";
|
||||
emit "run_tc filter add dev $physical protocol all prio 1 parent ${number}$i: handle ${number}${i} flow hash keys $type divisor 1024" if $type ne '-' && have_capability 'FLOW_FILTER';
|
||||
emit '';
|
||||
}
|
||||
|
||||
save_progress_message_short qq(" TC Device $physical defined.");
|
||||
|
||||
pop_indent;
|
||||
emit 'else';
|
||||
push_indent;
|
||||
|
||||
emit qq(error_message "WARNING: Device $physical is not in the UP state -- traffic-shaping configuration skipped");
|
||||
emit "${dev}_exists=";
|
||||
pop_indent;
|
||||
emit "fi\n";
|
||||
|
||||
progress_message " Simple tcdevice \"$currentline\" $done.";
|
||||
}
|
||||
|
||||
sub validate_tc_device( ) {
|
||||
my ( $device, $inband, $outband , $options , $redirected ) = split_line 3, 5, 'tcdevices';
|
||||
|
||||
@@ -509,13 +559,13 @@ sub validate_tc_device( ) {
|
||||
if ( @redirected ) {
|
||||
fatal_error "IFB devices may not have IN-BANDWIDTH" if $inband ne '-' && $inband;
|
||||
$classify = 1;
|
||||
}
|
||||
|
||||
for my $rdevice ( @redirected ) {
|
||||
fatal_error "Invalid device name ($rdevice)" if $rdevice =~ /[:+]/;
|
||||
my $rdevref = $tcdevices{$rdevice};
|
||||
fatal_error "REDIRECTED device ($rdevice) has not been defined in this file" unless $rdevref;
|
||||
fatal_error "IN-BANDWIDTH must be zero for REDIRECTED devices" if $rdevref->{in_bandwidth} ne '0kbit';
|
||||
for my $rdevice ( @redirected ) {
|
||||
fatal_error "Invalid device name ($rdevice)" if $rdevice =~ /[:+]/;
|
||||
my $rdevref = $tcdevices{$rdevice};
|
||||
fatal_error "REDIRECTED device ($rdevice) has not been defined in this file" unless $rdevref;
|
||||
fatal_error "IN-BANDWIDTH must be zero for REDIRECTED devices" if $rdevref->{in_bandwidth} ne '0kbit';
|
||||
}
|
||||
}
|
||||
|
||||
$tcdevices{$device} = { in_bandwidth => rate_to_kbit( $inband ) . 'kbit',
|
||||
@@ -531,6 +581,7 @@ sub validate_tc_device( ) {
|
||||
qdisc => $qdisc,
|
||||
guarantee => 0,
|
||||
name => $device,
|
||||
physical => physical_name $device
|
||||
} ,
|
||||
|
||||
push @tcdevices, $device;
|
||||
@@ -647,15 +698,17 @@ sub validate_tc_class( ) {
|
||||
if ( $devref->{classify} ) {
|
||||
warning_message "INTERFACE $device has the 'classify' option - MARK value ($mark) ignored";
|
||||
} else {
|
||||
fatal_error "Invalid Mark ($mark)" unless $mark =~ /^([0-9]+|0x[0-9a-fA-F]+)$/ && numeric_value( $mark ) <= 0xff;
|
||||
fatal_error "MARK may not be specified when TC_BITS=0" unless $config{TC_BITS};
|
||||
|
||||
$markval = numeric_value( $mark );
|
||||
fatal_error "Invalid MARK ($markval)" unless defined $markval;
|
||||
|
||||
fatal_error "Invalid Mark ($mark)" unless $markval <= $globals{TC_MAX};
|
||||
|
||||
if ( $classnumber ) {
|
||||
fatal_error "Duplicate Class NUMBER ($classnumber)" if $tcref->{$classnumber};
|
||||
} else {
|
||||
$classnumber = $config{WIDE_TC_MARKS} ? $tcref->{nextclass}++ : hex_value( $devnum . $markval );
|
||||
$classnumber = $config{WIDE_TC_MARKS} ? $devref->{nextclass}++ : hex_value( $devnum . $markval );
|
||||
fatal_error "Duplicate MARK ($mark)" if $tcref->{$classnumber};
|
||||
}
|
||||
}
|
||||
@@ -713,6 +766,7 @@ sub validate_tc_class( ) {
|
||||
parent => $parentclass,
|
||||
leaf => 1,
|
||||
guarantee => 0,
|
||||
limit => 127,
|
||||
};
|
||||
|
||||
$tcref = $tcref->{$classnumber};
|
||||
@@ -753,7 +807,7 @@ sub validate_tc_class( ) {
|
||||
fatal_error q(The 'occurs' option is only valid for IPv4) if $family == F_IPV6;
|
||||
fatal_error q(The 'occurs' option may not be used with 'classify') if $devref->{classify};
|
||||
fatal_error "Invalid 'occurs' ($val)" unless defined $occurs && $occurs > 1 && $occurs <= 256;
|
||||
fatal_error "Invalid 'occurs' ($val)" if $occurs > ( $config{WIDE_TC_MARKS} ? 8191 : 255 );
|
||||
fatal_error "Invalid 'occurs' ($val)" if $occurs > $globals{TC_MAX};
|
||||
fatal_error q(Duplicate 'occurs') if $tcref->{occurs} > 1;
|
||||
fatal_error q(The 'occurs' option is not valid with 'default') if $devref->{default} == $classnumber;
|
||||
fatal_error q(The 'occurs' option is not valid with 'tos') if @{$tcref->{tos}};
|
||||
@@ -761,6 +815,10 @@ sub validate_tc_class( ) {
|
||||
|
||||
$tcref->{occurs} = $occurs;
|
||||
$devref->{occurs} = 1;
|
||||
} elsif ( $option =~ /^limit=(\d+)$/ ) {
|
||||
warning_message "limit ignored with pfifo queuing" if $tcref->{pfifo};
|
||||
fatal_error "Invalid limit ($1)" if $1 < 3 || $1 > 128;
|
||||
$tcref->{limit} = $1;
|
||||
} else {
|
||||
fatal_error "Unknown option ($option)";
|
||||
}
|
||||
@@ -789,6 +847,7 @@ sub validate_tc_class( ) {
|
||||
pfifo => $tcref->{pfifo},
|
||||
occurs => 0,
|
||||
parent => $parentclass,
|
||||
limit => $tcref->{limit},
|
||||
};
|
||||
push @tcclasses, "$device:$classnumber";
|
||||
};
|
||||
@@ -825,7 +884,7 @@ sub process_tc_filter( ) {
|
||||
fatal_error "Unknown CLASS ($devclass)" unless $tcref && $tcref->{occurs};
|
||||
fatal_error "Filters may not specify an occurring CLASS" if $tcref->{occurs} > 1;
|
||||
|
||||
my $rule = "filter add dev $device protocol ip parent $devnum:0 prio 10 u32";
|
||||
my $rule = "filter add dev $devref->{physical} protocol ip parent $devnum:0 prio 10 u32";
|
||||
|
||||
if ( $source ne '-' ) {
|
||||
my ( $net , $mask ) = decompose_net( $source );
|
||||
@@ -896,7 +955,7 @@ sub process_tc_filter( ) {
|
||||
$lasttnum = $tnum;
|
||||
$lastrule = $rule;
|
||||
|
||||
emit( "\nrun_tc filter add dev $device parent $devnum:0 protocol ip prio 10 handle $tnum: u32 divisor 1" );
|
||||
emit( "\nrun_tc filter add dev $devref->{physical} parent $devnum:0 protocol ip prio 10 handle $tnum: u32 divisor 1" );
|
||||
}
|
||||
#
|
||||
# And link to it using the current contents of $rule
|
||||
@@ -906,7 +965,7 @@ sub process_tc_filter( ) {
|
||||
#
|
||||
# The rule to match the port(s) will be inserted into the new table
|
||||
#
|
||||
$rule = "filter add dev $device protocol ip parent $devnum:0 prio 10 u32 ht $tnum:0";
|
||||
$rule = "filter add dev $devref->{physical} protocol ip parent $devnum:0 prio 10 u32 ht $tnum:0";
|
||||
|
||||
if ( $portlist eq '-' ) {
|
||||
fatal_error "Only TCP, UDP and SCTP may specify SOURCE PORT"
|
||||
@@ -1003,16 +1062,104 @@ sub process_tc_filter( ) {
|
||||
|
||||
$currentline =~ s/\s+/ /g;
|
||||
|
||||
save_progress_message_short qq(" TC Filter \"$currentline\" defined.");
|
||||
save_progress_message_short qq(' TC Filter \"$currentline\" defined.');
|
||||
|
||||
emit '';
|
||||
|
||||
}
|
||||
|
||||
sub process_tc_priority() {
|
||||
my ( $band, $proto, $ports , $address, $interface, $helper ) = split_line1 1, 6, 'tcpri';
|
||||
|
||||
if ( $band eq 'COMMENT' ) {
|
||||
process_comment;
|
||||
return;
|
||||
}
|
||||
|
||||
my $val = numeric_value $band;
|
||||
|
||||
fatal_error "Invalid PRIORITY ($band)" unless $val && $val <= 3;
|
||||
|
||||
my $rule = do_helper( $helper ) . "-j MARK --set-mark $band";
|
||||
|
||||
$rule .= join('', '/', in_hex( $globals{TC_MASK} ) ) if have_capability( 'EXMARK' );
|
||||
|
||||
if ( $interface ne '-' ) {
|
||||
fatal_error "Invalid combination of columns" unless $address eq '-' && $proto eq '-' && $ports eq '-';
|
||||
|
||||
my $forwardref = $mangle_table->{tcfor};
|
||||
|
||||
add_rule( $forwardref ,
|
||||
join( '', match_source_dev( $interface) , $rule ) ,
|
||||
1 );
|
||||
} else {
|
||||
my $postref = $mangle_table->{tcpost};
|
||||
|
||||
if ( $address ne '-' ) {
|
||||
fatal_error "Invalid combination of columns" unless $proto eq '-' && $ports eq '-';
|
||||
add_rule( $postref ,
|
||||
join( '', match_source_net( $address) , $rule ) ,
|
||||
1 );
|
||||
} else {
|
||||
add_rule( $postref ,
|
||||
join( '', do_proto( $proto, $ports, '-' , 0 ) , $rule ) ,
|
||||
1 );
|
||||
|
||||
if ( $ports ne '-' ) {
|
||||
my $protocol = resolve_proto $proto;
|
||||
|
||||
if ( $proto =~ /^ipp2p/ ) {
|
||||
fatal_error "ipp2p may not be used when there are tracked providers and PROVIDER_OFFSET=0" if @routemarked_interfaces && $config{PROVIDER_OFFSET} == 0;
|
||||
$ipp2p = 1;
|
||||
}
|
||||
|
||||
add_rule( $postref ,
|
||||
join( '' , do_proto( $proto, '-', $ports, 0 ) , $rule ) ,
|
||||
1 )
|
||||
unless $proto =~ /^ipp2p/ || $protocol == ICMP || $protocol == IPv6_ICMP;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub setup_simple_traffic_shaping() {
|
||||
my $interfaces;
|
||||
|
||||
save_progress_message q("Setting up Traffic Control...");
|
||||
|
||||
my $fn = open_file 'tcinterfaces';
|
||||
|
||||
if ( $fn ) {
|
||||
first_entry "$doing $fn...";
|
||||
process_simple_device, $interfaces++ while read_a_line;
|
||||
} else {
|
||||
$fn = find_file 'tcinterfaces';
|
||||
}
|
||||
|
||||
my $fn1 = open_file 'tcpri';
|
||||
|
||||
if ( $fn1 ) {
|
||||
first_entry
|
||||
sub {
|
||||
progress_message2 "$doing $fn1...";
|
||||
warning_message "There are entries in $fn1 but $fn was empty" unless $interfaces;
|
||||
};
|
||||
|
||||
process_tc_priority while read_a_line;
|
||||
|
||||
clear_comment;
|
||||
|
||||
if ( $ipp2p ) {
|
||||
insert_rule1 $mangle_table->{tcpost} , 0 , '-m mark --mark 0/' . in_hex( $globals{TC_MASK} ) . ' -j CONNMARK --restore-mark --ctmask ' . in_hex( $globals{TC_MASK} );
|
||||
add_rule $mangle_table->{tcpost} , '-m mark ! --mark 0/' . in_hex( $globals{TC_MASK} ) . ' -j CONNMARK --save-mark --ctmask ' . in_hex( $globals{TC_MASK} );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub setup_traffic_shaping() {
|
||||
our $lastrule = '';
|
||||
|
||||
save_progress_message "Setting up Traffic Control...";
|
||||
save_progress_message q("Setting up Traffic Control...");
|
||||
|
||||
my $fn = open_file 'tcdevices';
|
||||
|
||||
@@ -1022,6 +1169,9 @@ sub setup_traffic_shaping() {
|
||||
validate_tc_device while read_a_line;
|
||||
}
|
||||
|
||||
my $sfq = $devnum;
|
||||
my $sfqinhex;
|
||||
|
||||
$devnum = $devnum > 10 ? 10 : 1;
|
||||
|
||||
$fn = open_file 'tcclasses';
|
||||
@@ -1033,12 +1183,15 @@ sub setup_traffic_shaping() {
|
||||
}
|
||||
|
||||
for my $device ( @tcdevices ) {
|
||||
my $dev = chain_base( $device );
|
||||
my $devref = $tcdevices{$device};
|
||||
my $defmark = in_hexp ( $devref->{default} || 0 );
|
||||
my $devnum = in_hexp $devref->{number};
|
||||
my $r2q = int calculate_r2q $devref->{out_bandwidth};
|
||||
|
||||
$device = physical_name $device;
|
||||
|
||||
my $dev = chain_base( $device );
|
||||
|
||||
emit "if interface_is_up $device; then";
|
||||
|
||||
push_indent;
|
||||
@@ -1088,7 +1241,7 @@ sub setup_traffic_shaping() {
|
||||
emit( "run_tc filter add dev $rdev parent ffff: protocol all u32 match u32 0 0 action mirred egress redirect dev $device > /dev/null" );
|
||||
}
|
||||
|
||||
save_progress_message_short " TC Device $device defined.";
|
||||
save_progress_message_short qq(" TC Device $device defined.");
|
||||
|
||||
pop_indent;
|
||||
emit 'else';
|
||||
@@ -1121,12 +1274,14 @@ sub setup_traffic_shaping() {
|
||||
my $classid = join( ':', in_hexp $devicenumber, $classnum);
|
||||
my $rate = "$tcref->{rate}kbit";
|
||||
my $quantum = calculate_quantum $rate, calculate_r2q( $devref->{out_bandwidth} );
|
||||
|
||||
$classids{$classid}=$device;
|
||||
$device = physical_name $device;
|
||||
|
||||
my $dev = chain_base $device;
|
||||
my $priority = $tcref->{priority} << 8;
|
||||
my $parent = in_hexp $tcref->{parent};
|
||||
|
||||
$classids{$classid}=$device;
|
||||
|
||||
if ( $lastdevice ne $device ) {
|
||||
if ( $lastdevice ) {
|
||||
pop_indent;
|
||||
@@ -1153,17 +1308,18 @@ sub setup_traffic_shaping() {
|
||||
}
|
||||
}
|
||||
|
||||
emit( "run_tc qdisc add dev $device parent $classid handle ${classnum}: sfq quantum \$quantum limit 127 perturb 10" ) if $tcref->{leaf} && ! $tcref->{pfifo};
|
||||
if ( $tcref->{leaf} && ! $tcref->{pfifo} ) {
|
||||
$sfqinhex = in_hexp( ++$sfq);
|
||||
emit( "run_tc qdisc add dev $device parent $classid handle $sfqinhex: sfq quantum \$quantum limit $tcref->{limit} perturb 10" );
|
||||
}
|
||||
#
|
||||
# add filters
|
||||
#
|
||||
unless ( $devref->{classify} ) {
|
||||
if ( $tcref->{occurs} == 1 ) {
|
||||
emit "run_tc filter add dev $device protocol all parent $devicenumber:0 prio " . ( $priority | 20 ) . " handle $mark fw classid $classid";
|
||||
}
|
||||
emit "run_tc filter add dev $device protocol all parent $devicenumber:0 prio " . ( $priority | 20 ) . " handle $mark fw classid $classid" if $tcref->{occurs} == 1;
|
||||
}
|
||||
|
||||
emit "run_tc filter add dev $device protocol all prio 1 parent $classnum: handle $classnum flow hash keys $tcref->{flow} divisor 1024" if $tcref->{flow};
|
||||
emit "run_tc filter add dev $device protocol all prio 1 parent $sfqinhex: handle $classnum flow hash keys $tcref->{flow} divisor 1024" if $tcref->{flow};
|
||||
#
|
||||
# options
|
||||
#
|
||||
@@ -1187,7 +1343,7 @@ sub setup_traffic_shaping() {
|
||||
$fn = open_file 'tcfilters';
|
||||
|
||||
if ( $fn ) {
|
||||
first_entry( sub { progress_message2 "$doing $fn..."; save_progress_message "Adding TC Filters"; } );
|
||||
first_entry( sub { progress_message2 "$doing $fn..."; save_progress_message q("Adding TC Filters"); } );
|
||||
|
||||
process_tc_filter while read_a_line;
|
||||
}
|
||||
@@ -1199,11 +1355,11 @@ sub setup_traffic_shaping() {
|
||||
#
|
||||
sub setup_tc() {
|
||||
|
||||
if ( $capabilities{MANGLE_ENABLED} && $config{MANGLE_ENABLED} ) {
|
||||
if ( $config{MANGLE_ENABLED} ) {
|
||||
ensure_mangle_chain 'tcpre';
|
||||
ensure_mangle_chain 'tcout';
|
||||
|
||||
if ( $capabilities{MANGLE_FORWARD} ) {
|
||||
if ( have_capability( 'MANGLE_FORWARD' ) ) {
|
||||
ensure_mangle_chain 'tcfor';
|
||||
ensure_mangle_chain 'tcpost';
|
||||
}
|
||||
@@ -1211,43 +1367,88 @@ sub setup_tc() {
|
||||
my $mark_part = '';
|
||||
|
||||
if ( @routemarked_interfaces && ! $config{TC_EXPERT} ) {
|
||||
$mark_part = $config{HIGH_ROUTE_MARKS} ? $config{WIDE_TC_MARKS} ? '-m mark --mark 0/0xFF0000' : '-m mark --mark 0/0xFF00' : '-m mark --mark 0/0xFF';
|
||||
$mark_part = '-m mark --mark 0/' . in_hex( $globals{PROVIDER_MASK} ) . ' ';
|
||||
|
||||
for my $interface ( @routemarked_interfaces ) {
|
||||
add_rule $mangle_table->{PREROUTING} , "-i $interface -j tcpre";
|
||||
unless ( $config{TRACK_PROVIDERS} ) {
|
||||
#
|
||||
# This is overloading TRACK_PROVIDERS a bit but sending tracked packets through PREROUTING is a PITA for users
|
||||
#
|
||||
for my $interface ( @routemarked_interfaces ) {
|
||||
add_rule $mangle_table->{PREROUTING} , match_source_dev( $interface ) . "-j tcpre";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_rule $mangle_table->{PREROUTING} , "$mark_part -j tcpre";
|
||||
add_rule $mangle_table->{OUTPUT} , "$mark_part -j tcout";
|
||||
add_jump $mangle_table->{PREROUTING} , 'tcpre', 0, $mark_part;
|
||||
add_jump $mangle_table->{OUTPUT} , 'tcout', 0, $mark_part;
|
||||
|
||||
if ( $capabilities{MANGLE_FORWARD} ) {
|
||||
add_rule $mangle_table->{FORWARD} , '-j tcfor';
|
||||
add_rule $mangle_table->{POSTROUTING} , '-j tcpost';
|
||||
}
|
||||
|
||||
if ( $config{HIGH_ROUTE_MARKS} ) {
|
||||
for my $chain qw(INPUT FORWARD) {
|
||||
insert_rule1 $mangle_table->{$chain}, 0, $config{WIDE_TC_MARKS} ? '-j MARK --and-mark 0xFFFF' : '-j MARK --and-mark 0xFF';
|
||||
}
|
||||
#
|
||||
# In POSTROUTING, we only want to clear routing mark and not IPMARK.
|
||||
#
|
||||
insert_rule1 $mangle_table->{POSTROUTING}, 0, $config{WIDE_TC_MARKS} ? '-m mark --mark 0/0xFFFF -j MARK --and-mark 0' : '-m mark --mark 0/0xFF -j MARK --and-mark 0';
|
||||
if ( have_capability( 'MANGLE_FORWARD' ) ) {
|
||||
add_rule( $mangle_table->{FORWARD}, '-j MARK --set-mark 0' ) if have_capability 'MARK';
|
||||
add_jump $mangle_table->{FORWARD} , 'tcfor', 0;
|
||||
add_jump $mangle_table->{POSTROUTING} , 'tcpost', 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $globals{TC_SCRIPT} ) {
|
||||
save_progress_message 'Setting up Traffic Control...';
|
||||
save_progress_message q('Setting up Traffic Control...');
|
||||
append_file $globals{TC_SCRIPT};
|
||||
} elsif ( $config{TC_ENABLED} eq 'Internal' ) {
|
||||
setup_traffic_shaping;
|
||||
} elsif ( $config{TC_ENABLED} eq 'Simple' ) {
|
||||
setup_simple_traffic_shaping;
|
||||
}
|
||||
|
||||
if ( $config{TC_ENABLED} ) {
|
||||
our @tccmd = ( { match => sub ( $ ) { $_[0] eq 'SAVE' } ,
|
||||
target => 'CONNMARK --save-mark --mask' ,
|
||||
mark => SMALLMARK ,
|
||||
mask => in_hex( $globals{TC_MASK} ) ,
|
||||
connmark => 1
|
||||
} ,
|
||||
{ match => sub ( $ ) { $_[0] eq 'RESTORE' },
|
||||
target => 'CONNMARK --restore-mark --mask' ,
|
||||
mark => SMALLMARK ,
|
||||
mask => in_hex( $globals{TC_MASK} ) ,
|
||||
connmark => 1
|
||||
} ,
|
||||
{ match => sub ( $ ) { $_[0] eq 'CONTINUE' },
|
||||
target => 'RETURN' ,
|
||||
mark => NOMARK ,
|
||||
mask => '' ,
|
||||
connmark => 0
|
||||
} ,
|
||||
{ match => sub ( $ ) { $_[0] eq 'SAME' },
|
||||
target => 'sticky' ,
|
||||
mark => NOMARK ,
|
||||
mask => '' ,
|
||||
connmark => 0
|
||||
} ,
|
||||
{ match => sub ( $ ) { $_[0] =~ /^IPMARK/ },
|
||||
target => 'IPMARK' ,
|
||||
mark => NOMARK,
|
||||
mask => '',
|
||||
connmark => 0
|
||||
} ,
|
||||
{ match => sub ( $ ) { $_[0] =~ '\|.*'} ,
|
||||
target => 'MARK --or-mark' ,
|
||||
mark => HIGHMARK ,
|
||||
mask => '' } ,
|
||||
{ match => sub ( $ ) { $_[0] =~ '&.*' },
|
||||
target => 'MARK --and-mark ' ,
|
||||
mark => HIGHMARK ,
|
||||
mask => '' ,
|
||||
connmark => 0
|
||||
} ,
|
||||
{ match => sub ( $ ) { $_[0] =~ /^TPROXY/ },
|
||||
target => 'TPROXY',
|
||||
mark => HIGHMARK,
|
||||
mask => '',
|
||||
connmark => '' },
|
||||
);
|
||||
|
||||
if ( my $fn = open_file 'tcrules' ) {
|
||||
|
||||
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'MANGLE_ENABLED' , 'a non-empty tcrules file' , 's'; } );
|
||||
first_entry "$doing $fn...";
|
||||
|
||||
process_tc_rule while read_a_line;
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007,2008,2009 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -34,7 +34,7 @@ use strict;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw( setup_tunnels );
|
||||
our @EXPORT_OK = ( );
|
||||
our $VERSION = '4.3_7';
|
||||
our $VERSION = '4.4_7';
|
||||
|
||||
#
|
||||
# Here starts the tunnel stuff -- we really should get rid of this crap...
|
||||
@@ -83,10 +83,10 @@ sub setup_tunnels() {
|
||||
for my $zone ( split_list $gatewayzones, 'zone' ) {
|
||||
my $type = zone_type( $zone );
|
||||
fatal_error "Invalid zone ($zone) for GATEWAY ZONE" if $type == FIREWALL || $type == BPORT;
|
||||
$inchainref = ensure_filter_chain "${zone}2${fw}", 1;
|
||||
$outchainref = ensure_filter_chain "${fw}2${zone}", 1;
|
||||
$inchainref = ensure_filter_chain rules_chain( ${zone}, ${fw} ), 1;
|
||||
$outchainref = ensure_filter_chain rules_chain( ${fw}, ${zone} ), 1;
|
||||
|
||||
unless ( $capabilities{POLICY_MATCH} ) {
|
||||
unless ( have_ipsec ) {
|
||||
add_tunnel_rule $inchainref, "-p 50 $source -j ACCEPT";
|
||||
add_tunnel_rule $outchainref, "-p 50 $dest -j ACCEPT";
|
||||
|
||||
@@ -239,8 +239,8 @@ sub setup_tunnels() {
|
||||
|
||||
fatal_error "Invalid tunnel ZONE ($zone)" if $zonetype == FIREWALL || $zonetype == BPORT;
|
||||
|
||||
my $inchainref = ensure_filter_chain "${zone}2${fw}", 1;
|
||||
my $outchainref = ensure_filter_chain "${fw}2${zone}", 1;
|
||||
my $inchainref = ensure_filter_chain rules_chain( ${zone}, ${fw} ), 1;
|
||||
my $outchainref = ensure_filter_chain rules_chain( ${fw}, ${zone} ), 1;
|
||||
|
||||
$gateway = ALLIP if $gateway eq '-';
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007,2008,2009 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -60,6 +60,8 @@ our @EXPORT = qw( NOTHING
|
||||
interface_number
|
||||
find_interface
|
||||
known_interface
|
||||
get_physical
|
||||
physical_name
|
||||
have_bridges
|
||||
port_to_bridge
|
||||
source_port_to_bridge
|
||||
@@ -70,10 +72,11 @@ our @EXPORT = qw( NOTHING
|
||||
validate_hosts_file
|
||||
find_hosts_by_option
|
||||
all_ipsets
|
||||
have_ipsec
|
||||
);
|
||||
|
||||
our @EXPORT_OK = qw( initialize );
|
||||
our $VERSION = '4.4_1';
|
||||
our $VERSION = '4.4_8';
|
||||
|
||||
#
|
||||
# IPSEC Option types
|
||||
@@ -135,7 +138,8 @@ our %reservedName = ( all => 1,
|
||||
#
|
||||
# %interfaces { <interface1> => { name => <name of interface>
|
||||
# root => <name without trailing '+'>
|
||||
# options => { <option1> = <val1> ,
|
||||
# options => { port => undef|1
|
||||
# <option1> = <val1> , #See %validinterfaceoptions
|
||||
# ...
|
||||
# }
|
||||
# zone => <zone name>
|
||||
@@ -143,6 +147,7 @@ our %reservedName = ( all => 1,
|
||||
# bridge => <bridge>
|
||||
# broadcasts => 'none', 'detect' or [ <addr1>, <addr2>, ... ]
|
||||
# number => <ordinal position in the interfaces file>
|
||||
# physical => <physical interface name>
|
||||
# }
|
||||
# }
|
||||
#
|
||||
@@ -150,7 +155,9 @@ our @interfaces;
|
||||
our %interfaces;
|
||||
our @bport_zones;
|
||||
our %ipsets;
|
||||
our %physical;
|
||||
our $family;
|
||||
our $have_ipsec;
|
||||
|
||||
use constant { FIREWALL => 1,
|
||||
IP => 2,
|
||||
@@ -163,6 +170,8 @@ use constant { SIMPLE_IF_OPTION => 1,
|
||||
NUMERIC_IF_OPTION => 4,
|
||||
OBSOLETE_IF_OPTION => 5,
|
||||
IPLIST_IF_OPTION => 6,
|
||||
STRING_IF_OPTION => 7,
|
||||
|
||||
MASK_IF_OPTION => 7,
|
||||
|
||||
IF_OPTION_ZONEONLY => 8,
|
||||
@@ -171,6 +180,10 @@ use constant { SIMPLE_IF_OPTION => 1,
|
||||
|
||||
our %validinterfaceoptions;
|
||||
|
||||
our %defaultinterfaceoptions = ( routefilter => 1 );
|
||||
|
||||
our %maxoptionvalue = ( routefilter => 2, mss => 100000 );
|
||||
|
||||
our %validhostoptions;
|
||||
|
||||
#
|
||||
@@ -188,11 +201,13 @@ sub initialize( $ ) {
|
||||
@zones = ();
|
||||
%zones = ();
|
||||
$firewall_zone = '';
|
||||
$have_ipsec = undef;
|
||||
|
||||
@interfaces = ();
|
||||
%interfaces = ();
|
||||
@bport_zones = ();
|
||||
%ipsets = ();
|
||||
%physical = ();
|
||||
|
||||
if ( $family == F_IPV4 ) {
|
||||
%validinterfaceoptions = (arp_filter => BINARY_IF_OPTION,
|
||||
@@ -209,12 +224,13 @@ sub initialize( $ ) {
|
||||
optional => SIMPLE_IF_OPTION,
|
||||
proxyarp => BINARY_IF_OPTION,
|
||||
routeback => SIMPLE_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_HOST,
|
||||
routefilter => BINARY_IF_OPTION ,
|
||||
routefilter => NUMERIC_IF_OPTION ,
|
||||
sourceroute => BINARY_IF_OPTION,
|
||||
tcpflags => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
upnp => SIMPLE_IF_OPTION,
|
||||
upnpclient => SIMPLE_IF_OPTION,
|
||||
mss => NUMERIC_IF_OPTION,
|
||||
physical => STRING_IF_OPTION + IF_OPTION_HOST,
|
||||
);
|
||||
%validhostoptions = (
|
||||
blacklist => 1,
|
||||
@@ -232,14 +248,15 @@ sub initialize( $ ) {
|
||||
dhcp => SIMPLE_IF_OPTION,
|
||||
maclist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY,
|
||||
nosmurfs => SIMPLE_IF_OPTION,
|
||||
nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
optional => SIMPLE_IF_OPTION,
|
||||
proxyndp => BINARY_IF_OPTION,
|
||||
routeback => SIMPLE_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_HOST,
|
||||
sourceroute => BINARY_IF_OPTION,
|
||||
tcpflags => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
mss => NUMERIC_IF_OPTION,
|
||||
forward => NUMERIC_IF_OPTION,
|
||||
forward => BINARY_IF_OPTION,
|
||||
physical => STRING_IF_OPTION + IF_OPTION_HOST,
|
||||
);
|
||||
%validhostoptions = (
|
||||
blacklist => 1,
|
||||
@@ -385,6 +402,7 @@ sub process_zone( \$ ) {
|
||||
}
|
||||
|
||||
if ( $type eq IPSEC ) {
|
||||
require_capability 'POLICY_MATCH' , 'IPSEC zones', '';
|
||||
for ( @parents ) {
|
||||
unless ( $zones{$_}{type} == IPSEC ) {
|
||||
set_super( $zones{$_} );
|
||||
@@ -496,17 +514,19 @@ sub zone_report()
|
||||
my $interfaceref = $hostref->{$type};
|
||||
|
||||
for my $interface ( sort keys %$interfaceref ) {
|
||||
my $iref = $interfaces{$interface};
|
||||
my $arrayref = $interfaceref->{$interface};
|
||||
for my $groupref ( @$arrayref ) {
|
||||
my $hosts = $groupref->{hosts};
|
||||
my $exclusions = join ',', @{$groupref->{exclusions}};
|
||||
if ( $hosts ) {
|
||||
my $grouplist = join ',', ( @$hosts );
|
||||
my $grouplist = join ',', ( @$hosts );
|
||||
my $exclusions = join ',', @{$groupref->{exclusions}};
|
||||
$grouplist = join '!', ( $grouplist, $exclusions) if $exclusions;
|
||||
|
||||
if ( $family == F_IPV4 ) {
|
||||
progress_message_nocompress " $interface:$grouplist";
|
||||
progress_message_nocompress " $iref->{physical}:$grouplist";
|
||||
} else {
|
||||
progress_message_nocompress " $interface:<$grouplist>";
|
||||
progress_message_nocompress " $iref->{physical}:<$grouplist>";
|
||||
}
|
||||
$printed = 1;
|
||||
}
|
||||
@@ -524,6 +544,9 @@ sub zone_report()
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# This function is called to create the contents of the ${VARDIR}/zones file
|
||||
#
|
||||
sub dump_zone_contents()
|
||||
{
|
||||
my @xlate;
|
||||
@@ -550,20 +573,21 @@ sub dump_zone_contents()
|
||||
my $interfaceref = $hostref->{$type};
|
||||
|
||||
for my $interface ( sort keys %$interfaceref ) {
|
||||
my $iref = $interfaces{$interface};
|
||||
my $arrayref = $interfaceref->{$interface};
|
||||
for my $groupref ( @$arrayref ) {
|
||||
my $hosts = $groupref->{hosts};
|
||||
my $exclusions = join ',', @{$groupref->{exclusions}};
|
||||
|
||||
if ( $hosts ) {
|
||||
my $grouplist = join ',', ( @$hosts );
|
||||
my $grouplist = join ',', ( @$hosts );
|
||||
my $exclusions = join ',', @{$groupref->{exclusions}};
|
||||
|
||||
$grouplist = join '!', ( $grouplist, $exclusions ) if $exclusions;
|
||||
|
||||
if ( $family == F_IPV4 ) {
|
||||
$entry .= " $interface:$grouplist";
|
||||
$entry .= " $iref->{physical}:$grouplist";
|
||||
} else {
|
||||
$entry .= " $interface:<$grouplist>";
|
||||
$entry .= " $iref->{physical}:<$grouplist>";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -649,7 +673,7 @@ sub add_group_to_zone($$$$$)
|
||||
|
||||
fatal_error "Duplicate Host Group ($interface:" . ALLIP . ") in zone $zone" if $allip && @$interfaceref;
|
||||
|
||||
$zoneref->{options}{complex} = 1 if @$interfaceref || ( @newnetworks > 1 ) || ( @exclusions );
|
||||
$zoneref->{options}{complex} = 1 if @$interfaceref || ( @newnetworks > 1 ) || ( @exclusions ) || $options->{routeback};
|
||||
|
||||
push @{$interfaceref}, { options => $options,
|
||||
hosts => \@newnetworks,
|
||||
@@ -708,8 +732,8 @@ sub firewall_zone() {
|
||||
#
|
||||
sub process_interface( $ ) {
|
||||
my $nextinum = $_[0];
|
||||
my $nets;
|
||||
my ($zone, $originalinterface, $networks, $options ) = split_line 2, 4, 'interfaces file';
|
||||
my $netsref = '';
|
||||
my ($zone, $originalinterface, $bcasts, $options ) = split_line 2, 4, 'interfaces file';
|
||||
my $zoneref;
|
||||
my $bridge = '';
|
||||
|
||||
@@ -722,18 +746,21 @@ sub process_interface( $ ) {
|
||||
fatal_error "Firewall zone not allowed in ZONE column of interface record" if $zoneref->{type} == FIREWALL;
|
||||
}
|
||||
|
||||
$networks = '' if $networks eq '-';
|
||||
$bcasts = '' if $bcasts eq '-';
|
||||
$options = '' if $options eq '-';
|
||||
|
||||
my ($interface, $port, $extra) = split /:/ , $originalinterface, 3;
|
||||
|
||||
fatal_error "Invalid INTERFACE ($originalinterface)" if ! $interface || defined $extra;
|
||||
|
||||
if ( defined $port ) {
|
||||
if ( defined $port && $port ne '' ) {
|
||||
fatal_error qq("Virtual" interfaces are not supported -- see http://www.shorewall.net/Shorewall_and_Aliased_Interfaces.html) if $port =~ /^\d+$/;
|
||||
require_capability( 'PHYSDEV_MATCH', 'Bridge Ports', '');
|
||||
fatal_error "Your iptables is not recent enough to support bridge ports" unless $capabilities{KLUDGEFREE};
|
||||
fatal_error "Your iptables is not recent enough to support bridge ports" unless have_capability( 'KLUDGEFREE' );
|
||||
|
||||
fatal_error "Invalid Interface Name ($interface:$port)" unless $port =~ /^[\w.@%-]+\+?$/;
|
||||
fatal_error "Duplicate Interface ($port)" if $interfaces{$port};
|
||||
|
||||
fatal_error "$interface is not a defined bridge" unless $interfaces{$interface} && $interfaces{$interface}{options}{bridge};
|
||||
fatal_error "Bridge Ports may only be associated with 'bport' zones" if $zone && $zoneref->{type} != BPORT;
|
||||
|
||||
@@ -745,10 +772,6 @@ sub process_interface( $ ) {
|
||||
}
|
||||
}
|
||||
|
||||
next if $port eq '';
|
||||
|
||||
fatal_error "Invalid Interface Name ($interface:$port)" unless $port =~ /^[\w.@%-]+\+?$/;
|
||||
|
||||
$bridge = $interface;
|
||||
$interface = $port;
|
||||
} else {
|
||||
@@ -767,16 +790,17 @@ sub process_interface( $ ) {
|
||||
$root = $interface;
|
||||
}
|
||||
|
||||
my $physical = $interface;
|
||||
my $broadcasts;
|
||||
|
||||
unless ( $networks eq '' || $networks eq 'detect' ) {
|
||||
my @broadcasts = split_list $networks, 'address';
|
||||
unless ( $bcasts eq '' || $bcasts eq 'detect' ) {
|
||||
my @broadcasts = split_list $bcasts, 'address';
|
||||
|
||||
for my $address ( @broadcasts ) {
|
||||
fatal_error 'Invalid BROADCAST address' unless $address =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/;
|
||||
}
|
||||
|
||||
if ( $capabilities{ADDRTYPE} ) {
|
||||
if ( have_capability( 'ADDRTYPE' ) ) {
|
||||
warning_message 'Shorewall no longer uses broadcast addresses in rule generation when Address Type Match is available';
|
||||
} else {
|
||||
$broadcasts = \@broadcasts;
|
||||
@@ -814,12 +838,12 @@ sub process_interface( $ ) {
|
||||
$hostoptions{$option} = 1 if $hostopt;
|
||||
} elsif ( $type == BINARY_IF_OPTION ) {
|
||||
$value = 1 unless defined $value;
|
||||
fatal_error "Option value for $option must be 0 or 1" unless ( $value eq '0' || $value eq '1' );
|
||||
fatal_error "The $option option may not be used with a wild-card interface name" if $wildcard;
|
||||
fatal_error "Option value for '$option' must be 0 or 1" unless ( $value eq '0' || $value eq '1' );
|
||||
fatal_error "The '$option' option may not be used with a wild-card interface name" if $wildcard;
|
||||
$options{$option} = $value;
|
||||
$hostoptions{$option} = $value if $hostopt;
|
||||
} elsif ( $type == ENUM_IF_OPTION ) {
|
||||
fatal_error "The $option option may not be used with a wild-card interface name" if $wildcard;
|
||||
fatal_error "The '$option' option may not be used with a wild-card interface name" if $wildcard;
|
||||
if ( $option eq 'arp_ignore' ) {
|
||||
if ( defined $value ) {
|
||||
if ( $value =~ /^[1-3,8]$/ ) {
|
||||
@@ -834,15 +858,14 @@ sub process_interface( $ ) {
|
||||
assert( 0 );
|
||||
}
|
||||
} elsif ( $type == NUMERIC_IF_OPTION ) {
|
||||
fatal_error "The $option option requires a value" unless defined $value;
|
||||
$value = $defaultinterfaceoptions{$option} unless defined $value;
|
||||
fatal_error "The '$option' option requires a value" unless defined $value;
|
||||
my $numval = numeric_value $value;
|
||||
fatal_error "Invalid value ($value) for option $option" unless defined $numval;
|
||||
fatal_error "Invalid value ($value) for option $option" unless defined $numval && $numval <= $maxoptionvalue{$option};
|
||||
$options{$option} = $numval;
|
||||
$hostoptions{$option} = $numval if $hostopt;
|
||||
} elsif ( $type == IPLIST_IF_OPTION ) {
|
||||
fatal_error "The $option option requires a value" unless defined $value;
|
||||
fatal_error q("nets=" may not be specified for a multi-zone interface) unless $zone;
|
||||
fatal_error "Duplicate $option option" if $nets;
|
||||
fatal_error "The '$option' option requires a value" unless defined $value;
|
||||
#
|
||||
# Remove parentheses from address list if present
|
||||
#
|
||||
@@ -852,51 +875,79 @@ sub process_interface( $ ) {
|
||||
#
|
||||
$value = join ',' , ALLIP , $value if $value =~ /^!/;
|
||||
|
||||
if ( $value eq 'dynamic' ) {
|
||||
require_capability( 'IPSET_MATCH', 'Dynamic nets', '');
|
||||
$value = "+${zone}_${interface}";
|
||||
$hostoptions{dynamic} = 1;
|
||||
$ipsets{"${zone}_${interface}"} = 1;
|
||||
if ( $option eq 'nets' ) {
|
||||
fatal_error q("nets=" may not be specified for a multi-zone interface) unless $zone;
|
||||
fatal_error "Duplicate $option option" if $netsref;
|
||||
if ( $value eq 'dynamic' ) {
|
||||
require_capability( 'IPSET_MATCH', 'Dynamic nets', '');
|
||||
$hostoptions{dynamic} = 1;
|
||||
#
|
||||
# Defer remaining processing until we have the final physical interface name
|
||||
#
|
||||
$netsref = 'dynamic';
|
||||
} else {
|
||||
$hostoptions{multicast} = 1;
|
||||
#
|
||||
# Convert into a Perl array reference
|
||||
#
|
||||
$netsref = [ split_list $value, 'address' ];
|
||||
}
|
||||
#
|
||||
# Assume 'broadcast'
|
||||
#
|
||||
$hostoptions{broadcast} = 1;
|
||||
} else {
|
||||
$hostoptions{multicast} = 1;
|
||||
assert(0);
|
||||
}
|
||||
} elsif ( $type == STRING_IF_OPTION ) {
|
||||
fatal_error "The '$option' option requires a value" unless defined $value;
|
||||
|
||||
if ( $option eq 'physical' ) {
|
||||
fatal_error "Invalid Physical interface name ($value)" unless $value =~ /^[\w.@%-]+\+?$/;
|
||||
|
||||
fatal_error "Duplicate physical interface name ($value)" if ( $physical{$value} && ! $port );
|
||||
|
||||
fatal_error "The type of 'physical' name ($value) doesn't match the type of interface name ($interface)" if $wildcard && ! $value =~ /\+$/;
|
||||
$physical = $value;
|
||||
} else {
|
||||
assert(0);
|
||||
}
|
||||
#
|
||||
# Convert into a Perl array reference
|
||||
#
|
||||
$nets = [ split_list $value, 'address' ];
|
||||
#
|
||||
# Assume 'broadcast'
|
||||
#
|
||||
$hostoptions{broadcast} = 1;
|
||||
} else {
|
||||
warning_message "Support for the $option interface option has been removed from Shorewall";
|
||||
}
|
||||
}
|
||||
|
||||
$zoneref->{options}{in_out}{routeback} = 1 if $zoneref && $options{routeback};
|
||||
if ( $netsref eq 'dynamic' ) {
|
||||
my $ipset = "${zone}_" . chain_base $physical;
|
||||
$netsref = [ "+$ipset" ];
|
||||
$ipsets{$ipset} = 1;
|
||||
}
|
||||
|
||||
if ( $options{bridge} ) {
|
||||
require_capability( 'PHYSDEV_MATCH', 'The "bridge" option', 's');
|
||||
fatal_error "Bridges may not have wildcard names" if $wildcard;
|
||||
$hostoptions{routeback} = $options{routeback} = 1;
|
||||
}
|
||||
|
||||
$hostoptionsref = \%hostoptions;
|
||||
$zoneref->{options}{in_out}{routeback} = 1 if $zoneref && $options{routeback};
|
||||
|
||||
$hostoptionsref = \%hostoptions;
|
||||
}
|
||||
|
||||
$interfaces{$interface} = { name => $interface ,
|
||||
bridge => $bridge ,
|
||||
nets => 0 ,
|
||||
number => $nextinum ,
|
||||
root => $root ,
|
||||
broadcasts => $broadcasts ,
|
||||
options => \%options ,
|
||||
zone => ''
|
||||
};
|
||||
$physical{$physical} = $interfaces{$interface} = { name => $interface ,
|
||||
bridge => $bridge ,
|
||||
nets => 0 ,
|
||||
number => $nextinum ,
|
||||
root => $root ,
|
||||
broadcasts => $broadcasts ,
|
||||
options => \%options ,
|
||||
zone => '',
|
||||
physical => $physical
|
||||
};
|
||||
|
||||
if ( $zone ) {
|
||||
$nets ||= [ allip ];
|
||||
add_group_to_zone( $zone, $zoneref->{type}, $interface, $nets, $hostoptionsref );
|
||||
$netsref ||= [ allip ];
|
||||
add_group_to_zone( $zone, $zoneref->{type}, $interface, $netsref, $hostoptionsref );
|
||||
add_group_to_zone( $zone,
|
||||
$zoneref->{type},
|
||||
$interface,
|
||||
@@ -949,6 +1000,20 @@ sub validate_interfaces_file( $ ) {
|
||||
fatal_error "No network interfaces defined" unless @interfaces;
|
||||
}
|
||||
|
||||
#
|
||||
# Map the passed name to the corresponding physical name in the passed interface
|
||||
#
|
||||
sub map_physical( $$ ) {
|
||||
my ( $name, $interfaceref ) = @_;
|
||||
my $physical = $interfaceref->{physical};
|
||||
|
||||
return $physical if $name eq $interfaceref->{name};
|
||||
|
||||
$physical =~ s/\+$//;
|
||||
|
||||
$physical . substr( $name, length $interfaceref->{root} );
|
||||
}
|
||||
|
||||
#
|
||||
# Returns true if passed interface matches an entry in /etc/shorewall/interfaces
|
||||
#
|
||||
@@ -963,13 +1028,17 @@ sub known_interface($)
|
||||
|
||||
for my $i ( @interfaces ) {
|
||||
$interfaceref = $interfaces{$i};
|
||||
my $val = $interfaceref->{root};
|
||||
next if $val eq $i;
|
||||
if ( substr( $interface, 0, length $val ) eq $val ) {
|
||||
my $root = $interfaceref->{root};
|
||||
if ( $i ne $root && substr( $interface, 0, length $root ) eq $root ) {
|
||||
#
|
||||
# Cache this result for future reference. We set the 'name' to the name of the entry that appears in /etc/shorewall/interfaces.
|
||||
# Cache this result for future reference. We set the 'name' to the name of the entry that appears in /etc/shorewall/interfaces and we do not set the root;
|
||||
#
|
||||
return $interfaces{$interface} = { options => $interfaceref->{options}, bridge => $interfaceref->{bridge} , name => $i , number => $interfaceref->{number} };
|
||||
return $interfaces{$interface} = { options => $interfaceref->{options},
|
||||
bridge => $interfaceref->{bridge} ,
|
||||
name => $i ,
|
||||
number => $interfaceref->{number} ,
|
||||
physical => map_physical( $interface, $interfaceref )
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1009,6 +1078,23 @@ sub find_interface( $ ) {
|
||||
$interfaceref;
|
||||
}
|
||||
|
||||
#
|
||||
# Returns the physical interface associated with the passed logical name
|
||||
#
|
||||
sub get_physical( $ ) {
|
||||
$interfaces{ $_[0] }->{physical};
|
||||
}
|
||||
|
||||
#
|
||||
# This one doesn't insist that the passed name be the name of a configured interface
|
||||
#
|
||||
sub physical_name( $ ) {
|
||||
my $device = shift;
|
||||
my $devref = known_interface $device;
|
||||
|
||||
$devref ? $devref->{physical} : $device;
|
||||
}
|
||||
|
||||
#
|
||||
# Returns true if there are bridge port zones defined in the config
|
||||
#
|
||||
@@ -1049,7 +1135,11 @@ sub find_interfaces_by_option( $ ) {
|
||||
my @ints = ();
|
||||
|
||||
for my $interface ( @interfaces ) {
|
||||
my $optionsref = $interfaces{$interface}{options};
|
||||
my $interfaceref = $interfaces{$interface};
|
||||
|
||||
next unless $interfaceref->{root};
|
||||
|
||||
my $optionsref = $interfaceref->{options};
|
||||
if ( $optionsref && defined $optionsref->{$option} ) {
|
||||
push @ints , $interface
|
||||
}
|
||||
@@ -1100,15 +1190,13 @@ sub process_host( ) {
|
||||
} else {
|
||||
fatal_error "Invalid HOST(S) column contents: $hosts";
|
||||
}
|
||||
} elsif ( $hosts =~ /^([\w.@%-]+\+?):<(.*)>\s*$/ || $hosts =~ /^([\w.@%-]+\+?):\[(.*)\]\s*$/ ) {
|
||||
$interface = $1;
|
||||
$hosts = $2;
|
||||
$zoneref->{options}{complex} = 1 if $hosts =~ /^\+/;
|
||||
fatal_error "Unknown interface ($interface)" unless $interfaces{$interface}{root};
|
||||
} else {
|
||||
if ( $hosts =~ /^([\w.@%-]+\+?):<(.*)>\s*$/ ) {
|
||||
$interface = $1;
|
||||
$hosts = $2;
|
||||
$zoneref->{options}{complex} = 1 if $hosts =~ /^\+/;
|
||||
fatal_error "Unknown interface ($interface)" unless $interfaces{$interface}{root};
|
||||
} else {
|
||||
fatal_error "Invalid HOST(S) column contents: $hosts";
|
||||
}
|
||||
fatal_error "Invalid HOST(S) column contents: $hosts";
|
||||
}
|
||||
|
||||
if ( $type == BPORT ) {
|
||||
@@ -1128,6 +1216,7 @@ sub process_host( ) {
|
||||
|
||||
for my $option ( @options ) {
|
||||
if ( $option eq 'ipsec' ) {
|
||||
require_capability 'POLICY_MATCH' , q(The 'ipsec' option), 's';
|
||||
$type = IPSEC;
|
||||
$zoneref->{options}{complex} = 1;
|
||||
$ipsec = 1;
|
||||
@@ -1160,9 +1249,10 @@ sub process_host( ) {
|
||||
|
||||
if ( $hosts eq 'dynamic' ) {
|
||||
require_capability( 'IPSET_MATCH', 'Dynamic nets', '');
|
||||
$hosts = "+${zone}_${interface}";
|
||||
my $physical = physical_name $interface;
|
||||
$hosts = "+${zone}_${physical}";
|
||||
$optionsref->{dynamic} = 1;
|
||||
$ipsets{"${zone}_${interface}"} = 1;
|
||||
$ipsets{"${zone}_${physical}"} = 1;
|
||||
|
||||
}
|
||||
|
||||
@@ -1182,11 +1272,19 @@ sub validate_hosts_file()
|
||||
|
||||
my $fn = open_file 'hosts';
|
||||
|
||||
first_entry "doing $fn...";
|
||||
first_entry "$doing $fn...";
|
||||
|
||||
$ipsec |= process_host while read_a_line;
|
||||
|
||||
$capabilities{POLICY_MATCH} = '' unless $ipsec || haveipseczones;
|
||||
$have_ipsec = $ipsec || haveipseczones;
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# Return an indication of whether IPSEC is present
|
||||
#
|
||||
sub have_ipsec() {
|
||||
return defined $have_ipsec ? $have_ipsec : have_capability 'POLICY_MATCH';
|
||||
}
|
||||
|
||||
#
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2007,2008,2009 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -36,6 +36,7 @@
|
||||
# --log=<filename> # Log file
|
||||
# --log_verbosity=<number> # Log Verbosity range -1 to 2
|
||||
# --family=<number> # IP family; 4 = IPv4 (default), 6 = IPv6
|
||||
# --preview # Preview the ruleset.
|
||||
#
|
||||
use strict;
|
||||
use FindBin;
|
||||
@@ -44,7 +45,6 @@ use Shorewall::Compiler;
|
||||
use Getopt::Long;
|
||||
|
||||
sub usage( $ ) {
|
||||
my $returnval = shift @_;
|
||||
|
||||
print STDERR 'usage: compiler.pl [ <option> ... ] [ <filename> ]
|
||||
|
||||
@@ -58,10 +58,11 @@ sub usage( $ ) {
|
||||
[ --log=<filename> ]
|
||||
[ --log-verbose={-1|0-2} ]
|
||||
[ --test ]
|
||||
[ --preview ]
|
||||
[ --family={4|6} ]
|
||||
';
|
||||
|
||||
$returnval;
|
||||
exit shift @_;
|
||||
}
|
||||
|
||||
#
|
||||
@@ -78,6 +79,7 @@ my $log_verbose = 0;
|
||||
my $help = 0;
|
||||
my $test = 0;
|
||||
my $family = 4; # F_IPV4
|
||||
my $preview = 0;
|
||||
|
||||
Getopt::Long::Configure ('bundling');
|
||||
|
||||
@@ -98,6 +100,7 @@ my $result = GetOptions('h' => \$help,
|
||||
'l=s' => \$log,
|
||||
'log_verbosity=i' => \$log_verbose,
|
||||
'test' => \$test,
|
||||
'preview' => \$preview,
|
||||
'f=i' => \$family,
|
||||
'family=i' => \$family,
|
||||
);
|
||||
@@ -105,7 +108,7 @@ my $result = GetOptions('h' => \$help,
|
||||
usage(1) unless $result && @ARGV < 2;
|
||||
usage(0) if $help;
|
||||
|
||||
compiler( object => defined $ARGV[0] ? $ARGV[0] : '',
|
||||
compiler( script => $ARGV[0] || '',
|
||||
directory => $shorewall_dir,
|
||||
verbosity => $verbose,
|
||||
timestamp => $timestamp,
|
||||
@@ -115,4 +118,5 @@ compiler( object => defined $ARGV[0] ? $ARGV[0] : '',
|
||||
log => $log,
|
||||
log_verbosity => $log_verbose,
|
||||
test => $test,
|
||||
preview => $preview,
|
||||
family => $family );
|
||||
|
@@ -1,288 +1,20 @@
|
||||
###############################################################################
|
||||
# Code imported from /usr/share/shorewall/prog.footer
|
||||
###############################################################################
|
||||
#
|
||||
# Clear Proxy Arp
|
||||
#
|
||||
delete_proxyarp() {
|
||||
if [ -f ${VARDIR}/proxyarp ]; then
|
||||
while read address interface external haveroute; do
|
||||
qt arp -i $external -d $address pub
|
||||
[ -z "${haveroute}${NOROUTES}" ] && qt $IP -4 route del $address dev $interface
|
||||
f=/proc/sys/net/ipv4/conf/$interface/proxy_arp
|
||||
[ -f $f ] && echo 0 > $f
|
||||
done < ${VARDIR}/proxyarp
|
||||
fi
|
||||
|
||||
rm -f ${VARDIR}/proxyarp
|
||||
}
|
||||
|
||||
#
|
||||
# Remove all Shorewall-added rules
|
||||
#
|
||||
clear_firewall() {
|
||||
stop_firewall
|
||||
|
||||
setpolicy INPUT ACCEPT
|
||||
setpolicy FORWARD ACCEPT
|
||||
setpolicy OUTPUT ACCEPT
|
||||
|
||||
run_iptables -F
|
||||
|
||||
echo 1 > /proc/sys/net/ipv4/ip_forward
|
||||
|
||||
if [ -n "$DISABLE_IPV6" ]; then
|
||||
if [ -x $IPTABLES ]; then
|
||||
$IP6TABLES -P INPUT ACCEPT 2> /dev/null
|
||||
$IP6TABLES -P OUTPUT ACCEPT 2> /dev/null
|
||||
$IP6TABLES -P FORWARD ACCEPT 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
run_clear_exit
|
||||
|
||||
set_state "Cleared"
|
||||
|
||||
logger -p kern.info "$PRODUCT Cleared"
|
||||
}
|
||||
|
||||
#
|
||||
# Issue a message and stop/restore the firewall
|
||||
#
|
||||
fatal_error()
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
|
||||
if [ $LOG_VERBOSE -gt 1 ]; then
|
||||
timestamp="$(date +'%_b %d %T') "
|
||||
echo "${timestamp} ERROR: $@" >> $STARTUP_LOG
|
||||
fi
|
||||
|
||||
stop_firewall
|
||||
[ -n "$TEMPFILE" ] && rm -f $TEMPFILE
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Issue a message and stop
|
||||
#
|
||||
startup_error() # $* = Error Message
|
||||
{
|
||||
echo " ERROR: $@: Firewall state not changed" >&2
|
||||
case $COMMAND in
|
||||
start)
|
||||
logger -p kern.err "ERROR:$PRODUCT start failed:Firewall state not changed"
|
||||
;;
|
||||
restart)
|
||||
logger -p kern.err "ERROR:$PRODUCT restart failed:Firewall state not changed"
|
||||
;;
|
||||
restore)
|
||||
logger -p kern.err "ERROR:$PRODUCT restore failed:Firewall state not changed"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $LOG_VERBOSE -gt 1 ]; then
|
||||
timestamp="$(date +'%_b %d %T') "
|
||||
|
||||
case $COMMAND in
|
||||
start)
|
||||
echo "${timestamp} ERROR:$PRODUCT start failed:Firewall state not changed" >> $STARTUP_LOG
|
||||
;;
|
||||
restart)
|
||||
echo "${timestamp} ERROR:$PRODUCT restart failed:Firewall state not changed" >> $STARTUP_LOG
|
||||
;;
|
||||
restore)
|
||||
echo "${timestamp} ERROR:$PRODUCT restore failed:Firewall state not changed" >> $STARTUP_LOG
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
kill $$
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Run iptables and if an error occurs, stop/restore the firewall
|
||||
#
|
||||
run_iptables()
|
||||
{
|
||||
local status
|
||||
|
||||
while [ 1 ]; do
|
||||
$IPTABLES $@
|
||||
status=$?
|
||||
[ $status -ne 4 ] && break
|
||||
done
|
||||
|
||||
if [ $status -ne 0 ]; then
|
||||
error_message "ERROR: Command \"$IPTABLES $@\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Run iptables retrying exit status 4
|
||||
#
|
||||
do_iptables()
|
||||
{
|
||||
local status
|
||||
|
||||
while [ 1 ]; do
|
||||
$IPTABLES $@
|
||||
status=$?
|
||||
[ $status -ne 4 ] && return $status;
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Run iptables and if an error occurs, stop/restore the firewall
|
||||
#
|
||||
run_ip()
|
||||
{
|
||||
if ! $IP -4 $@; then
|
||||
error_message "ERROR: Command \"$IP -4 $@\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Run tc and if an error occurs, stop/restore the firewall
|
||||
#
|
||||
run_tc() {
|
||||
if ! $TC $@ ; then
|
||||
error_message "ERROR: Command \"$TC $@\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Restore the rules generated by 'drop','reject','logdrop', etc.
|
||||
#
|
||||
restore_dynamic_rules() {
|
||||
if [ -f ${VARDIR}/save ]; then
|
||||
progress_message2 "Setting up dynamic rules..."
|
||||
rangematch='source IP range'
|
||||
while read target ignore1 ignore2 address ignore3 rest; do
|
||||
case $target in
|
||||
DROP|reject|logdrop|logreject)
|
||||
case $rest in
|
||||
$rangematch*)
|
||||
run_iptables -A dynamic -m iprange --src-range ${rest#source IP range} -j $target
|
||||
;;
|
||||
*)
|
||||
if [ -z "$rest" ]; then
|
||||
run_iptables -A dynamic -s $address -j $target
|
||||
else
|
||||
error_message "WARNING: Unable to restore dynamic rule \"$target $ignore1 $ignore2 $address $ignore3 $rest\""
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done < ${VARDIR}/save
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Get a list of all configured broadcast addresses on the system
|
||||
#
|
||||
get_all_bcasts()
|
||||
{
|
||||
$IP -f inet addr show 2> /dev/null | grep 'inet.*brd' | grep -v '/32 ' | sed 's/inet.*brd //; s/scope.*//;' | sort -u
|
||||
}
|
||||
|
||||
#
|
||||
# Run the .iptables_restore_input as a set of discrete iptables commands
|
||||
#
|
||||
debug_restore_input() {
|
||||
local first second rest table chain
|
||||
#
|
||||
# Clear the ruleset
|
||||
#
|
||||
qt1 $IPTABLES -t mangle -F
|
||||
qt1 $IPTABLES -t mangle -X
|
||||
|
||||
for chain in PREROUTING INPUT FORWARD POSTROUTING; do
|
||||
qt1 $IPTABLES -t mangle -P $chain ACCEPT
|
||||
done
|
||||
|
||||
qt1 $IPTABLES -t raw -F
|
||||
qt1 $IPTABLES -t raw -X
|
||||
|
||||
for chain in PREROUTING OUTPUT; do
|
||||
qt1 $IPTABLES -t raw -P $chain ACCEPT
|
||||
done
|
||||
|
||||
run_iptables -t nat -F
|
||||
run_iptables -t nat -X
|
||||
|
||||
for chain in PREROUTING POSTROUTING OUTPUT; do
|
||||
qt1 $IPTABLES -t nat -P $chain ACCEPT
|
||||
done
|
||||
|
||||
qt1 $IPTABLES -t filter -F
|
||||
qt1 $IPTABLES -t filter -X
|
||||
|
||||
for chain in INPUT FORWARD OUTPUT; do
|
||||
qt1 $IPTABLES -t filter -P $chain -P ACCEPT
|
||||
done
|
||||
|
||||
while read first second rest; do
|
||||
case $first in
|
||||
-*)
|
||||
#
|
||||
# We can't call run_iptables() here because the rules may contain quoted strings
|
||||
#
|
||||
eval $IPTABLES -t $table $first $second $rest
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
error_message "ERROR: Command \"$IPTABLES $first $second $rest\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
:*)
|
||||
chain=${first#:}
|
||||
|
||||
if [ "x$second" = x- ]; then
|
||||
do_iptables -t $table -N $chain
|
||||
else
|
||||
do_iptables -t $table -P $chain $second
|
||||
fi
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
error_message "ERROR: Command \"$IPTABLES $first $second $rest\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
#
|
||||
# This grotesque hack with the table names works around a bug/feature with ash
|
||||
#
|
||||
'*'raw)
|
||||
table=raw
|
||||
;;
|
||||
'*'mangle)
|
||||
table=mangle
|
||||
;;
|
||||
'*'nat)
|
||||
table=nat
|
||||
;;
|
||||
'*'filter)
|
||||
table=filter
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Give Usage Information
|
||||
#
|
||||
usage() {
|
||||
echo "Usage: $0 [ -q ] [ -v ] [ -n ] [ start|stop|clear|reset|refresh|restart|status|version ]"
|
||||
echo "Usage: $0 [ options ] [ start|stop|clear|reset|refresh|restart|status|version ]"
|
||||
echo
|
||||
echo "Options are:"
|
||||
echo
|
||||
echo " -v and -q Standard Shorewall verbosity controls"
|
||||
echo " -n Don't unpdate routing configuration"
|
||||
echo " -p Purge Conntrack Table"
|
||||
echo " -t Timestamp progress Messages"
|
||||
echo " -V <verbosity> Set verbosity explicitly"
|
||||
echo " -R <file> Override RESTOREFILE setting"
|
||||
exit $1
|
||||
}
|
||||
################################################################################
|
||||
@@ -300,10 +32,23 @@ if [ $# -gt 1 ]; then
|
||||
shift
|
||||
fi
|
||||
fi
|
||||
#
|
||||
# Map VERBOSE to VERBOSITY for compatibility with old Shorewall-lite installations
|
||||
#
|
||||
[ -z "$VERBOSITY" ] && [ -n "$VERBOSE" ] && VERBOSITY=$VERBOSE
|
||||
#
|
||||
# Map other old exported variables
|
||||
#
|
||||
g_purge=$PURGE
|
||||
g_noroutes=$NOROUTES
|
||||
g_timestamp=$TIMESTAMP
|
||||
g_recovering=$RECOVERING
|
||||
|
||||
initialize
|
||||
|
||||
if [ -n "$STARTUP_LOG" ]; then
|
||||
touch $STARTUP_LOG
|
||||
chmod 0600 $STARTUP_LOG
|
||||
if [ ${SHOREWALL_INIT_SCRIPT:-0} -eq 1 ]; then
|
||||
#
|
||||
# We're being run by a startup script that isn't redirecting STDOUT
|
||||
@@ -326,17 +71,78 @@ while [ $finished -eq 0 -a $# -gt 0 ]; do
|
||||
while [ -n "$option" ]; do
|
||||
case $option in
|
||||
v*)
|
||||
VERBOSE=$(($VERBOSE + 1 ))
|
||||
[ $VERBOSITY -lt 2 ] && VERBOSITY=$(($VERBOSITY + 1 ))
|
||||
option=${option#v}
|
||||
;;
|
||||
q*)
|
||||
VERBOSE=$(($VERBOSE - 1 ))
|
||||
[ $VERBOSITY -gt -1 ] && VERBOSITY=$(($VERBOSITY - 1 ))
|
||||
option=${option#q}
|
||||
;;
|
||||
n*)
|
||||
NOROUTES=Yes
|
||||
g_noroutes=Yes
|
||||
option=${option#n}
|
||||
;;
|
||||
t*)
|
||||
g_timestamp=Yes
|
||||
option=${option#t}
|
||||
;;
|
||||
p*)
|
||||
g_purge=Yes
|
||||
option=${option#p}
|
||||
;;
|
||||
r*)
|
||||
g_recovering=Yes
|
||||
option=${option#r}
|
||||
;;
|
||||
V*)
|
||||
option=${option#V}
|
||||
|
||||
if [ -z "$option" -a $# -gt 0 ]; then
|
||||
shift
|
||||
option=$1
|
||||
fi
|
||||
|
||||
if [ -n "$option" ]; then
|
||||
case $option in
|
||||
-1|0|1|2)
|
||||
VERBOSITY=$option
|
||||
option=
|
||||
;;
|
||||
*)
|
||||
startup_error "Invalid -V option value ($option)"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
startup_error "Missing -V option value"
|
||||
fi
|
||||
;;
|
||||
R*)
|
||||
option=${option#R}
|
||||
|
||||
if [ -z "$option" -a $# -gt 0 ]; then
|
||||
shift
|
||||
option=$1
|
||||
fi
|
||||
|
||||
if [ -n "$option" ]; then
|
||||
case $option in
|
||||
*/*)
|
||||
startup_error "-R must specify a simple file name: $option"
|
||||
;;
|
||||
.safe|.try|NONE)
|
||||
;;
|
||||
.*)
|
||||
error_message "ERROR: Reserved File Name: $RESTOREFILE"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
else
|
||||
startup_error "Missing -R option value"
|
||||
fi
|
||||
|
||||
RESTOREFILE=$option
|
||||
option=
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@@ -352,16 +158,15 @@ done
|
||||
|
||||
COMMAND="$1"
|
||||
|
||||
[ -n "${PRODUCT:=Shorewall}" ]
|
||||
|
||||
case "$COMMAND" in
|
||||
start)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
if shorewall_is_started; then
|
||||
error_message "$PRODUCT is already Running"
|
||||
error_message "$g_product is already Running"
|
||||
status=0
|
||||
else
|
||||
progress_message3 "Starting $PRODUCT...."
|
||||
progress_message3 "Starting $g_product...."
|
||||
detect_configuration
|
||||
define_firewall
|
||||
status=$?
|
||||
[ -n "$SUBSYSLOCK" -a $status -eq 0 ] && touch $SUBSYSLOCK
|
||||
@@ -370,7 +175,8 @@ case "$COMMAND" in
|
||||
;;
|
||||
stop)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
progress_message3 "Stopping $PRODUCT...."
|
||||
progress_message3 "Stopping $g_product...."
|
||||
detect_configuration
|
||||
stop_firewall
|
||||
status=0
|
||||
[ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK
|
||||
@@ -378,7 +184,7 @@ case "$COMMAND" in
|
||||
;;
|
||||
reset)
|
||||
if ! shorewall_is_started ; then
|
||||
error_message "$PRODUCT is not running"
|
||||
error_message "$g_product is not running"
|
||||
status=2
|
||||
elif [ $# -eq 1 ]; then
|
||||
$IPTABLES -Z
|
||||
@@ -386,7 +192,7 @@ case "$COMMAND" in
|
||||
$IPTABLES -t mangle -Z
|
||||
date > ${VARDIR}/restarted
|
||||
status=0
|
||||
progress_message3 "$PRODUCT Counters Reset"
|
||||
progress_message3 "$g_product Counters Reset"
|
||||
else
|
||||
shift
|
||||
status=0
|
||||
@@ -408,12 +214,13 @@ case "$COMMAND" in
|
||||
restart)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
if shorewall_is_started; then
|
||||
progress_message3 "Restarting $PRODUCT...."
|
||||
progress_message3 "Restarting $g_product...."
|
||||
else
|
||||
error_message "$PRODUCT is not running"
|
||||
progress_message3 "Starting $PRODUCT...."
|
||||
error_message "$g_product is not running"
|
||||
progress_message3 "Starting $g_product...."
|
||||
fi
|
||||
|
||||
detect_configuration
|
||||
define_firewall
|
||||
status=$?
|
||||
if [ -n "$SUBSYSLOCK" ]; then
|
||||
@@ -424,17 +231,19 @@ case "$COMMAND" in
|
||||
refresh)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
if shorewall_is_started; then
|
||||
progress_message3 "Refreshing $PRODUCT...."
|
||||
progress_message3 "Refreshing $g_product...."
|
||||
detect_configuration
|
||||
define_firewall
|
||||
status=$?
|
||||
progress_message3 "done."
|
||||
else
|
||||
echo "$PRODUCT is not running" >&2
|
||||
echo "$g_product is not running" >&2
|
||||
status=2
|
||||
fi
|
||||
;;
|
||||
restore)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
detect_configuration
|
||||
define_firewall
|
||||
status=$?
|
||||
if [ -n "$SUBSYSLOCK" ]; then
|
||||
@@ -443,7 +252,7 @@ case "$COMMAND" in
|
||||
;;
|
||||
clear)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
progress_message3 "Clearing $PRODUCT...."
|
||||
progress_message3 "Clearing $g_product...."
|
||||
clear_firewall
|
||||
status=0
|
||||
[ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK
|
||||
@@ -451,13 +260,13 @@ case "$COMMAND" in
|
||||
;;
|
||||
status)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
echo "$PRODUCT-$VERSION Status at $HOSTNAME - $(date)"
|
||||
echo "$g_product-$SHOREWALL_VERSION Status at $(hostname) - $(date)"
|
||||
echo
|
||||
if shorewall_is_started; then
|
||||
echo "$PRODUCT is running"
|
||||
echo "$g_product is running"
|
||||
status=0
|
||||
else
|
||||
echo "$PRODUCT is stopped"
|
||||
echo "$g_product is stopped"
|
||||
status=4
|
||||
fi
|
||||
|
||||
@@ -476,7 +285,7 @@ case "$COMMAND" in
|
||||
;;
|
||||
version)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
echo $VERSION
|
||||
echo $SHOREWALL_VERSION
|
||||
status=0
|
||||
;;
|
||||
help)
|
||||
|
@@ -1,249 +1,20 @@
|
||||
###############################################################################
|
||||
# Code imported from /usr/share/shorewall/prog.footer6
|
||||
###############################################################################
|
||||
#
|
||||
# Remove all Shorewall-added rules
|
||||
#
|
||||
clear_firewall() {
|
||||
stop_firewall
|
||||
|
||||
setpolicy INPUT ACCEPT
|
||||
setpolicy FORWARD ACCEPT
|
||||
setpolicy OUTPUT ACCEPT
|
||||
|
||||
run_iptables -F
|
||||
|
||||
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
|
||||
|
||||
run_clear_exit
|
||||
|
||||
set_state "Cleared"
|
||||
|
||||
logger -p kern.info "$PRODUCT Cleared"
|
||||
}
|
||||
|
||||
#
|
||||
# Issue a message and stop/restore the firewall
|
||||
#
|
||||
fatal_error()
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
|
||||
if [ $LOG_VERBOSE -gt 1 ]; then
|
||||
timestamp="$(date +'%_b %d %T') "
|
||||
echo "${timestamp} ERROR: $@" >> $STARTUP_LOG
|
||||
fi
|
||||
|
||||
stop_firewall
|
||||
[ -n "$TEMPFILE" ] && rm -f $TEMPFILE
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Issue a message and stop
|
||||
#
|
||||
startup_error() # $* = Error Message
|
||||
{
|
||||
echo " ERROR: $@: Firewall state not changed" >&2
|
||||
case $COMMAND in
|
||||
start)
|
||||
logger -p kern.err "ERROR:$PRODUCT start failed:Firewall state not changed"
|
||||
;;
|
||||
restart)
|
||||
logger -p kern.err "ERROR:$PRODUCT restart failed:Firewall state not changed"
|
||||
;;
|
||||
restore)
|
||||
logger -p kern.err "ERROR:$PRODUCT restore failed:Firewall state not changed"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $LOG_VERBOSE -gt 1 ]; then
|
||||
timestamp="$(date +'%_b %d %T') "
|
||||
|
||||
case $COMMAND in
|
||||
start)
|
||||
echo "${timestamp} ERROR:$PRODUCT start failed:Firewall state not changed" >> $STARTUP_LOG
|
||||
;;
|
||||
restart)
|
||||
echo "${timestamp} ERROR:$PRODUCT restart failed:Firewall state not changed" >> $STARTUP_LOG
|
||||
;;
|
||||
restore)
|
||||
echo "${timestamp} ERROR:$PRODUCT restore failed:Firewall state not changed" >> $STARTUP_LOG
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
kill $$
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Run iptables and if an error occurs, stop/restore the firewall
|
||||
#
|
||||
run_iptables()
|
||||
{
|
||||
local status
|
||||
|
||||
while [ 1 ]; do
|
||||
$IP6TABLES $@
|
||||
status=$?
|
||||
[ $status -ne 4 ] && break
|
||||
done
|
||||
|
||||
if [ $status -ne 0 ]; then
|
||||
error_message "ERROR: Command \"$IP6TABLES $@\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Run iptables retrying exit status 4
|
||||
#
|
||||
do_iptables()
|
||||
{
|
||||
local status
|
||||
|
||||
while [ 1 ]; do
|
||||
$IP6TABLES $@
|
||||
status=$?
|
||||
[ $status -ne 4 ] && return $status;
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Run iptables and if an error occurs, stop/restore the firewall
|
||||
#
|
||||
run_ip()
|
||||
{
|
||||
if ! $IP -6 $@; then
|
||||
error_message "ERROR: Command \"$IP -6 $@\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Run tc and if an error occurs, stop/restore the firewall
|
||||
#
|
||||
run_tc() {
|
||||
if ! $TC $@ ; then
|
||||
error_message "ERROR: Command \"$TC $@\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Restore the rules generated by 'drop','reject','logdrop', etc.
|
||||
#
|
||||
restore_dynamic_rules() {
|
||||
if [ -f ${VARDIR}/save ]; then
|
||||
progress_message2 "Setting up dynamic rules..."
|
||||
rangematch='source IP range'
|
||||
while read target ignore1 ignore2 address ignore3 rest; do
|
||||
case $target in
|
||||
DROP|reject|logdrop|logreject)
|
||||
case $rest in
|
||||
$rangematch*)
|
||||
run_iptables -A dynamic -m iprange --src-range ${rest#source IP range} -j $target
|
||||
;;
|
||||
*)
|
||||
if [ -z "$rest" ]; then
|
||||
run_iptables -A dynamic -s $address -j $target
|
||||
else
|
||||
error_message "WARNING: Unable to restore dynamic rule \"$target $ignore1 $ignore2 $address $ignore3 $rest\""
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done < ${VARDIR}/save
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Run the .iptables_restore_input as a set of discrete iptables commands
|
||||
#
|
||||
debug_restore_input() {
|
||||
local first second rest table chain
|
||||
#
|
||||
# Clear the ruleset
|
||||
#
|
||||
qt1 $IP6TABLES -t mangle -F
|
||||
qt1 $IP6TABLES -t mangle -X
|
||||
|
||||
for chain in PREROUTING INPUT FORWARD POSTROUTING; do
|
||||
qt1 $IP6TABLES -t mangle -P $chain ACCEPT
|
||||
done
|
||||
|
||||
qt1 $IP6TABLES -t raw -F
|
||||
qt1 $IP6TABLES -t raw -X
|
||||
|
||||
for chain in PREROUTING OUTPUT; do
|
||||
qt1 $IP6TABLES -t raw -P $chain ACCEPT
|
||||
done
|
||||
|
||||
qt1 $IP6TABLES -t filter -F
|
||||
qt1 $IP6TABLES -t filter -X
|
||||
|
||||
for chain in INPUT FORWARD OUTPUT; do
|
||||
qt1 $IP6TABLES -t filter -P $chain -P ACCEPT
|
||||
done
|
||||
|
||||
while read first second rest; do
|
||||
case $first in
|
||||
-*)
|
||||
#
|
||||
# We can't call run_iptables() here because the rules may contain quoted strings
|
||||
#
|
||||
eval $IP6TABLES -t $table $first $second $rest
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
error_message "ERROR: Command \"$IP6TABLES $first $second $rest\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
:*)
|
||||
chain=${first#:}
|
||||
|
||||
if [ "x$second" = x- ]; then
|
||||
do_iptables -t $table -N $chain
|
||||
else
|
||||
do_iptables -t $table -P $chain $second
|
||||
fi
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
error_message "ERROR: Command \"$IP6TABLES $first $second $rest\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
#
|
||||
# This grotesque hack with the table names works around a bug/feature with ash
|
||||
#
|
||||
'*'raw)
|
||||
table=raw
|
||||
;;
|
||||
'*'mangle)
|
||||
table=mangle
|
||||
;;
|
||||
'*'nat)
|
||||
table=nat
|
||||
;;
|
||||
'*'filter)
|
||||
table=filter
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Give Usage Information
|
||||
#
|
||||
usage() {
|
||||
echo "Usage: $0 [ -q ] [ -v ] [ -n ] [ start|stop|clear|reset|refresh|restart|status|version ]"
|
||||
echo "Usage: $0 [ options ] [ start|stop|clear|reset|refresh|restart|status|version ]"
|
||||
echo
|
||||
echo "Options are:"
|
||||
echo
|
||||
echo " -v and -q Standard Shorewall verbosity controls"
|
||||
echo " -n Don't unpdate routing configuration"
|
||||
echo " -p Purge Conntrack Table"
|
||||
echo " -t Timestamp progress Messages"
|
||||
echo " -V <verbosity> Set verbosity explicitly"
|
||||
echo " -R <file> Override RESTOREFILE setting"
|
||||
exit $1
|
||||
}
|
||||
################################################################################
|
||||
@@ -261,10 +32,23 @@ if [ $# -gt 1 ]; then
|
||||
shift
|
||||
fi
|
||||
fi
|
||||
#
|
||||
# Map VERBOSE to VERBOSITY for compatibility with old Shorewall6-lite installations
|
||||
#
|
||||
[ -z "$VERBOSITY" ] && [ -n "$VERBOSE" ] && VERBOSITY=$VERBOSE
|
||||
#
|
||||
# Map other old exported variables
|
||||
#
|
||||
g_purge=$PURGE
|
||||
g_noroutes=$NOROUTES
|
||||
g_timestamp=$TIMESTAMP
|
||||
g_recovering=$RECOVERING
|
||||
|
||||
initialize
|
||||
|
||||
if [ -n "$STARTUP_LOG" ]; then
|
||||
touch $STARTUP_LOG
|
||||
chmod 0600 $STARTUP_LOG
|
||||
if [ ${SHOREWALL_INIT_SCRIPT:-0} -eq 1 ]; then
|
||||
#
|
||||
# We're being run by a startup script that isn't redirecting STDOUT
|
||||
@@ -287,19 +71,77 @@ while [ $finished -eq 0 -a $# -gt 0 ]; do
|
||||
while [ -n "$option" ]; do
|
||||
case $option in
|
||||
v*)
|
||||
VERBOSE=$(($VERBOSE + 1 ))
|
||||
[ $VERBOSITY -lt 2 ] && VERBOSITY=$(($VERBOSITY + 1 ))
|
||||
option=${option#v}
|
||||
;;
|
||||
q*)
|
||||
VERBOSE=$(($VERBOSE - 1 ))
|
||||
[ $VERBOSITY -gt -1 ] && VERBOSITY=$(($VERBOSITY - 1 ))
|
||||
option=${option#q}
|
||||
;;
|
||||
n*)
|
||||
NOROUTES=Yes
|
||||
g_noroutes=Yes
|
||||
option=${option#n}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
t*)
|
||||
g_timestamp=Yes
|
||||
option=${option#t}
|
||||
;;
|
||||
p*)
|
||||
g_purge=Yes
|
||||
option=${option#p}
|
||||
;;
|
||||
r*)
|
||||
g_recovering=Yes
|
||||
option=${option#r}
|
||||
;;
|
||||
V*)
|
||||
option=${option#V}
|
||||
|
||||
if [ -z "$option" -a $# -gt 0 ]; then
|
||||
shift
|
||||
option=$1
|
||||
fi
|
||||
|
||||
if [ -n "$option" ]; then
|
||||
case $option in
|
||||
-1|0|1|2)
|
||||
VERBOSITY=$option
|
||||
option=
|
||||
;;
|
||||
*)
|
||||
startup_error "Invalid -V option value ($option)"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
startup_error "Missing -V option value"
|
||||
fi
|
||||
;;
|
||||
R*)
|
||||
option=${option#R}
|
||||
|
||||
if [ -z "$option" -a $# -gt 0 ]; then
|
||||
shift
|
||||
option=$1
|
||||
fi
|
||||
|
||||
if [ -n "$option" ]; then
|
||||
case $option in
|
||||
*/*)
|
||||
startup_error "-R must specify a simple file name: $option"
|
||||
;;
|
||||
.safe|.try|NONE)
|
||||
;;
|
||||
.*)
|
||||
error_message "ERROR: Reserved File Name: $RESTOREFILE"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
else
|
||||
startup_error "Missing -R option value"
|
||||
fi
|
||||
|
||||
RESTOREFILE=$option
|
||||
option=
|
||||
;;
|
||||
esac
|
||||
done
|
||||
@@ -313,21 +155,20 @@ done
|
||||
|
||||
COMMAND="$1"
|
||||
|
||||
[ -n "${PRODUCT:=Shorewall6}" ]
|
||||
|
||||
kernel=$(printf "%2d%02d%02d\n" $(echo $(uname -r) 2> /dev/null | sed 's/-.*//' | tr '.' ' ' ) | head -n1)
|
||||
kernel=$(printf "%2d%02d%02d" $(uname -r 2> /dev/null | sed -e 's/-.*//' -e 's/^\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/\1 \2 \3/g'))
|
||||
if [ $kernel -lt 20624 ]; then
|
||||
error_message "ERROR: $PRODUCT requires Linux kernel 2.6.24 or later"
|
||||
error_message "ERROR: $g_product requires Linux kernel 2.6.24 or later"
|
||||
status=2
|
||||
else
|
||||
case "$COMMAND" in
|
||||
start)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
if shorewall6_is_started; then
|
||||
error_message "$PRODUCT is already Running"
|
||||
error_message "$g_product is already Running"
|
||||
status=0
|
||||
else
|
||||
progress_message3 "Starting $PRODUCT...."
|
||||
progress_message3 "Starting $g_product...."
|
||||
detect_configuration
|
||||
define_firewall
|
||||
status=$?
|
||||
[ -n "$SUBSYSLOCK" -a $status -eq 0 ] && touch $SUBSYSLOCK
|
||||
@@ -336,7 +177,8 @@ else
|
||||
;;
|
||||
stop)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
progress_message3 "Stopping $PRODUCT...."
|
||||
progress_message3 "Stopping $g_product...."
|
||||
detect_configuration
|
||||
stop_firewall
|
||||
status=0
|
||||
[ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK
|
||||
@@ -344,14 +186,14 @@ else
|
||||
;;
|
||||
reset)
|
||||
if ! shorewall6_is_started ; then
|
||||
error_message "$PRODUCT is not running"
|
||||
error_message "$g_product is not running"
|
||||
status=2
|
||||
elif [ $# -eq 1 ]; then
|
||||
$IP6TABLES -Z
|
||||
$IP6TABLES -t mangle -Z
|
||||
date > ${VARDIR}/restarted
|
||||
status=0
|
||||
progress_message3 "$PRODUCT Counters Reset"
|
||||
progress_message3 "$g_product Counters Reset"
|
||||
else
|
||||
shift
|
||||
status=0
|
||||
@@ -373,12 +215,13 @@ else
|
||||
restart)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
if shorewall6_is_started; then
|
||||
progress_message3 "Restarting $PRODUCT...."
|
||||
progress_message3 "Restarting $g_product...."
|
||||
else
|
||||
error_message "$PRODUCT is not running"
|
||||
progress_message3 "Starting $PRODUCT...."
|
||||
error_message "$g_product is not running"
|
||||
progress_message3 "Starting $g_product...."
|
||||
fi
|
||||
|
||||
detect_configuration
|
||||
define_firewall
|
||||
status=$?
|
||||
if [ -n "$SUBSYSLOCK" ]; then
|
||||
@@ -389,17 +232,19 @@ else
|
||||
refresh)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
if shorewall6_is_started; then
|
||||
progress_message3 "Refreshing $PRODUCT...."
|
||||
progress_message3 "Refreshing $g_product...."
|
||||
detect_configuration
|
||||
define_firewall
|
||||
status=$?
|
||||
progress_message3 "done."
|
||||
else
|
||||
echo "$PRODUCT is not running" >&2
|
||||
echo "$g_product is not running" >&2
|
||||
status=2
|
||||
fi
|
||||
;;
|
||||
restore)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
detect_configuration
|
||||
define_firewall
|
||||
status=$?
|
||||
if [ -n "$SUBSYSLOCK" ]; then
|
||||
@@ -408,7 +253,7 @@ else
|
||||
;;
|
||||
clear)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
progress_message3 "Clearing $PRODUCT...."
|
||||
progress_message3 "Clearing $g_product...."
|
||||
clear_firewall
|
||||
status=0
|
||||
[ -n "$SUBSYSLOCK" ] && rm -f $SUBSYSLOCK
|
||||
@@ -416,13 +261,13 @@ else
|
||||
;;
|
||||
status)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
echo "$PRODUCT-$VERSION Status at $HOSTNAME - $(date)"
|
||||
echo "$g_product-$SHOREWALL_VERSION Status at $(hostname) - $(date)"
|
||||
echo
|
||||
if shorewall6_is_started; then
|
||||
echo "$PRODUCT is running"
|
||||
echo "$g_product is running"
|
||||
status=0
|
||||
else
|
||||
echo "$PRODUCT is stopped"
|
||||
echo "$g_product is stopped"
|
||||
status=4
|
||||
fi
|
||||
|
||||
@@ -441,7 +286,7 @@ else
|
||||
;;
|
||||
version)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
echo $VERSION
|
||||
echo $SHOREWALL_VERSION
|
||||
status=0
|
||||
;;
|
||||
help)
|
||||
|
@@ -1,11 +1,18 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 1999-2009 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 1999-2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Options are:
|
||||
#
|
||||
# -n Don't alter Routing
|
||||
# -v and -q Standard Shorewall Verbosity control
|
||||
# -t Timestamp progress messages
|
||||
# -p Purge conntrack table
|
||||
# -r Recover from failed start/restart
|
||||
# -V <verbosity> Set verbosity level explicitly
|
||||
# -R <restore> Overrides RESTOREFILE setting
|
||||
#
|
||||
# Commands are:
|
||||
#
|
||||
@@ -22,14 +29,6 @@
|
||||
################################################################################
|
||||
# Functions imported from /usr/share/shorewall/prog.header
|
||||
################################################################################
|
||||
#
|
||||
# Message to stderr
|
||||
#
|
||||
error_message() # $* = Error Message
|
||||
{
|
||||
echo " $@" >&2
|
||||
}
|
||||
|
||||
#
|
||||
# Conditionally produce message
|
||||
#
|
||||
@@ -38,12 +37,12 @@ progress_message() # $* = Message
|
||||
local timestamp
|
||||
timestamp=
|
||||
|
||||
if [ $VERBOSE -gt 1 ]; then
|
||||
[ -n "$TIMESTAMP" ] && timestamp="$(date +%H:%M:%S) "
|
||||
if [ $VERBOSITY -gt 1 ]; then
|
||||
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
||||
echo "${timestamp}$@"
|
||||
fi
|
||||
|
||||
if [ $LOG_VERBOSE -gt 1 ]; then
|
||||
if [ $LOG_VERBOSITY -gt 1 ]; then
|
||||
timestamp="$(date +'%b %_d %T') "
|
||||
echo "${timestamp}$@" >> $STARTUP_LOG
|
||||
fi
|
||||
@@ -54,12 +53,12 @@ progress_message2() # $* = Message
|
||||
local timestamp
|
||||
timestamp=
|
||||
|
||||
if [ $VERBOSE -gt 0 ]; then
|
||||
[ -n "$TIMESTAMP" ] && timestamp="$(date +%H:%M:%S) "
|
||||
if [ $VERBOSITY -gt 0 ]; then
|
||||
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
||||
echo "${timestamp}$@"
|
||||
fi
|
||||
|
||||
if [ $LOG_VERBOSE -gt 0 ]; then
|
||||
if [ $LOG_VERBOSITY -gt 0 ]; then
|
||||
timestamp="$(date +'%b %_d %T') "
|
||||
echo "${timestamp}$@" >> $STARTUP_LOG
|
||||
fi
|
||||
@@ -70,93 +69,17 @@ progress_message3() # $* = Message
|
||||
local timestamp
|
||||
timestamp=
|
||||
|
||||
if [ $VERBOSE -ge 0 ]; then
|
||||
[ -n "$TIMESTAMP" ] && timestamp="$(date +%H:%M:%S) "
|
||||
if [ $VERBOSITY -ge 0 ]; then
|
||||
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
||||
echo "${timestamp}$@"
|
||||
fi
|
||||
|
||||
if [ $LOG_VERBOSE -ge 0 ]; then
|
||||
if [ $LOG_VERBOSITY -ge 0 ]; then
|
||||
timestamp="$(date +'%b %_d %T') "
|
||||
echo "${timestamp}$@" >> $STARTUP_LOG
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Split a colon-separated list into a space-separated list
|
||||
#
|
||||
split() {
|
||||
local ifs
|
||||
ifs=$IFS
|
||||
IFS=:
|
||||
echo $*
|
||||
IFS=$ifs
|
||||
}
|
||||
|
||||
#
|
||||
# Search a list looking for a match -- returns zero if a match found
|
||||
# 1 otherwise
|
||||
#
|
||||
list_search() # $1 = element to search for , $2-$n = list
|
||||
{
|
||||
local e
|
||||
e=$1
|
||||
|
||||
while [ $# -gt 1 ]; do
|
||||
shift
|
||||
[ "x$e" = "x$1" ] && return 0
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
#
|
||||
# Suppress all output for a command
|
||||
#
|
||||
qt()
|
||||
{
|
||||
"$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
qt1()
|
||||
{
|
||||
local status
|
||||
|
||||
while [ 1 ]; do
|
||||
"$@" >/dev/null 2>&1
|
||||
status=$?
|
||||
[ $status -ne 4 ] && return $status
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Determine if Shorewall is "running"
|
||||
#
|
||||
shorewall_is_started() {
|
||||
qt1 $IPTABLES -L shorewall -n
|
||||
}
|
||||
|
||||
#
|
||||
# Echos the fully-qualified name of the calling shell program
|
||||
#
|
||||
my_pathname() {
|
||||
cd $(dirname $0)
|
||||
echo $PWD/$(basename $0)
|
||||
}
|
||||
|
||||
#
|
||||
# Source a user exit file if it exists
|
||||
#
|
||||
run_user_exit() # $1 = file name
|
||||
{
|
||||
local user_exit
|
||||
user_exit=$(find_file $1)
|
||||
|
||||
if [ -f $user_exit ]; then
|
||||
progress_message "Processing $user_exit ..."
|
||||
. $user_exit
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Set a standard chain's policy
|
||||
#
|
||||
@@ -197,243 +120,6 @@ deleteallchains() {
|
||||
run_iptables -X
|
||||
}
|
||||
|
||||
#
|
||||
# Load a Kernel Module -- assumes that the variable 'moduledirectories' contains
|
||||
# a space-separated list of directories to search for
|
||||
# the module and that 'moduleloader' contains the
|
||||
# module loader command.
|
||||
#
|
||||
loadmodule() # $1 = module name, $2 - * arguments
|
||||
{
|
||||
local modulename
|
||||
modulename=$1
|
||||
local modulefile
|
||||
local suffix
|
||||
|
||||
if ! list_search $modulename $DONT_LOAD $MODULES; then
|
||||
shift
|
||||
|
||||
for suffix in $MODULE_SUFFIX ; do
|
||||
for directory in $moduledirectories; do
|
||||
modulefile=$directory/${modulename}.${suffix}
|
||||
|
||||
if [ -f $modulefile ]; then
|
||||
case $moduleloader in
|
||||
insmod)
|
||||
insmod $modulefile $*
|
||||
;;
|
||||
*)
|
||||
modprobe $modulename $*
|
||||
;;
|
||||
esac
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Reload the Modules
|
||||
#
|
||||
reload_kernel_modules() {
|
||||
|
||||
local save_modules_dir
|
||||
save_modules_dir=$MODULESDIR
|
||||
local directory
|
||||
local moduledirectories
|
||||
moduledirectories=
|
||||
local moduleloader
|
||||
moduleloader=modprobe
|
||||
local uname
|
||||
|
||||
if ! qt mywhich modprobe; then
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=o gz ko o.gz ko.gz}" ]
|
||||
|
||||
[ -z "$MODULESDIR" ] && \
|
||||
uname=$(uname -r) && \
|
||||
MODULESDIR=/lib/modules/$uname/kernel/net/ipv4/netfilter:/lib/modules/$uname/kernel/net/netfilter:/lib/modules/$uname/extra:/lib/modules/$uname/extra/ipset
|
||||
|
||||
MODULES=$(lsmod | cut -d ' ' -f1)
|
||||
|
||||
for directory in $(split $MODULESDIR); do
|
||||
[ -d $directory ] && moduledirectories="$moduledirectories $directory"
|
||||
done
|
||||
|
||||
[ -n "$moduledirectories" ] && while read command; do
|
||||
eval $command
|
||||
done
|
||||
|
||||
MODULESDIR=$save_modules_dir
|
||||
}
|
||||
|
||||
#
|
||||
# Load kernel modules required for Shorewall
|
||||
#
|
||||
load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
|
||||
{
|
||||
local save_modules_dir
|
||||
save_modules_dir=$MODULESDIR
|
||||
local directory
|
||||
local moduledirectories
|
||||
moduledirectories=
|
||||
local moduleloader
|
||||
moduleloader=modprobe
|
||||
local savemoduleinfo
|
||||
savemoduleinfo=${1:-Yes} # So old compiled scripts still work
|
||||
local uname
|
||||
|
||||
if ! qt mywhich modprobe; then
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=o gz ko o.gz ko.gz}" ]
|
||||
|
||||
[ -z "$MODULESDIR" ] && \
|
||||
uname=$(uname -r) && \
|
||||
MODULESDIR=/lib/modules/$uname/kernel/net/ipv4/netfilter:/lib/modules/$uname/kernel/net/netfilter:/lib/modules/$uname/extra:/lib/modules/$uname/extra/ipset
|
||||
|
||||
for directory in $(split $MODULESDIR); do
|
||||
[ -d $directory ] && moduledirectories="$moduledirectories $directory"
|
||||
done
|
||||
|
||||
modules=$(find_file modules)
|
||||
|
||||
if [ -f $modules -a -n "$moduledirectories" ]; then
|
||||
MODULES=$(lsmod | cut -d ' ' -f1)
|
||||
progress_message "Loading Modules..."
|
||||
. $modules
|
||||
if [ $savemoduleinfo = Yes ]; then
|
||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||
echo MODULESDIR="$MODULESDIR" > ${VARDIR}/.modulesdir
|
||||
cp -f $modules ${VARDIR}/.modules
|
||||
fi
|
||||
elif [ $savemoduleinfo = Yes ]; then
|
||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||
> ${VARDIR}/.modulesdir
|
||||
> ${VARDIR}/.modules
|
||||
fi
|
||||
|
||||
MODULESDIR=$save_modules_dir
|
||||
}
|
||||
|
||||
#
|
||||
# Note: The following set of IP address manipulation functions have anomalous
|
||||
# behavior when the shell only supports 32-bit signed arithmetic and
|
||||
# the IP address is 128.0.0.0 or 128.0.0.1.
|
||||
#
|
||||
|
||||
LEFTSHIFT='<<'
|
||||
|
||||
#
|
||||
# Convert an IP address in dot quad format to an integer
|
||||
#
|
||||
decodeaddr() {
|
||||
local x
|
||||
local temp
|
||||
temp=0
|
||||
local ifs
|
||||
ifs=$IFS
|
||||
|
||||
IFS=.
|
||||
|
||||
for x in $1; do
|
||||
temp=$(( $(( $temp $LEFTSHIFT 8 )) | $x ))
|
||||
done
|
||||
|
||||
echo $temp
|
||||
|
||||
IFS=$ifs
|
||||
}
|
||||
|
||||
#
|
||||
# convert an integer to dot quad format
|
||||
#
|
||||
encodeaddr() {
|
||||
addr=$1
|
||||
local x
|
||||
local y
|
||||
y=$(($addr & 255))
|
||||
|
||||
for x in 1 2 3 ; do
|
||||
addr=$(($addr >> 8))
|
||||
y=$(($addr & 255)).$y
|
||||
done
|
||||
|
||||
echo $y
|
||||
}
|
||||
|
||||
#
|
||||
# Netmask from CIDR
|
||||
#
|
||||
ip_netmask() {
|
||||
local vlsm
|
||||
vlsm=${1#*/}
|
||||
|
||||
[ $vlsm -eq 0 ] && echo 0 || echo $(( -1 $LEFTSHIFT $(( 32 - $vlsm )) ))
|
||||
}
|
||||
|
||||
#
|
||||
# Network address from CIDR
|
||||
#
|
||||
ip_network() {
|
||||
local decodedaddr
|
||||
decodedaddr=$(decodeaddr ${1%/*})
|
||||
local netmask
|
||||
netmask=$(ip_netmask $1)
|
||||
|
||||
echo $(encodeaddr $(($decodedaddr & $netmask)))
|
||||
}
|
||||
|
||||
#
|
||||
# The following hack is supplied to compensate for the fact that many of
|
||||
# the popular light-weight Bourne shell derivatives don't support XOR ("^").
|
||||
#
|
||||
ip_broadcast() {
|
||||
local x
|
||||
x=$(( 32 - ${1#*/} ))
|
||||
|
||||
[ $x -eq 32 ] && echo -1 || echo $(( $(( 1 $LEFTSHIFT $x )) - 1 ))
|
||||
}
|
||||
|
||||
#
|
||||
# Calculate broadcast address from CIDR
|
||||
#
|
||||
broadcastaddress() {
|
||||
local decodedaddr
|
||||
decodedaddr=$(decodeaddr ${1%/*})
|
||||
local netmask
|
||||
netmask=$(ip_netmask $1)
|
||||
local broadcast
|
||||
broadcast=$(ip_broadcast $1)
|
||||
|
||||
echo $(encodeaddr $(( $(($decodedaddr & $netmask)) | $broadcast )))
|
||||
}
|
||||
|
||||
#
|
||||
# Test for network membership
|
||||
#
|
||||
in_network() # $1 = IP address, $2 = CIDR network
|
||||
{
|
||||
local netmask
|
||||
netmask=$(ip_netmask $2)
|
||||
#
|
||||
# Use string comparison to work around a broken BusyBox ash in OpenWRT
|
||||
#
|
||||
test $(( $(decodeaddr $1) & $netmask)) = $(( $(decodeaddr ${2%/*}) & $netmask ))
|
||||
}
|
||||
|
||||
#
|
||||
# Query NetFilter about the existence of a filter chain
|
||||
#
|
||||
chain_exists() # $1 = chain name
|
||||
{
|
||||
qt1 $IPTABLES -L $1 -n
|
||||
}
|
||||
|
||||
#
|
||||
# Find the value 'dev' in the passed arguments then echo the next value
|
||||
#
|
||||
@@ -534,32 +220,6 @@ find_interface_by_address() {
|
||||
[ -n "$dev" ] && echo $dev
|
||||
}
|
||||
|
||||
#
|
||||
# Find the interface with the passed MAC address
|
||||
#
|
||||
|
||||
find_interface_by_mac() {
|
||||
local mac
|
||||
mac=$1
|
||||
local first
|
||||
local second
|
||||
local rest
|
||||
local dev
|
||||
|
||||
$IP link list | while read first second rest; do
|
||||
case $first in
|
||||
*:)
|
||||
dev=$second
|
||||
;;
|
||||
*)
|
||||
if [ "$second" = $mac ]; then
|
||||
echo ${dev%:}
|
||||
return
|
||||
fi
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Determine if Interface is up
|
||||
#
|
||||
@@ -567,45 +227,12 @@ interface_is_up() {
|
||||
[ -n "$($IP link list dev $1 2> /dev/null | grep -e '[<,]UP[,>]')" ]
|
||||
}
|
||||
|
||||
#
|
||||
# Find interface address--returns the first IP address assigned to the passed
|
||||
# device
|
||||
#
|
||||
find_first_interface_address() # $1 = interface
|
||||
{
|
||||
#
|
||||
# get the line of output containing the first IP address
|
||||
#
|
||||
addr=$($IP -f inet addr show $1 2> /dev/null | grep 'inet .* global' | head -n1)
|
||||
#
|
||||
# If there wasn't one, bail out now
|
||||
#
|
||||
[ -n "$addr" ] || startup_error "Can't determine the IP address of $1"
|
||||
#
|
||||
# Strip off the trailing VLSM mask (or the peer IP in case of a P-t-P link)
|
||||
# along with everything else on the line
|
||||
#
|
||||
echo $addr | sed 's/\s*inet //;s/\/.*//;s/ peer.*//'
|
||||
}
|
||||
|
||||
find_first_interface_address_if_any() # $1 = interface
|
||||
{
|
||||
#
|
||||
# get the line of output containing the first IP address
|
||||
#
|
||||
addr=$($IP -f inet addr show $1 2> /dev/null | grep 'inet .* global' | head -n1)
|
||||
#
|
||||
# Strip off the trailing VLSM mask (or the peer IP in case of a P-t-P link)
|
||||
# along with everything else on the line
|
||||
#
|
||||
[ -n "$addr" ] && echo $addr | sed 's/\s*inet //;s/\/.*//;s/ peer.*//' || echo 0.0.0.0
|
||||
}
|
||||
|
||||
#
|
||||
# Determine if interface is usable from a Netfilter prespective
|
||||
#
|
||||
interface_is_usable() # $1 = interface
|
||||
{
|
||||
[ "$1" = lo ] && return 0
|
||||
interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != 0.0.0.0 ] && run_isusable_exit $1
|
||||
}
|
||||
|
||||
@@ -658,71 +285,6 @@ get_interface_bcasts() # $1 = interface
|
||||
$IP -f inet addr show dev $1 2> /dev/null | grep 'inet.*brd' | sed 's/inet.*brd //; s/scope.*//;' | sort -u
|
||||
}
|
||||
|
||||
#
|
||||
# Internal version of 'which'
|
||||
#
|
||||
mywhich() {
|
||||
local dir
|
||||
|
||||
for dir in $(split $PATH); do
|
||||
if [ -x $dir/$1 ]; then
|
||||
echo $dir/$1
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 2
|
||||
}
|
||||
|
||||
#
|
||||
# Find a File -- For relative file name, look in each ${CONFIG_PATH} then ${CONFDIR}
|
||||
#
|
||||
find_file()
|
||||
{
|
||||
local saveifs
|
||||
saveifs=
|
||||
local directory
|
||||
|
||||
case $1 in
|
||||
/*)
|
||||
echo $1
|
||||
;;
|
||||
*)
|
||||
for directory in $(split $CONFIG_PATH); do
|
||||
if [ -f $directory/$1 ]; then
|
||||
echo $directory/$1
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
echo ${CONFDIR}/$1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
# Set the Shorewall state
|
||||
#
|
||||
set_state () # $1 = state
|
||||
{
|
||||
echo "$1 ($(date))" > ${VARDIR}/state
|
||||
}
|
||||
|
||||
#
|
||||
# Perform variable substitution on the passed argument and echo the result
|
||||
#
|
||||
expand() # $@ = contents of variable which may be the name of another variable
|
||||
{
|
||||
eval echo \"$@\"
|
||||
}
|
||||
|
||||
#
|
||||
# Function for including one file into another
|
||||
#
|
||||
INCLUDE() {
|
||||
. $(find_file $(expand $@))
|
||||
}
|
||||
|
||||
#
|
||||
# Delete IP address
|
||||
#
|
||||
@@ -875,16 +437,6 @@ disable_ipv6() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to truncate a string -- It uses 'cut -b -<n>'
|
||||
# rather than ${v:first:last} because light-weight shells like ash and
|
||||
# dash do not support that form of expansion.
|
||||
#
|
||||
|
||||
truncate() # $1 = length
|
||||
{
|
||||
cut -b -${1}
|
||||
}
|
||||
|
||||
#
|
||||
# Clear the current traffic shaping configuration
|
||||
#
|
||||
@@ -950,7 +502,7 @@ get_device_mtu1() # $1 = device
|
||||
#
|
||||
undo_routing() {
|
||||
|
||||
if [ -z "$NOROUTES" ]; then
|
||||
if [ -z "$g_noroutes" ]; then
|
||||
#
|
||||
# Restore rt_tables database
|
||||
#
|
||||
@@ -974,7 +526,7 @@ undo_routing() {
|
||||
# Restore the default route that was in place before the initial 'shorewall start'
|
||||
#
|
||||
restore_default_route() {
|
||||
if [ -z "$NOROUTES" -a -f ${VARDIR}/default_route ]; then
|
||||
if [ -z "$g_noroutes" -a -f ${VARDIR}/default_route ]; then
|
||||
local default_route
|
||||
default_route=
|
||||
local route
|
||||
@@ -1017,25 +569,6 @@ restore_default_route() {
|
||||
return $result
|
||||
}
|
||||
|
||||
#
|
||||
# Determine how to do "echo -e"
|
||||
#
|
||||
|
||||
find_echo() {
|
||||
local result
|
||||
|
||||
result=$(echo "a\tb")
|
||||
[ ${#result} -eq 3 ] && { echo echo; return; }
|
||||
|
||||
result=$(echo -e "a\tb")
|
||||
[ ${#result} -eq 3 ] && { echo "echo -e"; return; }
|
||||
|
||||
result=$(mywhich echo)
|
||||
[ -n "$result" ] && { echo "$result -e"; return; }
|
||||
|
||||
echo echo
|
||||
}
|
||||
|
||||
#
|
||||
# Determine the MAC address of the passed IP through the passed interface
|
||||
#
|
||||
@@ -1058,11 +591,11 @@ find_mac() # $1 = IP address, $2 = interface
|
||||
}
|
||||
|
||||
#
|
||||
# Flush the conntrack table if $PURGE is non-empty
|
||||
# Flush the conntrack table if $g_purge is non-empty
|
||||
#
|
||||
conditionally_flush_conntrack() {
|
||||
|
||||
if [ -n "$PURGE" ]; then
|
||||
if [ -n "$g_purge" ]; then
|
||||
if [ -n $(mywhich conntrack) ]; then
|
||||
conntrack -F
|
||||
else
|
||||
@@ -1071,6 +604,283 @@ conditionally_flush_conntrack() {
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Clear Proxy Arp
|
||||
#
|
||||
delete_proxyarp() {
|
||||
if [ -f ${VARDIR}/proxyarp ]; then
|
||||
while read address interface external haveroute; do
|
||||
qt arp -i $external -d $address pub
|
||||
[ -z "${haveroute}${g_noroutes}" ] && qt $IP -4 route del $address dev $interface
|
||||
f=/proc/sys/net/ipv4/conf/$interface/proxy_arp
|
||||
[ -f $f ] && echo 0 > $f
|
||||
done < ${VARDIR}/proxyarp
|
||||
fi
|
||||
|
||||
rm -f ${VARDIR}/proxyarp
|
||||
}
|
||||
|
||||
#
|
||||
# Remove all Shorewall-added rules
|
||||
#
|
||||
clear_firewall() {
|
||||
stop_firewall
|
||||
|
||||
setpolicy INPUT ACCEPT
|
||||
setpolicy FORWARD ACCEPT
|
||||
setpolicy OUTPUT ACCEPT
|
||||
|
||||
run_iptables -F
|
||||
|
||||
echo 1 > /proc/sys/net/ipv4/ip_forward
|
||||
|
||||
if [ -n "$DISABLE_IPV6" ]; then
|
||||
if [ -x $IP6TABLES ]; then
|
||||
$IP6TABLES -P INPUT ACCEPT 2> /dev/null
|
||||
$IP6TABLES -P OUTPUT ACCEPT 2> /dev/null
|
||||
$IP6TABLES -P FORWARD ACCEPT 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
run_clear_exit
|
||||
|
||||
set_state "Cleared"
|
||||
|
||||
logger -p kern.info "$g_product Cleared"
|
||||
}
|
||||
|
||||
#
|
||||
# Issue a message and stop/restore the firewall
|
||||
#
|
||||
fatal_error()
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
|
||||
if [ $LOG_VERBOSITY -gt 1 ]; then
|
||||
timestamp="$(date +'%_b %d %T') "
|
||||
echo "${timestamp} ERROR: $@" >> $STARTUP_LOG
|
||||
fi
|
||||
|
||||
stop_firewall
|
||||
[ -n "$TEMPFILE" ] && rm -f $TEMPFILE
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Issue a message and stop
|
||||
#
|
||||
startup_error() # $* = Error Message
|
||||
{
|
||||
echo " ERROR: $@: Firewall state not changed" >&2
|
||||
case $COMMAND in
|
||||
start)
|
||||
logger -p kern.err "ERROR:$g_product start failed:Firewall state not changed"
|
||||
;;
|
||||
restart)
|
||||
logger -p kern.err "ERROR:$g_product restart failed:Firewall state not changed"
|
||||
;;
|
||||
restore)
|
||||
logger -p kern.err "ERROR:$g_product restore failed:Firewall state not changed"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $LOG_VERBOSITY -gt 1 ]; then
|
||||
timestamp="$(date +'%_b %d %T') "
|
||||
|
||||
case $COMMAND in
|
||||
start)
|
||||
echo "${timestamp} ERROR:$g_product start failed:Firewall state not changed" >> $STARTUP_LOG
|
||||
;;
|
||||
restart)
|
||||
echo "${timestamp} ERROR:$g_product restart failed:Firewall state not changed" >> $STARTUP_LOG
|
||||
;;
|
||||
restore)
|
||||
echo "${timestamp} ERROR:$g_product restore failed:Firewall state not changed" >> $STARTUP_LOG
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
kill $$
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Run iptables and if an error occurs, stop/restore the firewall
|
||||
#
|
||||
run_iptables()
|
||||
{
|
||||
local status
|
||||
|
||||
while [ 1 ]; do
|
||||
$IPTABLES $@
|
||||
status=$?
|
||||
[ $status -ne 4 ] && break
|
||||
done
|
||||
|
||||
if [ $status -ne 0 ]; then
|
||||
error_message "ERROR: Command \"$IPTABLES $@\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Run iptables retrying exit status 4
|
||||
#
|
||||
do_iptables()
|
||||
{
|
||||
local status
|
||||
|
||||
while [ 1 ]; do
|
||||
$IPTABLES $@
|
||||
status=$?
|
||||
[ $status -ne 4 ] && return $status;
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Run iptables and if an error occurs, stop/restore the firewall
|
||||
#
|
||||
run_ip()
|
||||
{
|
||||
if ! $IP -4 $@; then
|
||||
error_message "ERROR: Command \"$IP -4 $@\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Run tc and if an error occurs, stop/restore the firewall
|
||||
#
|
||||
run_tc() {
|
||||
if ! $TC $@ ; then
|
||||
error_message "ERROR: Command \"$TC $@\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Restore the rules generated by 'drop','reject','logdrop', etc.
|
||||
#
|
||||
restore_dynamic_rules() {
|
||||
if [ -f ${VARDIR}/save ]; then
|
||||
progress_message2 "Setting up dynamic rules..."
|
||||
rangematch='source IP range'
|
||||
while read target ignore1 ignore2 address ignore3 rest; do
|
||||
case $target in
|
||||
DROP|reject|logdrop|logreject)
|
||||
case $rest in
|
||||
$rangematch*)
|
||||
run_iptables -A dynamic -m iprange --src-range ${rest#source IP range} -j $target
|
||||
;;
|
||||
*)
|
||||
if [ -z "$rest" ]; then
|
||||
run_iptables -A dynamic -s $address -j $target
|
||||
else
|
||||
error_message "WARNING: Unable to restore dynamic rule \"$target $ignore1 $ignore2 $address $ignore3 $rest\""
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done < ${VARDIR}/save
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Get a list of all configured broadcast addresses on the system
|
||||
#
|
||||
get_all_bcasts()
|
||||
{
|
||||
$IP -f inet addr show 2> /dev/null | grep 'inet.*brd' | grep -v '/32 ' | sed 's/inet.*brd //; s/scope.*//;' | sort -u
|
||||
}
|
||||
|
||||
#
|
||||
# Run the .iptables_restore_input as a set of discrete iptables commands
|
||||
#
|
||||
debug_restore_input() {
|
||||
local first second rest table chain
|
||||
#
|
||||
# Clear the ruleset
|
||||
#
|
||||
qt1 $IPTABLES -t mangle -F
|
||||
qt1 $IPTABLES -t mangle -X
|
||||
|
||||
for chain in PREROUTING INPUT FORWARD POSTROUTING; do
|
||||
qt1 $IPTABLES -t mangle -P $chain ACCEPT
|
||||
done
|
||||
|
||||
qt1 $IPTABLES -t raw -F
|
||||
qt1 $IPTABLES -t raw -X
|
||||
|
||||
for chain in PREROUTING OUTPUT; do
|
||||
qt1 $IPTABLES -t raw -P $chain ACCEPT
|
||||
done
|
||||
|
||||
run_iptables -t nat -F
|
||||
run_iptables -t nat -X
|
||||
|
||||
for chain in PREROUTING POSTROUTING OUTPUT; do
|
||||
qt1 $IPTABLES -t nat -P $chain ACCEPT
|
||||
done
|
||||
|
||||
qt1 $IPTABLES -t filter -F
|
||||
qt1 $IPTABLES -t filter -X
|
||||
|
||||
for chain in INPUT FORWARD OUTPUT; do
|
||||
qt1 $IPTABLES -t filter -P $chain -P ACCEPT
|
||||
done
|
||||
|
||||
while read first second rest; do
|
||||
case $first in
|
||||
-*)
|
||||
#
|
||||
# We can't call run_iptables() here because the rules may contain quoted strings
|
||||
#
|
||||
eval $IPTABLES -t $table $first $second $rest
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
error_message "ERROR: Command \"$IPTABLES $first $second $rest\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
:*)
|
||||
chain=${first#:}
|
||||
|
||||
if [ "x$second" = x- ]; then
|
||||
do_iptables -t $table -N $chain
|
||||
else
|
||||
do_iptables -t $table -P $chain $second
|
||||
fi
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
error_message "ERROR: Command \"$IPTABLES $first $second $rest\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
#
|
||||
# This grotesque hack with the table names works around a bug/feature with ash
|
||||
#
|
||||
'*'raw)
|
||||
table=raw
|
||||
;;
|
||||
'*'mangle)
|
||||
table=mangle
|
||||
;;
|
||||
'*'nat)
|
||||
table=nat
|
||||
;;
|
||||
'*'filter)
|
||||
table=filter
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# End of functions in /usr/share/shorewall/prog.header
|
||||
################################################################################
|
||||
|
@@ -1,11 +1,18 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 1999-2009 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 1999-2010- Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Options are:
|
||||
#
|
||||
# -n Don't alter Routing
|
||||
# -v and -q Standard Shorewall Verbosity control
|
||||
# -t Timestamp progress messages
|
||||
# -p Purge conntrack table
|
||||
# -r Recover from failed start/restart
|
||||
# -V <verbosity> Set verbosity level explicitly
|
||||
# -R <restore> Overrides RESTOREFILE setting
|
||||
#
|
||||
# Commands are:
|
||||
#
|
||||
@@ -22,14 +29,6 @@
|
||||
################################################################################
|
||||
# Functions imported from /usr/share/shorewall/prog.header6
|
||||
################################################################################
|
||||
#
|
||||
# Message to stderr
|
||||
#
|
||||
error_message() # $* = Error Message
|
||||
{
|
||||
echo " $@" >&2
|
||||
}
|
||||
|
||||
#
|
||||
# Conditionally produce message
|
||||
#
|
||||
@@ -38,12 +37,12 @@ progress_message() # $* = Message
|
||||
local timestamp
|
||||
timestamp=
|
||||
|
||||
if [ $VERBOSE -gt 1 ]; then
|
||||
[ -n "$TIMESTAMP" ] && timestamp="$(date +%H:%M:%S) "
|
||||
if [ $VERBOSITY -gt 1 ]; then
|
||||
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
||||
echo "${timestamp}$@"
|
||||
fi
|
||||
|
||||
if [ $LOG_VERBOSE -gt 1 ]; then
|
||||
if [ $LOG_VERBOSITY -gt 1 ]; then
|
||||
timestamp="$(date +'%b %_d %T') "
|
||||
echo "${timestamp}$@" >> $STARTUP_LOG
|
||||
fi
|
||||
@@ -54,12 +53,12 @@ progress_message2() # $* = Message
|
||||
local timestamp
|
||||
timestamp=
|
||||
|
||||
if [ $VERBOSE -gt 0 ]; then
|
||||
[ -n "$TIMESTAMP" ] && timestamp="$(date +%H:%M:%S) "
|
||||
if [ $VERBOSITY -gt 0 ]; then
|
||||
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
||||
echo "${timestamp}$@"
|
||||
fi
|
||||
|
||||
if [ $LOG_VERBOSE -gt 0 ]; then
|
||||
if [ $LOG_VERBOSITY -gt 0 ]; then
|
||||
timestamp="$(date +'%b %_d %T') "
|
||||
echo "${timestamp}$@" >> $STARTUP_LOG
|
||||
fi
|
||||
@@ -70,117 +69,17 @@ progress_message3() # $* = Message
|
||||
local timestamp
|
||||
timestamp=
|
||||
|
||||
if [ $VERBOSE -ge 0 ]; then
|
||||
[ -n "$TIMESTAMP" ] && timestamp="$(date +%H:%M:%S) "
|
||||
if [ $VERBOSITY -ge 0 ]; then
|
||||
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
||||
echo "${timestamp}$@"
|
||||
fi
|
||||
|
||||
if [ $LOG_VERBOSE -ge 0 ]; then
|
||||
if [ $LOG_VERBOSITY -ge 0 ]; then
|
||||
timestamp="$(date +'%b %_d %T') "
|
||||
echo "${timestamp}$@" >> $STARTUP_LOG
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Split a colon-separated list into a space-separated list
|
||||
#
|
||||
split() {
|
||||
local ifs
|
||||
ifs=$IFS
|
||||
IFS=:
|
||||
echo $*
|
||||
IFS=$ifs
|
||||
}
|
||||
|
||||
#
|
||||
# Undo the effect of 'split()'
|
||||
#
|
||||
join()
|
||||
{
|
||||
local f
|
||||
local o
|
||||
o=
|
||||
|
||||
for f in $* ; do
|
||||
o="${o:+$o:}$f"
|
||||
done
|
||||
|
||||
echo $o
|
||||
}
|
||||
|
||||
#
|
||||
# Return the number of elements in a list
|
||||
#
|
||||
list_count() # $* = list
|
||||
{
|
||||
return $#
|
||||
}
|
||||
|
||||
#
|
||||
# Search a list looking for a match -- returns zero if a match found
|
||||
# 1 otherwise
|
||||
#
|
||||
list_search() # $1 = element to search for , $2-$n = list
|
||||
{
|
||||
local e
|
||||
e=$1
|
||||
|
||||
while [ $# -gt 1 ]; do
|
||||
shift
|
||||
[ "x$e" = "x$1" ] && return 0
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
#
|
||||
# Suppress all output for a command
|
||||
#
|
||||
qt()
|
||||
{
|
||||
"$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
qt1()
|
||||
{
|
||||
local status
|
||||
|
||||
while [ 1 ]; do
|
||||
"$@" >/dev/null 2>&1
|
||||
status=$?
|
||||
[ $status -ne 4 ] && return $status
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Determine if Shorewall is "running"
|
||||
#
|
||||
shorewall6_is_started() {
|
||||
qt1 $IP6TABLES -L shorewall -n
|
||||
}
|
||||
|
||||
#
|
||||
# Echos the fully-qualified name of the calling shell program
|
||||
#
|
||||
my_pathname() {
|
||||
cd $(dirname $0)
|
||||
echo $PWD/$(basename $0)
|
||||
}
|
||||
|
||||
#
|
||||
# Source a user exit file if it exists
|
||||
#
|
||||
run_user_exit() # $1 = file name
|
||||
{
|
||||
local user_exit
|
||||
user_exit=$(find_file $1)
|
||||
|
||||
if [ -f $user_exit ]; then
|
||||
progress_message "Processing $user_exit ..."
|
||||
. $user_exit
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Set a standard chain's policy
|
||||
#
|
||||
@@ -213,131 +112,6 @@ deleteallchains() {
|
||||
run_iptables -X
|
||||
}
|
||||
|
||||
#
|
||||
# Load a Kernel Module -- assumes that the variable 'moduledirectories' contains
|
||||
# a space-separated list of directories to search for
|
||||
# the module and that 'moduleloader' contains the
|
||||
# module loader command.
|
||||
#
|
||||
loadmodule() # $1 = module name, $2 - * arguments
|
||||
{
|
||||
local modulename
|
||||
modulename=$1
|
||||
local modulefile
|
||||
local suffix
|
||||
|
||||
if ! list_search $modulename $DONT_LOAD $MODULES; then
|
||||
shift
|
||||
|
||||
for suffix in $MODULE_SUFFIX ; do
|
||||
for directory in $moduledirectories; do
|
||||
modulefile=$directory/${modulename}.${suffix}
|
||||
|
||||
if [ -f $modulefile ]; then
|
||||
case $moduleloader in
|
||||
insmod)
|
||||
insmod $modulefile $*
|
||||
;;
|
||||
*)
|
||||
modprobe $modulename $*
|
||||
;;
|
||||
esac
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Reload the Modules
|
||||
#
|
||||
reload_kernel_modules() {
|
||||
|
||||
local save_modules_dir
|
||||
save_modules_dir=$MODULESDIR
|
||||
local directory
|
||||
local moduledirectories
|
||||
moduledirectories=
|
||||
local moduleloader
|
||||
moduleloader=modprobe
|
||||
|
||||
if ! qt mywhich modprobe; then
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=o gz ko o.gz ko.gz}" ]
|
||||
|
||||
[ -z "$MODULESDIR" ] && MODULESDIR=/lib/modules/$(uname -r)/kernel/net/ipv6/netfilter:/lib/modules/$(uname -r)/kernel/net/netfilter
|
||||
MODULES=$(lsmod | cut -d ' ' -f1)
|
||||
|
||||
for directory in $(split $MODULESDIR); do
|
||||
[ -d $directory ] && moduledirectories="$moduledirectories $directory"
|
||||
done
|
||||
|
||||
[ -n "$moduledirectories" ] && while read command; do
|
||||
eval $command
|
||||
done
|
||||
|
||||
MODULESDIR=$save_modules_dir
|
||||
}
|
||||
|
||||
#
|
||||
# Load kernel modules required for Shorewall6
|
||||
#
|
||||
load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
|
||||
{
|
||||
local save_modules_dir
|
||||
save_modules_dir=$MODULESDIR
|
||||
local directory
|
||||
local moduledirectories
|
||||
moduledirectories=
|
||||
local moduleloader
|
||||
moduleloader=modprobe
|
||||
local savemoduleinfo
|
||||
savemoduleinfo=${1:-Yes} # So old compiled scripts still work
|
||||
|
||||
if ! qt mywhich modprobe; then
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=o gz ko o.gz ko.gz}" ]
|
||||
|
||||
[ -z "$MODULESDIR" ] && \
|
||||
MODULESDIR=/lib/modules/$(uname -r)/kernel/net/ipv6/netfilter:/lib/modules/$(uname -r)/kernel/net/netfilter
|
||||
|
||||
for directory in $(split $MODULESDIR); do
|
||||
[ -d $directory ] && moduledirectories="$moduledirectories $directory"
|
||||
done
|
||||
|
||||
modules=$(find_file modules)
|
||||
|
||||
if [ -f $modules -a -n "$moduledirectories" ]; then
|
||||
MODULES=$(lsmod | cut -d ' ' -f1)
|
||||
progress_message "Loading Modules..."
|
||||
. $modules
|
||||
if [ $savemoduleinfo = Yes ]; then
|
||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||
echo MODULESDIR="$MODULESDIR" > ${VARDIR}/.modulesdir
|
||||
cp -f $modules ${VARDIR}/.modules
|
||||
fi
|
||||
elif [ $savemoduleinfo = Yes ]; then
|
||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||
> ${VARDIR}/.modulesdir
|
||||
> ${VARDIR}/.modules
|
||||
fi
|
||||
|
||||
MODULESDIR=$save_modules_dir
|
||||
}
|
||||
|
||||
#
|
||||
# Query NetFilter about the existence of a filter chain
|
||||
#
|
||||
chain_exists() # $1 = chain name
|
||||
{
|
||||
qt1 $IP6TABLES -L $1 -n
|
||||
}
|
||||
|
||||
#
|
||||
# Find the value 'dev' in the passed arguments then echo the next value
|
||||
#
|
||||
@@ -400,32 +174,6 @@ find_default_interface() {
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Find the interface with the passed MAC address
|
||||
#
|
||||
|
||||
find_interface_by_mac() {
|
||||
local mac
|
||||
mac=$1
|
||||
local first
|
||||
local second
|
||||
local rest
|
||||
local dev
|
||||
|
||||
$IP link list | while read first second rest; do
|
||||
case $first in
|
||||
*:)
|
||||
dev=$second
|
||||
;;
|
||||
*)
|
||||
if [ "$second" = $mac ]; then
|
||||
echo ${dev%:}
|
||||
return
|
||||
fi
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Determine if Interface is up
|
||||
#
|
||||
@@ -433,45 +181,12 @@ interface_is_up() {
|
||||
[ -n "$($IP link list dev $1 2> /dev/null | grep -e '[<,]UP[,>]')" ]
|
||||
}
|
||||
|
||||
#
|
||||
# Find interface address--returns the first IP address assigned to the passed
|
||||
# device
|
||||
#
|
||||
find_first_interface_address() # $1 = interface
|
||||
{
|
||||
#
|
||||
# get the line of output containing the first IP address
|
||||
#
|
||||
addr=$($IP -f inet6 addr show $1 2> /dev/null | grep 'inet6 .* global' | head -n1)
|
||||
#
|
||||
# If there wasn't one, bail out now
|
||||
#
|
||||
[ -n "$addr" ] || startup_error "Can't determine the IPv6 address of $1"
|
||||
#
|
||||
# Strip off the trailing VLSM mask (or the peer IP in case of a P-t-P link)
|
||||
# along with everything else on the line
|
||||
#
|
||||
echo $addr | sed 's/\s*inet6 //;s/\/.*//;s/ peer.*//'
|
||||
}
|
||||
|
||||
find_first_interface_address_if_any() # $1 = interface
|
||||
{
|
||||
#
|
||||
# get the line of output containing the first IP address
|
||||
#
|
||||
addr=$($IP -f inet6 addr show $1 2> /dev/null | grep 'inet6 2.* global' | head -n1)
|
||||
#
|
||||
# Strip off the trailing VLSM mask (or the peer IP in case of a P-t-P link)
|
||||
# along with everything else on the line
|
||||
#
|
||||
[ -n "$addr" ] && echo $addr | sed 's/\s*inet6 //;s/\/.*//;s/ peer.*//' || echo ::
|
||||
}
|
||||
|
||||
#
|
||||
# Determine if interface is usable from a Netfilter prespective
|
||||
#
|
||||
interface_is_usable() # $1 = interface
|
||||
{
|
||||
[ "$1" = lo ] && return 0
|
||||
interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != :: ] && run_isusable_exit $1
|
||||
}
|
||||
|
||||
@@ -681,71 +396,6 @@ get_all_acasts()
|
||||
find_interface_full_addresses | convert_to_anycast | sort -u
|
||||
}
|
||||
|
||||
#
|
||||
# Internal version of 'which'
|
||||
#
|
||||
mywhich() {
|
||||
local dir
|
||||
|
||||
for dir in $(split $PATH); do
|
||||
if [ -x $dir/$1 ]; then
|
||||
echo $dir/$1
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 2
|
||||
}
|
||||
|
||||
#
|
||||
# Find a File -- For relative file name, look in each ${CONFIG_PATH} then ${CONFDIR}
|
||||
#
|
||||
find_file()
|
||||
{
|
||||
local saveifs
|
||||
saveifs=
|
||||
local directory
|
||||
|
||||
case $1 in
|
||||
/*)
|
||||
echo $1
|
||||
;;
|
||||
*)
|
||||
for directory in $(split $CONFIG_PATH); do
|
||||
if [ -f $directory/$1 ]; then
|
||||
echo $directory/$1
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
echo ${CONFDIR}/$1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
# Set the Shorewall state
|
||||
#
|
||||
set_state () # $1 = state
|
||||
{
|
||||
echo "$1 ($(date))" > ${VARDIR}/state
|
||||
}
|
||||
|
||||
#
|
||||
# Perform variable substitution on the passed argument and echo the result
|
||||
#
|
||||
expand() # $@ = contents of variable which may be the name of another variable
|
||||
{
|
||||
eval echo \"$@\"
|
||||
}
|
||||
|
||||
#
|
||||
# Function for including one file into another
|
||||
#
|
||||
INCLUDE() {
|
||||
. $(find_file $(expand $@))
|
||||
}
|
||||
|
||||
#
|
||||
# Detect the gateway through an interface
|
||||
#
|
||||
@@ -771,20 +421,6 @@ detect_gateway() # $1 = interface
|
||||
[ -n "$gateway" ] && echo $gateway
|
||||
}
|
||||
|
||||
# Function to truncate a string -- It uses 'cut -b -<n>'
|
||||
# rather than ${v:first:last} because light-weight shells like ash and
|
||||
# dash do not support that form of expansion.
|
||||
#
|
||||
|
||||
truncate() # $1 = length
|
||||
{
|
||||
cut -b -${1}
|
||||
}
|
||||
|
||||
#
|
||||
# Clear the current traffic shaping configuration
|
||||
#
|
||||
|
||||
delete_tc1()
|
||||
{
|
||||
clear_one_tc() {
|
||||
@@ -846,7 +482,7 @@ get_device_mtu1() # $1 = device
|
||||
#
|
||||
undo_routing() {
|
||||
|
||||
if [ -z "$NOROUTES" ]; then
|
||||
if [ -z "$g_noroutes" ]; then
|
||||
#
|
||||
# Restore rt_tables database
|
||||
#
|
||||
@@ -870,7 +506,7 @@ undo_routing() {
|
||||
# Restore the default route that was in place before the initial 'shorewall start'
|
||||
#
|
||||
restore_default_route() {
|
||||
if [ -z "$NOROUTES" -a -f ${VARDIR}/default_route ]; then
|
||||
if [ -z "$g_noroutes" -a -f ${VARDIR}/default_route ]; then
|
||||
local default_route
|
||||
default_route=
|
||||
local route
|
||||
@@ -933,11 +569,11 @@ find_echo() {
|
||||
}
|
||||
|
||||
#
|
||||
# Flush the conntrack table if $PURGE is non-empty
|
||||
# Flush the conntrack table if $g_purge is non-empty
|
||||
#
|
||||
conditionally_flush_conntrack() {
|
||||
|
||||
if [ -n "$PURGE" ]; then
|
||||
if [ -n "$g_purge" ]; then
|
||||
if [ -n $(which conntrack) ]; then
|
||||
conntrack -F
|
||||
else
|
||||
@@ -946,6 +582,244 @@ conditionally_flush_conntrack() {
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Remove all Shorewall-added rules
|
||||
#
|
||||
clear_firewall() {
|
||||
stop_firewall
|
||||
|
||||
setpolicy INPUT ACCEPT
|
||||
setpolicy FORWARD ACCEPT
|
||||
setpolicy OUTPUT ACCEPT
|
||||
|
||||
run_iptables -F
|
||||
|
||||
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
|
||||
|
||||
run_clear_exit
|
||||
|
||||
set_state "Cleared"
|
||||
|
||||
logger -p kern.info "$g_product Cleared"
|
||||
}
|
||||
|
||||
#
|
||||
# Issue a message and stop/restore the firewall
|
||||
#
|
||||
fatal_error()
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
|
||||
if [ $LOG_VERBOSITY -gt 1 ]; then
|
||||
timestamp="$(date +'%_b %d %T') "
|
||||
echo "${timestamp} ERROR: $@" >> $STARTUP_LOG
|
||||
fi
|
||||
|
||||
stop_firewall
|
||||
[ -n "$TEMPFILE" ] && rm -f $TEMPFILE
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Issue a message and stop
|
||||
#
|
||||
startup_error() # $* = Error Message
|
||||
{
|
||||
echo " ERROR: $@: Firewall state not changed" >&2
|
||||
case $COMMAND in
|
||||
start)
|
||||
logger -p kern.err "ERROR:$g_product start failed:Firewall state not changed"
|
||||
;;
|
||||
restart)
|
||||
logger -p kern.err "ERROR:$g_product restart failed:Firewall state not changed"
|
||||
;;
|
||||
restore)
|
||||
logger -p kern.err "ERROR:$g_product restore failed:Firewall state not changed"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $LOG_VERBOSITY -gt 1 ]; then
|
||||
timestamp="$(date +'%_b %d %T') "
|
||||
|
||||
case $COMMAND in
|
||||
start)
|
||||
echo "${timestamp} ERROR:$g_product start failed:Firewall state not changed" >> $STARTUP_LOG
|
||||
;;
|
||||
restart)
|
||||
echo "${timestamp} ERROR:$g_product restart failed:Firewall state not changed" >> $STARTUP_LOG
|
||||
;;
|
||||
restore)
|
||||
echo "${timestamp} ERROR:$g_product restore failed:Firewall state not changed" >> $STARTUP_LOG
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
kill $$
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Run iptables and if an error occurs, stop/restore the firewall
|
||||
#
|
||||
run_iptables()
|
||||
{
|
||||
local status
|
||||
|
||||
while [ 1 ]; do
|
||||
$IP6TABLES $@
|
||||
status=$?
|
||||
[ $status -ne 4 ] && break
|
||||
done
|
||||
|
||||
if [ $status -ne 0 ]; then
|
||||
error_message "ERROR: Command \"$IP6TABLES $@\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Run iptables retrying exit status 4
|
||||
#
|
||||
do_iptables()
|
||||
{
|
||||
local status
|
||||
|
||||
while [ 1 ]; do
|
||||
$IP6TABLES $@
|
||||
status=$?
|
||||
[ $status -ne 4 ] && return $status;
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Run iptables and if an error occurs, stop/restore the firewall
|
||||
#
|
||||
run_ip()
|
||||
{
|
||||
if ! $IP -6 $@; then
|
||||
error_message "ERROR: Command \"$IP -6 $@\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Run tc and if an error occurs, stop/restore the firewall
|
||||
#
|
||||
run_tc() {
|
||||
if ! $TC $@ ; then
|
||||
error_message "ERROR: Command \"$TC $@\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Restore the rules generated by 'drop','reject','logdrop', etc.
|
||||
#
|
||||
restore_dynamic_rules() {
|
||||
if [ -f ${VARDIR}/save ]; then
|
||||
progress_message2 "Setting up dynamic rules..."
|
||||
rangematch='source IP range'
|
||||
while read target ignore1 ignore2 address ignore3 rest; do
|
||||
case $target in
|
||||
DROP|reject|logdrop|logreject)
|
||||
case $rest in
|
||||
$rangematch*)
|
||||
run_iptables -A dynamic -m iprange --src-range ${rest#source IP range} -j $target
|
||||
;;
|
||||
*)
|
||||
if [ -z "$rest" ]; then
|
||||
run_iptables -A dynamic -s $address -j $target
|
||||
else
|
||||
error_message "WARNING: Unable to restore dynamic rule \"$target $ignore1 $ignore2 $address $ignore3 $rest\""
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done < ${VARDIR}/save
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Run the .iptables_restore_input as a set of discrete iptables commands
|
||||
#
|
||||
debug_restore_input() {
|
||||
local first second rest table chain
|
||||
#
|
||||
# Clear the ruleset
|
||||
#
|
||||
qt1 $IP6TABLES -t mangle -F
|
||||
qt1 $IP6TABLES -t mangle -X
|
||||
|
||||
for chain in PREROUTING INPUT FORWARD POSTROUTING; do
|
||||
qt1 $IP6TABLES -t mangle -P $chain ACCEPT
|
||||
done
|
||||
|
||||
qt1 $IP6TABLES -t raw -F
|
||||
qt1 $IP6TABLES -t raw -X
|
||||
|
||||
for chain in PREROUTING OUTPUT; do
|
||||
qt1 $IP6TABLES -t raw -P $chain ACCEPT
|
||||
done
|
||||
|
||||
qt1 $IP6TABLES -t filter -F
|
||||
qt1 $IP6TABLES -t filter -X
|
||||
|
||||
for chain in INPUT FORWARD OUTPUT; do
|
||||
qt1 $IP6TABLES -t filter -P $chain -P ACCEPT
|
||||
done
|
||||
|
||||
while read first second rest; do
|
||||
case $first in
|
||||
-*)
|
||||
#
|
||||
# We can't call run_iptables() here because the rules may contain quoted strings
|
||||
#
|
||||
eval $IP6TABLES -t $table $first $second $rest
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
error_message "ERROR: Command \"$IP6TABLES $first $second $rest\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
:*)
|
||||
chain=${first#:}
|
||||
|
||||
if [ "x$second" = x- ]; then
|
||||
do_iptables -t $table -N $chain
|
||||
else
|
||||
do_iptables -t $table -P $chain $second
|
||||
fi
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
error_message "ERROR: Command \"$IP6TABLES $first $second $rest\" Failed"
|
||||
stop_firewall
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
#
|
||||
# This grotesque hack with the table names works around a bug/feature with ash
|
||||
#
|
||||
'*'raw)
|
||||
table=raw
|
||||
;;
|
||||
'*'mangle)
|
||||
table=mangle
|
||||
;;
|
||||
'*'nat)
|
||||
table=nat
|
||||
;;
|
||||
'*'filter)
|
||||
table=filter
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# End of functions imported from /usr/share/shorewall/prog.header6
|
||||
################################################################################
|
||||
|
@@ -1,10 +1,176 @@
|
||||
Changes in Shorewall 4.4.2.2
|
||||
Changes in Shorewall 4.4.8
|
||||
|
||||
1) Another fix for 'routeback' in routestopped.
|
||||
1) Correct handling of RATE LIMIT on NAT rules.
|
||||
|
||||
Changes in Shorewall 4.4.2.1
|
||||
2) Don't create a logging chain for rules with '-j RETURN'.
|
||||
|
||||
1) Fix 'routeback' in routestopped.
|
||||
3) Avoid duplicate SFQ class numbers.
|
||||
|
||||
4) Fix low per-IP rate limits.
|
||||
|
||||
5) Fix Debian init script exit status
|
||||
|
||||
6) Fix NFQUEUE(queue-num) in policy
|
||||
|
||||
7) Implement -s option in install.sh
|
||||
|
||||
8) Add HKP Macro
|
||||
|
||||
9) Fix multiple policy matches with OPTIMIZE 4 and not KLUDGEFREE
|
||||
|
||||
10) Eliminate up-cased variable names that aren't documented options.
|
||||
|
||||
11) Don't show 'OLD' capabilities if they are not available.
|
||||
|
||||
12) Attempt to flag use of '-' as a port-range separator.
|
||||
|
||||
13) Add undocumented OPTIMIZE=-1 setting.
|
||||
|
||||
14) Replace OPTIMIZE=-1 with undocumented optimize 4096 which DISABLES
|
||||
default optimizations.
|
||||
|
||||
15) Add support for UDPLITE
|
||||
|
||||
16) Distinguish between 'Started' and 'Restored' in ${VARDIR}/state
|
||||
|
||||
17) Issue warnings when 'blacklist' but no blacklist file entries.
|
||||
|
||||
18) Don't optimize 'blacklst'.
|
||||
|
||||
Changes in Shorewall 4.4.7
|
||||
|
||||
1) Backport optimization changes from 4.5.
|
||||
|
||||
2) Backport two new options from 4.5.
|
||||
|
||||
3) Backport TPROXY from 4.5
|
||||
|
||||
4) Add TC_PRIOMAP to shorewall*.conf
|
||||
|
||||
5) Implement LOAD_HELPERS_ONLY
|
||||
|
||||
6) Avoid excessive module loading with LOAD_HELPERS_ONLY=Yes
|
||||
|
||||
7) Fix case where MARK target is unavailable.
|
||||
|
||||
8) Change default to ADD_IP_ALIASES=No
|
||||
|
||||
9) Correct defects in generate_matrix().
|
||||
|
||||
10) Fix and optimize 'nosmurfs'.
|
||||
|
||||
11) Use 'OLD_HL_MATCH' to suppress use of 'flow' in Simple TC.
|
||||
|
||||
Changes in Shorewall 4.4.6
|
||||
|
||||
1) Fix for rp_filter and kernel 2.6.31.
|
||||
|
||||
2) Add a hack to work around a bug in Lenny + xtables-addons
|
||||
|
||||
3) Re-enable SAVE_IPSETS
|
||||
|
||||
4) Allow both <...> and [...] for IPv6 Addresses.
|
||||
|
||||
5) Port mark geometry change from 4.5.
|
||||
|
||||
6) Add Macro patch from Tuomo Soini
|
||||
|
||||
7) Add 'show macro' command.
|
||||
|
||||
8) Add -r option to check.
|
||||
|
||||
9) Port simplified TC from 4.5.
|
||||
|
||||
Changes in Shorewall 4.4.5
|
||||
|
||||
1) Fix 15-port limit removal change.
|
||||
|
||||
2) Fix handling of interfaces with the 'bridge' option.
|
||||
|
||||
3) Generate error for port number 0
|
||||
|
||||
4) Allow zone::serverport in rules DEST column.
|
||||
|
||||
5) Fix 'show policies' in Shorewall6.
|
||||
|
||||
6) Auto-load tc modules.
|
||||
|
||||
7) Allow LOGFILE=/dev/null
|
||||
|
||||
8) Fix shorewall6-lite/shorecap
|
||||
|
||||
9) Fix MODULE_SUFFIX.
|
||||
|
||||
10) Fix ENHANCED_REJECT detection for IPv4.
|
||||
|
||||
11) Fix DONT_LOAD vs 'reload -c'
|
||||
|
||||
12) Fix handling of SOURCE and DEST vs macros.
|
||||
|
||||
13) Remove silly logic in expand_rule().
|
||||
|
||||
14) Add current and limit to Conntrack Table Heading.
|
||||
|
||||
Changes in Shorewall 4.4.4
|
||||
|
||||
1) Change STARTUP_LOG and LOG_VERBOSITY in default shorewall6.conf.
|
||||
|
||||
2) Fix access to uninitialized variable.
|
||||
|
||||
3) Add logrotate scripts.
|
||||
|
||||
4) Allow long port lists in /etc/shorewall/routestopped.
|
||||
|
||||
5) Implement 'physical' interface option.
|
||||
|
||||
6) Implement ZONE2ZONE option.
|
||||
|
||||
7) Suppress duplicate COMMENT warnings.
|
||||
|
||||
8) Implement 'show policies' command.
|
||||
|
||||
9) Fix route_rule suppression for down provider.
|
||||
|
||||
10) Suppress redundant tests for provider availability in route rules
|
||||
processing.
|
||||
|
||||
11) Implement the '-l' option to the 'show' command.
|
||||
|
||||
12) Fix class number assignment when WIDE_TC_MARKS=Yes
|
||||
|
||||
13) Allow wide marks in tcclasses when WIDE_TC_MARKS=Yes
|
||||
|
||||
Changes in Shorewall 4.4.3
|
||||
|
||||
1) Move Debian INITLOG initialization to /etc/default/shorewall
|
||||
|
||||
2) Fix 'routeback' in /etc/shorewall/routestopped.
|
||||
|
||||
3) Rename 'object' to 'script' in compiler and config modules.
|
||||
|
||||
4) Correct RETAIN_ALIASES=No.
|
||||
|
||||
5) Fix detection of IP config.
|
||||
|
||||
6) Fix nested zones.
|
||||
|
||||
7) Move all function declarations from prog.footer to prog.header
|
||||
|
||||
8) Remove superfluous variables from generated script
|
||||
|
||||
9) Make 'track' the default.
|
||||
|
||||
10) Add TRACK_PROVIDERS option.
|
||||
|
||||
11) Fix IPv6 address parsing bug.
|
||||
|
||||
12) Add hack to work around iproute IPv6 bug in route handling
|
||||
|
||||
13) Correct messages issued when an optional provider is not usable.
|
||||
|
||||
14) Fix optional interfaces.
|
||||
|
||||
15) Add 'limit' option to tcclasses.
|
||||
|
||||
Changes in Shorewall 4.4.2
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Shorewall version 4 - Filegw File
|
||||
# Shorewall version 4 - Findgw File
|
||||
#
|
||||
# /etc/shorewall/findgw
|
||||
#
|
||||
|
@@ -32,9 +32,9 @@ VERBOSITY=1
|
||||
|
||||
LOGFILE=/var/log/messages
|
||||
|
||||
STARTUP_LOG=
|
||||
STARTUP_LOG=/var/log/shorewall-init.log
|
||||
|
||||
LOG_VERBOSITY=
|
||||
LOG_VERBOSITY=2
|
||||
|
||||
LOGFORMAT="Shorewall:%s:%s:"
|
||||
|
||||
@@ -107,7 +107,7 @@ RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
|
||||
|
||||
IP_FORWARDING=On
|
||||
|
||||
ADD_IP_ALIASES=Yes
|
||||
ADD_IP_ALIASES=No
|
||||
|
||||
ADD_SNAT_ALIASES=No
|
||||
|
||||
@@ -117,6 +117,8 @@ TC_ENABLED=Internal
|
||||
|
||||
TC_EXPERT=No
|
||||
|
||||
TC_PRIOMAP="2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2"
|
||||
|
||||
CLEAR_TC=Yes
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
@@ -135,7 +137,7 @@ BLACKLISTNEWONLY=Yes
|
||||
|
||||
DELAYBLACKLISTLOAD=No
|
||||
|
||||
MODULE_SUFFIX=
|
||||
MODULE_SUFFIX=ko
|
||||
|
||||
DISABLE_IPV6=No
|
||||
|
||||
@@ -189,6 +191,18 @@ AUTOMAKE=No
|
||||
|
||||
WIDE_TC_MARKS=No
|
||||
|
||||
TRACK_PROVIDERS=No
|
||||
|
||||
ZONE2ZONE=2
|
||||
|
||||
ACCOUNTING=Yes
|
||||
|
||||
DYNAMIC_BLACKLIST=Yes
|
||||
|
||||
OPTIMIZE_ACCOUNTING=No
|
||||
|
||||
LOAD_HELPERS_ONLY=No
|
||||
|
||||
###############################################################################
|
||||
# P A C K E T D I S P O S I T I O N
|
||||
###############################################################################
|
||||
|
11
Shorewall/configfiles/tcinterfaces
Normal file
11
Shorewall/configfiles/tcinterfaces
Normal file
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Shorewall version 4 - Tcinterfaces File
|
||||
#
|
||||
# For information about entries in this file, type "man shorewall-tcinterfaces"
|
||||
#
|
||||
# See http://shorewall.net/simple_traffic_shaping.htm for additional
|
||||
# information.
|
||||
#
|
||||
###############################################################################
|
||||
#INTERFACE TYPE IN-BANDWIDTH
|
||||
|
13
Shorewall/configfiles/tcpri
Normal file
13
Shorewall/configfiles/tcpri
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Shorewall version 4 - Tcpri File
|
||||
#
|
||||
# For information about entries in this file, type "man shorewall-tcpri"
|
||||
#
|
||||
# See http://shorewall.net/simple_traffic_shaping.htm for additional
|
||||
# information.
|
||||
#
|
||||
###############################################################################
|
||||
#BAND PROTO PORT(S) ADDRESS IN-INTERFACE HELPER
|
||||
|
||||
|
||||
|
@@ -21,4 +21,9 @@ startup=0
|
||||
|
||||
OPTIONS=""
|
||||
|
||||
#
|
||||
# Init Log -- if /dev/null, use the STARTUP_LOG defined in shorewall.conf
|
||||
#
|
||||
INITLOG=/dev/null
|
||||
|
||||
# EOF
|
||||
|
63
Shorewall/helpers
Normal file
63
Shorewall/helpers
Normal file
@@ -0,0 +1,63 @@
|
||||
#
|
||||
# Shorewall version 4 - Helpers File
|
||||
#
|
||||
# /usr/share/shorewall/helpers
|
||||
#
|
||||
# This file loads the kernel helper modules.
|
||||
#
|
||||
# THE ORDER OF THE COMMANDS BELOW IS IMPORTANT!!!!!! You MUST load in
|
||||
# dependency order. i.e., if M2 depends on M1 then you must load M1
|
||||
# before you load M2.
|
||||
#
|
||||
# If you need to modify this file, copy it to /etc/shorewall and modify the
|
||||
# copy.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# Helpers
|
||||
#
|
||||
loadmodule ip_conntrack_amanda
|
||||
loadmodule ip_conntrack_ftp
|
||||
loadmodule ip_conntrack_h323
|
||||
loadmodule ip_conntrack_irc
|
||||
loadmodule ip_conntrack_netbios_ns
|
||||
loadmodule ip_conntrack_pptp
|
||||
loadmodule ip_conntrack_sip
|
||||
loadmodule ip_conntrack_tftp
|
||||
loadmodule ip_nat_amanda
|
||||
loadmodule ip_nat_ftp
|
||||
loadmodule ip_nat_h323
|
||||
loadmodule ip_nat_irc
|
||||
loadmodule ip_nat_pptp
|
||||
loadmodule ip_nat_sip
|
||||
loadmodule ip_nat_snmp_basic
|
||||
loadmodule ip_nat_tftp
|
||||
loadmodule ip_set
|
||||
loadmodule ip_set_iphash
|
||||
loadmodule ip_set_ipmap
|
||||
loadmodule ip_set_macipmap
|
||||
loadmodule ip_set_portmap
|
||||
#
|
||||
# 2.6.20+ helpers
|
||||
#
|
||||
loadmodule nf_conntrack_ftp
|
||||
loadmodule nf_conntrack_h323
|
||||
loadmodule nf_conntrack_irc
|
||||
loadmodule nf_conntrack_netbios_ns
|
||||
loadmodule nf_conntrack_netlink
|
||||
loadmodule nf_conntrack_pptp
|
||||
loadmodule nf_conntrack_proto_gre
|
||||
loadmodule nf_conntrack_proto_sctp
|
||||
loadmodule nf_conntrack_sip sip_direct_media=0
|
||||
loadmodule nf_conntrack_tftp
|
||||
loadmodule nf_conntrack_sane
|
||||
loadmodule nf_nat_amanda
|
||||
loadmodule nf_nat_ftp
|
||||
loadmodule nf_nat_h323
|
||||
loadmodule nf_nat_irc
|
||||
loadmodule nf_nat
|
||||
loadmodule nf_nat_pptp
|
||||
loadmodule nf_nat_proto_gre
|
||||
loadmodule nf_nat_sip
|
||||
loadmodule nf_nat_snmp_basic
|
||||
loadmodule nf_nat_tftp
|
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: shorewall
|
||||
# Required-Start: $network
|
||||
# Required-Stop: $network
|
||||
# Required-Start: $network $remote_fs
|
||||
# Required-Stop: $network $remote_fs
|
||||
# Default-Start: S
|
||||
# Default-Stop: 0 6
|
||||
# Short-Description: Configure the firewall at boot time
|
||||
@@ -15,13 +15,11 @@
|
||||
SRWL=/sbin/shorewall
|
||||
SRWL_OPTS="-tvv"
|
||||
WAIT_FOR_IFUP=/usr/share/shorewall/wait4ifup
|
||||
# Note, set INITLOG to /dev/null if you want to
|
||||
# use Shorewall's STARTUP_LOG feature.
|
||||
INITLOG=/var/log/shorewall-init.log
|
||||
test -n ${INITLOG:=/var/log/shorewall-init.log}
|
||||
|
||||
test -x $SRWL || exit 0
|
||||
test -x $WAIT_FOR_IFUP || exit 0
|
||||
test -n $INITLOG || {
|
||||
test -n "$INITLOG" || {
|
||||
echo "INITLOG cannot be empty, please configure $0" ;
|
||||
exit 1;
|
||||
}
|
||||
@@ -40,6 +38,7 @@ echo_notdone () {
|
||||
echo "not done (check $INITLOG)."
|
||||
fi
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
not_configured () {
|
||||
@@ -49,7 +48,7 @@ not_configured () {
|
||||
then
|
||||
echo ""
|
||||
echo "Please read about Debian specific customization in"
|
||||
echo "/usr/share/doc/shorewall-common/README.Debian.gz."
|
||||
echo "/usr/share/doc/shorewall/README.Debian.gz."
|
||||
fi
|
||||
echo "#################"
|
||||
exit 0
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2000,2001,2002,2003,2004,2005 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2000,2001,2002,2003,2004,2005,2006,2007,2009,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Shorewall documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -22,7 +22,7 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
VERSION=4.4.2.2
|
||||
VERSION=4.4.8
|
||||
|
||||
usage() # $1 = exit status
|
||||
{
|
||||
@@ -109,6 +109,7 @@ fi
|
||||
|
||||
DEBIAN=
|
||||
CYGWIN=
|
||||
SPARSE=
|
||||
MANDIR=${MANDIR:-"/usr/share/man"}
|
||||
|
||||
case $(uname) in
|
||||
@@ -121,6 +122,7 @@ case $(uname) in
|
||||
OWNER=$(id -un)
|
||||
GROUP=$(id -gn)
|
||||
CYGWIN=Yes
|
||||
SPARSE=Yes
|
||||
;;
|
||||
*)
|
||||
[ -z "$OWNER" ] && OWNER=root
|
||||
@@ -139,6 +141,9 @@ while [ $# -gt 0 ] ; do
|
||||
echo "Shorewall Firewall Installer Version $VERSION"
|
||||
exit 0
|
||||
;;
|
||||
-s)
|
||||
SPARSE=Yes
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@@ -175,15 +180,20 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$CYGWIN" ]; then
|
||||
if [ -d /etc/apt -a -e /usr/bin/dpkg ]; then
|
||||
if [ -n "$CYGWIN" ]; then
|
||||
echo "Installing Cygwin-specific configuration..."
|
||||
else
|
||||
if [ -f /etc/debian_version ]; then
|
||||
echo "Installing Debian-specific configuration..."
|
||||
DEBIAN=yes
|
||||
SPARSE=yes
|
||||
elif [ -f /etc/slackware-version ] ; then
|
||||
echo "installing Slackware specific configuration..."
|
||||
echo "Installing Slackware-specific configuration..."
|
||||
DEST="/etc/rc.d"
|
||||
MANDIR="/usr/man"
|
||||
SLACKWARE=yes
|
||||
elif [ -f /etc/arch-release ] ; then
|
||||
echo "Installing ArchLinux-specific configuration..."
|
||||
DEST="/etc/rc.d"
|
||||
INIT="shorewall"
|
||||
ARCHLINUX=yes
|
||||
@@ -196,7 +206,7 @@ fi
|
||||
#
|
||||
cd "$(dirname $0)"
|
||||
|
||||
echo "Installing Shorewall-common Version $VERSION"
|
||||
echo "Installing Shorewall Version $VERSION"
|
||||
|
||||
#
|
||||
# Check for /etc/shorewall
|
||||
@@ -242,6 +252,12 @@ mkdir -p ${PREFIX}/var/lib/shorewall
|
||||
chmod 755 ${PREFIX}/etc/shorewall
|
||||
chmod 755 ${PREFIX}/usr/share/shorewall
|
||||
chmod 755 ${PREFIX}/usr/share/shorewall/configfiles
|
||||
|
||||
if [ -n "$PREFIX" ]; then
|
||||
mkdir -p ${PREFIX}/etc/logrotate.d
|
||||
chmod 755 ${PREFIX}/etc/logrotate.d
|
||||
fi
|
||||
|
||||
#
|
||||
# Install the config file
|
||||
#
|
||||
@@ -270,7 +286,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/zones ${PREFIX}/usr/share/shorewall/configfiles/zones
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/zones ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/zones ]; then
|
||||
run_install $OWNERSHIP -m 0744 configfiles/zones ${PREFIX}/etc/shorewall/zones
|
||||
echo "Zones file installed as ${PREFIX}/etc/shorewall/zones"
|
||||
fi
|
||||
@@ -303,7 +319,7 @@ echo "wait4ifup installed in ${PREFIX}/usr/share/shorewall/wait4ifup"
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/policy ${PREFIX}/usr/share/shorewall/configfiles/policy
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/policy ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/policy ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/policy ${PREFIX}/etc/shorewall/policy
|
||||
echo "Policy file installed as ${PREFIX}/etc/shorewall/policy"
|
||||
fi
|
||||
@@ -312,7 +328,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/interfaces ${PREFIX}/usr/share/shorewall/configfiles/interfaces
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/interfaces ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/interfaces ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/interfaces ${PREFIX}/etc/shorewall/interfaces
|
||||
echo "Interfaces file installed as ${PREFIX}/etc/shorewall/interfaces"
|
||||
fi
|
||||
@@ -322,7 +338,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/hosts ${PREFIX}/usr/share/shorewall/configfiles/hosts
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/hosts ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/hosts ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/hosts ${PREFIX}/etc/shorewall/hosts
|
||||
echo "Hosts file installed as ${PREFIX}/etc/shorewall/hosts"
|
||||
fi
|
||||
@@ -331,7 +347,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/rules ${PREFIX}/usr/share/shorewall/configfiles/rules
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/rules ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/rules ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/rules ${PREFIX}/etc/shorewall/rules
|
||||
echo "Rules file installed as ${PREFIX}/etc/shorewall/rules"
|
||||
fi
|
||||
@@ -340,7 +356,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/nat ${PREFIX}/usr/share/shorewall/configfiles/nat
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/nat ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/nat ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/nat ${PREFIX}/etc/shorewall/nat
|
||||
echo "NAT file installed as ${PREFIX}/etc/shorewall/nat"
|
||||
fi
|
||||
@@ -349,7 +365,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/netmap ${PREFIX}/usr/share/shorewall/configfiles/netmap
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/netmap ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/netmap ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/netmap ${PREFIX}/etc/shorewall/netmap
|
||||
echo "NETMAP file installed as ${PREFIX}/etc/shorewall/netmap"
|
||||
fi
|
||||
@@ -369,7 +385,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/proxyarp ${PREFIX}/usr/share/shorewall/configfiles/proxyarp
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/proxyarp ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/proxyarp ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/proxyarp ${PREFIX}/etc/shorewall/proxyarp
|
||||
echo "Proxy ARP file installed as ${PREFIX}/etc/shorewall/proxyarp"
|
||||
fi
|
||||
@@ -378,7 +394,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/routestopped ${PREFIX}/usr/share/shorewall/configfiles/routestopped
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/routestopped ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/routestopped ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/routestopped ${PREFIX}/etc/shorewall/routestopped
|
||||
echo "Stopped Routing file installed as ${PREFIX}/etc/shorewall/routestopped"
|
||||
fi
|
||||
@@ -387,7 +403,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/maclist ${PREFIX}/usr/share/shorewall/configfiles/maclist
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/maclist ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/maclist ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/maclist ${PREFIX}/etc/shorewall/maclist
|
||||
echo "MAC list file installed as ${PREFIX}/etc/shorewall/maclist"
|
||||
fi
|
||||
@@ -396,7 +412,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/masq ${PREFIX}/usr/share/shorewall/configfiles/masq
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/masq ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/masq ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/masq ${PREFIX}/etc/shorewall/masq
|
||||
echo "Masquerade file installed as ${PREFIX}/etc/shorewall/masq"
|
||||
fi
|
||||
@@ -405,7 +421,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/notrack ${PREFIX}/usr/share/shorewall/configfiles/notrack
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/notrack ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/notrack ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/notrack ${PREFIX}/etc/shorewall/notrack
|
||||
echo "Notrack file installed as ${PREFIX}/etc/shorewall/notrack"
|
||||
fi
|
||||
@@ -415,22 +431,48 @@ fi
|
||||
run_install $OWNERSHIP -m 0600 modules ${PREFIX}/usr/share/shorewall/modules
|
||||
echo "Modules file installed as ${PREFIX}/usr/share/shorewall/modules"
|
||||
|
||||
#
|
||||
# Install the Module Helpers file
|
||||
#
|
||||
run_install $OWNERSHIP -m 0600 helpers ${PREFIX}/usr/share/shorewall/helpers
|
||||
echo "Helper modules file installed as ${PREFIX}/usr/share/shorewall/helpers"
|
||||
|
||||
#
|
||||
# Install the TC Rules file
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/tcrules ${PREFIX}/usr/share/shorewall/configfiles/tcrules
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/tcrules ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/tcrules ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/tcrules ${PREFIX}/etc/shorewall/tcrules
|
||||
echo "TC Rules file installed as ${PREFIX}/etc/shorewall/tcrules"
|
||||
fi
|
||||
|
||||
#
|
||||
# Install the TC Interfaces file
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/tcinterfaces ${PREFIX}/usr/share/shorewall/configfiles/tcinterfaces
|
||||
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/tcinterfaces ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/tcinterfaces ${PREFIX}/etc/shorewall/tcinterfaces
|
||||
echo "TC Interfaces file installed as ${PREFIX}/etc/shorewall/tcinterfaces"
|
||||
fi
|
||||
|
||||
#
|
||||
# Install the TC Priority file
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/tcpri ${PREFIX}/usr/share/shorewall/configfiles/tcpri
|
||||
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/tcpri ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/tcpri ${PREFIX}/etc/shorewall/tcpri
|
||||
echo "TC Priority file installed as ${PREFIX}/etc/shorewall/tcpri"
|
||||
fi
|
||||
|
||||
#
|
||||
# Install the TOS file
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/tos ${PREFIX}/usr/share/shorewall/configfiles/tos
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/tos ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/tos ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/tos ${PREFIX}/etc/shorewall/tos
|
||||
echo "TOS file installed as ${PREFIX}/etc/shorewall/tos"
|
||||
fi
|
||||
@@ -439,7 +481,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/tunnels ${PREFIX}/usr/share/shorewall/configfiles/tunnels
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/tunnels ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/tunnels ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/tunnels ${PREFIX}/etc/shorewall/tunnels
|
||||
echo "Tunnels file installed as ${PREFIX}/etc/shorewall/tunnels"
|
||||
fi
|
||||
@@ -448,7 +490,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/blacklist ${PREFIX}/usr/share/shorewall/configfiles/blacklist
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/blacklist ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/blacklist ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/blacklist ${PREFIX}/etc/shorewall/blacklist
|
||||
echo "Blacklist file installed as ${PREFIX}/etc/shorewall/blacklist"
|
||||
fi
|
||||
@@ -457,7 +499,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/findgw ${PREFIX}/usr/share/shorewall/configfiles/findgw
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/findgw ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/findgw ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/findgw ${PREFIX}/etc/shorewall/findgw
|
||||
echo "Find GW file installed as ${PREFIX}/etc/shorewall/findgw"
|
||||
fi
|
||||
@@ -485,7 +527,7 @@ delete_file ${PREFIX}/usr/share/shorewall/xmodules
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/providers ${PREFIX}/usr/share/shorewall/configfiles/providers
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/providers ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/providers ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/providers ${PREFIX}/etc/shorewall/providers
|
||||
echo "Providers file installed as ${PREFIX}/etc/shorewall/providers"
|
||||
fi
|
||||
@@ -495,7 +537,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/route_rules ${PREFIX}/usr/share/shorewall/configfiles/route_rules
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/route_rules ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/route_rules ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/route_rules ${PREFIX}/etc/shorewall/route_rules
|
||||
echo "Routing rules file installed as ${PREFIX}/etc/shorewall/route_rules"
|
||||
fi
|
||||
@@ -505,7 +547,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/tcclasses ${PREFIX}/usr/share/shorewall/configfiles/tcclasses
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/tcclasses ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/tcclasses ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/tcclasses ${PREFIX}/etc/shorewall/tcclasses
|
||||
echo "TC Classes file installed as ${PREFIX}/etc/shorewall/tcclasses"
|
||||
fi
|
||||
@@ -515,7 +557,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/tcdevices ${PREFIX}/usr/share/shorewall/configfiles/tcdevices
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/tcdevices ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/tcdevices ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/tcdevices ${PREFIX}/etc/shorewall/tcdevices
|
||||
echo "TC Devices file installed as ${PREFIX}/etc/shorewall/tcdevices"
|
||||
fi
|
||||
@@ -525,7 +567,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/tcfilters ${PREFIX}/usr/share/shorewall/configfiles/tcfilters
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/tcfilters ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/tcfilters ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/tcfilters ${PREFIX}/etc/shorewall/tcfilters
|
||||
echo "TC Filters file installed as ${PREFIX}/etc/shorewall/tcfilters"
|
||||
fi
|
||||
@@ -540,7 +582,7 @@ echo "Default config path file installed as ${PREFIX}/usr/share/shorewall/config
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/init ${PREFIX}/usr/share/shorewall/configfiles/init
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/init ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/init ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/init ${PREFIX}/etc/shorewall/init
|
||||
echo "Init file installed as ${PREFIX}/etc/shorewall/init"
|
||||
fi
|
||||
@@ -549,7 +591,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/initdone ${PREFIX}/usr/share/shorewall/configfiles/initdone
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/initdone ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/initdone ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/initdone ${PREFIX}/etc/shorewall/initdone
|
||||
echo "Initdone file installed as ${PREFIX}/etc/shorewall/initdone"
|
||||
fi
|
||||
@@ -558,7 +600,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/start ${PREFIX}/usr/share/shorewall/configfiles/start
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/start ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/start ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/start ${PREFIX}/etc/shorewall/start
|
||||
echo "Start file installed as ${PREFIX}/etc/shorewall/start"
|
||||
fi
|
||||
@@ -567,7 +609,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/stop ${PREFIX}/usr/share/shorewall/configfiles/stop
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/stop ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/stop ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/stop ${PREFIX}/etc/shorewall/stop
|
||||
echo "Stop file installed as ${PREFIX}/etc/shorewall/stop"
|
||||
fi
|
||||
@@ -576,7 +618,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/stopped ${PREFIX}/usr/share/shorewall/configfiles/stopped
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/stopped ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/stopped ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/stopped ${PREFIX}/etc/shorewall/stopped
|
||||
echo "Stopped file installed as ${PREFIX}/etc/shorewall/stopped"
|
||||
fi
|
||||
@@ -585,7 +627,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/ecn ${PREFIX}/usr/share/shorewall/configfiles/ecn
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/ecn ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/ecn ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/ecn ${PREFIX}/etc/shorewall/ecn
|
||||
echo "ECN file installed as ${PREFIX}/etc/shorewall/ecn"
|
||||
fi
|
||||
@@ -594,7 +636,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/accounting ${PREFIX}/usr/share/shorewall/configfiles/accounting
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/accounting ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/accounting ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/accounting ${PREFIX}/etc/shorewall/accounting
|
||||
echo "Accounting file installed as ${PREFIX}/etc/shorewall/accounting"
|
||||
fi
|
||||
@@ -603,7 +645,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/lib.private ${PREFIX}/usr/share/shorewall/configfiles/lib.private
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/lib.private ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/lib.private ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/lib.private ${PREFIX}/etc/shorewall/lib.private
|
||||
echo "Private library file installed as ${PREFIX}/etc/shorewall/lib.private"
|
||||
fi
|
||||
@@ -612,7 +654,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/started ${PREFIX}/usr/share/shorewall/configfiles/started
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/started ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/started ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/started ${PREFIX}/etc/shorewall/started
|
||||
echo "Started file installed as ${PREFIX}/etc/shorewall/started"
|
||||
fi
|
||||
@@ -621,7 +663,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/restored ${PREFIX}/usr/share/shorewall/configfiles/restored
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/restored ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/restored ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/restored ${PREFIX}/etc/shorewall/restored
|
||||
echo "Restored file installed as ${PREFIX}/etc/shorewall/restored"
|
||||
fi
|
||||
@@ -630,7 +672,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/clear ${PREFIX}/usr/share/shorewall/configfiles/clear
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/clear ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/clear ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/clear ${PREFIX}/etc/shorewall/clear
|
||||
echo "Clear file installed as ${PREFIX}/etc/shorewall/clear"
|
||||
fi
|
||||
@@ -639,7 +681,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/isusable ${PREFIX}/usr/share/shorewall/configfiles/isusable
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/isusable ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/isusable ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/isusable ${PREFIX}/etc/shorewall/isusable
|
||||
echo "Isusable file installed as ${PREFIX}/etc/shorewall/isusable"
|
||||
fi
|
||||
@@ -648,7 +690,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/refresh ${PREFIX}/usr/share/shorewall/configfiles/refresh
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/refresh ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/refresh ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/refresh ${PREFIX}/etc/shorewall/refresh
|
||||
echo "Refresh file installed as ${PREFIX}/etc/shorewall/refresh"
|
||||
fi
|
||||
@@ -657,7 +699,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/refreshed ${PREFIX}/usr/share/shorewall/configfiles/refreshed
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/refreshed ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/refreshed ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/refreshed ${PREFIX}/etc/shorewall/refreshed
|
||||
echo "Refreshed file installed as ${PREFIX}/etc/shorewall/refreshed"
|
||||
fi
|
||||
@@ -666,7 +708,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/tcclear ${PREFIX}/usr/share/shorewall/configfiles/tcclear
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/tcclear ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/tcclear ]; then
|
||||
run_install $OWNERSHIP -m 0600 configfiles/tcclear ${PREFIX}/etc/shorewall/tcclear
|
||||
echo "Tcclear file installed as ${PREFIX}/etc/shorewall/tcclear"
|
||||
fi
|
||||
@@ -681,7 +723,7 @@ echo "Standard actions file installed as ${PREFIX}/usr/shared/shorewall/actions.
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 configfiles/actions ${PREFIX}/usr/share/shorewall/configfiles/actions
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall/actions ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall/actions ]; then
|
||||
run_install $OWNERSHIP -m 0644 configfiles/actions ${PREFIX}/etc/shorewall/actions
|
||||
echo "Actions file installed as ${PREFIX}/etc/shorewall/actions"
|
||||
fi
|
||||
@@ -691,7 +733,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 Makefile-lite ${PREFIX}/usr/share/shorewall/configfiles/Makefile
|
||||
|
||||
if [ -z "$CYGWIN" ]; then
|
||||
if [ -z "$SPARSE" ]; then
|
||||
run_install $OWNERSHIP -m 0600 Makefile ${PREFIX}/etc/shorewall/Makefile
|
||||
echo "Makefile installed as ${PREFIX}/etc/shorewall/Makefile"
|
||||
fi
|
||||
@@ -792,6 +834,11 @@ cd ..
|
||||
|
||||
echo "Man Pages Installed"
|
||||
|
||||
if [ -d ${PREFIX}/etc/logrotate.d ]; then
|
||||
run_install $OWNERSHIP -m 0644 logrotate ${PREFIX}/etc/logrotate.d/shorewall
|
||||
echo "Logrotate file installed as ${PREFIX}/etc/logrotate.d/shorewall"
|
||||
fi
|
||||
|
||||
if [ -z "$PREFIX" ]; then
|
||||
rm -rf /usr/share/shorewall-perl
|
||||
rm -rf /usr/share/shorewall-shell
|
||||
@@ -804,7 +851,7 @@ if [ -z "$PREFIX" -a -n "$first_install" -a -z "$CYGWIN" ]; then
|
||||
echo "shorewall will start automatically at boot"
|
||||
echo "Set startup=1 in /etc/default/shorewall to enable"
|
||||
touch /var/log/shorewall-init.log
|
||||
qt mywhich perl && perl -p -w -i -e 's/^STARTUP_ENABLED=No/STARTUP_ENABLED=Yes/;s/^IP_FORWARDING=On/IP_FORWARDING=Keep/;s/^SUBSYSLOCK=.*/SUBSYSLOCK=/;' /etc/shorewall/shorewall.conf
|
||||
perl -p -w -i -e 's/^STARTUP_ENABLED=No/STARTUP_ENABLED=Yes/;s/^IP_FORWARDING=On/IP_FORWARDING=Keep/;s/^SUBSYSLOCK=.*/SUBSYSLOCK=/;' /etc/shorewall/shorewall.conf
|
||||
else
|
||||
if [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then
|
||||
if insserv /etc/init.d/shorewall ; then
|
||||
@@ -837,4 +884,4 @@ fi
|
||||
#
|
||||
# Report Success
|
||||
#
|
||||
echo "shorewall-common Version $VERSION Installed"
|
||||
echo "shorewall Version $VERSION Installed"
|
||||
|
@@ -1,16 +1 @@
|
||||
1) 'shorewall check' produces an internal error if 'routeback' appears
|
||||
in /etc/shorewall/routestopped.
|
||||
|
||||
You can work around this problem by using 'source' rather than
|
||||
'routeback'.
|
||||
|
||||
Corrected in Shorewall 4.4.2.1.
|
||||
|
||||
2) 'routestopped' appearing in /etc/shorewall/routestopped doesn't
|
||||
work (routeback traffic is not allowed).
|
||||
|
||||
You can work around this problem by using 'source' rather than
|
||||
'routeback'.
|
||||
|
||||
Corrected in Shorewall 4.4.2.2.
|
||||
|
||||
There are no known problems in Shorewall 4.4.8
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Shorewall 4.2 -- /usr/share/shorewall/lib.base
|
||||
# Shorewall 4.4 -- /usr/share/shorewall/lib.base
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
@@ -24,26 +24,17 @@
|
||||
# This library contains the code common to all Shorewall components.
|
||||
#
|
||||
# - It is loaded by /sbin/shorewall.
|
||||
# - It is loaded by /usr/share/shorewall/firewall.
|
||||
# - It is released as part of Shorewall Lite where it is used by /sbin/shorewall-lite
|
||||
# and /usr/share/shorewall-lite/shorecap.
|
||||
#
|
||||
|
||||
SHOREWALL_LIBVERSION=40000
|
||||
SHOREWALL_CAPVERSION=40402
|
||||
SHOREWALL_LIBVERSION=40407
|
||||
SHOREWALL_CAPVERSION=40408
|
||||
|
||||
[ -n "${VARDIR:=/var/lib/shorewall}" ]
|
||||
[ -n "${SHAREDIR:=/usr/share/shorewall}" ]
|
||||
[ -n "${CONFDIR:=/etc/shorewall}" ]
|
||||
|
||||
#
|
||||
# Message to stderr
|
||||
#
|
||||
error_message() # $* = Error Message
|
||||
{
|
||||
echo " $@" >&2
|
||||
}
|
||||
|
||||
#
|
||||
# Conditionally produce message
|
||||
#
|
||||
@@ -52,8 +43,8 @@ progress_message() # $* = Message
|
||||
local timestamp
|
||||
timestamp=
|
||||
|
||||
if [ $VERBOSE -gt 1 ]; then
|
||||
[ -n "$TIMESTAMP" ] && timestamp="$(date +%H:%M:%S) "
|
||||
if [ $VERBOSITY -gt 1 ]; then
|
||||
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
||||
echo "${timestamp}$@"
|
||||
fi
|
||||
}
|
||||
@@ -63,8 +54,8 @@ progress_message2() # $* = Message
|
||||
local timestamp
|
||||
timestamp=
|
||||
|
||||
if [ $VERBOSE -gt 0 ]; then
|
||||
[ -n "$TIMESTAMP" ] && timestamp="$(date +%H:%M:%S) "
|
||||
if [ $VERBOSITY -gt 0 ]; then
|
||||
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
||||
echo "${timestamp}$@"
|
||||
fi
|
||||
}
|
||||
@@ -74,40 +65,12 @@ progress_message3() # $* = Message
|
||||
local timestamp
|
||||
timestamp=
|
||||
|
||||
if [ $VERBOSE -ge 0 ]; then
|
||||
[ -n "$TIMESTAMP" ] && timestamp="$(date +%H:%M:%S) "
|
||||
if [ $VERBOSITY -ge 0 ]; then
|
||||
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
|
||||
echo "${timestamp}$@"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Split a colon-separated list into a space-separated list
|
||||
#
|
||||
split() {
|
||||
local ifs
|
||||
ifs=$IFS
|
||||
IFS=:
|
||||
echo $*
|
||||
IFS=$ifs
|
||||
}
|
||||
|
||||
#
|
||||
# Search a list looking for a match -- returns zero if a match found
|
||||
# 1 otherwise
|
||||
#
|
||||
list_search() # $1 = element to search for , $2-$n = list
|
||||
{
|
||||
local e
|
||||
e=$1
|
||||
|
||||
while [ $# -gt 1 ]; do
|
||||
shift
|
||||
[ "x$e" = "x$1" ] && return 0
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
#
|
||||
# Undo the effect of 'separate_list()'
|
||||
#
|
||||
@@ -124,167 +87,6 @@ combine_list()
|
||||
echo $o
|
||||
}
|
||||
|
||||
#
|
||||
# Suppress all output for a command
|
||||
#
|
||||
qt()
|
||||
{
|
||||
"$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
#
|
||||
# Determine if Shorewall is "running"
|
||||
#
|
||||
shorewall_is_started() {
|
||||
qt $IPTABLES -L shorewall -n
|
||||
}
|
||||
|
||||
#
|
||||
# Echos the fully-qualified name of the calling shell program
|
||||
#
|
||||
my_pathname() {
|
||||
cd $(dirname $0)
|
||||
echo $PWD/$(basename $0)
|
||||
}
|
||||
|
||||
#
|
||||
# Source a user exit file if it exists
|
||||
#
|
||||
run_user_exit() # $1 = file name
|
||||
{
|
||||
local user_exit
|
||||
user_exit=$(find_file $1)
|
||||
|
||||
if [ -f $user_exit ]; then
|
||||
progress_message "Processing $user_exit ..."
|
||||
. $user_exit
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Load a Kernel Module -- assumes that the variable 'moduledirectories' contains
|
||||
# a space-separated list of directories to search for
|
||||
# the module and that 'moduleloader' contains the
|
||||
# module loader command.
|
||||
#
|
||||
loadmodule() # $1 = module name, $2 - * arguments
|
||||
{
|
||||
local modulename
|
||||
modulename=$1
|
||||
local modulefile
|
||||
local suffix
|
||||
|
||||
if ! list_search $modulename $MODULES $DONT_LOAD ; then
|
||||
shift
|
||||
|
||||
for suffix in $MODULE_SUFFIX ; do
|
||||
for directory in $moduledirectories; do
|
||||
modulefile=$directory/${modulename}.${suffix}
|
||||
|
||||
if [ -f $modulefile ]; then
|
||||
case $moduleloader in
|
||||
insmod)
|
||||
insmod $modulefile $*
|
||||
;;
|
||||
*)
|
||||
modprobe $modulename $*
|
||||
;;
|
||||
esac
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Reload the Modules
|
||||
#
|
||||
reload_kernel_modules() {
|
||||
|
||||
local save_modules_dir
|
||||
save_modules_dir=$MODULESDIR
|
||||
local directory
|
||||
local moduledirectories
|
||||
moduledirectories=
|
||||
local moduleloader
|
||||
moduleloader=modprobe
|
||||
local uname
|
||||
|
||||
if ! qt mywhich modprobe; then
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=o gz ko o.gz ko.gz}" ]
|
||||
|
||||
|
||||
[ -z "$MODULESDIR" ] && \
|
||||
uname=$(uname -r) && \
|
||||
MODULESDIR=/lib/modules/$uname/kernel/net/ipv4/netfilter:/lib/modules/$uname/kernel/net/netfilter:/lib/modules/$uname/extra:/lib/modules/$uname/extra/ipset
|
||||
|
||||
MODULES=$(lsmod | cut -d ' ' -f1)
|
||||
|
||||
for directory in $(split $MODULESDIR); do
|
||||
[ -d $directory ] && moduledirectories="$moduledirectories $directory"
|
||||
done
|
||||
|
||||
[ -n "$moduledirectories" ] && while read command; do
|
||||
eval $command
|
||||
done
|
||||
|
||||
MODULESDIR=$save_modules_dir
|
||||
}
|
||||
|
||||
#
|
||||
# Load kernel modules required for Shorewall
|
||||
#
|
||||
load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
|
||||
{
|
||||
local save_modules_dir
|
||||
save_modules_dir=$MODULESDIR
|
||||
local directory
|
||||
local moduledirectories
|
||||
moduledirectories=
|
||||
local moduleloader
|
||||
moduleloader=modprobe
|
||||
local savemoduleinfo
|
||||
savemoduleinfo=${1:-Yes} # So old compiled scripts still work
|
||||
local uname
|
||||
|
||||
if ! qt mywhich modprobe; then
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=o gz ko o.gz ko.gz}" ]
|
||||
|
||||
[ -z "$MODULESDIR" ] && \
|
||||
uname=$(uname -r) && \
|
||||
MODULESDIR=/lib/modules/$uname/kernel/net/ipv4/netfilter:/lib/modules/$uname/kernel/net/netfilter:/lib/modules/$uname/extra:/lib/modules/$uname/extra/ipset
|
||||
|
||||
for directory in $(split $MODULESDIR); do
|
||||
[ -d $directory ] && moduledirectories="$moduledirectories $directory"
|
||||
done
|
||||
|
||||
modules=$(find_file modules)
|
||||
|
||||
if [ -f $modules -a -n "$moduledirectories" ]; then
|
||||
MODULES=$(lsmod | cut -d ' ' -f1)
|
||||
progress_message "Loading Modules..."
|
||||
. $modules
|
||||
if [ $savemoduleinfo = Yes ]; then
|
||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||
echo MODULESDIR="$MODULESDIR" > ${VARDIR}/.modulesdir
|
||||
cp -f $modules ${VARDIR}/.modules
|
||||
fi
|
||||
elif [ $savemoduleinfo = Yes ]; then
|
||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||
> ${VARDIR}/.modulesdir
|
||||
> ${VARDIR}/.modules
|
||||
fi
|
||||
|
||||
MODULESDIR=$save_modules_dir
|
||||
}
|
||||
|
||||
#
|
||||
# Call this function to assert mutual exclusion with Shorewall. If you invoke the
|
||||
# /sbin/shorewall program while holding mutual exclusion, you should pass "nolock" as
|
||||
@@ -334,12 +136,32 @@ mutex_off()
|
||||
}
|
||||
|
||||
#
|
||||
# Note: The following set of IP address manipulation functions have anomalous
|
||||
# behavior when the shell only supports 32-bit signed arithmetic and
|
||||
# the IP address is 128.0.0.0 or 128.0.0.1.
|
||||
# Find the interface with the passed MAC address
|
||||
#
|
||||
|
||||
LEFTSHIFT='<<'
|
||||
find_interface_by_mac() {
|
||||
local mac
|
||||
mac=$1
|
||||
local first
|
||||
local second
|
||||
local rest
|
||||
local dev
|
||||
|
||||
$IP link list | while read first second rest; do
|
||||
case $first in
|
||||
*:)
|
||||
dev=$second
|
||||
;;
|
||||
*)
|
||||
if [ "$second" = $mac ]; then
|
||||
echo ${dev%:}
|
||||
return
|
||||
fi
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
[ -z "$LEFTSHIFT" ] && . ${SHAREDIR}/lib.common
|
||||
|
||||
#
|
||||
# Validate an IP address
|
||||
@@ -369,44 +191,6 @@ valid_address() {
|
||||
return 0
|
||||
}
|
||||
|
||||
#
|
||||
# Convert an IP address in dot quad format to an integer
|
||||
#
|
||||
decodeaddr() {
|
||||
local x
|
||||
local temp
|
||||
temp=0
|
||||
local ifs
|
||||
ifs=$IFS
|
||||
|
||||
IFS=.
|
||||
|
||||
for x in $1; do
|
||||
temp=$(( $(( $temp $LEFTSHIFT 8 )) | $x ))
|
||||
done
|
||||
|
||||
echo $temp
|
||||
|
||||
IFS=$ifs
|
||||
}
|
||||
|
||||
#
|
||||
# convert an integer to dot quad format
|
||||
#
|
||||
encodeaddr() {
|
||||
addr=$1
|
||||
local x
|
||||
local y
|
||||
y=$(($addr & 255))
|
||||
|
||||
for x in 1 2 3 ; do
|
||||
addr=$(($addr >> 8))
|
||||
y=$(($addr & 255)).$y
|
||||
done
|
||||
|
||||
echo $y
|
||||
}
|
||||
|
||||
#
|
||||
# Miserable Hack to work around broken BusyBox ash in OpenWRT
|
||||
#
|
||||
@@ -507,66 +291,6 @@ ip_range_explicit() {
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Netmask from CIDR
|
||||
#
|
||||
ip_netmask() {
|
||||
local vlsm
|
||||
vlsm=${1#*/}
|
||||
|
||||
[ $vlsm -eq 0 ] && echo 0 || echo $(( -1 $LEFTSHIFT $(( 32 - $vlsm )) ))
|
||||
}
|
||||
|
||||
#
|
||||
# Network address from CIDR
|
||||
#
|
||||
ip_network() {
|
||||
local decodedaddr
|
||||
decodedaddr=$(decodeaddr ${1%/*})
|
||||
local netmask
|
||||
netmask=$(ip_netmask $1)
|
||||
|
||||
echo $(encodeaddr $(($decodedaddr & $netmask)))
|
||||
}
|
||||
|
||||
#
|
||||
# The following hack is supplied to compensate for the fact that many of
|
||||
# the popular light-weight Bourne shell derivatives don't support XOR ("^").
|
||||
#
|
||||
ip_broadcast() {
|
||||
local x
|
||||
x=$(( 32 - ${1#*/} ))
|
||||
|
||||
[ $x -eq 32 ] && echo -1 || echo $(( $(( 1 $LEFTSHIFT $x )) - 1 ))
|
||||
}
|
||||
|
||||
#
|
||||
# Calculate broadcast address from CIDR
|
||||
#
|
||||
broadcastaddress() {
|
||||
local decodedaddr
|
||||
decodedaddr=$(decodeaddr ${1%/*})
|
||||
local netmask
|
||||
netmask=$(ip_netmask $1)
|
||||
local broadcast
|
||||
broadcast=$(ip_broadcast $1)
|
||||
|
||||
echo $(encodeaddr $(( $(($decodedaddr & $netmask)) | $broadcast )))
|
||||
}
|
||||
|
||||
#
|
||||
# Test for network membership
|
||||
#
|
||||
in_network() # $1 = IP address, $2 = CIDR network
|
||||
{
|
||||
local netmask
|
||||
netmask=$(ip_netmask $2)
|
||||
#
|
||||
# We compare the values as strings rather than integers to work around broken BusyBox ash on OpenWRT
|
||||
#
|
||||
test $(( $(decodeaddr $1) & $netmask)) = $(( $(decodeaddr ${2%/*}) & $netmask ))
|
||||
}
|
||||
|
||||
#
|
||||
# Netmask to VLSM
|
||||
#
|
||||
@@ -590,90 +314,6 @@ ip_vlsm() {
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Query NetFilter about the existence of a filter chain
|
||||
#
|
||||
chain_exists() # $1 = chain name
|
||||
{
|
||||
qt $IPTABLES -L $1 -n
|
||||
}
|
||||
|
||||
#
|
||||
# Find the interface with the passed MAC address
|
||||
#
|
||||
|
||||
find_interface_by_mac() {
|
||||
local mac
|
||||
mac=$1
|
||||
local first
|
||||
local second
|
||||
local rest
|
||||
local dev
|
||||
|
||||
ip link list | while read first second rest; do
|
||||
case $first in
|
||||
*:)
|
||||
dev=$second
|
||||
;;
|
||||
*)
|
||||
if [ "$second" = $mac ]; then
|
||||
echo ${dev%:}
|
||||
return
|
||||
fi
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Find interface address--returns the first IP address assigned to the passed
|
||||
# device
|
||||
#
|
||||
find_first_interface_address() # $1 = interface
|
||||
{
|
||||
#
|
||||
# get the line of output containing the first IP address
|
||||
#
|
||||
addr=$(ip -f inet addr show $1 2> /dev/null | grep 'inet .* global' | head -n1)
|
||||
#
|
||||
# If there wasn't one, bail out now
|
||||
#
|
||||
[ -n "$addr" ] || fatal_error "Can't determine the IP address of $1"
|
||||
#
|
||||
# Strip off the trailing VLSM mask (or the peer IP in case of a P-t-P link)
|
||||
# along with everything else on the line
|
||||
#
|
||||
echo $addr | sed 's/\s*inet //;s/\/.*//;s/ peer.*//'
|
||||
}
|
||||
|
||||
find_first_interface_address_if_any() # $1 = interface
|
||||
{
|
||||
#
|
||||
# get the line of output containing the first IP address
|
||||
#
|
||||
addr=$(ip -f inet addr show $1 2> /dev/null | grep 'inet .* global' | head -n1)
|
||||
#
|
||||
# Strip off the trailing VLSM mask (or the peer IP in case of a P-t-P link)
|
||||
# along with everything else on the line
|
||||
#
|
||||
[ -n "$addr" ] && echo $addr | sed 's/\s*inet //;s/\/.*//;s/ peer.*//' || echo 0.0.0.0
|
||||
}
|
||||
|
||||
#
|
||||
# Internal version of 'which'
|
||||
#
|
||||
mywhich() {
|
||||
local dir
|
||||
|
||||
for dir in $(split $PATH); do
|
||||
if [ -x $dir/$1 ]; then
|
||||
echo $dir/$1
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 2
|
||||
}
|
||||
|
||||
#
|
||||
# Set default config path
|
||||
#
|
||||
@@ -690,32 +330,6 @@ ensure_config_path() {
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Find a File -- For relative file name, look in each ${CONFIG_PATH} then ${CONFDIR}
|
||||
#
|
||||
find_file()
|
||||
{
|
||||
local saveifs
|
||||
saveifs=
|
||||
local directory
|
||||
|
||||
case $1 in
|
||||
/*)
|
||||
echo $1
|
||||
;;
|
||||
*)
|
||||
for directory in $(split $CONFIG_PATH); do
|
||||
if [ -f $directory/$1 ]; then
|
||||
echo $directory/$1
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
echo ${CONFDIR}/$1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
# Get fully-qualified name of file
|
||||
#
|
||||
@@ -750,359 +364,11 @@ resolve_file() # $1 = file name
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
# Perform variable substitution on the passed argument and echo the result
|
||||
#
|
||||
expand() # $@ = contents of variable which may be the name of another variable
|
||||
{
|
||||
eval echo \"$@\"
|
||||
}
|
||||
|
||||
#
|
||||
# Function for including one file into another
|
||||
#
|
||||
INCLUDE() {
|
||||
. $(find_file $(expand $@))
|
||||
}
|
||||
|
||||
#
|
||||
# Set the Shorewall state
|
||||
#
|
||||
set_state () # $1 = state
|
||||
{
|
||||
echo "$1 ($(date))" > ${VARDIR}/state
|
||||
}
|
||||
|
||||
#
|
||||
# Determine which optional facilities are supported by iptables/netfilter
|
||||
#
|
||||
determine_capabilities() {
|
||||
[ -n "$IPTABLES" ] || IPTABLES=$(mywhich iptables)
|
||||
|
||||
if [ -z "$IPTABLES" ]; then
|
||||
echo " ERROR: No executable iptables binary can be found on your PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
qt $IPTABLES -t nat -L -n && NAT_ENABLED=Yes || NAT_ENABLED=
|
||||
qt $IPTABLES -t mangle -L -n && MANGLE_ENABLED=Yes || MANGLE_ENABLED=
|
||||
|
||||
CONNTRACK_MATCH=
|
||||
NEW_CONNTRACK_MATCH=
|
||||
OLD_CONNTRACK_MATCH=
|
||||
MULTIPORT=
|
||||
XMULTIPORT=
|
||||
POLICY_MATCH=
|
||||
PHYSDEV_MATCH=
|
||||
PHYSDEV_BRIDGE=
|
||||
IPRANGE_MATCH=
|
||||
RECENT_MATCH=
|
||||
OWNER_MATCH=
|
||||
IPSET_MATCH=
|
||||
CONNMARK=
|
||||
XCONNMARK=
|
||||
CONNMARK_MATCH=
|
||||
XCONNMARK_MATCH=
|
||||
RAW_TABLE=
|
||||
IPP2P_MATCH=
|
||||
OLD_IPP2P_MATCH=
|
||||
LENGTH_MATCH=
|
||||
CLASSIFY_TARGET=
|
||||
ENHANCED_REJECT=
|
||||
USEPKTTYPE=
|
||||
KLUDGEFREE=
|
||||
MARK=
|
||||
XMARK=
|
||||
MANGLE_FORWARD=
|
||||
COMMENTS=
|
||||
ADDRTYPE=
|
||||
TCPMSS_MATCH=
|
||||
HASHLIMIT_MATCH=
|
||||
NFQUEUE_TARGET=
|
||||
REALM_MATCH=
|
||||
HELPER_MATCH=
|
||||
CONNLIMIT_MATCH=
|
||||
TIME_MATCH=
|
||||
GOTO_TARGET=
|
||||
LOGMARK_TARGET=
|
||||
IPMARK_TARGET=
|
||||
LOG_TARGET=Yes
|
||||
PERSISTENT_SNAT=
|
||||
|
||||
chain=fooX$$
|
||||
|
||||
if [ -n "$NAT_ENABLED" ]; then
|
||||
if qt $IPTABLES -t nat -N $chain; then
|
||||
qt $IPTABLES -t nat -A $chain -j SNAT --to-source 1.2.3.4 --persistent && PERSISTENT_SNAT=Yes
|
||||
qt $IPTABLES -t nat -F $chain
|
||||
qt $IPTABLES -t nat -X $chain
|
||||
fi
|
||||
fi
|
||||
|
||||
qt $IPTABLES -F $chain
|
||||
qt $IPTABLES -X $chain
|
||||
if ! $IPTABLES -N $chain; then
|
||||
echo " ERROR: The command \"$IPTABLES -N $chain\" failed" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
chain1=${chain}1
|
||||
|
||||
qt $IPTABLES -F $chain1
|
||||
qt $IPTABLES -X $chain1
|
||||
if ! $IPTABLES -N $chain1; then
|
||||
echo " ERROR: The command \"$IPTABLES -N $chain1\" failed" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! qt $IPTABLES -A $chain -m state --state ESTABLISHED,RELATED -j ACCEPT; then
|
||||
echo " ERROR: Your kernel lacks connection tracking and/or state matching -- Shorewall will not run on this system" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
qt $IPTABLES -A $chain -m conntrack --ctorigdst 192.168.1.1 -j ACCEPT && CONNTRACK_MATCH=Yes
|
||||
|
||||
if [ -n "$CONNTRACK_MATCH" ]; then
|
||||
qt $IPTABLES -A $chain -m conntrack -p tcp --ctorigdstport 22 -j ACCEPT && NEW_CONNTRACK_MATCH=Yes
|
||||
qt $IPTABLES -A $chain -m conntrack ! --ctorigdst 1.2.3.4 || OLD_CONNTRACK_MATCH=Yes
|
||||
fi
|
||||
|
||||
if qt $IPTABLES -A $chain -p tcp -m multiport --dports 21,22 -j ACCEPT; then
|
||||
MULTIPORT=Yes
|
||||
qt $IPTABLES -A $chain -p tcp -m multiport --sports 60 -m multiport --dports 99 -j ACCEPT && KLUDEFREE=Yes
|
||||
fi
|
||||
|
||||
qt $IPTABLES -A $chain -p tcp -m multiport --dports 21:22 -j ACCEPT && XMULTIPORT=Yes
|
||||
qt $IPTABLES -A $chain -m policy --pol ipsec --mode tunnel --dir in -j ACCEPT && POLICY_MATCH=Yes
|
||||
|
||||
if qt $IPTABLES -A $chain -m physdev --physdev-out eth0 -j ACCEPT; then
|
||||
PHYSDEV_MATCH=Yes
|
||||
qt $IPTABLES -A $chain -m physdev --physdev-is-bridged --physdev-in eth0 --physdev-out eth0 -j ACCEPT && PHYSDEV_BRIDGE=Yes
|
||||
if [ -z "${KLUDGEFREE}" ]; then
|
||||
qt $IPTABLES -A $chain -m physdev --physdev-in eth0 -m physdev --physdev-out eth0 -j ACCEPT && KLUDGEFREE=Yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if qt $IPTABLES -A $chain -m iprange --src-range 192.168.1.5-192.168.1.124 -j ACCEPT; then
|
||||
IPRANGE_MATCH=Yes
|
||||
if [ -z "${KLUDGEFREE}" ]; then
|
||||
qt $IPTABLES -A $chain -m iprange --src-range 192.168.1.5-192.168.1.124 -m iprange --dst-range 192.168.1.5-192.168.1.124 -j ACCEPT && KLUDGEFREE=Yes
|
||||
fi
|
||||
fi
|
||||
|
||||
qt $IPTABLES -A $chain -m recent --update -j ACCEPT && RECENT_MATCH=Yes
|
||||
qt $IPTABLES -A $chain -m owner --uid-owner 0 -j ACCEPT && OWNER_MATCH=Yes
|
||||
|
||||
if qt $IPTABLES -A $chain -m connmark --mark 2 -j ACCEPT; then
|
||||
CONNMARK_MATCH=Yes
|
||||
qt $IPTABLES -A $chain -m connmark --mark 2/0xFF -j ACCEPT && XCONNMARK_MATCH=Yes
|
||||
fi
|
||||
|
||||
qt $IPTABLES -A $chain -p tcp -m ipp2p --edk -j ACCEPT && IPP2P_MATCH=Yes
|
||||
if [ -n "$IPP2P_MATCH" ]; then
|
||||
qt $IPTABLES -A $chain -p tcp -m ipp2p --ipp2p -j ACCEPT && OLD_IPP2P_MATCH=Yes
|
||||
fi
|
||||
|
||||
qt $IPTABLES -A $chain -m length --length 10:20 -j ACCEPT && LENGTH_MATCH=Yes
|
||||
qt $IPTABLES -A $chain -j REJECT --reject-with icmp-host-prohibited && ENHANCED_REJECT=Yes
|
||||
|
||||
qt $IPTABLES -A $chain -j ACCEPT -m comment --comment "This is a comment" && COMMENTS=Yes
|
||||
|
||||
if [ -n "$MANGLE_ENABLED" ]; then
|
||||
qt $IPTABLES -t mangle -N $chain
|
||||
|
||||
if qt $IPTABLES -t mangle -A $chain -j MARK --set-mark 1; then
|
||||
MARK=Yes
|
||||
qt $IPTABLES -t mangle -A $chain -j MARK --and-mark 0xFF && XMARK=Yes
|
||||
fi
|
||||
|
||||
if qt $IPTABLES -t mangle -A $chain -j CONNMARK --save-mark; then
|
||||
CONNMARK=Yes
|
||||
qt $IPTABLES -t mangle -A $chain -j CONNMARK --save-mark --mask 0xFF && XCONNMARK=Yes
|
||||
fi
|
||||
|
||||
qt $IPTABLES -t mangle -A $chain -j CLASSIFY --set-class 1:1 && CLASSIFY_TARGET=Yes
|
||||
qt $IPTABLES -t mangle -A $chain -j IPMARK --addr src && IPMARK_TARGET=Yes
|
||||
qt $IPTABLES -t mangle -F $chain
|
||||
qt $IPTABLES -t mangle -X $chain
|
||||
qt $IPTABLES -t mangle -L FORWARD -n && MANGLE_FORWARD=Yes
|
||||
fi
|
||||
|
||||
qt $IPTABLES -t raw -L -n && RAW_TABLE=Yes
|
||||
|
||||
if qt mywhich ipset; then
|
||||
qt ipset -X $chain # Just in case something went wrong the last time
|
||||
|
||||
if qt ipset -N $chain iphash ; then
|
||||
if qt $IPTABLES -A $chain -m set --set $chain src -j ACCEPT; then
|
||||
qt $IPTABLES -D $chain -m set --set $chain src -j ACCEPT
|
||||
IPSET_MATCH=Yes
|
||||
fi
|
||||
qt ipset -X $chain
|
||||
fi
|
||||
fi
|
||||
|
||||
qt $IPTABLES -A $chain -m pkttype --pkt-type broadcast -j ACCEPT && USEPKTTYPE=Yes
|
||||
qt $IPTABLES -A $chain -m addrtype --src-type BROADCAST -j ACCEPT && ADDRTYPE=Yes
|
||||
qt $IPTABLES -A $chain -p tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1000:1500 -j ACCEPT && TCPMSS_MATCH=Yes
|
||||
qt $IPTABLES -A $chain -m hashlimit --hashlimit-upto 4 --hashlimit-burst 5 --hashlimit-name $chain --hashlimit-mode dstip -j ACCEPT && HASHLIMIT_MATCH=Yes
|
||||
if [ -z "$HASHLIMIT_MATCH" ]; then
|
||||
qt $IPTABLES -A $chain -m hashlimit --hashlimit 4 --hashlimit-burst 5 --hashlimit-name $chain --hashlimit-mode dstip -j ACCEPT && NEW_HL_MATCH=Yes
|
||||
HASHLIMIT_MATCH=$OLD_HL_MATCH
|
||||
fi
|
||||
qt $IPTABLES -A $chain -j NFQUEUE --queue-num 4 && NFQUEUE_TARGET=Yes
|
||||
qt $IPTABLES -A $chain -m realm --realm 4 && REALM_MATCH=Yes
|
||||
qt $IPTABLES -A $chain -m helper --helper "ftp" && HELPER_MATCH=Yes
|
||||
qt $IPTABLES -A $chain -m connlimit --connlimit-above 8 -j DROP && CONNLIMIT_MATCH=Yes
|
||||
qt $IPTABLES -A $chain -m time --timestart 23:00 -j DROP && TIME_MATCH=Yes
|
||||
qt $IPTABLES -A $chain -g $chain1 && GOTO_TARGET=Yes
|
||||
qt $IPTABLES -A $chain -j LOGMARK && LOGMARK_TARGET=Yes
|
||||
qt $IPTABLES -A $chain -j LOG || LOG_TARGET=
|
||||
|
||||
qt $IPTABLES -F $chain
|
||||
qt $IPTABLES -X $chain
|
||||
qt $IPTABLES -F $chain1
|
||||
qt $IPTABLES -X $chain1
|
||||
|
||||
CAPVERSION=$SHOREWALL_CAPVERSION
|
||||
}
|
||||
|
||||
report_capabilities() {
|
||||
report_capability() # $1 = Capability Description , $2 Capability Setting (if any)
|
||||
{
|
||||
local setting
|
||||
setting=
|
||||
|
||||
[ "x$2" = "xYes" ] && setting="Available" || setting="Not available"
|
||||
|
||||
echo " " $1: $setting
|
||||
}
|
||||
|
||||
if [ $VERBOSE -gt 1 ]; then
|
||||
echo "Shorewall has detected the following iptables/netfilter capabilities:"
|
||||
report_capability "NAT" $NAT_ENABLED
|
||||
report_capability "Packet Mangling" $MANGLE_ENABLED
|
||||
report_capability "Multi-port Match" $MULTIPORT
|
||||
[ -n "$MULTIPORT" ] && report_capability "Extended Multi-port Match" $XMULTIPORT
|
||||
report_capability "Connection Tracking Match" $CONNTRACK_MATCH
|
||||
if [ -n "$CONNTRACK_MATCH" ]; then
|
||||
report_capability "Extended Connection Tracking Match Support" $NEW_CONNTRACK_MATCH
|
||||
report_capability "Old Connection Tracking Match Syntax" $OLD_CONNTRACK_MATCH
|
||||
fi
|
||||
report_capability "Packet Type Match" $USEPKTTYPE
|
||||
report_capability "Policy Match" $POLICY_MATCH
|
||||
report_capability "Physdev Match" $PHYSDEV_MATCH
|
||||
report_capability "Physdev-is-bridged Support" $PHYSDEV_BRIDGE
|
||||
report_capability "Packet length Match" $LENGTH_MATCH
|
||||
report_capability "IP range Match" $IPRANGE_MATCH
|
||||
report_capability "Recent Match" $RECENT_MATCH
|
||||
report_capability "Owner Match" $OWNER_MATCH
|
||||
report_capability "Ipset Match" $IPSET_MATCH
|
||||
report_capability "CONNMARK Target" $CONNMARK
|
||||
[ -n "$CONNMARK" ] && report_capability "Extended CONNMARK Target" $XCONNMARK
|
||||
report_capability "Connmark Match" $CONNMARK_MATCH
|
||||
[ -n "$CONNMARK_MATCH" ] && report_capability "Extended Connmark Match" $XCONNMARK_MATCH
|
||||
report_capability "Raw Table" $RAW_TABLE
|
||||
report_capability "IPP2P Match" $IPP2P_MATCH
|
||||
[ -n "$IPP2P_MATCH" ] && report_capability "Old IPP2P Match Syntax" $OLD_IPP2P_MATCH
|
||||
report_capability "CLASSIFY Target" $CLASSIFY_TARGET
|
||||
report_capability "Extended REJECT" $ENHANCED_REJECT
|
||||
report_capability "Repeat match" $KLUDGEFREE
|
||||
report_capability "MARK Target" $MARK
|
||||
[ -n "$MARK" ] && report_capability "Extended MARK Target" $XMARK
|
||||
report_capability "Mangle FORWARD Chain" $MANGLE_FORWARD
|
||||
report_capability "Comments" $COMMENTS
|
||||
report_capability "Address Type Match" $ADDRTYPE
|
||||
report_capability "TCPMSS Match" $TCPMSS_MATCH
|
||||
report_capability "Hashlimit Match" $HASHLIMIT_MATCH
|
||||
report_capability "Old Hashlimit Match" $OLD_HL_MATCH
|
||||
report_capability "NFQUEUE Target" $NFQUEUE_TARGET
|
||||
report_capability "Realm Match" $REALM_MATCH
|
||||
report_capability "Helper Match" $HELPER_MATCH
|
||||
report_capability "Connlimit Match" $CONNLIMIT_MATCH
|
||||
report_capability "Time Match" $TIME_MATCH
|
||||
report_capability "Goto Support" $GOTO_TARGET
|
||||
report_capability "LOGMARK Target" $LOGMARK_TARGET
|
||||
report_capability "IPMARK Target" $IPMARK_TARGET
|
||||
report_capability "LOG Target" $LOG_TARGET
|
||||
report_capability "Persistent SNAT" $PERSISTENT_SNAT
|
||||
fi
|
||||
|
||||
[ -n "$PKTTYPE" ] || USEPKTTYPE=
|
||||
|
||||
}
|
||||
|
||||
report_capabilities1() {
|
||||
report_capability1() # $1 = Capability
|
||||
{
|
||||
eval echo $1=\$$1
|
||||
}
|
||||
|
||||
echo "#"
|
||||
echo "# Shorewall $VERSION detected the following iptables/netfilter capabilities - $(date)"
|
||||
echo "#"
|
||||
report_capability1 NAT_ENABLED
|
||||
report_capability1 MANGLE_ENABLED
|
||||
report_capability1 MULTIPORT
|
||||
report_capability1 XMULTIPORT
|
||||
report_capability1 CONNTRACK_MATCH
|
||||
report_capability1 NEW_CONNTRACK_MATCH
|
||||
report_capability1 OLD_CONNTRACK_MATCH
|
||||
report_capability1 USEPKTTYPE
|
||||
report_capability1 POLICY_MATCH
|
||||
report_capability1 PHYSDEV_MATCH
|
||||
report_capability1 PHYSDEV_BRIDGE
|
||||
report_capability1 LENGTH_MATCH
|
||||
report_capability1 IPRANGE_MATCH
|
||||
report_capability1 RECENT_MATCH
|
||||
report_capability1 OWNER_MATCH
|
||||
report_capability1 IPSET_MATCH
|
||||
report_capability1 CONNMARK
|
||||
report_capability1 XCONNMARK
|
||||
report_capability1 CONNMARK_MATCH
|
||||
report_capability1 XCONNMARK_MATCH
|
||||
report_capability1 RAW_TABLE
|
||||
report_capability1 IPP2P_MATCH
|
||||
report_capability1 OLD_IPP2P_MATCH
|
||||
report_capability1 CLASSIFY_TARGET
|
||||
report_capability1 ENHANCED_REJECT
|
||||
report_capability1 KLUDGEFREE
|
||||
report_capability1 MARK
|
||||
report_capability1 XMARK
|
||||
report_capability1 MANGLE_FORWARD
|
||||
report_capability1 COMMENTS
|
||||
report_capability1 ADDRTYPE
|
||||
report_capability1 TCPMSS_MATCH
|
||||
report_capability1 HASHLIMIT_MATCH
|
||||
report_capability1 OLD_HL_MATCH
|
||||
report_capability1 NFQUEUE_TARGET
|
||||
report_capability1 REALM_MATCH
|
||||
report_capability1 HELPER_MATCH
|
||||
report_capability1 CONNLIMIT_MATCH
|
||||
report_capability1 TIME_MATCH
|
||||
report_capability1 GOTO_TARGET
|
||||
report_capability1 LOGMARK_TARGET
|
||||
report_capability1 IPMARK_TARGET
|
||||
report_capability1 LOG_TARGET
|
||||
report_capability1 PERSISTENT_SNAT
|
||||
|
||||
echo CAPVERSION=$SHOREWALL_CAPVERSION
|
||||
}
|
||||
|
||||
# Function to truncate a string -- It uses 'cut -b -<n>'
|
||||
# rather than ${v:first:last} because light-weight shells like ash and
|
||||
# dash do not support that form of expansion.
|
||||
#
|
||||
|
||||
truncate() # $1 = length
|
||||
{
|
||||
cut -b -${1}
|
||||
}
|
||||
|
||||
#
|
||||
# Determine how to do "echo -e"
|
||||
#
|
||||
|
||||
find_echo() {
|
||||
local result
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
540
Shorewall/lib.common
Normal file
540
Shorewall/lib.common
Normal file
@@ -0,0 +1,540 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Shorewall 4.4 -- /usr/share/shorewall/lib.common.
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of Version 2 of the GNU General Public License
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# The purpose of this library is to hold those functions used by both the CLI and by the
|
||||
# generated firewall scripts. To avoid versioning issues, it is copied into generated
|
||||
# scripts rather than loaded at run-time.
|
||||
#
|
||||
|
||||
#
|
||||
# Get the Shorewall version of the passed script
|
||||
#
|
||||
get_script_version() { # $1 = script
|
||||
local temp
|
||||
local version
|
||||
local ifs
|
||||
local digits
|
||||
|
||||
temp=$( $SHOREWALL_SHELL $1 version | sed 's/-.*//' )
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
version=0
|
||||
else
|
||||
ifs=$IFS
|
||||
IFS=.
|
||||
temp=$(echo $temp)
|
||||
IFS=$ifs
|
||||
digits=0
|
||||
|
||||
for temp in $temp; do
|
||||
version=${version}$(printf '%02d' $temp)
|
||||
digits=$(($digits + 1))
|
||||
[ $digits -eq 3 ] && break
|
||||
done
|
||||
fi
|
||||
|
||||
echo $version
|
||||
}
|
||||
|
||||
#
|
||||
# Do required exports or create the required option string and run the passed script using
|
||||
# $SHOREWALL_SHELL
|
||||
#
|
||||
run_it() {
|
||||
local script
|
||||
local options
|
||||
local version
|
||||
|
||||
export VARDIR
|
||||
|
||||
script=$1
|
||||
shift
|
||||
|
||||
version=$(get_script_version $script)
|
||||
|
||||
if [ $version -lt 040408 ]; then
|
||||
#
|
||||
# Old script that doesn't understand 4.4.8 script options
|
||||
#
|
||||
export RESTOREFILE
|
||||
export VERBOSITY
|
||||
export NOROUTES=$g_noroutes
|
||||
export PURGE=$g_purge
|
||||
export TIMESTAMP=$g_timestamp
|
||||
export RECOVERING=$g_recovering
|
||||
|
||||
if [ "$g_product" != Shorewall ]; then
|
||||
#
|
||||
# Shorewall Lite
|
||||
#
|
||||
export LOGFORMAT
|
||||
export IPTABLES
|
||||
fi
|
||||
else
|
||||
#
|
||||
# 4.4.8 or later -- no additional exports required
|
||||
#
|
||||
options='-'
|
||||
|
||||
[ -n "$g_noroutes" ] && options=${options}n
|
||||
[ -n "$g_timestamp" ] && options=${options}t
|
||||
[ -n "$g_purge" ] && options=${options}p
|
||||
[ -n "$g_recovering" ] && options=${options}r
|
||||
|
||||
options="${options}V $VERBOSITY"
|
||||
|
||||
[ -n "$RESTOREFILE" ] && options="${options} -R $RESTOREFILE"
|
||||
fi
|
||||
|
||||
$SHOREWALL_SHELL $script $options $@
|
||||
}
|
||||
|
||||
#
|
||||
# Message to stderr
|
||||
#
|
||||
error_message() # $* = Error Message
|
||||
{
|
||||
echo " $@" >&2
|
||||
}
|
||||
|
||||
#
|
||||
# Split a colon-separated list into a space-separated list
|
||||
#
|
||||
split() {
|
||||
local ifs
|
||||
ifs=$IFS
|
||||
IFS=:
|
||||
echo $*
|
||||
IFS=$ifs
|
||||
}
|
||||
|
||||
#
|
||||
# Search a list looking for a match -- returns zero if a match found
|
||||
# 1 otherwise
|
||||
#
|
||||
list_search() # $1 = element to search for , $2-$n = list
|
||||
{
|
||||
local e
|
||||
e=$1
|
||||
|
||||
while [ $# -gt 1 ]; do
|
||||
shift
|
||||
[ "x$e" = "x$1" ] && return 0
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
#
|
||||
# Suppress all output for a command
|
||||
#
|
||||
qt()
|
||||
{
|
||||
"$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
qt1()
|
||||
{
|
||||
local status
|
||||
|
||||
while [ 1 ]; do
|
||||
"$@" >/dev/null 2>&1
|
||||
status=$?
|
||||
[ $status -ne 4 ] && return $status
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Determine if Shorewall is "running"
|
||||
#
|
||||
shorewall_is_started() {
|
||||
qt $IPTABLES -L shorewall -n
|
||||
}
|
||||
|
||||
#
|
||||
# Echos the fully-qualified name of the calling shell program
|
||||
#
|
||||
my_pathname() {
|
||||
cd $(dirname $0)
|
||||
echo $PWD/$(basename $0)
|
||||
}
|
||||
|
||||
#
|
||||
# Source a user exit file if it exists
|
||||
#
|
||||
run_user_exit() # $1 = file name
|
||||
{
|
||||
local user_exit
|
||||
user_exit=$(find_file $1)
|
||||
|
||||
if [ -f $user_exit ]; then
|
||||
progress_message "Processing $user_exit ..."
|
||||
. $user_exit
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Load a Kernel Module -- assumes that the variable 'moduledirectories' contains
|
||||
# a space-separated list of directories to search for
|
||||
# the module and that 'moduleloader' contains the
|
||||
# module loader command.
|
||||
#
|
||||
loadmodule() # $1 = module name, $2 - * arguments
|
||||
{
|
||||
local modulename
|
||||
modulename=$1
|
||||
local modulefile
|
||||
local suffix
|
||||
|
||||
if ! list_search $modulename $DONT_LOAD $MODULES; then
|
||||
shift
|
||||
|
||||
for suffix in $MODULE_SUFFIX ; do
|
||||
for directory in $moduledirectories; do
|
||||
modulefile=$directory/${modulename}.${suffix}
|
||||
|
||||
if [ -f $modulefile ]; then
|
||||
case $moduleloader in
|
||||
insmod)
|
||||
insmod $modulefile $*
|
||||
;;
|
||||
*)
|
||||
modprobe $modulename $*
|
||||
;;
|
||||
esac
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Reload the Modules
|
||||
#
|
||||
reload_kernel_modules() {
|
||||
|
||||
local save_modules_dir
|
||||
save_modules_dir=$MODULESDIR
|
||||
local directory
|
||||
local moduledirectories
|
||||
moduledirectories=
|
||||
local moduleloader
|
||||
moduleloader=modprobe
|
||||
local uname
|
||||
|
||||
if ! qt mywhich modprobe; then
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=o gz ko o.gz ko.gz}" ]
|
||||
|
||||
[ -z "$MODULESDIR" ] && \
|
||||
uname=$(uname -r) && \
|
||||
MODULESDIR=/lib/modules/$uname/kernel/net/ipv4/netfilter:/lib/modules/$uname/kernel/net/netfilter:/lib/modules/$uname/kernel/net/sched:/lib/modules/$uname/extra:/lib/modules/$uname/extra/ipset
|
||||
|
||||
MODULES=$(lsmod | cut -d ' ' -f1)
|
||||
|
||||
for directory in $(split $MODULESDIR); do
|
||||
[ -d $directory ] && moduledirectories="$moduledirectories $directory"
|
||||
done
|
||||
|
||||
[ -n "$moduledirectories" ] && while read command; do
|
||||
eval $command
|
||||
done
|
||||
|
||||
MODULESDIR=$save_modules_dir
|
||||
}
|
||||
|
||||
#
|
||||
# Load kernel modules required for Shorewall
|
||||
#
|
||||
load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
|
||||
{
|
||||
local save_modules_dir
|
||||
save_modules_dir=$MODULESDIR
|
||||
local directory
|
||||
local moduledirectories
|
||||
moduledirectories=
|
||||
local moduleloader
|
||||
moduleloader=modprobe
|
||||
local savemoduleinfo
|
||||
savemoduleinfo=${1:-Yes} # So old compiled scripts still work
|
||||
local uname
|
||||
|
||||
if ! qt mywhich modprobe; then
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=o gz ko o.gz ko.gz}" ]
|
||||
|
||||
[ -z "$MODULESDIR" ] && \
|
||||
uname=$(uname -r) && \
|
||||
MODULESDIR=/lib/modules/$uname/kernel/net/ipv4/netfilter:/lib/modules/$uname/kernel/net/netfilter:/lib/modules/$uname/kernel/net/sched:/lib/modules/$uname/extra:/lib/modules/$uname/extra/ipset
|
||||
|
||||
for directory in $(split $MODULESDIR); do
|
||||
[ -d $directory ] && moduledirectories="$moduledirectories $directory"
|
||||
done
|
||||
|
||||
[ -n "$LOAD_HELPERS_ONLY" ] && modules=$(find_file helpers) || modules=$(find_file modules)
|
||||
|
||||
if [ -f $modules -a -n "$moduledirectories" ]; then
|
||||
MODULES=$(lsmod | cut -d ' ' -f1)
|
||||
progress_message "Loading Modules..."
|
||||
. $modules
|
||||
if [ $savemoduleinfo = Yes ]; then
|
||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||
echo MODULESDIR="$MODULESDIR" > ${VARDIR}/.modulesdir
|
||||
cp -f $modules ${VARDIR}/.modules
|
||||
fi
|
||||
elif [ $savemoduleinfo = Yes ]; then
|
||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||
> ${VARDIR}/.modulesdir
|
||||
> ${VARDIR}/.modules
|
||||
fi
|
||||
|
||||
MODULESDIR=$save_modules_dir
|
||||
}
|
||||
|
||||
#
|
||||
# Note: The following set of IP address manipulation functions have anomalous
|
||||
# behavior when the shell only supports 32-bit signed arithmetic and
|
||||
# the IP address is 128.0.0.0 or 128.0.0.1.
|
||||
#
|
||||
|
||||
LEFTSHIFT='<<'
|
||||
|
||||
#
|
||||
# Convert an IP address in dot quad format to an integer
|
||||
#
|
||||
decodeaddr() {
|
||||
local x
|
||||
local temp
|
||||
temp=0
|
||||
local ifs
|
||||
ifs=$IFS
|
||||
|
||||
IFS=.
|
||||
|
||||
for x in $1; do
|
||||
temp=$(( $(( $temp $LEFTSHIFT 8 )) | $x ))
|
||||
done
|
||||
|
||||
echo $temp
|
||||
|
||||
IFS=$ifs
|
||||
}
|
||||
|
||||
#
|
||||
# convert an integer to dot quad format
|
||||
#
|
||||
encodeaddr() {
|
||||
addr=$1
|
||||
local x
|
||||
local y
|
||||
y=$(($addr & 255))
|
||||
|
||||
for x in 1 2 3 ; do
|
||||
addr=$(($addr >> 8))
|
||||
y=$(($addr & 255)).$y
|
||||
done
|
||||
|
||||
echo $y
|
||||
}
|
||||
|
||||
#
|
||||
# Netmask from CIDR
|
||||
#
|
||||
ip_netmask() {
|
||||
local vlsm
|
||||
vlsm=${1#*/}
|
||||
|
||||
[ $vlsm -eq 0 ] && echo 0 || echo $(( -1 $LEFTSHIFT $(( 32 - $vlsm )) ))
|
||||
}
|
||||
|
||||
#
|
||||
# Network address from CIDR
|
||||
#
|
||||
ip_network() {
|
||||
local decodedaddr
|
||||
decodedaddr=$(decodeaddr ${1%/*})
|
||||
local netmask
|
||||
netmask=$(ip_netmask $1)
|
||||
|
||||
echo $(encodeaddr $(($decodedaddr & $netmask)))
|
||||
}
|
||||
|
||||
#
|
||||
# The following hack is supplied to compensate for the fact that many of
|
||||
# the popular light-weight Bourne shell derivatives don't support XOR ("^").
|
||||
#
|
||||
ip_broadcast() {
|
||||
local x
|
||||
x=$(( 32 - ${1#*/} ))
|
||||
|
||||
[ $x -eq 32 ] && echo -1 || echo $(( $(( 1 $LEFTSHIFT $x )) - 1 ))
|
||||
}
|
||||
|
||||
#
|
||||
# Calculate broadcast address from CIDR
|
||||
#
|
||||
broadcastaddress() {
|
||||
local decodedaddr
|
||||
decodedaddr=$(decodeaddr ${1%/*})
|
||||
local netmask
|
||||
netmask=$(ip_netmask $1)
|
||||
local broadcast
|
||||
broadcast=$(ip_broadcast $1)
|
||||
|
||||
echo $(encodeaddr $(( $(($decodedaddr & $netmask)) | $broadcast )))
|
||||
}
|
||||
|
||||
#
|
||||
# Test for network membership
|
||||
#
|
||||
in_network() # $1 = IP address, $2 = CIDR network
|
||||
{
|
||||
local netmask
|
||||
netmask=$(ip_netmask $2)
|
||||
#
|
||||
# Use string comparison to work around a broken BusyBox ash in OpenWRT
|
||||
#
|
||||
test $(( $(decodeaddr $1) & $netmask)) = $(( $(decodeaddr ${2%/*}) & $netmask ))
|
||||
}
|
||||
|
||||
#
|
||||
# Find interface address--returns the first IP address assigned to the passed
|
||||
# device
|
||||
#
|
||||
find_first_interface_address() # $1 = interface
|
||||
{
|
||||
#
|
||||
# get the line of output containing the first IP address
|
||||
#
|
||||
addr=$($IP -f inet addr show $1 2> /dev/null | grep 'inet .* global' | head -n1)
|
||||
#
|
||||
# If there wasn't one, bail out now
|
||||
#
|
||||
[ -n "$addr" ] || startup_error "Can't determine the IP address of $1"
|
||||
#
|
||||
# Strip off the trailing VLSM mask (or the peer IP in case of a P-t-P link)
|
||||
# along with everything else on the line
|
||||
#
|
||||
echo $addr | sed 's/\s*inet //;s/\/.*//;s/ peer.*//'
|
||||
}
|
||||
|
||||
find_first_interface_address_if_any() # $1 = interface
|
||||
{
|
||||
#
|
||||
# get the line of output containing the first IP address
|
||||
#
|
||||
addr=$($IP -f inet addr show $1 2> /dev/null | grep 'inet .* global' | head -n1)
|
||||
#
|
||||
# Strip off the trailing VLSM mask (or the peer IP in case of a P-t-P link)
|
||||
# along with everything else on the line
|
||||
#
|
||||
[ -n "$addr" ] && echo $addr | sed 's/\s*inet //;s/\/.*//;s/ peer.*//' || echo 0.0.0.0
|
||||
}
|
||||
|
||||
#
|
||||
# Internal version of 'which'
|
||||
#
|
||||
mywhich() {
|
||||
local dir
|
||||
|
||||
for dir in $(split $PATH); do
|
||||
if [ -x $dir/$1 ]; then
|
||||
echo $dir/$1
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 2
|
||||
}
|
||||
|
||||
#
|
||||
# Query NetFilter about the existence of a filter chain
|
||||
#
|
||||
chain_exists() # $1 = chain name
|
||||
{
|
||||
qt1 $IPTABLES -L $1 -n
|
||||
}
|
||||
|
||||
#
|
||||
# Find a File -- For relative file name, look in each ${CONFIG_PATH} then ${CONFDIR}
|
||||
#
|
||||
find_file()
|
||||
{
|
||||
local saveifs
|
||||
saveifs=
|
||||
local directory
|
||||
|
||||
case $1 in
|
||||
/*)
|
||||
echo $1
|
||||
;;
|
||||
*)
|
||||
for directory in $(split $CONFIG_PATH); do
|
||||
if [ -f $directory/$1 ]; then
|
||||
echo $directory/$1
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
echo ${CONFDIR}/$1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
# Set the Shorewall state
|
||||
#
|
||||
set_state () # $1 = state
|
||||
{
|
||||
echo "$1 ($(date))" > ${VARDIR}/state
|
||||
}
|
||||
|
||||
#
|
||||
# Perform variable substitution on the passed argument and echo the result
|
||||
#
|
||||
expand() # $@ = contents of variable which may be the name of another variable
|
||||
{
|
||||
eval echo \"$@\"
|
||||
}
|
||||
|
||||
#
|
||||
# Function for including one file into another
|
||||
#
|
||||
INCLUDE() {
|
||||
. $(find_file $(expand $@))
|
||||
}
|
||||
|
||||
# Function to truncate a string -- It uses 'cut -b -<n>'
|
||||
# rather than ${v:first:last} because light-weight shells like ash and
|
||||
# dash do not support that form of expansion.
|
||||
#
|
||||
|
||||
truncate() # $1 = length
|
||||
{
|
||||
cut -b -${1}
|
||||
}
|
5
Shorewall/logrotate
Normal file
5
Shorewall/logrotate
Normal file
@@ -0,0 +1,5 @@
|
||||
/var/log/shorewall-init.log {
|
||||
missingok
|
||||
notifempty
|
||||
create 0600 root root
|
||||
}
|
@@ -54,6 +54,8 @@ loadmodule xt_owner
|
||||
loadmodule xt_physdev
|
||||
loadmodule xt_pkttype
|
||||
loadmodule xt_tcpmss
|
||||
loadmodule xt_IPMARK
|
||||
loadmodule xt_TPROXY
|
||||
#
|
||||
# Helpers
|
||||
#
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# This file should be placed in /sbin/shorewall.
|
||||
#
|
||||
@@ -62,19 +62,17 @@ get_config() {
|
||||
|
||||
ensure_config_path
|
||||
|
||||
if [ -z "$EXPORT" -a "$(id -u)" = 0 ]; then
|
||||
if [ -z "$g_export" -a "$(id -u)" = 0 ]; then
|
||||
#
|
||||
# This block is avoided for compile for export and when the user isn't root
|
||||
#
|
||||
export CONFIG_PATH
|
||||
|
||||
if [ "$3" = Yes ]; then
|
||||
[ -z "$LOGFILE" ] && LOGFILE=/var/log/messages
|
||||
|
||||
if [ -n "$(syslog_circular_buffer)" ]; then
|
||||
LOGREAD="logread | tac"
|
||||
elif [ -f $LOGFILE ]; then
|
||||
LOGREAD="tac $LOGFILE"
|
||||
g_logread="logread | tac"
|
||||
elif [ -r $LOGFILE ]; then
|
||||
g_logread="tac $LOGFILE"
|
||||
else
|
||||
echo "LOGFILE ($LOGFILE) does not exist!" >&2
|
||||
exit 2
|
||||
@@ -94,8 +92,6 @@ get_config() {
|
||||
fi
|
||||
fi
|
||||
|
||||
export IPTABLES
|
||||
|
||||
if [ -n "$IP" ]; then
|
||||
case "$IP" in
|
||||
*/*)
|
||||
@@ -117,8 +113,6 @@ get_config() {
|
||||
IP='ip'
|
||||
fi
|
||||
|
||||
export IP
|
||||
|
||||
if [ -n "$IPSET" ]; then
|
||||
case "$IPSET" in
|
||||
*/*)
|
||||
@@ -140,8 +134,6 @@ get_config() {
|
||||
IPSET='ipset'
|
||||
fi
|
||||
|
||||
export IPSET
|
||||
|
||||
if [ -n "$TC" ]; then
|
||||
case "$TC" in
|
||||
*/*)
|
||||
@@ -162,9 +154,6 @@ get_config() {
|
||||
else
|
||||
TC='tc'
|
||||
fi
|
||||
|
||||
export TC
|
||||
|
||||
#
|
||||
# Compile by non-root needs no restore file
|
||||
#
|
||||
@@ -172,8 +161,6 @@ get_config() {
|
||||
|
||||
validate_restorefile RESTOREFILE
|
||||
|
||||
export RESTOREFILE
|
||||
|
||||
if [ "$2" = Yes ]; then
|
||||
case $STARTUP_ENABLED in
|
||||
No|no|NO)
|
||||
@@ -213,8 +200,6 @@ get_config() {
|
||||
|
||||
[ -n "$LOGFORMAT" ] && LOGFORMAT="${LOGFORMAT%%%*}"
|
||||
|
||||
export LOGFORMAT
|
||||
|
||||
if [ -n "$STARTUP_LOG" ]; then
|
||||
if [ -n "$LOG_VERBOSITY" ]; then
|
||||
case $LOG_VERBOSITY in
|
||||
@@ -259,17 +244,15 @@ get_config() {
|
||||
;;
|
||||
esac
|
||||
|
||||
[ -n "$USE_VERBOSITY" ] && VERBOSE=$USE_VERBOSITY || VERBOSE=$(($VERBOSE_OFFSET + $VERBOSITY))
|
||||
[ -n "$g_use_verbosity" ] && VERBOSITY=$g_use_verbosity || VERBOSITY=$(($g_verbose_offset + $VERBOSITY))
|
||||
|
||||
if [ $VERBOSE -lt -1 ]; then
|
||||
VERBOSE=-1
|
||||
elif [ $VERBOSE -gt 2 ]; then
|
||||
VERBOSE=2
|
||||
if [ $VERBOSITY -lt -1 ]; then
|
||||
VERBOSITY=-1
|
||||
elif [ $VERBOSITY -gt 2 ]; then
|
||||
VERBOSITY=2
|
||||
fi
|
||||
|
||||
export VERBOSE
|
||||
|
||||
[ -n "${HOSTNAME:=$(hostname)}" ]
|
||||
g_hostname=$(hostname 2> /dev/null)
|
||||
|
||||
[ -n "$RSH_COMMAND" ] || RSH_COMMAND='ssh ${root}@${system} ${command}'
|
||||
[ -n "$RCP_COMMAND" ] || RCP_COMMAND='scp ${files} ${root}@${system}:${destination}'
|
||||
@@ -288,20 +271,6 @@ get_config() {
|
||||
;;
|
||||
esac
|
||||
|
||||
case $FAST_STOP in
|
||||
Yes|yes)
|
||||
;;
|
||||
No|no)
|
||||
FAST_STOP=
|
||||
;;
|
||||
*)
|
||||
if [ -n "$FAST_STOP" ]; then
|
||||
echo " ERROR: Invalid FAST_STOP setting ($FAST_STOP)" >&2
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
case $AUTOMAKE in
|
||||
Yes|yes)
|
||||
;;
|
||||
@@ -315,6 +284,20 @@ get_config() {
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
case $LOAD_HELPERS_ONLY in
|
||||
Yes|yes)
|
||||
;;
|
||||
No|no)
|
||||
LOAD_HELPERS_ONLY=
|
||||
;;
|
||||
*)
|
||||
if [ -n "$LOAD_HELPERS_ONLY" ]; then
|
||||
echo " ERROR: Invalid LOAD_HELPERS_ONLY setting ($LOAD_HELPERS_ONLY)" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
@@ -346,8 +329,8 @@ compiler() {
|
||||
esac
|
||||
|
||||
debugflags="-w"
|
||||
[ -n "$DEBUG" ] && debugflags='-wd'
|
||||
[ -n "$PROFILE" ] && debugflags='-wd:DProf'
|
||||
[ -n "$g_debug" ] && debugflags='-wd'
|
||||
[ -n "$g_profile" ] && debugflags='-wd:DProf'
|
||||
|
||||
# Perl compiler only takes the output file as a argument
|
||||
|
||||
@@ -355,15 +338,16 @@ compiler() {
|
||||
[ "$1" = nolock ] && shift;
|
||||
shift
|
||||
|
||||
options="--verbose=$VERBOSE"
|
||||
options="--verbose=$VERBOSITY"
|
||||
[ -n "$STARTUP_LOG" ] && options="$options --log=$STARTUP_LOG"
|
||||
[ -n "$LOG_VERBOSITY" ] && options="$options --log_verbosity=$LOG_VERBOSITY";
|
||||
[ -n "$EXPORT" ] && options="$options --export"
|
||||
[ -n "$g_export" ] && options="$options --export"
|
||||
[ -n "$SHOREWALL_DIR" ] && options="$options --directory=$SHOREWALL_DIR"
|
||||
[ -n "$TIMESTAMP" ] && options="$options --timestamp"
|
||||
[ -n "$TEST" ] && options="$options --test"
|
||||
[ "$debugging" = trace ] && options="$options --debug"
|
||||
[ -n "$REFRESHCHAINS" ] && options="$options --refresh=$REFRESHCHAINS"
|
||||
[ -n "$g_timestamp" ] && options="$options --timestamp"
|
||||
[ -n "$g_test" ] && options="$options --test"
|
||||
[ -n "$g_preview" ] && options="$options --preview"
|
||||
[ "$g_debugging" = trace ] && options="$options --debug"
|
||||
[ -n "$g_refreshchains" ] && options="$options --refresh=$g_refreshchains"
|
||||
#
|
||||
# Run the appropriate params file
|
||||
#
|
||||
@@ -388,15 +372,15 @@ start_command() {
|
||||
|
||||
if [ -n "$AUTOMAKE" ]; then
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
${VARDIR}/firewall $debugging start
|
||||
run_it ${VARDIR}/firewall $g_debugging start
|
||||
rc=$?
|
||||
[ -n "$nolock" ] || mutex_off
|
||||
else
|
||||
progress_message3 "Compiling..."
|
||||
|
||||
if compiler $debugging $nolock compile ${VARDIR}/.start; then
|
||||
if compiler $g_debugging $nolock compile ${VARDIR}/.start; then
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
${VARDIR}/.start $debugging start
|
||||
run_it ${VARDIR}/.start $g_debugging start
|
||||
rc=$?
|
||||
[ -n "$nolock" ] || mutex_off
|
||||
else
|
||||
@@ -428,16 +412,16 @@ start_command() {
|
||||
option=
|
||||
;;
|
||||
d*)
|
||||
DEBUG=Yes
|
||||
g_debug=Yes
|
||||
option=${option#d}
|
||||
;;
|
||||
f*)
|
||||
FAST=Yes
|
||||
g_fast=Yes
|
||||
option=${option#f}
|
||||
;;
|
||||
p*)
|
||||
[ -n "$(which conntrack)" ] || fatal_error "The '-p' option requires the conntrack utility which does not appear to be installed on this system"
|
||||
PURGE=Yes
|
||||
g_purge=Yes
|
||||
option=${option%p}
|
||||
;;
|
||||
*)
|
||||
@@ -457,7 +441,7 @@ start_command() {
|
||||
0)
|
||||
;;
|
||||
1)
|
||||
[ -n "$SHOREWALL_DIR" -o -n "$FAST" ] && usage 2
|
||||
[ -n "$SHOREWALL_DIR" -o -n "$g_fast" ] && usage 2
|
||||
|
||||
if [ ! -d $1 ]; then
|
||||
if [ -e $1 ]; then
|
||||
@@ -468,7 +452,6 @@ start_command() {
|
||||
fi
|
||||
|
||||
SHOREWALL_DIR=$(resolve_file $1)
|
||||
export SHOREWALL_DIR
|
||||
AUTOMAKE=
|
||||
;;
|
||||
*)
|
||||
@@ -476,42 +459,38 @@ start_command() {
|
||||
;;
|
||||
esac
|
||||
|
||||
export NOROUTES
|
||||
export PURGE
|
||||
|
||||
if [ -n "${FAST}${AUTOMAKE}" ]; then
|
||||
if [ -n "${g_fast}${AUTOMAKE}" ]; then
|
||||
if qt mywhich make; then
|
||||
#
|
||||
# RESTOREFILE is exported by get_config()
|
||||
#
|
||||
restorefile=$RESTOREFILE
|
||||
|
||||
if [ -z "$FAST" ]; then
|
||||
if [ -z "$g_fast" ]; then
|
||||
#
|
||||
# Automake -- use the last compiled script
|
||||
#
|
||||
RESTOREFILE=firewall
|
||||
fi
|
||||
|
||||
if ! make -qf ${CONFDIR}/Makefile; then
|
||||
FAST=
|
||||
export RESTOREFILE
|
||||
|
||||
if make -qf ${CONFDIR}/Makefile; then
|
||||
g_fast=
|
||||
AUTOMAKE=
|
||||
fi
|
||||
|
||||
RESTOREFILE=$restorefile
|
||||
else
|
||||
FAST=
|
||||
g_fast=
|
||||
AUTOMAKE=
|
||||
fi
|
||||
|
||||
if [ -n "$FAST" ]; then
|
||||
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
||||
if [ -n "$g_fast" ]; then
|
||||
g_restorepath=${VARDIR}/$RESTOREFILE
|
||||
|
||||
if [ -x $RESTOREPATH ]; then
|
||||
if [ -x $g_restorepath ]; then
|
||||
echo Restoring Shorewall...
|
||||
$SHOREWALL_SHELL $RESTOREPATH restore
|
||||
run_it $g_restorepath restore
|
||||
date > ${VARDIR}/restarted
|
||||
progress_message3 Shorewall restored from $RESTOREPATH
|
||||
progress_message3 Shorewall restored from $g_restorepath
|
||||
else
|
||||
do_it
|
||||
fi
|
||||
@@ -543,19 +522,19 @@ compile_command() {
|
||||
while [ -n "$option" ]; do
|
||||
case $option in
|
||||
e*)
|
||||
EXPORT=Yes
|
||||
g_export=Yes
|
||||
option=${option#e}
|
||||
;;
|
||||
p*)
|
||||
PROFILE=Yes
|
||||
g_profile=Yes
|
||||
option=${option#p}
|
||||
;;
|
||||
t*)
|
||||
TEST=Yes
|
||||
g_test=Yes
|
||||
option=${option#t}
|
||||
;;
|
||||
d*)
|
||||
DEBUG=Yes;
|
||||
g_debug=Yes;
|
||||
option=${option#d}
|
||||
;;
|
||||
-)
|
||||
@@ -596,7 +575,6 @@ compile_command() {
|
||||
fi
|
||||
|
||||
SHOREWALL_DIR=$(resolve_file $1)
|
||||
export SHOREWALL_DIR
|
||||
file=$2
|
||||
;;
|
||||
*)
|
||||
@@ -604,11 +582,9 @@ compile_command() {
|
||||
;;
|
||||
esac
|
||||
|
||||
export EXPORT
|
||||
|
||||
[ "x$file" = x- ] || progress_message3 "Compiling..."
|
||||
|
||||
compiler $debugging compile $file
|
||||
compiler $g_debugging compile $file
|
||||
}
|
||||
|
||||
#
|
||||
@@ -631,17 +607,21 @@ check_command() {
|
||||
option=
|
||||
;;
|
||||
e*)
|
||||
EXPORT=Yes
|
||||
g_export=Yes
|
||||
option=${option#e}
|
||||
;;
|
||||
p*)
|
||||
PROFILE=Yes
|
||||
g_profile=Yes
|
||||
option=${option#p}
|
||||
;;
|
||||
d*)
|
||||
DEBUG=Yes;
|
||||
g_debug=Yes;
|
||||
option=${option#d}
|
||||
;;
|
||||
r*)
|
||||
g_preview=Yes;
|
||||
option=${option#r}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@@ -670,18 +650,15 @@ check_command() {
|
||||
fi
|
||||
|
||||
SHOREWALL_DIR=$(resolve_file $1)
|
||||
export SHOREWALL_DIR
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
|
||||
export EXPORT
|
||||
|
||||
progress_message3 "Checking..."
|
||||
|
||||
compiler $debugging $nolock check
|
||||
compiler $g_debugging $nolock check
|
||||
}
|
||||
|
||||
#
|
||||
@@ -707,20 +684,20 @@ restart_command() {
|
||||
option=
|
||||
;;
|
||||
d*)
|
||||
DEBUG=Yes
|
||||
g_debug=Yes
|
||||
option=${option#d}
|
||||
;;
|
||||
f*)
|
||||
FAST=Yes
|
||||
g_fast=Yes
|
||||
option=${option#f}
|
||||
;;
|
||||
n*)
|
||||
NOROUTES=Yes
|
||||
g_noroutes=Yes
|
||||
option=${option#n}
|
||||
;;
|
||||
p*)
|
||||
[ -n "$(which conntrack)" ] || fatal_error "The '-p' option requires the conntrack utility which does not appear to be installed on this system"
|
||||
PURGE=Yes
|
||||
g_purge=Yes
|
||||
option=${option%p}
|
||||
;;
|
||||
*)
|
||||
@@ -751,8 +728,7 @@ restart_command() {
|
||||
fi
|
||||
|
||||
SHOREWALL_DIR=$(resolve_file $1)
|
||||
[ -n "$FAST" ] && fatal_error "Directory may not be specified with the -f option"
|
||||
export SHOREWALL_DIR
|
||||
[ -n "$g_fast" ] && fatal_error "Directory may not be specified with the -f option"
|
||||
AUTOMAKE=
|
||||
;;
|
||||
*)
|
||||
@@ -762,27 +738,24 @@ restart_command() {
|
||||
|
||||
[ -n "$STARTUP_ENABLED" ] || fatal_error "Startup is disabled"
|
||||
|
||||
export NOROUTES
|
||||
export PURGE
|
||||
|
||||
if [ -z "$FAST" -a -n "$AUTOMAKE" ]; then
|
||||
if [ -z "$g_fast" -a -n "$AUTOMAKE" ]; then
|
||||
if qt mywhich make; then
|
||||
#
|
||||
# RESTOREFILE is exported by get_config()
|
||||
#
|
||||
restorefile=$RESTOREFILE
|
||||
RESTOREFILE=firewall
|
||||
make -qf ${CONFDIR}/Makefile && FAST=Yes
|
||||
make -qf ${CONFDIR}/Makefile && g_fast=Yes
|
||||
RESTOREFILE=$restorefile
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$FAST" ]; then
|
||||
if [ -z "$g_fast" ]; then
|
||||
progress_message3 "Compiling..."
|
||||
|
||||
if compiler $debugging $nolock compile ${VARDIR}/.restart; then
|
||||
if compiler $g_debugging $nolock compile ${VARDIR}/.restart; then
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
$SHOREWALL_SHELL ${VARDIR}/.restart $debugging restart
|
||||
run_it ${VARDIR}/.restart $g_debugging restart
|
||||
rc=$?
|
||||
[ -n "$nolock" ] || mutex_off
|
||||
else
|
||||
@@ -792,7 +765,7 @@ restart_command() {
|
||||
else
|
||||
[ -x ${VARDIR}/firewall ] || fatal_error "No ${VARDIR}/firewall file found"
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
$SHOREWALL_SHELL ${VARDIR}/firewall $debugging restart
|
||||
run_it ${VARDIR}/firewall $g_debugging restart
|
||||
rc=$?
|
||||
[ -n "$nolock" ] || mutex_off
|
||||
fi
|
||||
@@ -833,11 +806,11 @@ refresh_command() {
|
||||
done
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
REFRESHCHAINS=$1
|
||||
g_refreshchains=$1
|
||||
shift
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
REFRESHCHAINS="$REFRESHCHAINS,$1"
|
||||
g_refreshchains="$g_refreshchains,$1"
|
||||
shift
|
||||
done
|
||||
fi
|
||||
@@ -846,13 +819,11 @@ refresh_command() {
|
||||
|
||||
[ -n "$STARTUP_ENABLED" ] || fatal_error "Startup is disabled"
|
||||
|
||||
export NOROUTES
|
||||
|
||||
progress_message3 "Compiling..."
|
||||
|
||||
if compiler $debugging $nolock compile ${VARDIR}/.refresh; then
|
||||
if compiler $g_debugging $nolock compile ${VARDIR}/.refresh; then
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
$SHOREWALL_SHELL ${VARDIR}/.refresh $debugging refresh
|
||||
run_it ${VARDIR}/.refresh $g_debugging refresh
|
||||
rc=$?
|
||||
[ -n "$nolock" ] || mutex_off
|
||||
else
|
||||
@@ -889,7 +860,7 @@ safe_commands() {
|
||||
option=
|
||||
;;
|
||||
n*)
|
||||
NOROUTES=Yes
|
||||
g_noroutes=Yes
|
||||
option=${option#n}
|
||||
;;
|
||||
*)
|
||||
@@ -920,7 +891,6 @@ safe_commands() {
|
||||
fi
|
||||
|
||||
SHOREWALL_DIR=$(resolve_file $1)
|
||||
export SHOREWALL_DIR
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
@@ -951,19 +921,19 @@ safe_commands() {
|
||||
|
||||
progress_message3 "Compiling..."
|
||||
|
||||
if ! compiler $debugging nolock compile ${VARDIR}/.$command; then
|
||||
if ! compiler $g_debugging nolock compile ${VARDIR}/.$command; then
|
||||
status=$?
|
||||
exit $status
|
||||
fi
|
||||
|
||||
case $command in
|
||||
start)
|
||||
export RESTOREFILE=NONE
|
||||
RESTOREFILE=NONE
|
||||
progress_message3 "Starting..."
|
||||
;;
|
||||
restart)
|
||||
export RESTOREFILE=.safe
|
||||
RESTOREPATH=${VARDIR}/.safe
|
||||
RESTOREFILE=.safe
|
||||
g_restorepath=${VARDIR}/.safe
|
||||
save_config
|
||||
progress_message3 "Restarting..."
|
||||
;;
|
||||
@@ -971,7 +941,7 @@ safe_commands() {
|
||||
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
|
||||
if ${VARDIR}/.$command $command; then
|
||||
if ${VARDIR}/.$command $g_debugging $command; then
|
||||
|
||||
echo -n "Do you want to accept the new firewall configuration? [y/n] "
|
||||
|
||||
@@ -1016,7 +986,6 @@ try_command() {
|
||||
fi
|
||||
|
||||
SHOREWALL_DIR=$(resolve_file $1)
|
||||
export SHOREWALL_DIR
|
||||
}
|
||||
|
||||
while [ $finished -eq 0 -a $# -gt 0 ]; do
|
||||
@@ -1032,7 +1001,7 @@ try_command() {
|
||||
option=
|
||||
;;
|
||||
n*)
|
||||
NOROUTES=Yes
|
||||
g_noroutes=Yes
|
||||
option=${option#n}
|
||||
;;
|
||||
*)
|
||||
@@ -1088,19 +1057,19 @@ try_command() {
|
||||
|
||||
progress_message3 "Compiling..."
|
||||
|
||||
if ! compiler $debugging $nolock compile ${VARDIR}/.$command; then
|
||||
if ! compiler $g_debugging $nolock compile ${VARDIR}/.$command; then
|
||||
status=$?
|
||||
exit $status
|
||||
fi
|
||||
|
||||
case $command in
|
||||
start)
|
||||
export RESTOREFILE=NONE
|
||||
RESTOREFILE=NONE
|
||||
progress_message3 "Starting..."
|
||||
;;
|
||||
restart)
|
||||
export RESTOREFILE=.try
|
||||
RESTOREPATH=${VARDIR}/.try
|
||||
RESTOREFILE=.try
|
||||
g_restorepath=${VARDIR}/.try
|
||||
save_config
|
||||
progress_message3 "Restarting..."
|
||||
;;
|
||||
@@ -1159,7 +1128,7 @@ reload_command() # $* = original arguments less the command.
|
||||
local root
|
||||
root=root
|
||||
|
||||
LITEDIR=/var/lib/shorewall-lite
|
||||
litedir=/var/lib/shorewall-lite
|
||||
|
||||
while [ $finished -eq 0 -a $# -gt 0 ]; do
|
||||
option=$1
|
||||
@@ -1214,9 +1183,9 @@ reload_command() # $* = original arguments less the command.
|
||||
;;
|
||||
esac
|
||||
|
||||
litedir=$(rsh_command /sbin/shorewall-lite show config 2> /dev/null | grep ^LITEDIR | sed 's/LITEDIR is //')
|
||||
temp=$(rsh_command /sbin/shorewall-lite show config 2> /dev/null | grep ^LITEDIR | sed 's/LITEDIR is //')
|
||||
|
||||
[ -n "$litedir" ] && LITEDIR=$litedir
|
||||
[ -n "$temp" ] && litedir="$temp"
|
||||
|
||||
if [ -z "$getcaps" ]; then
|
||||
SHOREWALL_DIR=$(resolve_file $directory)
|
||||
@@ -1231,19 +1200,21 @@ reload_command() # $* = original arguments less the command.
|
||||
ensure_config_path
|
||||
fi
|
||||
|
||||
[ -n "$DONT_LOAD" ] && DONT_LOAD="$(echo $DONT_LOAD | tr ',' ' ')"
|
||||
|
||||
progress_message "Getting Capabilities on system $system..."
|
||||
if ! rsh_command "MODULESDIR=$MODULESDIR MODULE_SUFFIX=\"$MODULE_SUFFIX\" IPTABLES=$IPTABLES /usr/share/shorewall-lite/shorecap" > $directory/capabilities; then
|
||||
if ! rsh_command "MODULESDIR=$MODULESDIR MODULE_SUFFIX=\"$MODULE_SUFFIX\" IPTABLES=$IPTABLES DONT_LOAD=\"$DONT_LOAD\" /usr/share/shorewall-lite/shorecap" > $directory/capabilities; then
|
||||
fatal_error "ERROR: Capturing capabilities on system $system failed"
|
||||
fi
|
||||
fi
|
||||
|
||||
file=$(resolve_file $directory/firewall)
|
||||
|
||||
[ -n "$TIMESTAMP" ] && timestamp='-t' || timestamp=
|
||||
[ -n "$g_timestamp" ] && timestamp='-t' || timestamp=
|
||||
|
||||
if shorewall $debugging $verbose $timestamp compile -e $directory $directory/firewall && \
|
||||
progress_message3 "Copying $file and ${file}.conf to ${system}:${LITEDIR}..." && \
|
||||
rcp_command "$directory/firewall $directory/firewall.conf" ${LITEDIR}
|
||||
if shorewall $g_debugging $verbose $timestamp compile -e $directory $directory/firewall && \
|
||||
progress_message3 "Copying $file and ${file}.conf to ${system}:${litedir}..." && \
|
||||
rcp_command "$directory/firewall $directory/firewall.conf" ${litedir}
|
||||
then
|
||||
save=$(find_file save);
|
||||
|
||||
@@ -1251,15 +1222,15 @@ reload_command() # $* = original arguments less the command.
|
||||
|
||||
progress_message3 "Copy complete"
|
||||
if [ $COMMAND = reload ]; then
|
||||
rsh_command "/sbin/shorewall-lite $debugging $verbose $timestamp restart" && \
|
||||
rsh_command "/sbin/shorewall-lite $g_debugging $verbose $timestamp restart" && \
|
||||
progress_message3 "System $system reloaded" || saveit=
|
||||
else
|
||||
rsh_command "/sbin/shorewall-lite $debugging $verbose $timestamp start" && \
|
||||
rsh_command "/sbin/shorewall-lite $g_debugging $verbose $timestamp start" && \
|
||||
progress_message3 "System $system loaded" || saveit=
|
||||
fi
|
||||
|
||||
if [ -n "$saveit" ]; then
|
||||
rsh_command "/sbin/shorewall-lite $debugging $verbose $timestamp save" && \
|
||||
rsh_command "/sbin/shorewall-lite $g_debugging $verbose $timestamp save" && \
|
||||
progress_message3 "Configuration on system $system saved"
|
||||
fi
|
||||
fi
|
||||
@@ -1328,7 +1299,7 @@ export_command() # $* = original arguments less the command.
|
||||
|
||||
file=$(resolve_file $directory/firewall)
|
||||
|
||||
if shorewall $debugging $verbose compile -e $directory $directory/firewall && \
|
||||
if shorewall $g_debugging $verbose compile -e $directory $directory/firewall && \
|
||||
echo "Copying $file and ${file}.conf to ${target#*@}..." && \
|
||||
scp $directory/firewall $directory/firewall.conf $target
|
||||
then
|
||||
@@ -1349,7 +1320,7 @@ usage() # $1 = exit status
|
||||
echo "where <command> is one of:"
|
||||
echo " add <interface>[:<host-list>] ... <zone>"
|
||||
echo " allow <address> ..."
|
||||
echo " check [ -e ] [ <directory> ]"
|
||||
echo " check [ -e ] [ -r ] [ <directory> ]"
|
||||
echo " clear [ -f ]"
|
||||
echo " compile [ -e ] [ -d ] [ <directory name> ] [ <path name> ]"
|
||||
echo " delete <interface>[:<host-list>] ... <zone>"
|
||||
@@ -1382,12 +1353,14 @@ usage() # $1 = exit status
|
||||
echo " show config"
|
||||
echo " show connections"
|
||||
echo " show dynamic <zone>"
|
||||
echo " show filter"
|
||||
echo " show filters"
|
||||
echo " show ip"
|
||||
echo " show [ -m ] log"
|
||||
echo " show macro <macro>"
|
||||
echo " show macros"
|
||||
echo " show [ -x ] mangle|nat|raw|routing"
|
||||
echo " show tc"
|
||||
echo " show policies"
|
||||
echo " show tc [ device ]"
|
||||
echo " show vardir"
|
||||
echo " show zones"
|
||||
echo " start [ -f ] [ -n ] [ -p ] [ <directory> ]"
|
||||
@@ -1404,10 +1377,10 @@ usage() # $1 = exit status
|
||||
#
|
||||
# Execution begins here
|
||||
#
|
||||
debugging=
|
||||
g_debugging=
|
||||
|
||||
if [ $# -gt 0 ] && [ "x$1" = "xdebug" -o "x$1" = "xtrace" ]; then
|
||||
debugging=$1
|
||||
g_debugging=$1
|
||||
shift
|
||||
fi
|
||||
|
||||
@@ -1419,15 +1392,16 @@ if [ $# -gt 0 ] && [ "$1" = "nolock" ]; then
|
||||
fi
|
||||
|
||||
SHOREWALL_DIR=
|
||||
IPT_OPTIONS="-nv"
|
||||
FAST=
|
||||
VERBOSE_OFFSET=0
|
||||
USE_VERBOSITY=
|
||||
NOROUTES=
|
||||
PURGE=
|
||||
EXPORT=
|
||||
export TIMESTAMP=
|
||||
noroutes=
|
||||
g_noroutes=
|
||||
g_purge=
|
||||
|
||||
g_ipt_options="-nv"
|
||||
g_fast=
|
||||
g_verbose_offset=0
|
||||
g_use_verbosity=
|
||||
g_debug=
|
||||
g_export=
|
||||
g_refreshchains=
|
||||
|
||||
finished=0
|
||||
|
||||
@@ -1459,52 +1433,52 @@ while [ $finished -eq 0 ]; do
|
||||
shift
|
||||
;;
|
||||
e*)
|
||||
EXPORT=Yes
|
||||
g_export=Yes
|
||||
option=${option#e}
|
||||
;;
|
||||
x*)
|
||||
IPT_OPTIONS="-xnv"
|
||||
g_ipt_options="-xnv"
|
||||
option=${option#x}
|
||||
;;
|
||||
q*)
|
||||
VERBOSE_OFFSET=$(($VERBOSE_OFFSET - 1 ))
|
||||
g_verbose_offset=$(($g_verbose_offset - 1 ))
|
||||
option=${option#q}
|
||||
;;
|
||||
f*)
|
||||
FAST=Yes
|
||||
g_fast=Yes
|
||||
option=${option#f}
|
||||
;;
|
||||
v*)
|
||||
option=${option#v}
|
||||
case $option in
|
||||
-1*)
|
||||
USE_VERBOSITY=-1
|
||||
g_use_verbosity=-1
|
||||
option=${option#-1}
|
||||
;;
|
||||
0*)
|
||||
USE_VERBOSITY=0
|
||||
g_use_verbosity=0
|
||||
option=${option#0}
|
||||
;;
|
||||
1*)
|
||||
USE_VERBOSITY=1
|
||||
g_use_verbosity=1
|
||||
option=${option#1}
|
||||
;;
|
||||
2*)
|
||||
USE_VERBOSITY=2
|
||||
g_use_verbosity=2
|
||||
option=${option#2}
|
||||
;;
|
||||
*)
|
||||
VERBOSE_OFFSET=$(($VERBOSE_OFFSET + 1 ))
|
||||
USE_VERBOSITY=
|
||||
g_verbose_offset=$(($g_verbose_offset + 1 ))
|
||||
g_use_verbosity=
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
n*)
|
||||
NOROUTES=Yes
|
||||
g_noroutes=Yes
|
||||
option=${option#n}
|
||||
;;
|
||||
t*)
|
||||
TIMESTAMP=Yes
|
||||
g_timestamp=Yes
|
||||
option=${option#t}
|
||||
;;
|
||||
-)
|
||||
@@ -1561,7 +1535,7 @@ version_command() {
|
||||
|
||||
[ $# -gt 0 ] && usage 1
|
||||
|
||||
echo $version
|
||||
echo $SHOREWALL_VERSION
|
||||
|
||||
}
|
||||
|
||||
@@ -1569,14 +1543,14 @@ if [ $# -eq 0 ]; then
|
||||
usage 1
|
||||
fi
|
||||
|
||||
[ -n "$SHOREWALL_DIR" ] && export SHOREWALL_DIR
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
||||
export PATH
|
||||
MUTEX_TIMEOUT=
|
||||
|
||||
SHAREDIR=/usr/share/shorewall
|
||||
CONFDIR=/etc/shorewall
|
||||
export PRODUCT="Shorewall"
|
||||
g_product="Shorewall"
|
||||
g_recovering=
|
||||
g_timestamp=
|
||||
|
||||
[ -f ${CONFDIR}/vardir ] && . ${CONFDIR}/vardir
|
||||
|
||||
@@ -1586,47 +1560,40 @@ if [ ! -f ${VARDIR}/firewall ]; then
|
||||
[ -f ${VARDIR}/.restore ] && cp -f ${VARDIR}/.restore ${VARDIR}/firewall
|
||||
fi
|
||||
|
||||
FIREWALL=${VARDIR}/firewall
|
||||
LIBRARIES="$SHAREDIR/lib.base $SHAREDIR/lib.cli"
|
||||
VERSION_FILE=$SHAREDIR/version
|
||||
REFRESHCHAINS=
|
||||
g_firewall=${VARDIR}/firewall
|
||||
|
||||
for library in $LIBRARIES; do
|
||||
if [ -f $library ]; then
|
||||
. $library
|
||||
else
|
||||
echo "$library does not exist!" >&2
|
||||
exit 2
|
||||
fi
|
||||
for library in base cli; do
|
||||
. ${SHAREDIR}/lib.$library
|
||||
done
|
||||
|
||||
if [ -f $VERSION_FILE ]; then
|
||||
version=$(cat $VERSION_FILE)
|
||||
version_file=$SHAREDIR/version
|
||||
if [ -f $version_file ]; then
|
||||
SHOREWALL_VERSION=$(cat $version_file)
|
||||
else
|
||||
echo " ERROR: Shorewall is not properly installed" >&2
|
||||
echo " The file $VERSION_FILE does not exist" >&2
|
||||
echo " The file $version_file does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
banner="Shorewall-$version Status at $HOSTNAME -"
|
||||
banner="Shorewall-$SHOREWALL_VERSION Status at $g_hostname -"
|
||||
|
||||
case $(echo -e) in
|
||||
-e*)
|
||||
RING_BELL="echo \a"
|
||||
ECHO_E="echo"
|
||||
g_ring_bell="echo \a"
|
||||
g_echo_e="echo"
|
||||
;;
|
||||
*)
|
||||
RING_BELL="echo -e \a"
|
||||
ECHO_E="echo -e"
|
||||
g_ring_bell="echo -e \a"
|
||||
g_echo_e="echo -e"
|
||||
;;
|
||||
esac
|
||||
|
||||
case $(echo -n "Testing") in
|
||||
-n*)
|
||||
ECHO_N=
|
||||
g_echo_n=
|
||||
;;
|
||||
*)
|
||||
ECHO_N=-n
|
||||
g_echo_n=-n
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -1641,19 +1608,17 @@ case "$COMMAND" in
|
||||
stop|clear)
|
||||
get_config
|
||||
[ $# -ne 1 ] && usage 1
|
||||
[ -x $FIREWALL ] || fatal_error "Shorewall has never been started"
|
||||
export NOROUTES
|
||||
[ -x $g_firewall ] || fatal_error "Shorewall has never been started"
|
||||
mutex_on
|
||||
$SHOREWALL_SHELL $FIREWALL $debugging $nolock $COMMAND
|
||||
run_it $g_firewall $g_debugging $nolock $COMMAND
|
||||
mutex_off
|
||||
;;
|
||||
reset)
|
||||
get_config
|
||||
export NOROUTES
|
||||
shift
|
||||
mutex_on
|
||||
[ -x $FIREWALL ] || fatal_error "Shorewall has never been started"
|
||||
$SHOREWALL_SHELL $FIREWALL $debugging $nolock reset $@
|
||||
[ -x $g_firewall ] || fatal_error "Shorewall has never been started"
|
||||
run_it $g_firewall $g_debugging $nolock reset $@
|
||||
mutex_off
|
||||
;;
|
||||
compile)
|
||||
@@ -1695,7 +1660,7 @@ case "$COMMAND" in
|
||||
[ $# -eq 1 ] || usage 1
|
||||
[ "$(id -u)" != 0 ] && fatal_error "ERROR: The status command may only be run by root"
|
||||
get_config
|
||||
echo "Shorewall-$version Status at $HOSTNAME - $(date)"
|
||||
echo "Shorewall-$SHOREWALL_VERSION Status at $g_hostname - $(date)"
|
||||
echo
|
||||
if shorewall_is_started ; then
|
||||
echo "Shorewall is running"
|
||||
@@ -1726,7 +1691,7 @@ case "$COMMAND" in
|
||||
;;
|
||||
hits)
|
||||
get_config Yes No Yes
|
||||
[ -n "$debugging" ] && set -x
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
shift
|
||||
hits_command $@
|
||||
;;
|
||||
@@ -1741,14 +1706,19 @@ case "$COMMAND" in
|
||||
;;
|
||||
logwatch)
|
||||
get_config Yes Yes Yes
|
||||
banner="Shorewall-$version Logwatch at $HOSTNAME -"
|
||||
banner="Shorewall-$SHOREWALL_VERSION Logwatch at $g_hostname -"
|
||||
logwatch_command $@
|
||||
;;
|
||||
drop)
|
||||
get_config
|
||||
[ -n "$debugging" ] && set -x
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
[ $# -eq 1 ] && usage 1
|
||||
if shorewall_is_started ; then
|
||||
if ! chain_exists dynamic; then
|
||||
echo "Dynamic blacklisting is not supported in the current $g_product configuration"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
block DROP Dropped $*
|
||||
[ -n "$nolock" ] || mutex_off
|
||||
@@ -1758,9 +1728,14 @@ case "$COMMAND" in
|
||||
;;
|
||||
logdrop)
|
||||
get_config
|
||||
[ -n "$debugging" ] && set -x
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
[ $# -eq 1 ] && usage 1
|
||||
if shorewall_is_started ; then
|
||||
if ! chain_exists dynamic; then
|
||||
echo "Dynamic blacklisting is not supported in the current $g_product configuration"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
block logdrop Dropped $*
|
||||
[ -n "$nolock" ] || mutex_off
|
||||
@@ -1770,7 +1745,7 @@ case "$COMMAND" in
|
||||
;;
|
||||
reject|logreject)
|
||||
get_config
|
||||
[ -n "$debugging" ] && set -x
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
[ $# -eq 1 ] && usage 1
|
||||
if shorewall_is_started ; then
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
@@ -1796,7 +1771,7 @@ case "$COMMAND" in
|
||||
;;
|
||||
save)
|
||||
get_config
|
||||
[ -n "$debugging" ] && set -x
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
|
||||
case $# in
|
||||
1)
|
||||
@@ -1810,7 +1785,7 @@ case "$COMMAND" in
|
||||
;;
|
||||
esac
|
||||
|
||||
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
||||
g_restorepath=${VARDIR}/$RESTOREFILE
|
||||
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
|
||||
@@ -1836,20 +1811,19 @@ case "$COMMAND" in
|
||||
;;
|
||||
esac
|
||||
|
||||
g_restorepath=${VARDIR}/$RESTOREFILE
|
||||
|
||||
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
||||
|
||||
if [ -x $RESTOREPATH ]; then
|
||||
rm -f $RESTOREPATH
|
||||
rm -f ${RESTOREPATH}-iptables
|
||||
echo " $RESTOREPATH removed"
|
||||
elif [ -f $RESTOREPATH ]; then
|
||||
echo " $RESTOREPATH exists and is not a saved Shorewall configuration"
|
||||
if [ -x $g_restorepath ]; then
|
||||
rm -f $g_restorepath
|
||||
rm -f ${g_restorepath}-iptables
|
||||
echo " $g_restorepath removed"
|
||||
elif [ -f $g_restorepath ]; then
|
||||
echo " $g_restorepath exists and is not a saved Shorewall configuration"
|
||||
fi
|
||||
rm -f ${VARDIR}/save
|
||||
;;
|
||||
ipcalc)
|
||||
[ -n "$debugging" ] && set -x
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
if [ $# -eq 2 ]; then
|
||||
address=${2%/*}
|
||||
vlsm=${2#*/}
|
||||
@@ -1874,7 +1848,7 @@ case "$COMMAND" in
|
||||
;;
|
||||
|
||||
iprange)
|
||||
[ -n "$debugging" ] && set -x
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
case $2 in
|
||||
*.*.*.*-*.*.*.*)
|
||||
for address in ${2%-*} ${2#*-}; do
|
||||
@@ -1889,7 +1863,7 @@ case "$COMMAND" in
|
||||
esac
|
||||
;;
|
||||
ipdecimal)
|
||||
[ -n "$debugging" ] && set -x
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
[ $# -eq 2 ] || usage 1
|
||||
case $2 in
|
||||
*.*.*.*)
|
||||
@@ -1908,7 +1882,7 @@ case "$COMMAND" in
|
||||
;;
|
||||
call)
|
||||
get_config
|
||||
[ -n "$debugging" ] && set -x
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
#
|
||||
# Undocumented way to call functions in ${SHAREDIR}/functions directly
|
||||
#
|
||||
|
@@ -1,6 +1,6 @@
|
||||
%define name shorewall
|
||||
%define version 4.4.2
|
||||
%define release 2
|
||||
%define version 4.4.8
|
||||
%define release 0base
|
||||
|
||||
Summary: Shoreline Firewall is an iptables-based firewall for Linux systems.
|
||||
Name: %{name}
|
||||
@@ -77,6 +77,8 @@ fi
|
||||
%attr(0644,root,root) %config(noreplace) /etc/shorewall/*
|
||||
%attr(0600,root,root) /etc/shorewall/Makefile
|
||||
|
||||
%attr(0644,root,root) /etc/logrotate.d/shorewall
|
||||
|
||||
%attr(0755,root,root) /sbin/shorewall
|
||||
|
||||
%attr(0644,root,root) /usr/share/shorewall/version
|
||||
@@ -87,8 +89,10 @@ fi
|
||||
%attr(- ,root,root) /usr/share/shorewall/functions
|
||||
%attr(0644,root,root) /usr/share/shorewall/lib.base
|
||||
%attr(0644,root,root) /usr/share/shorewall/lib.cli
|
||||
%attr(0644,root,root) /usr/share/shorewall/lib.common
|
||||
%attr(0644,root,root) /usr/share/shorewall/macro.*
|
||||
%attr(0644,root,root) /usr/share/shorewall/modules
|
||||
%attr(0644,root,root) /usr/share/shorewall/helpers
|
||||
%attr(0644,root,root) /usr/share/shorewall/configpath
|
||||
%attr(0755,root,root) /usr/share/shorewall/wait4ifup
|
||||
|
||||
@@ -104,10 +108,46 @@ fi
|
||||
%doc COPYING INSTALL changelog.txt releasenotes.txt Contrib/* Samples
|
||||
|
||||
%changelog
|
||||
* Sat Oct 03 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.2-2
|
||||
* Fri Oct 02 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.2-1
|
||||
* Fri Mar 19 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0base
|
||||
* Tue Mar 16 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0RC2
|
||||
* Mon Mar 08 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0RC1
|
||||
* Sun Feb 28 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0Beta2
|
||||
* Thu Feb 11 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0Beta1
|
||||
* Fri Feb 05 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0base
|
||||
* Tue Feb 02 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0RC2
|
||||
* Wed Jan 27 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0RC1
|
||||
* Mon Jan 25 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0Beta4
|
||||
* Fri Jan 22 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0Beta3
|
||||
* Fri Jan 22 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0Beta2
|
||||
* Thu Jan 21 2010 Tom Eastep tom@shorewall.net
|
||||
- Add /usr/share/shorewall/helpers
|
||||
* Sun Jan 17 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0Beta1
|
||||
* Wed Jan 13 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.6-0base
|
||||
* Wed Jan 13 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.6-0Beta1
|
||||
* Thu Dec 24 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.5-0base
|
||||
* Sat Nov 21 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.4-0base
|
||||
* Fri Nov 13 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.4-0Beta2
|
||||
* Wed Nov 11 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.4-0Beta1
|
||||
* Tue Nov 03 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.3-0base
|
||||
* Sun Sep 06 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.2-0base
|
||||
* Fri Sep 04 2009 Tom Eastep tom@shorewall.net
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2000,2001,2002,2003,2004,2005 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Shorewall documentation is available at http://www.shorewall.net
|
||||
#
|
||||
@@ -26,7 +26,7 @@
|
||||
# You may only use this script to uninstall the version
|
||||
# shown below. Simply run this script to remove Shorewall Firewall
|
||||
|
||||
VERSION=4.4.2.2
|
||||
VERSION=4.4.8
|
||||
|
||||
usage() # $1 = exit status
|
||||
{
|
||||
@@ -108,6 +108,7 @@ rm -rf /usr/share/shorewall
|
||||
rm -rf /usr/share/shorewall-*.bkout
|
||||
rm -rf /usr/share/man/man5/shorewall*
|
||||
rm -rf /usr/share/man/man8/shorewall*
|
||||
rm -f /etc/logrotate.d/shorewall
|
||||
|
||||
echo "Shorewall Uninstalled"
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
This is the Shorewall6-lite development 4.3 branch of SVN.
|
||||
This is the Shorewall6-lite stable 4.4 branch of Git.
|
||||
|
@@ -21,4 +21,9 @@ startup=0
|
||||
|
||||
OPTIONS=""
|
||||
|
||||
#
|
||||
# Init Log -- if /dev/null, use the STARTUP_LOG defined in shorewall.conf
|
||||
#
|
||||
INITLOG=/dev/null
|
||||
|
||||
# EOF
|
||||
|
@@ -28,7 +28,7 @@
|
||||
# shown below. Simply run this script to revert to your prior version of
|
||||
# Shoreline Firewall.
|
||||
|
||||
VERSION=4.4.2.2
|
||||
VERSION=4.4.8
|
||||
|
||||
usage() # $1 = exit status
|
||||
{
|
||||
|
@@ -2,8 +2,8 @@
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: shorewall6-lite
|
||||
# Required-Start: $network
|
||||
# Required-Stop: $network
|
||||
# Required-Start: $network $remote_fs
|
||||
# Required-Stop: $network $remote_fs
|
||||
# Default-Start: S
|
||||
# Default-Stop: 0 6
|
||||
# Short-Description: Configure the firewall at boot time
|
||||
@@ -15,9 +15,7 @@
|
||||
|
||||
SRWL=/sbin/shorewall6-lite
|
||||
SRWL_OPTS="-tvv"
|
||||
# Note, set INITLOG to /dev/null if you do not want to
|
||||
# keep logs of the firewall (not recommended)
|
||||
INITLOG=/var/log/shorewall6-lite-init.log
|
||||
test -n ${INITLOG:=/var/log/shorewall6-lite-init.log}
|
||||
|
||||
[ "$INITLOG" eq "/dev/null" && SHOREWALL_INIT_SCRIPT=1 || SHOREWALL_INIT_SCRIPT=0
|
||||
|
||||
@@ -25,7 +23,7 @@ export SHOREWALL_INIT_SCRIPT
|
||||
|
||||
test -x $SRWL || exit 0
|
||||
test -x $WAIT_FOR_IFUP || exit 0
|
||||
test -n $INITLOG || {
|
||||
test -n "$INITLOG" || {
|
||||
echo "INITLOG cannot be empty, please configure $0" ;
|
||||
exit 1;
|
||||
}
|
||||
@@ -44,6 +42,7 @@ echo_notdone () {
|
||||
echo "not done (check $INITLOG)."
|
||||
fi
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
not_configured () {
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2000,2001,2002,2003,2004,2005,2006,2007 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Shorewall documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -22,7 +22,7 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
VERSION=4.4.2.2
|
||||
VERSION=4.4.8
|
||||
|
||||
usage() # $1 = exit status
|
||||
{
|
||||
@@ -219,6 +219,11 @@ mkdir -p ${PREFIX}/var/lib/shorewall6-lite
|
||||
chmod 755 ${PREFIX}/etc/shorewall6-lite
|
||||
chmod 755 ${PREFIX}/usr/share/shorewall6-lite
|
||||
|
||||
if [ -n "$PREFIX" ]; then
|
||||
mkdir -p ${PREFIX}/etc/logrotate.d
|
||||
chmod 755 ${PREFIX}/etc/logrotate.d
|
||||
fi
|
||||
|
||||
#
|
||||
# Install the config file
|
||||
#
|
||||
@@ -303,6 +308,11 @@ cd ..
|
||||
|
||||
echo "Man Pages Installed"
|
||||
|
||||
if [ -d ${PREFIX}/etc/logrotate.d ]; then
|
||||
run_install $OWNERSHIP -m 0644 logrotate ${PREFIX}/etc/logrotate.d/shorewall6-lite
|
||||
echo "Logrotate file installed as ${PREFIX}/etc/logrotate.d/shorewall6-lite"
|
||||
fi
|
||||
|
||||
#
|
||||
# Create the version file
|
||||
#
|
||||
|
5
Shorewall6-lite/logrotate
Normal file
5
Shorewall6-lite/logrotate
Normal file
@@ -0,0 +1,5 @@
|
||||
/var/log/shorewall6-init.log {
|
||||
missingok
|
||||
notifempty
|
||||
create 0600 root root
|
||||
}
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2006,2007 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# This file should be placed in /sbin/shorewall.
|
||||
#
|
||||
@@ -45,21 +45,22 @@
|
||||
# used during firewall compilation, then the generated firewall program will likewise not
|
||||
# require Shorewall to be installed.
|
||||
|
||||
SHAREDIR=/usr/share/shorewall-lite
|
||||
VARDIR=/var/lib/shorewall-lite
|
||||
CONFDIR=/etc/shorewall-lite
|
||||
PRODUCT="Shorewall Lite"
|
||||
SHAREDIR=/usr/share/shorewall6-lite
|
||||
VARDIR=/var/lib/shorewall6-lite
|
||||
CONFDIR=/etc/shorewall6-lite
|
||||
g_product="Shorewall Lite"
|
||||
|
||||
. /usr/share/shorewall-lite/lib.base
|
||||
. /usr/share/shorewall-lite/configpath
|
||||
. /usr/share/shorewall6-lite/lib.base
|
||||
. /usr/share/shorewall6-lite/lib.cli
|
||||
. /usr/share/shorewall6-lite/configpath
|
||||
|
||||
[ -n "$PATH" ] || PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
||||
|
||||
VERSION=$(cat /usr/share/shorewall-lite/version)
|
||||
SHOREWALL_VERSION=$(cat /usr/share/shorewall6-lite/version)
|
||||
|
||||
[ -n "$IPTABLES" ] || IPTABLES=$(mywhich iptables)
|
||||
[ -n "$IP6TABLES" ] || IP6TABLES=$(mywhich iptables)
|
||||
|
||||
VERBOSE=0
|
||||
VERBOSITY=0
|
||||
load_kernel_modules No
|
||||
determine_capabilities
|
||||
report_capabilities1
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2006 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# This file should be placed in /sbin/shorewall-lite.
|
||||
#
|
||||
@@ -95,7 +95,7 @@ get_config() {
|
||||
|
||||
if ( ps ax 2> /dev/null | grep -v grep | qt grep 'syslogd.*-C' ) ; then
|
||||
LOGREAD="logread | tac"
|
||||
elif [ -f $LOGFILE ]; then
|
||||
elif [ -r $LOGFILE ]; then
|
||||
LOGREAD="tac $LOGFILE"
|
||||
else
|
||||
echo "LOGFILE ($LOGFILE) does not exist!" >&2
|
||||
@@ -117,8 +117,6 @@ get_config() {
|
||||
|
||||
[ -n "$LOGFORMAT" ] || LOGFORMAT="Shorewall:"
|
||||
|
||||
export LOGFORMAT
|
||||
|
||||
if [ -n "$IP6TABLES" ]; then
|
||||
if [ ! -x "$IP6TABLES" ]; then
|
||||
echo " ERROR: The program specified in IP6TABLES does not exist or is not executable" >&2
|
||||
@@ -127,13 +125,11 @@ get_config() {
|
||||
else
|
||||
IP6TABLES=$(mywhich ip6tables 2> /dev/null)
|
||||
if [ -z "$IP6TABLES" ] ; then
|
||||
echo " ERROR: Can't find iptables executable" >&2
|
||||
echo " ERROR: Can't find ip6tables executable" >&2
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
export IP6TABLES
|
||||
|
||||
if [ -n "$SHOREWALL_SHELL" ]; then
|
||||
if [ ! -x "$SHOREWALL_SHELL" ]; then
|
||||
echo " WARNING: The program specified in SHOREWALL_SHELL does not exist or is not executable; falling back to /bin/sh" >&2
|
||||
@@ -145,29 +141,33 @@ get_config() {
|
||||
|
||||
validate_restorefile RESTOREFILE
|
||||
|
||||
export RESTOREFILE
|
||||
|
||||
[ -n "${VERBOSITY:=2}" ]
|
||||
|
||||
[ -n "$USE_VERBOSITY" ] && VERBOSE=$USE_VERBOSITY || VERBOSE=$(($VERBOSE_OFFSET + $VERBOSITY))
|
||||
[ -n "$g_use_verbosity" ] && VERBOSITY=$g_use_verbosity || VERBOSITY=$(($g_verbose_offset + $VERBOSITY))
|
||||
|
||||
export VERBOSE
|
||||
g_hostname=$(hostname 2> /dev/null)
|
||||
|
||||
[ -n "${HOSTNAME:=$(hostname)}" ]
|
||||
IP=$(mywhich ip 2> /dev/null)
|
||||
if [ -z "$IP" ] ; then
|
||||
echo " ERROR: Can't find ip executable" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
IPSET=ipset
|
||||
TC=tc
|
||||
}
|
||||
|
||||
#
|
||||
# Verify that we have a compiled firewall script
|
||||
#
|
||||
verify_firewall_script() {
|
||||
if [ ! -f $FIREWALL ]; then
|
||||
if [ ! -f $g_firewall ]; then
|
||||
echo " ERROR: Shorewall6 Lite is not properly installed" >&2
|
||||
if [ -L $FIREWALL ]; then
|
||||
echo " $FIREWALL is a symbolic link to a" >&2
|
||||
if [ -L $g_firewall ]; then
|
||||
echo " $g_firewall is a symbolic link to a" >&2
|
||||
echo " non-existant file" >&2
|
||||
else
|
||||
echo " The file $FIREWALL does not exist" >&2
|
||||
echo " The file $g_firewall does not exist" >&2
|
||||
fi
|
||||
|
||||
exit 2
|
||||
@@ -187,7 +187,7 @@ start_command() {
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
|
||||
if [ -x ${LITEDIR}/firewall ]; then
|
||||
${LITEDIR}/firewall $debugging start
|
||||
run_it ${LITEDIR}/firewall $debugging start
|
||||
rc=$?
|
||||
else
|
||||
error_message "${LITEDIR}/firewall is missing or is not executable"
|
||||
@@ -219,12 +219,12 @@ start_command() {
|
||||
option=
|
||||
;;
|
||||
f*)
|
||||
FAST=Yes
|
||||
g_fast=Yes
|
||||
option=${option#f}
|
||||
;;
|
||||
p*)
|
||||
[ -n "$(which conntrack)" ] || fatal_error "The '-p' option requires the conntrack utility which does not appear to be installed on this system"
|
||||
PURGE=Yes
|
||||
g_purge=Yes
|
||||
option=${option%p}
|
||||
;;
|
||||
*)
|
||||
@@ -244,40 +244,24 @@ start_command() {
|
||||
0)
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
usage 1 ;;
|
||||
esac
|
||||
|
||||
export NOROUTES
|
||||
|
||||
if [ -n "$FAST" ]; then
|
||||
if [ -n "$g_fast" ]; then
|
||||
if qt mywhich make; then
|
||||
#
|
||||
# RESTOREFILE is exported by get_config()
|
||||
#
|
||||
make -qf ${CONFDIR}/Makefile || FAST=
|
||||
export RESTOREFILE
|
||||
make -qf ${CONFDIR}/Makefile || g_fast=
|
||||
fi
|
||||
|
||||
if [ -n "$FAST" ]; then
|
||||
if [ -n "$g_fast" ]; then
|
||||
|
||||
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
||||
|
||||
if [ -x $RESTOREPATH ]; then
|
||||
if [ -x ${RESTOREPATH}-ipsets ]; then
|
||||
echo Restoring Ipsets...
|
||||
#
|
||||
# We must purge iptables to be sure that there are no
|
||||
# references to ipsets
|
||||
#
|
||||
iptables -F
|
||||
iptables -X
|
||||
$SHOREWALL_SHELL ${RESTOREPATH}-ipsets
|
||||
fi
|
||||
g_restorepath=${VARDIR}/$RESTOREFILE
|
||||
|
||||
if [ -x $g_restorepath ]; then
|
||||
echo Restoring Shorewall6 Lite...
|
||||
$SHOREWALL_SHELL $RESTOREPATH restore
|
||||
run_it $g_restorepath restore
|
||||
date > ${VARDIR}/restarted
|
||||
progress_message3 Shorewall6 Lite restored from $RESTOREPATH
|
||||
progress_message3 Shorewall6 Lite restored from $g_restorepath
|
||||
else
|
||||
do_it
|
||||
fi
|
||||
@@ -313,12 +297,12 @@ restart_command() {
|
||||
option=
|
||||
;;
|
||||
n*)
|
||||
NOROUTES=Yes
|
||||
g_noroutes=Yes
|
||||
option=${option#n}
|
||||
;;
|
||||
p*)
|
||||
[ -n "$(which conntrack)" ] || fatal_error "The '-p' option requires the conntrack utility which does not appear to be installed on this system"
|
||||
PURGE=Yes
|
||||
g_purge=Yes
|
||||
option=${option%p}
|
||||
;;
|
||||
*)
|
||||
@@ -342,12 +326,10 @@ restart_command() {
|
||||
;;
|
||||
esac
|
||||
|
||||
export NOROUTES
|
||||
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
|
||||
if [ -x ${LITEDIR}/firewall ]; then
|
||||
$SHOREWALL_SHELL ${LITEDIR}/firewall $debugging restart
|
||||
run_it ${LITEDIR}/firewall $debugging restart
|
||||
rc=$?
|
||||
else
|
||||
error_message "${LITEDIR}/firewall is missing or is not executable"
|
||||
@@ -367,28 +349,26 @@ usage() # $1 = exit status
|
||||
echo "Usage: $(basename $0) [debug|trace] [nolock] [ -q ] [ -v[-1|{0-2}] ] [ -t ] <command>"
|
||||
echo "where <command> is one of:"
|
||||
echo " allow <address> ..."
|
||||
echo " clear"
|
||||
echo " clear [ -f ]"
|
||||
echo " drop <address> ..."
|
||||
echo " dump [ -x ]"
|
||||
echo " forget [ <file name> ]"
|
||||
echo " help"
|
||||
echo " hits [ -t ]"
|
||||
echo " ipcalc { <address>/<vlsm> | <address> <netmask> }"
|
||||
echo " ipdecimal { <address> | <integer> }"
|
||||
echo " iprange <address>-<address>"
|
||||
echo " load [ -s ] [ -c ] [ -r <root user> ] [ <directory> ] <system>"
|
||||
echo " logdrop <address> ..."
|
||||
echo " logreject <address> ..."
|
||||
echo " logwatch [<refresh interval>]"
|
||||
echo " refresh [ <chain>... ]"
|
||||
echo " reject <address> ..."
|
||||
echo " reset"
|
||||
echo " restart [ -n ] [ -p ]"
|
||||
echo " reset [ <chain> ... ]"
|
||||
echo " restart [ -n ] [ -f ]"
|
||||
echo " restore [ -n ] [ <file name> ]"
|
||||
echo " save [ <file name> ]"
|
||||
echo " show [ -x ] [ -m ] [ -f ] [ -t {filter|mangle|nat} ] [ {chain [<chain> [ <chain> ... ]|capabilities|classifiers|config|connections|filters|ip|log|mangle|nat|routing|tc|vardir|zones} ]"
|
||||
echo " start [ -f ] [ -n ] [ -p ]"
|
||||
echo " stop"
|
||||
echo " show [ -x ] [ -m ] [-f] [ -t {filter|mangle} ] [ {chain [<chain> [ <chain> ... ]capabilities|classifiers|config|connections|filters|ip|log|macros|mangle|nat|policies|raw|routing|tc|vardir|zones} ]"
|
||||
echo " start [ -f ] [ <directory> ]"
|
||||
echo " stop [ -f ]"
|
||||
echo " status"
|
||||
echo " version"
|
||||
echo " version [ -a ]"
|
||||
echo
|
||||
exit $1
|
||||
}
|
||||
@@ -410,14 +390,14 @@ if [ $# -gt 0 ] && [ "$1" = "nolock" ]; then
|
||||
shift
|
||||
fi
|
||||
|
||||
IPT_OPTIONS="-nv"
|
||||
FAST=
|
||||
VERBOSE_OFFSET=0
|
||||
USE_VERBOSITY=
|
||||
NOROUTES=
|
||||
EXPORT=
|
||||
export TIMESTAMP=
|
||||
noroutes=
|
||||
g_ipt_options="-nv"
|
||||
g_fast=
|
||||
g_verbose_offset=0
|
||||
g_use_verbosity=
|
||||
g_noroutes=
|
||||
g_timestamp=
|
||||
g_recovering=
|
||||
g_purge=
|
||||
|
||||
finished=0
|
||||
|
||||
@@ -436,48 +416,48 @@ while [ $finished -eq 0 ]; do
|
||||
while [ -n "$option" ]; do
|
||||
case $option in
|
||||
x*)
|
||||
IPT_OPTIONS="-xnv"
|
||||
g_ipt_options="-xnv"
|
||||
option=${option#x}
|
||||
;;
|
||||
q*)
|
||||
VERBOSE_OFFSET=$(($VERBOSE_OFFSET - 1 ))
|
||||
g_verbose_offset=$(($g_verbose_offset - 1 ))
|
||||
option=${option#q}
|
||||
;;
|
||||
f*)
|
||||
FAST=Yes
|
||||
g_fast=Yes
|
||||
option=${option#f}
|
||||
;;
|
||||
v*)
|
||||
option=${option#v}
|
||||
case $option in
|
||||
-1*)
|
||||
USE_VERBOSITY=-1
|
||||
g_use_verbosity=-1
|
||||
option=${option#-1}
|
||||
;;
|
||||
0*)
|
||||
USE_VERBOSITY=0
|
||||
g_use_verbosity=0
|
||||
option=${option#0}
|
||||
;;
|
||||
1*)
|
||||
USE_VERBOSITY=1
|
||||
g_use_verbosity=1
|
||||
option=${option#1}
|
||||
;;
|
||||
2*)
|
||||
USE_VERBOSITY=2
|
||||
g_use_verbosity=2
|
||||
option=${option#2}
|
||||
;;
|
||||
*)
|
||||
VERBOSE_OFFSET=$(($VERBOSE_OFFSET + 1 ))
|
||||
USE_VERBOSITY=
|
||||
g_verbose_offset=$(($g_verbose_offset + 1 ))
|
||||
g_use_verbosity=
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
n*)
|
||||
NOROUTES=Yes
|
||||
g_noroutes=Yes
|
||||
option=${option#n}
|
||||
;;
|
||||
t*)
|
||||
TIMESTAMP=Yes
|
||||
g_timestamp=Yes
|
||||
option=${option#t}
|
||||
;;
|
||||
-)
|
||||
@@ -502,12 +482,11 @@ if [ $# -eq 0 ]; then
|
||||
fi
|
||||
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
||||
export PATH
|
||||
MUTEX_TIMEOUT=
|
||||
|
||||
SHAREDIR=/usr/share/shorewall6-lite
|
||||
CONFDIR=/etc/shorewall6-lite
|
||||
export PRODUCT="Shorewall6 Lite"
|
||||
g_product="Shorewall6 Lite"
|
||||
|
||||
[ -f ${CONFDIR}/vardir ] && . ${CONFDIR}/vardir ]
|
||||
|
||||
@@ -515,17 +494,10 @@ export PRODUCT="Shorewall6 Lite"
|
||||
|
||||
[ -d $VARDIR ] || mkdir -p $VARDIR || fatal_error "Unable to create $VARDIR"
|
||||
|
||||
LIBRARIES="$SHAREDIR/lib.base $SHAREDIR/lib.cli"
|
||||
VERSION_FILE=$SHAREDIR/version
|
||||
HELP=$SHAREDIR/help
|
||||
version_file=$SHAREDIR/version
|
||||
|
||||
for library in $LIBRARIES; do
|
||||
if [ -f $library ]; then
|
||||
. $library
|
||||
else
|
||||
echo "Installation error: $library does not exist!" >&2
|
||||
exit 2
|
||||
fi
|
||||
for library in base cli; do
|
||||
. ${SHAREDIR}/lib.$library
|
||||
done
|
||||
|
||||
ensure_config_path
|
||||
@@ -545,7 +517,6 @@ else
|
||||
fi
|
||||
|
||||
ensure_config_path
|
||||
export CONFIG_PATH
|
||||
|
||||
LITEDIR=${VARDIR}
|
||||
|
||||
@@ -553,17 +524,17 @@ LITEDIR=${VARDIR}
|
||||
|
||||
get_config
|
||||
|
||||
FIREWALL=$LITEDIR/firewall
|
||||
g_firewall=$LITEDIR/firewall
|
||||
|
||||
if [ -f $VERSION_FILE ]; then
|
||||
version=$(cat $VERSION_FILE)
|
||||
if [ -f $version_file ]; then
|
||||
SHOREWALL_VERSION=$(cat $version_file)
|
||||
else
|
||||
echo " ERROR: Shorewall6 Lite is not properly installed" >&2
|
||||
echo " The file $VERSION_FILE does not exist" >&2
|
||||
echo " The file $SHOREWALL_VERSION_FILE does not exist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
banner="Shorewall6 Lite $version Status at $HOSTNAME -"
|
||||
banner="Shorewall6 Lite $SHOREWALL_VERSION Status at $g_hostname -"
|
||||
|
||||
case $(echo -e) in
|
||||
-e*)
|
||||
@@ -595,8 +566,7 @@ case "$COMMAND" in
|
||||
stop|reset|clear)
|
||||
[ $# -ne 1 ] && usage 1
|
||||
verify_firewall_script
|
||||
export NOROUTES
|
||||
exec $SHOREWALL_SHELL $FIREWALL $debugging $nolock $COMMAND
|
||||
run_it $g_firewall $debugging $nolock $COMMAND
|
||||
;;
|
||||
restart)
|
||||
shift
|
||||
@@ -609,7 +579,7 @@ case "$COMMAND" in
|
||||
status)
|
||||
[ $# -eq 1 ] || usage 1
|
||||
[ "$(id -u)" != 0 ] && fatal_error "ERROR: The status command may only be run by root"
|
||||
echo "Shorewall6 Lite $version Status at $HOSTNAME - $(date)"
|
||||
echo "Shorewall6 Lite $SHOREWALL_VERSION Status at $g_hostname - $(date)"
|
||||
echo
|
||||
if shorewall6_is_started ; then
|
||||
echo "Shorewall6 Lite is running"
|
||||
@@ -643,7 +613,7 @@ case "$COMMAND" in
|
||||
hits_command $@
|
||||
;;
|
||||
version)
|
||||
echo $version Lite
|
||||
echo $SHOREWALL_VERSION Lite
|
||||
;;
|
||||
logwatch)
|
||||
logwatch_command $@
|
||||
@@ -702,7 +672,7 @@ case "$COMMAND" in
|
||||
;;
|
||||
esac
|
||||
|
||||
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
||||
g_restorepath=${VARDIR}/$RESTOREFILE
|
||||
|
||||
[ "$nolock" ] || mutex_on
|
||||
|
||||
@@ -724,20 +694,20 @@ case "$COMMAND" in
|
||||
esac
|
||||
|
||||
|
||||
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
||||
g_restorepath=${VARDIR}/$RESTOREFILE
|
||||
|
||||
if [ -x $RESTOREPATH ]; then
|
||||
if [ -x $g_restorepath ]; then
|
||||
|
||||
if [ -x ${RESTOREPATH}-ipsets ]; then
|
||||
rm -f ${RESTOREPATH}-ipsets
|
||||
echo " ${RESTOREPATH}-ipsets removed"
|
||||
if [ -x ${g_restorepath}-ipsets ]; then
|
||||
rm -f ${g_restorepath}-ipsets
|
||||
echo " ${g_restorepath}-ipsets removed"
|
||||
fi
|
||||
|
||||
rm -f $RESTOREPATH
|
||||
rm -f ${RESTOREPATH}-iptables
|
||||
echo " $RESTOREPATH removed"
|
||||
elif [ -f $RESTOREPATH ]; then
|
||||
echo " $RESTOREPATH exists and is not a saved Shorewall6 configuration"
|
||||
rm -f $g_restorepath
|
||||
rm -f ${g_restorepath}-iptables
|
||||
echo " $g_restorepath removed"
|
||||
elif [ -f $g_restorepath ]; then
|
||||
echo " $g_restorepath exists and is not a saved Shorewall6 configuration"
|
||||
fi
|
||||
rm -f ${VARDIR}/save
|
||||
;;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
%define name shorewall6-lite
|
||||
%define version 4.4.2
|
||||
%define release 2
|
||||
%define version 4.4.8
|
||||
%define release 0base
|
||||
|
||||
Summary: Shoreline Firewall 6 Lite is an ip6tables-based firewall for Linux systems.
|
||||
Name: %{name}
|
||||
@@ -70,6 +70,8 @@ fi
|
||||
%attr(0755,root,root) %dir /usr/share/shorewall6-lite
|
||||
%attr(0700,root,root) %dir /var/lib/shorewall6-lite
|
||||
|
||||
%attr(0644,root,root) /etc/logrotate.d/shorewall6-lite
|
||||
|
||||
%attr(0755,root,root) /sbin/shorewall6-lite
|
||||
|
||||
%attr(0644,root,root) /usr/share/shorewall6-lite/version
|
||||
@@ -77,6 +79,7 @@ fi
|
||||
%attr(- ,root,root) /usr/share/shorewall6-lite/functions
|
||||
%attr(0644,root,root) /usr/share/shorewall6-lite/lib.base
|
||||
%attr(0644,root,root) /usr/share/shorewall6-lite/lib.cli
|
||||
%attr(0644,root,root) /usr/share/shorewall6-lite/lib.common
|
||||
%attr(0644,root,root) /usr/share/shorewall6-lite/modules
|
||||
%attr(0544,root,root) /usr/share/shorewall6-lite/shorecap
|
||||
%attr(0755,root,root) /usr/share/shorewall6-lite/wait4ifup
|
||||
@@ -89,10 +92,44 @@ fi
|
||||
%doc COPYING changelog.txt releasenotes.txt
|
||||
|
||||
%changelog
|
||||
* Sat Oct 03 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.2-2
|
||||
* Fri Oct 02 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.2-1
|
||||
* Fri Mar 19 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0base
|
||||
* Tue Mar 16 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0RC2
|
||||
* Mon Mar 08 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0RC1
|
||||
* Sun Feb 28 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0Beta2
|
||||
* Thu Feb 11 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.8-0Beta1
|
||||
* Fri Feb 05 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0base
|
||||
* Tue Feb 02 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0RC2
|
||||
* Wed Jan 27 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0RC1
|
||||
* Mon Jan 25 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0Beta4
|
||||
* Fri Jan 22 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0Beta3
|
||||
* Fri Jan 22 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0Beta2
|
||||
* Sun Jan 17 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.7-0Beta1
|
||||
* Wed Jan 13 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.6-0base
|
||||
* Tue Jan 12 2010 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.6-0Beta1
|
||||
* Thu Dec 24 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.5-0base
|
||||
* Sat Nov 21 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.4-0base
|
||||
* Fri Nov 13 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.4-0Beta2
|
||||
* Wed Nov 11 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.4-0Beta1
|
||||
* Tue Nov 03 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.3-0base
|
||||
* Sun Sep 06 2009 Tom Eastep tom@shorewall.net
|
||||
- Updated to 4.4.2-0base
|
||||
* Fri Sep 04 2009 Tom Eastep tom@shorewall.net
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2000,2001,2002,2003,2004,2005,2006,2007 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Shorewall documentation is available at http://shorewall.sourceforge.net
|
||||
#
|
||||
@@ -26,7 +26,7 @@
|
||||
# You may only use this script to uninstall the version
|
||||
# shown below. Simply run this script to remove Shorewall Firewall
|
||||
|
||||
VERSION=4.4.2.2
|
||||
VERSION=4.4.8
|
||||
|
||||
usage() # $1 = exit status
|
||||
{
|
||||
@@ -94,6 +94,7 @@ rm -rf /var/lib/shorewall6-lite
|
||||
rm -rf /var/lib/shorewall6-lite-*.bkout
|
||||
rm -rf /usr/share/shorewall6-lite
|
||||
rm -rf /usr/share/shorewall6-lite-*.bkout
|
||||
rm -f /etc/logrotate.d/shorewall6-lite
|
||||
|
||||
echo "Shorewall6 Lite Uninstalled"
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
This is the Shorewall6 development 4.3 branch of SVN.
|
||||
This is the Shorewall6 stable 4.4 branch of Git.
|
||||
|
@@ -22,7 +22,7 @@
|
||||
#
|
||||
# Reject 'auth'
|
||||
#
|
||||
Auth/REJECT
|
||||
Auth(REJECT)
|
||||
#
|
||||
# ACCEPT critical ICMP types
|
||||
#
|
||||
@@ -35,7 +35,7 @@ dropInvalid
|
||||
#
|
||||
# Drop Microsoft noise so that it doesn't clutter up the log.
|
||||
#
|
||||
SMB/DROP
|
||||
SMB(DROP)
|
||||
#
|
||||
# Drop 'newnotsyn' traffic so that it doesn't get logged.
|
||||
#
|
||||
|
@@ -18,7 +18,7 @@
|
||||
#
|
||||
# Don't log 'auth' -- REJECT
|
||||
#
|
||||
Auth/REJECT
|
||||
Auth(REJECT)
|
||||
#
|
||||
# ACCEPT critical ICMP types
|
||||
#
|
||||
@@ -32,7 +32,7 @@ dropInvalid
|
||||
#
|
||||
# Reject Microsoft noise so that it doesn't clutter up the log.
|
||||
#
|
||||
SMB/REJECT
|
||||
SMB(REJECT)
|
||||
#
|
||||
# Drop 'newnotsyn' traffic so that it doesn't get logged.
|
||||
#
|
||||
|
@@ -28,7 +28,7 @@
|
||||
# shown below. Simply run this script to revert to your prior version of
|
||||
# Shoreline Firewall.
|
||||
|
||||
VERSION=4.4.2.2
|
||||
VERSION=4.4.8
|
||||
|
||||
usage() # $1 = exit status
|
||||
{
|
||||
|
36
Shorewall6/helpers
Normal file
36
Shorewall6/helpers
Normal file
@@ -0,0 +1,36 @@
|
||||
#
|
||||
# Shorewall6 version 4 - Helpers File
|
||||
#
|
||||
# /usr/share/shorewall6/helpers
|
||||
#
|
||||
# This file loads the modules that may be needed by the firewall.
|
||||
#
|
||||
# THE ORDER OF THE COMMANDS BELOW IS IMPORTANT!!!!!! You MUST load in
|
||||
# dependency order. i.e., if M2 depends on M1 then you must load M1
|
||||
# before you load M2.
|
||||
#
|
||||
# If you need to modify this file, copy it to /etc/shorewall and modify the
|
||||
# copy.
|
||||
#
|
||||
###############################################################################
|
||||
#
|
||||
# Helpers
|
||||
#
|
||||
loadmodule nf_conntrack_amanda
|
||||
loadmodule nf_conntrack_ftp
|
||||
loadmodule nf_conntrack_h323
|
||||
loadmodule nf_conntrack_irc
|
||||
loadmodule nf_conntrack_netbios_ns
|
||||
loadmodule nf_conntrack_netbios_ns
|
||||
loadmodule nf_conntrack_netlink
|
||||
loadmodule nf_conntrack_pptp
|
||||
loadmodule nf_conntrack_proto_sctp
|
||||
loadmodule nf_conntrack_proto_udplite
|
||||
loadmodule nf_conntrack_sane
|
||||
loadmodule nf_conntrack_sip sip_direct_media=0
|
||||
loadmodule nf_conntrack_pptp
|
||||
loadmodule nf_conntrack_proto_gre
|
||||
loadmodule nf_conntrack_proto_sctp
|
||||
loadmodule nf_conntrack_sip
|
||||
loadmodule nf_conntrack_tftp
|
||||
loadmodule nf_conntrack_sane
|
@@ -1,8 +1,8 @@
|
||||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: shorewall6
|
||||
# Required-Start: $network
|
||||
# Required-Stop: $network
|
||||
# Required-Start: $network $remote_fs
|
||||
# Required-Stop: $network $remote_fs
|
||||
# Default-Start: S
|
||||
# Default-Stop: 0 6
|
||||
# Short-Description: Configure the firewall at boot time
|
||||
@@ -15,13 +15,11 @@
|
||||
SRWL=/sbin/shorewall6
|
||||
SRWL_OPTS="-tvv"
|
||||
WAIT_FOR_IFUP=/usr/share/shorewall6/wait4ifup
|
||||
# Note, set INITLOG to /dev/null if you do not want to
|
||||
# keep logs of the firewall (not recommended)
|
||||
INITLOG=/var/log/shorewall6-init.log
|
||||
test -n ${INITLOG:=/var/log/shorewall6-init.log}
|
||||
|
||||
test -x $SRWL || exit 0
|
||||
test -x $WAIT_FOR_IFUP || exit 0
|
||||
test -n $INITLOG || {
|
||||
test -n "$INITLOG" || {
|
||||
echo "INITLOG cannot be empty, please configure $0" ;
|
||||
exit 1;
|
||||
}
|
||||
@@ -40,6 +38,7 @@ echo_notdone () {
|
||||
echo "not done (check $INITLOG)."
|
||||
fi
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
not_configured () {
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2000,2001,2002,2003,2004,2005,2008 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 2000,2001,2002,2003,2004,2005,2008,2009,2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Shorewall documentation is available at http://shorewall.net
|
||||
#
|
||||
@@ -22,7 +22,7 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
VERSION=4.4.2.2
|
||||
VERSION=4.4.8
|
||||
|
||||
usage() # $1 = exit status
|
||||
{
|
||||
@@ -110,6 +110,7 @@ fi
|
||||
DEBIAN=
|
||||
CYGWIN=
|
||||
MANDIR=${MANDIR:-"/usr/share/man"}
|
||||
SPARSE=
|
||||
|
||||
case $(uname) in
|
||||
CYGWIN*)
|
||||
@@ -121,6 +122,7 @@ case $(uname) in
|
||||
OWNER=$(id -un)
|
||||
GROUP=$(id -gn)
|
||||
CYGWIN=Yes
|
||||
SPARSE=Yes
|
||||
;;
|
||||
*)
|
||||
[ -z "$OWNER" ] && OWNER=root
|
||||
@@ -139,6 +141,9 @@ while [ $# -gt 0 ] ; do
|
||||
echo "Shorewall6 Firewall Installer Version $VERSION"
|
||||
exit 0
|
||||
;;
|
||||
-s)
|
||||
SPARSE=Yes
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@@ -168,14 +173,20 @@ if [ -n "$PREFIX" ]; then
|
||||
else
|
||||
[ -x /usr/share/shorewall/compiler.pl ] || \
|
||||
{ echo " ERROR: Shorewall >= 4.3.5 is not installed" >&2; exit 1; }
|
||||
if [ -z "$CYGWIN" ]; then
|
||||
if [ -n "$CYGWIN" ]; then
|
||||
echo "Installing Cygwin-specific configuration..."
|
||||
else
|
||||
if [ -d /etc/apt -a -e /usr/bin/dpkg ]; then
|
||||
echo "Installing Debian-specific configuration..."
|
||||
DEBIAN=yes
|
||||
SPARSE=yes
|
||||
elif [ -f /etc/slackware-version ] ; then
|
||||
echo "Installing Slackware-specific configuration..."
|
||||
DEST="/etc/rc.d"
|
||||
SLACKWARE=yes
|
||||
INIT="rc.firewall"
|
||||
elif [ -f /etc/arch-release ] ; then
|
||||
echo "Installing ArchLinux-specific configuration..."
|
||||
DEST="/etc/rc.d"
|
||||
INIT="shorewall6"
|
||||
ARCHLINUX=yes
|
||||
@@ -234,6 +245,12 @@ mkdir -p ${PREFIX}/var/lib/shorewall6
|
||||
chmod 755 ${PREFIX}/etc/shorewall6
|
||||
chmod 755 ${PREFIX}/usr/share/shorewall6
|
||||
chmod 755 ${PREFIX}/usr/share/shorewall6/configfiles
|
||||
|
||||
if [ -n "$PREFIX" ]; then
|
||||
mkdir -p ${PREFIX}/etc/logrotate.d
|
||||
chmod 755 ${PREFIX}/etc/logrotate.d
|
||||
fi
|
||||
|
||||
#
|
||||
# Install the config file
|
||||
#
|
||||
@@ -255,7 +272,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 zones ${PREFIX}/usr/share/shorewall6/configfiles/zones
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/zones ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/zones ]; then
|
||||
run_install $OWNERSHIP -m 0744 zones ${PREFIX}/etc/shorewall6/zones
|
||||
echo "Zones file installed as ${PREFIX}/etc/shorewall6/zones"
|
||||
fi
|
||||
@@ -288,7 +305,7 @@ echo "wait4ifup installed in ${PREFIX}/usr/share/shorewall6/wait4ifup"
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 policy ${PREFIX}/usr/share/shorewall6/configfiles/policy
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/policy ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/policy ]; then
|
||||
run_install $OWNERSHIP -m 0600 policy ${PREFIX}/etc/shorewall6/policy
|
||||
echo "Policy file installed as ${PREFIX}/etc/shorewall6/policy"
|
||||
fi
|
||||
@@ -297,7 +314,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 interfaces ${PREFIX}/usr/share/shorewall6/configfiles/interfaces
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/interfaces ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/interfaces ]; then
|
||||
run_install $OWNERSHIP -m 0600 interfaces ${PREFIX}/etc/shorewall6/interfaces
|
||||
echo "Interfaces file installed as ${PREFIX}/etc/shorewall6/interfaces"
|
||||
fi
|
||||
@@ -307,7 +324,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 hosts ${PREFIX}/usr/share/shorewall6/configfiles/hosts
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/hosts ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/hosts ]; then
|
||||
run_install $OWNERSHIP -m 0600 hosts ${PREFIX}/etc/shorewall6/hosts
|
||||
echo "Hosts file installed as ${PREFIX}/etc/shorewall6/hosts"
|
||||
fi
|
||||
@@ -316,7 +333,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 rules ${PREFIX}/usr/share/shorewall6/configfiles/rules
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/rules ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/rules ]; then
|
||||
run_install $OWNERSHIP -m 0600 rules ${PREFIX}/etc/shorewall6/rules
|
||||
echo "Rules file installed as ${PREFIX}/etc/shorewall6/rules"
|
||||
fi
|
||||
@@ -336,7 +353,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 routestopped ${PREFIX}/usr/share/shorewall6/configfiles/routestopped
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/routestopped ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/routestopped ]; then
|
||||
run_install $OWNERSHIP -m 0600 routestopped ${PREFIX}/etc/shorewall6/routestopped
|
||||
echo "Stopped Routing file installed as ${PREFIX}/etc/shorewall6/routestopped"
|
||||
fi
|
||||
@@ -345,7 +362,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 maclist ${PREFIX}/usr/share/shorewall6/configfiles/maclist
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/maclist ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/maclist ]; then
|
||||
run_install $OWNERSHIP -m 0600 maclist ${PREFIX}/etc/shorewall6/maclist
|
||||
echo "MAC list file installed as ${PREFIX}/etc/shorewall6/maclist"
|
||||
fi
|
||||
@@ -355,22 +372,48 @@ fi
|
||||
run_install $OWNERSHIP -m 0600 modules ${PREFIX}/usr/share/shorewall6/modules
|
||||
echo "Modules file installed as ${PREFIX}/usr/share/shorewall6/modules"
|
||||
|
||||
#
|
||||
# Install the Module Helpers file
|
||||
#
|
||||
run_install $OWNERSHIP -m 0600 helpers ${PREFIX}/usr/share/shorewall6/helpers
|
||||
echo "Helper modules file installed as ${PREFIX}/usr/share/shorewall6/helpers"
|
||||
|
||||
#
|
||||
# Install the TC Rules file
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 tcrules ${PREFIX}/usr/share/shorewall6/configfiles/tcrules
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/tcrules ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/tcrules ]; then
|
||||
run_install $OWNERSHIP -m 0600 tcrules ${PREFIX}/etc/shorewall6/tcrules
|
||||
echo "TC Rules file installed as ${PREFIX}/etc/shorewall6/tcrules"
|
||||
fi
|
||||
|
||||
#
|
||||
# Install the TC Interfaces file
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 tcinterfaces ${PREFIX}/usr/share/shorewall6/configfiles/tcinterfaces
|
||||
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/tcinterfaces ]; then
|
||||
run_install $OWNERSHIP -m 0600 tcinterfaces ${PREFIX}/etc/shorewall6/tcinterfaces
|
||||
echo "TC Interfaces file installed as ${PREFIX}/etc/shorewall6/tcinterfaces"
|
||||
fi
|
||||
|
||||
#
|
||||
# Install the TC Priority file
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 tcpri ${PREFIX}/usr/share/shorewall6/configfiles/tcpri
|
||||
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/tcpri ]; then
|
||||
run_install $OWNERSHIP -m 0600 tcpri ${PREFIX}/etc/shorewall6/tcpri
|
||||
echo "TC Priority file installed as ${PREFIX}/etc/shorewall6/tcpri"
|
||||
fi
|
||||
|
||||
#
|
||||
# Install the TOS file
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 tos ${PREFIX}/usr/share/shorewall6/configfiles/tos
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/tos ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/tos ]; then
|
||||
run_install $OWNERSHIP -m 0600 tos ${PREFIX}/etc/shorewall6/tos
|
||||
echo "TOS file installed as ${PREFIX}/etc/shorewall6/tos"
|
||||
fi
|
||||
@@ -379,7 +422,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 tunnels ${PREFIX}/usr/share/shorewall6/configfiles/tunnels
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/tunnels ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/tunnels ]; then
|
||||
run_install $OWNERSHIP -m 0600 tunnels ${PREFIX}/etc/shorewall6/tunnels
|
||||
echo "Tunnels file installed as ${PREFIX}/etc/shorewall6/tunnels"
|
||||
fi
|
||||
@@ -388,7 +431,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 blacklist ${PREFIX}/usr/share/shorewall6/configfiles/blacklist
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/blacklist ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/blacklist ]; then
|
||||
run_install $OWNERSHIP -m 0600 blacklist ${PREFIX}/etc/shorewall6/blacklist
|
||||
echo "Blacklist file installed as ${PREFIX}/etc/shorewall6/blacklist"
|
||||
fi
|
||||
@@ -397,7 +440,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 providers ${PREFIX}/usr/share/shorewall6/configfiles/providers
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/providers ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/providers ]; then
|
||||
run_install $OWNERSHIP -m 0600 providers ${PREFIX}/etc/shorewall6/providers
|
||||
echo "Providers file installed as ${PREFIX}/etc/shorewall6/providers"
|
||||
fi
|
||||
@@ -407,7 +450,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 route_rules ${PREFIX}/usr/share/shorewall6/configfiles/route_rules
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/route_rules ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/route_rules ]; then
|
||||
run_install $OWNERSHIP -m 0600 route_rules ${PREFIX}/etc/shorewall6/route_rules
|
||||
echo "Routing rules file installed as ${PREFIX}/etc/shorewall6/route_rules"
|
||||
fi
|
||||
@@ -417,7 +460,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 tcclasses ${PREFIX}/usr/share/shorewall6/configfiles/tcclasses
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/tcclasses ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/tcclasses ]; then
|
||||
run_install $OWNERSHIP -m 0600 tcclasses ${PREFIX}/etc/shorewall6/tcclasses
|
||||
echo "TC Classes file installed as ${PREFIX}/etc/shorewall6/tcclasses"
|
||||
fi
|
||||
@@ -427,7 +470,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 tcdevices ${PREFIX}/usr/share/shorewall6/configfiles/tcdevices
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/tcdevices ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/tcdevices ]; then
|
||||
run_install $OWNERSHIP -m 0600 tcdevices ${PREFIX}/etc/shorewall6/tcdevices
|
||||
echo "TC Devices file installed as ${PREFIX}/etc/shorewall6/tcdevices"
|
||||
fi
|
||||
@@ -437,7 +480,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 notrack ${PREFIX}/usr/share/shorewall6/configfiles/notrack
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/notrack ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/notrack ]; then
|
||||
run_install $OWNERSHIP -m 0600 notrack ${PREFIX}/etc/shorewall6/notrack
|
||||
echo "Notrack file installed as ${PREFIX}/etc/shorewall6/notrack"
|
||||
fi
|
||||
@@ -451,7 +494,7 @@ echo "Default config path file installed as ${PREFIX}/usr/share/shorewall6/confi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 init ${PREFIX}/usr/share/shorewall6/configfiles/init
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/init ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/init ]; then
|
||||
run_install $OWNERSHIP -m 0600 init ${PREFIX}/etc/shorewall6/init
|
||||
echo "Init file installed as ${PREFIX}/etc/shorewall6/init"
|
||||
fi
|
||||
@@ -460,7 +503,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 start ${PREFIX}/usr/share/shorewall6/configfiles/start
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/start ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/start ]; then
|
||||
run_install $OWNERSHIP -m 0600 start ${PREFIX}/etc/shorewall6/start
|
||||
echo "Start file installed as ${PREFIX}/etc/shorewall6/start"
|
||||
fi
|
||||
@@ -469,7 +512,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 stop ${PREFIX}/usr/share/shorewall6/configfiles/stop
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/stop ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/stop ]; then
|
||||
run_install $OWNERSHIP -m 0600 stop ${PREFIX}/etc/shorewall6/stop
|
||||
echo "Stop file installed as ${PREFIX}/etc/shorewall6/stop"
|
||||
fi
|
||||
@@ -478,7 +521,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 stopped ${PREFIX}/usr/share/shorewall6/configfiles/stopped
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/stopped ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/stopped ]; then
|
||||
run_install $OWNERSHIP -m 0600 stopped ${PREFIX}/etc/shorewall6/stopped
|
||||
echo "Stopped file installed as ${PREFIX}/etc/shorewall6/stopped"
|
||||
fi
|
||||
@@ -487,7 +530,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 accounting ${PREFIX}/usr/share/shorewall6/configfiles/accounting
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/accounting ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/accounting ]; then
|
||||
run_install $OWNERSHIP -m 0600 accounting ${PREFIX}/etc/shorewall6/accounting
|
||||
echo "Accounting file installed as ${PREFIX}/etc/shorewall6/accounting"
|
||||
fi
|
||||
@@ -496,7 +539,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 started ${PREFIX}/usr/share/shorewall6/configfiles/started
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/started ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/started ]; then
|
||||
run_install $OWNERSHIP -m 0600 started ${PREFIX}/etc/shorewall6/started
|
||||
echo "Started file installed as ${PREFIX}/etc/shorewall6/started"
|
||||
fi
|
||||
@@ -505,7 +548,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 restored ${PREFIX}/usr/share/shorewall6/configfiles/restored
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/restored ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/restored ]; then
|
||||
run_install $OWNERSHIP -m 0600 restored ${PREFIX}/etc/shorewall6/restored
|
||||
echo "Restored file installed as ${PREFIX}/etc/shorewall6/restored"
|
||||
fi
|
||||
@@ -514,7 +557,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 clear ${PREFIX}/usr/share/shorewall6/configfiles/clear
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/clear ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/clear ]; then
|
||||
run_install $OWNERSHIP -m 0600 clear ${PREFIX}/etc/shorewall6/clear
|
||||
echo "Clear file installed as ${PREFIX}/etc/shorewall6/clear"
|
||||
fi
|
||||
@@ -523,7 +566,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 isusable ${PREFIX}/usr/share/shorewall6/configfiles/isusable
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/isusable ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/isusable ]; then
|
||||
run_install $OWNERSHIP -m 0600 isusable ${PREFIX}/etc/shorewall6/isusable
|
||||
echo "Isusable file installed as ${PREFIX}/etc/shorewall/isusable"
|
||||
fi
|
||||
@@ -532,7 +575,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 refresh ${PREFIX}/usr/share/shorewall6/configfiles/refresh
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/refresh ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/refresh ]; then
|
||||
run_install $OWNERSHIP -m 0600 refresh ${PREFIX}/etc/shorewall6/refresh
|
||||
echo "Refresh file installed as ${PREFIX}/etc/shorewall6/refresh"
|
||||
fi
|
||||
@@ -541,7 +584,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 refreshed ${PREFIX}/usr/share/shorewall6/configfiles/refreshed
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/refreshed ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/refreshed ]; then
|
||||
run_install $OWNERSHIP -m 0600 refreshed ${PREFIX}/etc/shorewall6/refreshed
|
||||
echo "Refreshed file installed as ${PREFIX}/etc/shorewall6/refreshed"
|
||||
fi
|
||||
@@ -550,7 +593,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 tcclear ${PREFIX}/usr/share/shorewall6/configfiles/tcclear
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/tcclear ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/tcclear ]; then
|
||||
run_install $OWNERSHIP -m 0600 tcclear ${PREFIX}/etc/shorewall6/tcclear
|
||||
echo "Tcclear file installed as ${PREFIX}/etc/shorewall6/tcclear"
|
||||
fi
|
||||
@@ -565,7 +608,7 @@ echo "Standard actions file installed as ${PREFIX}/usr/shared/shorewall6/actions
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 actions ${PREFIX}/usr/share/shorewall6/configfiles/actions
|
||||
|
||||
if [ -z "$CYGWIN" -a ! -f ${PREFIX}/etc/shorewall6/actions ]; then
|
||||
if [ -z "$SPARSE" -a ! -f ${PREFIX}/etc/shorewall6/actions ]; then
|
||||
run_install $OWNERSHIP -m 0644 actions ${PREFIX}/etc/shorewall6/actions
|
||||
echo "Actions file installed as ${PREFIX}/etc/shorewall6/actions"
|
||||
fi
|
||||
@@ -575,7 +618,7 @@ fi
|
||||
#
|
||||
run_install $OWNERSHIP -m 0644 Makefile-lite ${PREFIX}/usr/share/shorewall6/configfiles/Makefile
|
||||
|
||||
if [ -z "$CYGWIN" ]; then
|
||||
if [ -z "$SPARSE" ]; then
|
||||
run_install $OWNERSHIP -m 0600 Makefile ${PREFIX}/etc/shorewall6/Makefile
|
||||
echo "Makefile installed as ${PREFIX}/etc/shorewall6/Makefile"
|
||||
fi
|
||||
@@ -642,6 +685,11 @@ cd ..
|
||||
|
||||
echo "Man Pages Installed"
|
||||
|
||||
if [ -d ${PREFIX}/etc/logrotate.d ]; then
|
||||
run_install $OWNERSHIP -m 0644 logrotate ${PREFIX}/etc/logrotate.d/shorewall6
|
||||
echo "Logrotate file installed as ${PREFIX}/etc/logrotate.d/shorewall6"
|
||||
fi
|
||||
|
||||
if [ -z "$PREFIX" -a -n "$first_install" -a -z "$CYGWIN" ]; then
|
||||
if [ -n "$DEBIAN" ]; then
|
||||
run_install $OWNERSHIP -m 0644 default.debian /etc/default/shorewall6
|
||||
@@ -649,7 +697,7 @@ if [ -z "$PREFIX" -a -n "$first_install" -a -z "$CYGWIN" ]; then
|
||||
echo "shorewall6 will start automatically at boot"
|
||||
echo "Set startup=1 in /etc/default/shorewall6 to enable"
|
||||
touch /var/log/shorewall6-init.log
|
||||
qt mywhich perl && perl -p -w -i -e 's/^STARTUP_ENABLED=No/STARTUP_ENABLED=Yes/;s/^IP_FORWARDING=On/IP_FORWARDING=Keep/;s/^SUBSYSLOCK=.*/SUBSYSLOCK=/;' /etc/shorewall6/shorewall6.conf
|
||||
perl -p -w -i -e 's/^STARTUP_ENABLED=No/STARTUP_ENABLED=Yes/;s/^IP_FORWARDING=On/IP_FORWARDING=Keep/;s/^SUBSYSLOCK=.*/SUBSYSLOCK=/;' /etc/shorewall6/shorewall6.conf
|
||||
else
|
||||
if [ -x /sbin/insserv -o -x /usr/sbin/insserv ]; then
|
||||
if insserv /etc/init.d/shorewall6 ; then
|
||||
@@ -682,4 +730,4 @@ fi
|
||||
#
|
||||
# Report Success
|
||||
#
|
||||
echo "shorewall6-common Version $VERSION Installed"
|
||||
echo "shorewall6 Version $VERSION Installed"
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -34,6 +34,7 @@ fatal_error() # $@ = Message
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Display a chain if it exists
|
||||
#
|
||||
|
||||
@@ -132,10 +133,10 @@ syslog_circular_buffer() {
|
||||
#
|
||||
packet_log() # $1 = number of messages
|
||||
{
|
||||
if [ -n "$SHOWMACS" -o $VERBOSE -gt 2 ]; then
|
||||
$LOGREAD | grep 'IN=.* OUT=.*SRC=.*:.*DST=' | head -n$1 | tac | sed 's/ kernel://; s/\[.*\] //' | sed s/" $host $LOGFORMAT"/" "/
|
||||
if [ -n "$g_showmacs" -o $VERBOSITY -gt 2 ]; then
|
||||
$g_logread | grep 'IN=.* OUT=.*SRC=.*:.*DST=' | head -n$1 | tac | sed 's/ kernel://; s/\[.*\] //' | sed s/" $host $LOGFORMAT"/" "/
|
||||
else
|
||||
$LOGREAD | grep 'IN=.* OUT=.*SRC=.*:.*DST=' | head -n$1 | tac | sed 's/ kernel://; s/MAC=.* SRC=/SRC=/; s/\[.*\] '// | sed s/" $host $LOGFORMAT"/" "/
|
||||
$g_logread | grep 'IN=.* OUT=.*SRC=.*:.*DST=' | head -n$1 | tac | sed 's/ kernel://; s/MAC=.* SRC=/SRC=/; s/\[.*\] '// | sed s/" $host $LOGFORMAT"/" "/
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -158,9 +159,13 @@ show_tc() {
|
||||
fi
|
||||
}
|
||||
|
||||
ip -o link list | while read inx interface details; do
|
||||
show_one_tc ${interface%:}
|
||||
done
|
||||
if [ $# -gt 0 ]; then
|
||||
show_one_tc $1
|
||||
else
|
||||
ip -o link list | while read inx interface details; do
|
||||
show_one_tc ${interface%:}
|
||||
done
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
@@ -194,7 +199,7 @@ logwatch() # $1 = timeout -- if negative, prompt each time that
|
||||
# an 'interesting' packet count changes
|
||||
{
|
||||
|
||||
host=$(echo $HOSTNAME | sed 's/\..*$//')
|
||||
host=$(echo $g_hostname | sed 's/\..*$//')
|
||||
oldrejects=$($IP6TABLES -L -v -n | grep 'LOG')
|
||||
|
||||
if [ $1 -lt 0 ]; then
|
||||
@@ -222,13 +227,13 @@ logwatch() # $1 = timeout -- if negative, prompt each time that
|
||||
if [ "$rejects" != "$oldrejects" ]; then
|
||||
oldrejects="$rejects"
|
||||
|
||||
$RING_BELL
|
||||
$g_ring_bell
|
||||
|
||||
packet_log 40
|
||||
|
||||
if [ "$pause" = "Yes" ]; then
|
||||
echo
|
||||
echo $ECHO_N 'Enter any character to continue: '
|
||||
echo $g_echo_n 'Enter any character to continue: '
|
||||
read foo
|
||||
else
|
||||
timed_read
|
||||
@@ -244,6 +249,30 @@ logwatch() # $1 = timeout -- if negative, prompt each time that
|
||||
#
|
||||
# Save currently running configuration
|
||||
#
|
||||
do_save() {
|
||||
local status
|
||||
status=0
|
||||
|
||||
if [ -f ${VARDIR}/firewall ]; then
|
||||
if $iptables_save > ${VARDIR}/restore-$$; then
|
||||
cp -f ${VARDIR}/firewall $g_restorepath
|
||||
mv -f ${VARDIR}/restore-$$ ${g_restorepath}-iptables
|
||||
chmod +x $g_restorepath
|
||||
echo " Currently-running Configuration Saved to $g_restorepath"
|
||||
run_user_exit save
|
||||
else
|
||||
rm -f ${VARDIR}/restore-$$
|
||||
echo " ERROR: Currently-running Configuration Not Saved" >&2
|
||||
status=1
|
||||
fi
|
||||
else
|
||||
echo " ERROR: ${VARDIR}/firewall does not exist" >&2
|
||||
status=1
|
||||
fi
|
||||
|
||||
return $status
|
||||
}
|
||||
|
||||
save_config() {
|
||||
|
||||
local result
|
||||
@@ -256,8 +285,8 @@ save_config() {
|
||||
if shorewall6_is_started ; then
|
||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||
|
||||
if [ -f $RESTOREPATH -a ! -x $RESTOREPATH ]; then
|
||||
echo " ERROR: $RESTOREPATH exists and is not a saved $PRODUCT configuration" >&2
|
||||
if [ -f $g_restorepath -a ! -x $g_restorepath ]; then
|
||||
echo " ERROR: $g_restorepath exists and is not a saved $g_product configuration" >&2
|
||||
else
|
||||
case $RESTOREFILE in
|
||||
capabilities|chains|default_route|firewall|firewall.conf|nat|proxyarp|restarted|rt_tables|save|state|undo_routing|zones)
|
||||
@@ -266,24 +295,15 @@ save_config() {
|
||||
*)
|
||||
validate_restorefile RESTOREFILE
|
||||
|
||||
if $IP6TABLES -L dynamic -n > ${VARDIR}/save; then
|
||||
echo " Dynamic Rules Saved"
|
||||
if [ -f ${VARDIR}/firewall ]; then
|
||||
if $iptables_save > ${VARDIR}/restore-$$; then
|
||||
cp -f ${VARDIR}/firewall $RESTOREPATH
|
||||
mv -f ${VARDIR}/restore-$$ ${RESTOREPATH}-iptables
|
||||
chmod +x $RESTOREPATH
|
||||
echo " Currently-running Configuration Saved to $RESTOREPATH"
|
||||
run_user_exit save
|
||||
else
|
||||
rm -f ${VARDIR}/restore-$$
|
||||
echo " ERROR: Currently-running Configuration Not Saved" >&2
|
||||
fi
|
||||
if chain_exists dynamic; then
|
||||
if $IP6TABLES -L dynamic -n > ${VARDIR}/save; then
|
||||
echo " Dynamic Rules Saved"
|
||||
do_save
|
||||
else
|
||||
echo " ERROR: ${VARDIR}/firewall does not exist" >&2
|
||||
echo "Error Saving the Dynamic Rules" >&2
|
||||
fi
|
||||
else
|
||||
echo "Error Saving the Dynamic Rules" >&2
|
||||
do_save && rm -f ${VARDIR}/save
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
@@ -334,7 +354,7 @@ show_command() {
|
||||
if [ ${#macro} -gt 10 ]; then
|
||||
echo " $macro ${foo#\#}"
|
||||
else
|
||||
$ECHO_E " $macro \t${foo#\#}"
|
||||
$g_echo_e " $macro \t${foo#\#}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -352,19 +372,19 @@ show_command() {
|
||||
option=
|
||||
;;
|
||||
v*)
|
||||
VERBOSE=$(($VERBOSE + 1 ))
|
||||
VERBOSITY=$(($VERBOSITY + 1 ))
|
||||
option=${option#v}
|
||||
;;
|
||||
x*)
|
||||
IPT_OPTIONS="-xnv"
|
||||
g_ipt_options="-xnv"
|
||||
option=${option#x}
|
||||
;;
|
||||
m*)
|
||||
SHOWMACS=Yes
|
||||
g_showmacs=Yes
|
||||
option=${option#m}
|
||||
;;
|
||||
f*)
|
||||
FILEMODE=Yes
|
||||
g_filemode=Yes
|
||||
option=${option#f}
|
||||
;;
|
||||
t)
|
||||
@@ -383,6 +403,10 @@ show_command() {
|
||||
option=
|
||||
shift
|
||||
;;
|
||||
l*)
|
||||
g_ipt_options1="--line-numbers"
|
||||
option=${option#l}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@@ -396,52 +420,56 @@ show_command() {
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "$debugging" ] && set -x
|
||||
g_ipt_options="$g_ipt_options $g_ipt_options1"
|
||||
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
case "$1" in
|
||||
connections)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
echo "$PRODUCT $version Connections at $HOSTNAME - $(date)"
|
||||
local count=$(cat /proc/sys/net/netfilter/nf_conntrack_count)
|
||||
local max=$(cat /proc/sys/net/netfilter/nf_conntrack_max)
|
||||
echo "$g_product $SHOREWALL_VERSION Connections ($count of $max) at $g_hostname - $(date)"
|
||||
echo
|
||||
grep '^ipv6' /proc/net/nf_conntrack
|
||||
;;
|
||||
tos|mangle)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
echo "$PRODUCT $version Mangle Table at $HOSTNAME - $(date)"
|
||||
echo "$g_product $SHOREWALL_VERSION Mangle Table at $g_hostname - $(date)"
|
||||
echo
|
||||
show_reset
|
||||
$IP6TABLES -t mangle -L $IPT_OPTIONS
|
||||
$IP6TABLES -t mangle -L $g_ipt_options
|
||||
;;
|
||||
raw)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
echo "$PRODUCT $version raw Table at $HOSTNAME - $(date)"
|
||||
echo "$g_product $SHOREWALL_VERSION raw Table at $g_hostname - $(date)"
|
||||
echo
|
||||
show_reset
|
||||
$IP6TABLES -t raw -L $IPT_OPTIONS
|
||||
$IP6TABLES -t raw -L $g_ipt_options
|
||||
;;
|
||||
log)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
echo "$PRODUCT $version Log ($LOGFILE) at $HOSTNAME - $(date)"
|
||||
echo "$g_product $SHOREWALL_VERSION Log ($LOGFILE) at $g_hostname - $(date)"
|
||||
echo
|
||||
show_reset
|
||||
host=$(echo $HOSTNAME | sed 's/\..*$//')
|
||||
host=$(echo $g_hostname | sed 's/\..*$//')
|
||||
packet_log 20
|
||||
;;
|
||||
tc)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
echo "$PRODUCT $version Traffic Control at $HOSTNAME - $(date)"
|
||||
[ $# -gt 2 ] && usage 1
|
||||
echo "$g_product $SHOREWALL_VERSION Traffic Control at $g_hostname - $(date)"
|
||||
echo
|
||||
show_tc
|
||||
;;
|
||||
classifiers|filters)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
echo "$PRODUCT $version Classifiers at $HOSTNAME - $(date)"
|
||||
echo "$g_product $SHOREWALL_VERSION Classifiers at $g_hostname - $(date)"
|
||||
echo
|
||||
show_classifiers
|
||||
;;
|
||||
zones)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
if [ -f ${VARDIR}/zones ]; then
|
||||
echo "$PRODUCT $version Zones at $HOSTNAME - $(date)"
|
||||
echo "$g_product $SHOREWALL_VERSION Zones at $g_hostname - $(date)"
|
||||
echo
|
||||
while read zone type hosts; do
|
||||
echo "$zone ($type)"
|
||||
@@ -465,8 +493,8 @@ show_command() {
|
||||
capabilities)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
determine_capabilities
|
||||
VERBOSE=2
|
||||
if [ -n "$FILEMODE" ]; then
|
||||
VERBOSITY=2
|
||||
if [ -n "$g_filemode" ]; then
|
||||
report_capabilities1
|
||||
else
|
||||
report_capabilities
|
||||
@@ -474,13 +502,13 @@ show_command() {
|
||||
;;
|
||||
ip)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
echo "$PRODUCT $version IP at $HOSTNAME - $(date)"
|
||||
echo "$g_product $SHOREWALL_VERSION IP at $g_hostname - $(date)"
|
||||
echo
|
||||
ip -6 addr list
|
||||
;;
|
||||
routing)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
echo "$PRODUCT $version Routing at $HOSTNAME - $(date)"
|
||||
echo "$g_product $SHOREWALL_VERSION Routing at $g_hostname - $(date)"
|
||||
echo
|
||||
show_routing
|
||||
;;
|
||||
@@ -491,22 +519,28 @@ show_command() {
|
||||
;;
|
||||
chain)
|
||||
shift
|
||||
echo "$PRODUCT $version $([ $# -gt 1 ] && echo "Chains " || [ $# -gt 0 ] && echo "Chain " || echo $table Table)$* at $HOSTNAME - $(date)"
|
||||
echo "$g_product $SHOREWALL_VERSION $([ $# -gt 1 ] && echo "Chains " || [ $# -gt 0 ] && echo "Chain " || echo $table Table)$* at $g_hostname - $(date)"
|
||||
echo
|
||||
show_reset
|
||||
if [ $# -gt 0 ]; then
|
||||
for chain in $*; do
|
||||
$IP6TABLES -t $table -L $chain $IPT_OPTIONS
|
||||
$IP6TABLES -t $table -L $chain $g_ipt_options
|
||||
done
|
||||
else
|
||||
$IP6TABLES -t $table -L $IPT_OPTIONS
|
||||
$IP6TABLES -t $table -L $g_ipt_options
|
||||
fi
|
||||
;;
|
||||
vardir)
|
||||
echo $VARDIR;
|
||||
;;
|
||||
policies)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
echo "$g_product $SHOREWALL_VERSION Policies at $g_hostname - $(date)"
|
||||
echo
|
||||
[ -f ${VARDIR}/policies ] && cat ${VARDIR}/policies;
|
||||
;;
|
||||
*)
|
||||
if [ "$PRODUCT" = Shorewall6 ]; then
|
||||
if [ "$g_product" = Shorewall6 ]; then
|
||||
case $1 in
|
||||
actions)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
@@ -553,23 +587,23 @@ show_command() {
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
[ -n "$table_given" ] || for chain in $*; do
|
||||
if ! qt $IP6TABLES -t $table -L $chain $IPT_OPTIONS; then
|
||||
echo "usage $(basename $0) show [ -x ] [ -m ] [-f] [ -t {filter|mangle} ] [ {chain [<chain> [ <chain> ... ]|actions|capabilities|classifiers|config|connections|filters|ip|log|macros|mangle|routing|tc|zones} ] " >&2
|
||||
if ! qt $IP6TABLES -t $table -L $chain $g_ipt_options; then
|
||||
error_message "ERROR: Chain '$chain' is not recognized by $IP6TABLES."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$PRODUCT $version $([ $# -gt 1 ] && echo "Chains " || echo "Chain ")$* at $HOSTNAME - $(date)"
|
||||
echo "$g_product $SHOREWALL_VERSION $([ $# -gt 1 ] && echo "Chains " || echo "Chain ")$* at $g_hostname - $(date)"
|
||||
echo
|
||||
show_reset
|
||||
for chain in $*; do
|
||||
$IP6TABLES -t $table -L $chain $IPT_OPTIONS
|
||||
$IP6TABLES -t $table -L $chain $g_ipt_options
|
||||
done
|
||||
else
|
||||
echo "$PRODUCT $version $table Table at $HOSTNAME - $(date)"
|
||||
echo "$g_product $SHOREWALL_VERSION $table Table at $g_hostname - $(date)"
|
||||
echo
|
||||
show_reset
|
||||
$IP6TABLES -t $table -L $IPT_OPTIONS
|
||||
$IP6TABLES -t $table -L $g_ipt_options
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
@@ -595,13 +629,17 @@ dump_command() {
|
||||
option=
|
||||
;;
|
||||
x*)
|
||||
IPT_OPTIONS="-xnv"
|
||||
g_ipt_options="-xnv"
|
||||
option=${option#x}
|
||||
;;
|
||||
m*)
|
||||
SHOWMACS=Yes
|
||||
g_showmacs=Yes
|
||||
option=${option#m}
|
||||
;;
|
||||
l*)
|
||||
g_ipt_options1="--line-numbers"
|
||||
option=${option#l}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@@ -615,12 +653,14 @@ dump_command() {
|
||||
esac
|
||||
done
|
||||
|
||||
[ $VERBOSE -lt 2 ] && VERBOSE=2
|
||||
g_ipt_options="$g_ipt_options $g_ipt_options1"
|
||||
|
||||
[ -n "$debugging" ] && set -x
|
||||
[ $VERBOSITY -lt 2 ] && VERBOSITY=2
|
||||
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
[ $# -eq 0 ] || usage 1
|
||||
clear_term
|
||||
echo "$PRODUCT $version Dump at $HOSTNAME - $(date)"
|
||||
echo "$g_product $SHOREWALL_VERSION Dump at $g_hostname - $(date)"
|
||||
echo
|
||||
|
||||
if [ -f /usr/share/shorewall/version ]; then
|
||||
@@ -629,19 +669,26 @@ dump_command() {
|
||||
fi
|
||||
|
||||
show_reset
|
||||
host=$(echo $HOSTNAME | sed 's/\..*$//')
|
||||
$IP6TABLES -L $IPT_OPTIONS
|
||||
host=$(echo $g_hostname | sed 's/\..*$//')
|
||||
$IP6TABLES -L $g_ipt_options
|
||||
|
||||
heading "Log ($LOGFILE)"
|
||||
packet_log 20
|
||||
|
||||
heading "Mangle Table"
|
||||
$IP6TABLES -t mangle -L $IPT_OPTIONS
|
||||
if qt $IP6TABLES -t mangle -L -n; then
|
||||
heading "Mangle Table"
|
||||
$IP6TABLES -t mangle -L $g_ipt_options
|
||||
fi
|
||||
|
||||
heading "Raw Table"
|
||||
$IP6TABLES -t raw -L $IPT_OPTIONS
|
||||
if qt $IP6TABLES -t raw -L -n; then
|
||||
heading "Raw Table"
|
||||
$IP6TABLES -t raw -L $g_ipt_options
|
||||
fi
|
||||
|
||||
heading "Conntrack Table"
|
||||
local count=$(cat /proc/sys/net/netfilter/nf_conntrack_count)
|
||||
local max=$(cat /proc/sys/net/netfilter/nf_conntrack_max)
|
||||
|
||||
heading "Conntrack Table ($count out of $max)"
|
||||
grep '^ipv6' /proc/net/nf_conntrack
|
||||
|
||||
heading "IP Configuration"
|
||||
@@ -673,8 +720,8 @@ dump_command() {
|
||||
|
||||
show_routing
|
||||
|
||||
heading "ARP"
|
||||
arp -na
|
||||
heading "Neighbors"
|
||||
ip -6 neigh ls
|
||||
|
||||
if qt mywhich lsmod; then
|
||||
heading "Modules"
|
||||
@@ -716,7 +763,7 @@ restore_command() {
|
||||
option=
|
||||
;;
|
||||
n*)
|
||||
NOROUTES=Yes
|
||||
g_noroutes=Yes
|
||||
option=${option#n}
|
||||
;;
|
||||
*)
|
||||
@@ -749,27 +796,25 @@ restore_command() {
|
||||
exit 2
|
||||
fi
|
||||
|
||||
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
||||
|
||||
export NOROUTES
|
||||
g_restorepath=${VARDIR}/$RESTOREFILE
|
||||
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
|
||||
if [ -x $RESTOREPATH ]; then
|
||||
if [ -x ${RESTOREPATH}-ipsets ] ; then
|
||||
if [ -x $g_restorepath ]; then
|
||||
if [ -x ${g_restorepath}-ipsets ] ; then
|
||||
echo Restoring Ipsets...
|
||||
$IP6TABLES -F
|
||||
$IP6TABLES -X
|
||||
$SHOREWALL_SHELL ${RESTOREPATH}-ipsets
|
||||
$SHOREWALL_SHELL ${g_restorepath}-ipsets
|
||||
fi
|
||||
|
||||
progress_message3 "Restoring Shorewall6..."
|
||||
|
||||
$SHOREWALL_SHELL $RESTOREPATH restore && progress_message3 "$PRODUCT restored from ${VARDIR}/$RESTOREFILE"
|
||||
run_it $g_restorepath restore && progress_message3 "$g_product restored from ${VARDIR}/$RESTOREFILE"
|
||||
|
||||
[ -n "$nolock" ] || mutex_off
|
||||
else
|
||||
echo "File $RESTOREPATH: file not found"
|
||||
echo "File $g_restorepath: file not found"
|
||||
[ -n "$nolock" ] || mutex_off
|
||||
exit 2
|
||||
fi
|
||||
@@ -827,20 +872,20 @@ heading() {
|
||||
#
|
||||
make_verbose() {
|
||||
local v
|
||||
v=$VERBOSE_OFFSET
|
||||
v=$g_verbose_offset
|
||||
local option
|
||||
option=-
|
||||
|
||||
if [ -n "$USE_VERBOSITY" ]; then
|
||||
echo "-v$USE_VERBOSITY"
|
||||
elif [ $VERBOSE_OFFSET -gt 0 ]; then
|
||||
if [ -n "$g_use_verbosity" ]; then
|
||||
echo "-v$g_use_verbosity"
|
||||
elif [ $g_verbose_offset -gt 0 ]; then
|
||||
while [ $v -gt 0 ]; do
|
||||
option="${option}v"
|
||||
v=$(($v - 1))
|
||||
done
|
||||
|
||||
echo $option
|
||||
elif [ $VERBOSE_OFFSET -lt 0 ]; then
|
||||
elif [ $g_verbose_offset -lt 0 ]; then
|
||||
while [ $v -lt 0 ]; do
|
||||
option="${option}q"
|
||||
v=$(($v + 1))
|
||||
@@ -860,6 +905,12 @@ block() # $1 = command, $2 = Finished, $3 - $n addresses
|
||||
local finished
|
||||
finished=$2
|
||||
|
||||
if ! chain_exists dynamic; then
|
||||
echo "Dynamic blacklisting is not enabled in the current $g_product configuration" >&2
|
||||
[ -n "$nolock" ] || mutex_off
|
||||
exit 2
|
||||
fi
|
||||
|
||||
shift 3
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
@@ -926,15 +977,15 @@ hits_command() {
|
||||
[ $# -eq 0 ] || usage 1
|
||||
|
||||
clear_term
|
||||
echo "$PRODUCT $version Hits at $HOSTNAME - $(date)"
|
||||
echo "$g_product $SHOREWALL_VERSION Hits at $g_hostname - $(date)"
|
||||
echo
|
||||
|
||||
timeout=30
|
||||
|
||||
if $LOGREAD | grep -q "${today}IN=.* OUT=" ; then
|
||||
if $g_logread | grep -q "${today}IN=.* OUT=" ; then
|
||||
echo " HITS IP DATE"
|
||||
echo " ---- --------------- ------"
|
||||
$LOGREAD | grep "${today}IN=.* OUT=" | sed 's/\(.\{6\}\)\(.*SRC=\)\(.*\)\( DST=.*\)/\3 \1/' | sort | uniq -c | sort -rn | while read count address month day; do
|
||||
$g_logread | grep "${today}IN=.* OUT=" | sed 's/\(.\{6\}\)\(.*SRC=\)\(.*\)\( DST=.*\)/\3 \1/' | sort | uniq -c | sort -rn | while read count address month day; do
|
||||
printf '%7d %-15s %3s %2d\n' $count $address $month $day
|
||||
done
|
||||
|
||||
@@ -942,7 +993,7 @@ hits_command() {
|
||||
|
||||
echo " HITS IP PORT"
|
||||
echo " ---- --------------- -----"
|
||||
$LOGREAD | grep "${today}IN=.* OUT=" | sed 's/\(.*SRC=\)\(.*\)\( DST=.*DPT=\)\([0-9]\{1,5\}\)\(.*\)/\2 \4/
|
||||
$g_logread | grep "${today}IN=.* OUT=" | sed 's/\(.*SRC=\)\(.*\)\( DST=.*DPT=\)\([0-9]\{1,5\}\)\(.*\)/\2 \4/
|
||||
t
|
||||
s/\(.*SRC=\)\(.*\)\( DST=.*\)/\2/' | sort | uniq -c | sort -rn | while read count address port; do
|
||||
printf '%7d %-15s %d\n' $count $address $port
|
||||
@@ -952,7 +1003,7 @@ hits_command() {
|
||||
|
||||
echo " HITS DATE"
|
||||
echo " ---- ------"
|
||||
$LOGREAD | grep "${today}IN=.* OUT=" | sed 's/\(.\{6\}\)\(.*\)/\1/' | sort | uniq -c | sort -rn | while read count month day; do
|
||||
$g_logread | grep "${today}IN=.* OUT=" | sed 's/\(.\{6\}\)\(.*\)/\1/' | sort | uniq -c | sort -rn | while read count month day; do
|
||||
printf '%7d %3s %2d\n' $count $month $day
|
||||
done
|
||||
|
||||
@@ -960,7 +1011,7 @@ hits_command() {
|
||||
|
||||
echo " HITS PORT SERVICE(S)"
|
||||
echo " ---- ----- ----------"
|
||||
$LOGREAD | grep "${today}IN=.* OUT=.*DPT" | sed 's/\(.*DPT=\)\([0-9]\{1,5\}\)\(.*\)/\2/' | sort | uniq -c | sort -rn | while read count port ; do
|
||||
$g_logread | grep "${today}IN=.* OUT=.*DPT" | sed 's/\(.*DPT=\)\([0-9]\{1,5\}\)\(.*\)/\2/' | sort | uniq -c | sort -rn | while read count port ; do
|
||||
# List all services defined for the given port
|
||||
srv=$(grep "^[^#].*\\b$port/" /etc/services | cut -f 1 | cut -f 1 -d' ' | sort -u)
|
||||
srv=$(echo $srv | sed 's/ /,/g')
|
||||
@@ -978,9 +1029,14 @@ hits_command() {
|
||||
# 'allow' command executor
|
||||
#
|
||||
allow_command() {
|
||||
[ -n "$debugging" ] && set -x
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
[ $# -eq 1 ] && usage 1
|
||||
if shorewall6_is_started ; then
|
||||
if ! chain_exists dynamic; then
|
||||
echo "Dynamic blacklisting is not enabled in the current $g_product configuration" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
[ -n "$nolock" ] || mutex_on
|
||||
while [ $# -gt 1 ]; do
|
||||
shift
|
||||
@@ -1011,7 +1067,7 @@ allow_command() {
|
||||
done
|
||||
[ -n "$nolock" ] || mutex_off
|
||||
else
|
||||
error_message "ERROR: $PRODUCT is not started"
|
||||
error_message "ERROR: $g_product is not started"
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
@@ -1035,15 +1091,15 @@ logwatch_command() {
|
||||
while [ -n "$option" ]; do
|
||||
case $option in
|
||||
v*)
|
||||
VERBOSE=$(($VERBOSE + 1 ))
|
||||
VERBOSITY=$(($VERBOSITY + 1 ))
|
||||
option=${option#v}
|
||||
;;
|
||||
q*)
|
||||
VERBOSE=$(($VERBOSE - 1 ))
|
||||
VERBOSITY=$(($VERBOSITY - 1 ))
|
||||
option=${option#q}
|
||||
;;
|
||||
m*)
|
||||
SHOWMACS=Yes
|
||||
g_showmacs=Yes
|
||||
option=${option#m}
|
||||
;;
|
||||
-)
|
||||
@@ -1063,7 +1119,7 @@ logwatch_command() {
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "$debugging" ] && set -x
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
|
||||
if [ $# -eq 1 ]; then
|
||||
logwatch $1
|
||||
@@ -1073,3 +1129,320 @@ logwatch_command() {
|
||||
usage 1
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Determine which optional facilities are supported by iptables/netfilter
|
||||
#
|
||||
determine_capabilities() {
|
||||
CONNTRACK_MATCH=
|
||||
NEW_CONNTRACK_MATCH=
|
||||
OLD_CONNTRACK_MATCH=
|
||||
MULTIPORT=
|
||||
XMULTIPORT=
|
||||
POLICY_MATCH=
|
||||
PHYSDEV_MATCH=
|
||||
PHYSDEV_BRIDGE=
|
||||
IPRANGE_MATCH=
|
||||
RECENT_MATCH=
|
||||
OWNER_MATCH=
|
||||
IPSET_MATCH=
|
||||
CONNMARK=
|
||||
XCONNMARK=
|
||||
CONNMARK_MATCH=
|
||||
XCONNMARK_MATCH=
|
||||
RAW_TABLE=
|
||||
IPP2P_MATCH=
|
||||
OLD_IPP2P_MATCH=
|
||||
LENGTH_MATCH=
|
||||
CLASSIFY_TARGET=
|
||||
ENHANCED_REJECT=
|
||||
USEPKTTYPE=
|
||||
KLUDGEFREE=
|
||||
MARK=
|
||||
XMARK=
|
||||
EXMARK=
|
||||
TPROXY_TARGET=
|
||||
MANGLE_FORWARD=
|
||||
COMMENTS=
|
||||
ADDRTYPE=
|
||||
TCPMSS_MATCH=
|
||||
HASHLIMIT_MATCH=
|
||||
NFQUEUE_TARGET=
|
||||
REALM_MATCH=
|
||||
HELPER_MATCH=
|
||||
CONNLIMIT_MATCH=
|
||||
TIME_MATCH=
|
||||
GOTO_TARGET=
|
||||
IPMARK_TARGET=
|
||||
LOG_TARGET=Yes
|
||||
FLOW_FILTER=
|
||||
|
||||
chain=fooX$$
|
||||
|
||||
[ -n "$IP6TABLES" ] || IP6TABLES=$(mywhich ip6tables)
|
||||
|
||||
if [ -z "$IP6TABLES" ]; then
|
||||
echo " ERROR: No executable iptables binary can be found on your PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[ -n "$IP" ] || IP=$(which ip)
|
||||
|
||||
[ -n "$IP" -a -x "$IP" ] || IP=
|
||||
|
||||
qt $IP6TABLES -t mangle -L -n && MANGLE_ENABLED=Yes || MANGLE_ENABLED=
|
||||
|
||||
qt $IP6TABLES -F $chain
|
||||
qt $IP6TABLES -X $chain
|
||||
if ! $IP6TABLES -N $chain; then
|
||||
echo " ERROR: The command \"$IP6TABLES -N $chain\" failed" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
chain1=${chain}1
|
||||
|
||||
qt $IP6TABLES -F $chain1
|
||||
qt $IP6TABLES -X $chain1
|
||||
if ! $IP6TABLES -N $chain1; then
|
||||
echo " ERROR: The command \"$IP6TABLES -N $chain1\" failed" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! qt $IP6TABLES -A $chain -m state --state ESTABLISHED,RELATED -j ACCEPT; then
|
||||
echo " ERROR: Your kernel lacks connection tracking and/or state matching -- Shorewall will not run on this system" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
qt $IP6TABLES -A $chain -m conntrack --ctorigdst ::1 -j ACCEPT && CONNTRACK_MATCH=Yes
|
||||
|
||||
if [ -n "$CONNTRACK_MATCH" ]; then
|
||||
qt $IP6TABLES -A $chain -m conntrack -p tcp --ctorigdstport 22 -j ACCEPT && NEW_CONNTRACK_MATCH=Yes
|
||||
qt $IP6TABLES -A $chain -m conntrack ! --ctorigdst ::1 || OLD_CONNTRACK_MATCH=Yes
|
||||
fi
|
||||
|
||||
if qt $IP6TABLES -A $chain -p tcp -m multiport --dports 21,22 -j ACCEPT; then
|
||||
MULTIPORT=Yes
|
||||
qt $IP6TABLES -A $chain -p tcp -m multiport --sports 60 -m multiport --dports 99 -j ACCEPT && KLUDEFREE=Yes
|
||||
fi
|
||||
|
||||
qt $IP6TABLES -A $chain -p tcp -m multiport --dports 21:22 -j ACCEPT && XMULTIPORT=Yes
|
||||
qt $IP6TABLES -A $chain -m policy --pol ipsec --mode tunnel --dir in -j ACCEPT && POLICY_MATCH=Yes
|
||||
|
||||
if qt $IP6TABLES -A $chain -m physdev --physdev-out eth0 -j ACCEPT; then
|
||||
PHYSDEV_MATCH=Yes
|
||||
qt $IP6TABLES -A $chain -m physdev --physdev-is-bridged --physdev-in eth0 --physdev-out eth0 -j ACCEPT && PHYSDEV_BRIDGE=Yes
|
||||
if [ -z "${KLUDGEFREE}" ]; then
|
||||
qt $IP6TABLES -A $chain -m physdev --physdev-in eth0 -m physdev --physdev-out eth0 -j ACCEPT && KLUDGEFREE=Yes
|
||||
fi
|
||||
fi
|
||||
|
||||
if qt $IP6TABLES -A $chain -m iprange --src-range ::1-::2 -j ACCEPT; then
|
||||
IPRANGE_MATCH=Yes
|
||||
if [ -z "${KLUDGEFREE}" ]; then
|
||||
qt $IP6TABLES -A $chain -m iprange --src-range ::1-::2 -m iprange --dst-range ::1-::2 -j ACCEPT && KLUDGEFREE=Yes
|
||||
fi
|
||||
fi
|
||||
|
||||
qt $IP6TABLES -A $chain -m recent --update -j ACCEPT && RECENT_MATCH=Yes
|
||||
qt $IP6TABLES -A $chain -m owner --uid-owner 0 -j ACCEPT && OWNER_MATCH=Yes
|
||||
|
||||
if qt $IP6TABLES -A $chain -m connmark --mark 2 -j ACCEPT; then
|
||||
CONNMARK_MATCH=Yes
|
||||
qt $IP6TABLES -A $chain -m connmark --mark 2/0xFF -j ACCEPT && XCONNMARK_MATCH=Yes
|
||||
fi
|
||||
|
||||
qt $IP6TABLES -A $chain -p tcp -m ipp2p --edk -j ACCEPT && IPP2P_MATCH=Yes
|
||||
if [ -n "$IPP2P_MATCH" ]; then
|
||||
qt $IP6TABLES -A $chain -p tcp -m ipp2p --ipp2p -j ACCEPT && OLD_IPP2P_MATCH=Yes
|
||||
fi
|
||||
|
||||
qt $IP6TABLES -A $chain -m length --length 10:20 -j ACCEPT && LENGTH_MATCH=Yes
|
||||
qt $IP6TABLES -A $chain -j REJECT --reject-with icmp6-adm-prohibited && ENHANCED_REJECT=Yes
|
||||
|
||||
qt $IP6TABLES -A $chain -j ACCEPT -m comment --comment "This is a comment" && COMMENTS=Yes
|
||||
|
||||
if [ -n "$MANGLE_ENABLED" ]; then
|
||||
qt $IP6TABLES -t mangle -N $chain
|
||||
|
||||
if qt $IP6TABLES -t mangle -A $chain -j MARK --set-mark 1; then
|
||||
MARK=Yes
|
||||
qt $IP6TABLES -t mangle -A $chain -j MARK --and-mark 0xFF && XMARK=Yes
|
||||
qt $IP6TABLES -t mangle -A $chain -j MARK --set-mark 1/0xFF && EXMARK=Yes
|
||||
fi
|
||||
|
||||
if qt $IP6TABLES -t mangle -A $chain -j CONNMARK --save-mark; then
|
||||
CONNMARK=Yes
|
||||
qt $IP6TABLES -t mangle -A $chain -j CONNMARK --save-mark --mask 0xFF && XCONNMARK=Yes
|
||||
fi
|
||||
|
||||
qt $IP6TABLES -t mangle -A $chain -j CLASSIFY --set-class 1:1 && CLASSIFY_TARGET=Yes
|
||||
qt $IP6TABLES -t mangle -A $chain -j IPMARK --addr src && IPMARK_TARGET=Yes
|
||||
qt $IP6TABLES -t mangle -A $chain -p tcp -j TPROXY --on-port 0 --tproxy-mark 1 && TPROXY_TARGET=Yes
|
||||
qt $IP6TABLES -t mangle -F $chain
|
||||
qt $IP6TABLES -t mangle -X $chain
|
||||
qt $IP6TABLES -t mangle -L FORWARD -n && MANGLE_FORWARD=Yes
|
||||
fi
|
||||
|
||||
qt $IP6TABLES -t raw -L -n && RAW_TABLE=Yes
|
||||
|
||||
if qt mywhich ipset; then
|
||||
qt ipset -X $chain # Just in case something went wrong the last time
|
||||
|
||||
if qt ipset -N $chain iphash ; then
|
||||
if qt $IP6TABLES -A $chain -m set --set $chain src -j ACCEPT; then
|
||||
qt $IP6TABLES -D $chain -m set --set $chain src -j ACCEPT
|
||||
IPSET_MATCH=Yes
|
||||
fi
|
||||
qt ipset -X $chain
|
||||
fi
|
||||
fi
|
||||
|
||||
qt $IP6TABLES -A $chain -m pkttype --pkt-type broadcast -j ACCEPT && USEPKTTYPE=Yes
|
||||
qt $IP6TABLES -A $chain -m addrtype --src-type BROADCAST -j ACCEPT && ADDRTYPE=Yes
|
||||
qt $IP6TABLES -A $chain -p tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1000:1500 -j ACCEPT && TCPMSS_MATCH=Yes
|
||||
qt $IP6TABLES -A $chain -m hashlimit --hashlimit-upto 4 --hashlimit-burst 5 --hashlimit-name $chain --hashlimit-mode dstip -j ACCEPT && HASHLIMIT_MATCH=Yes
|
||||
if [ -z "$HASHLIMIT_MATCH" ]; then
|
||||
qt $IP6TABLES -A $chain -m hashlimit --hashlimit 4 --hashlimit-burst 5 --hashlimit-name $chain --hashlimit-mode dstip -j ACCEPT && OLD_HL_MATCH=Yes
|
||||
HASHLIMIT_MATCH=$OLD_HL_MATCH
|
||||
fi
|
||||
qt $IP6TABLES -A $chain -j NFQUEUE --queue-num 4 && NFQUEUE_TARGET=Yes
|
||||
qt $IP6TABLES -A $chain -m realm --realm 4 && REALM_MATCH=Yes
|
||||
qt $IP6TABLES -A $chain -m helper --helper "ftp" && HELPER_MATCH=Yes
|
||||
qt $IP6TABLES -A $chain -m connlimit --connlimit-above 8 -j DROP && CONNLIMIT_MATCH=Yes
|
||||
qt $IP6TABLES -A $chain -m time --timestart 23:00 -j DROP && TIME_MATCH=Yes
|
||||
qt $IP6TABLES -A $chain -g $chain1 && GOTO_TARGET=Yes
|
||||
qt $IP6TABLES -A $chain -j LOG || LOG_TARGET=
|
||||
|
||||
qt $IP6TABLES -F $chain
|
||||
qt $IP6TABLES -X $chain
|
||||
qt $IP6TABLES -F $chain1
|
||||
qt $IP6TABLES -X $chain1
|
||||
|
||||
[ -n "$IP" ] && $IP filter add flow help 2>&1 | grep -q ^Usage && FLOW_FILTER=Yes
|
||||
|
||||
CAPVERSION=$SHOREWALL_CAPVERSION
|
||||
KERNELVERSION=$(printf "%d%02d%02d" $(uname -r 2> /dev/null | sed -e 's/-.*//' -e 's/^\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/\1 \2 \3/g'))
|
||||
}
|
||||
|
||||
report_capabilities() {
|
||||
report_capability() # $1 = Capability Description , $2 Capability Setting (if any)
|
||||
{
|
||||
local setting
|
||||
setting=
|
||||
|
||||
[ "x$2" = "xYes" ] && setting="Available" || setting="Not available"
|
||||
|
||||
echo " " $1: $setting
|
||||
}
|
||||
|
||||
if [ $VERBOSITY -gt 1 ]; then
|
||||
echo "Shorewall6 has detected the following ip6tables/netfilter capabilities:"
|
||||
report_capability "Packet Mangling" $MANGLE_ENABLED
|
||||
report_capability "Multi-port Match" $MULTIPORT
|
||||
[ -n "$MULTIPORT" ] && report_capability "Extended Multi-port Match" $XMULTIPORT
|
||||
report_capability "Connection Tracking Match" $CONNTRACK_MATCH
|
||||
if [ -n "$CONNTRACK_MATCH" ]; then
|
||||
report_capability "Extended Connection Tracking Match Support" $NEW_CONNTRACK_MATCH
|
||||
[ -n "$OLD_CONNTRACK_MATCH" ] && report_capability "Old Connection Tracking Match Syntax" $OLD_CONNTRACK_MATCH
|
||||
fi
|
||||
report_capability "Packet Type Match" $USEPKTTYPE
|
||||
report_capability "Policy Match" $POLICY_MATCH
|
||||
report_capability "Physdev Match" $PHYSDEV_MATCH
|
||||
report_capability "Physdev-is-bridged Support" $PHYSDEV_BRIDGE
|
||||
report_capability "Packet length Match" $LENGTH_MATCH
|
||||
report_capability "IP range Match" $IPRANGE_MATCH
|
||||
report_capability "Recent Match" $RECENT_MATCH
|
||||
report_capability "Owner Match" $OWNER_MATCH
|
||||
report_capability "Ipset Match" $IPSET_MATCH
|
||||
report_capability "CONNMARK Target" $CONNMARK
|
||||
[ -n "$CONNMARK" ] && report_capability "Extended CONNMARK Target" $XCONNMARK
|
||||
report_capability "Connmark Match" $CONNMARK_MATCH
|
||||
[ -n "$CONNMARK_MATCH" ] && report_capability "Extended Connmark Match" $XCONNMARK_MATCH
|
||||
report_capability "Raw Table" $RAW_TABLE
|
||||
report_capability "IPP2P Match" $IPP2P_MATCH
|
||||
[ -n "$OLD_IPP2P_MATCH" ] && report_capability "Old IPP2P Match Syntax" $OLD_IPP2P_MATCH
|
||||
report_capability "CLASSIFY Target" $CLASSIFY_TARGET
|
||||
report_capability "Extended REJECT" $ENHANCED_REJECT
|
||||
report_capability "Repeat match" $KLUDGEFREE
|
||||
report_capability "MARK Target" $MARK
|
||||
[ -n "$MARK" ] && report_capability "Extended MARK Target" $XMARK
|
||||
[ -n "$XMARK" ] && report_capability "Extended MARK Target 2" $EXMARK
|
||||
report_capability "Mangle FORWARD Chain" $MANGLE_FORWARD
|
||||
report_capability "Comments" $COMMENTS
|
||||
report_capability "Address Type Match" $ADDRTYPE
|
||||
report_capability "TCPMSS Match" $TCPMSS_MATCH
|
||||
report_capability "Hashlimit Match" $HASHLIMIT_MATCH
|
||||
[ -n "$OLD_HL_MATCH" ] && report_capability "Old Hashlimit Match" $OLD_HL_MATCH
|
||||
report_capability "NFQUEUE Target" $NFQUEUE_TARGET
|
||||
report_capability "Realm Match" $REALM_MATCH
|
||||
report_capability "Helper Match" $HELPER_MATCH
|
||||
report_capability "Connlimit Match" $CONNLIMIT_MATCH
|
||||
report_capability "Time Match" $TIME_MATCH
|
||||
report_capability "Goto Support" $GOTO_TARGET
|
||||
report_capability "IPMARK Target" $IPMARK_TARGET
|
||||
report_capability "LOG Target" $LOG_TARGET
|
||||
report_capability "TPROXY Target" $TPROXY_TARGET
|
||||
report_capability "FLOW Classifier" $FLOW_FILTER
|
||||
fi
|
||||
|
||||
[ -n "$PKTTYPE" ] || USEPKTTYPE=
|
||||
|
||||
}
|
||||
|
||||
report_capabilities1() {
|
||||
report_capability1() # $1 = Capability
|
||||
{
|
||||
eval echo $1=\$$1
|
||||
}
|
||||
|
||||
echo "#"
|
||||
echo "# Shorewall6 $SHOREWALL_VERSION detected the following ip6tables/netfilter capabilities - $(date)"
|
||||
echo "#"
|
||||
report_capability1 MANGLE_ENABLED
|
||||
report_capability1 MULTIPORT
|
||||
report_capability1 XMULTIPORT
|
||||
report_capability1 CONNTRACK_MATCH
|
||||
report_capability1 NEW_CONNTRACK_MATCH
|
||||
report_capability1 OLD_CONNTRACK_MATCH
|
||||
report_capability1 USEPKTTYPE
|
||||
report_capability1 POLICY_MATCH
|
||||
report_capability1 PHYSDEV_MATCH
|
||||
report_capability1 PHYSDEV_BRIDGE
|
||||
report_capability1 LENGTH_MATCH
|
||||
report_capability1 IPRANGE_MATCH
|
||||
report_capability1 RECENT_MATCH
|
||||
report_capability1 OWNER_MATCH
|
||||
report_capability1 IPSET_MATCH
|
||||
report_capability1 CONNMARK
|
||||
report_capability1 XCONNMARK
|
||||
report_capability1 CONNMARK_MATCH
|
||||
report_capability1 XCONNMARK_MATCH
|
||||
report_capability1 RAW_TABLE
|
||||
report_capability1 IPP2P_MATCH
|
||||
report_capability1 OLD_IPP2P_MATCH
|
||||
report_capability1 CLASSIFY_TARGET
|
||||
report_capability1 ENHANCED_REJECT
|
||||
report_capability1 KLUDGEFREE
|
||||
report_capability1 MARK
|
||||
report_capability1 XMARK
|
||||
report_capability1 EXMARK
|
||||
report_capability1 MANGLE_FORWARD
|
||||
report_capability1 COMMENTS
|
||||
report_capability1 ADDRTYPE
|
||||
report_capability1 TCPMSS_MATCH
|
||||
report_capability1 HASHLIMIT_MATCH
|
||||
report_capability1 OLD_HL_MATCH
|
||||
report_capability1 NFQUEUE_TARGET
|
||||
report_capability1 REALM_MATCH
|
||||
report_capability1 HELPER_MATCH
|
||||
report_capability1 CONNLIMIT_MATCH
|
||||
report_capability1 TIME_MATCH
|
||||
report_capability1 GOTO_TARGET
|
||||
report_capability1 IPMARK_TARGET
|
||||
report_capability1 LOG_TARGET
|
||||
report_capability1 TPROXY_TARGET
|
||||
report_capability1 FLOW_FILTER
|
||||
|
||||
echo CAPVERSION=$SHOREWALL_CAPVERSION
|
||||
echo KERNELVERSION=$KERNELVERSION
|
||||
}
|
||||
|
476
Shorewall6/lib.common
Normal file
476
Shorewall6/lib.common
Normal file
@@ -0,0 +1,476 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Shorewall 4.4 -- /usr/share/shorewall6/lib.common.
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2010 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# Complete documentation is available at http://shorewall.net
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of Version 2 of the GNU General Public License
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# This library contains the wrapper code for running a generated script.
|
||||
#
|
||||
|
||||
#
|
||||
# Get the Shorewall version of the passed script
|
||||
#
|
||||
get_script_version() { # $1 = script
|
||||
local temp
|
||||
local version
|
||||
local ifs
|
||||
local digits
|
||||
|
||||
temp=$( $SHOREWALL_SHELL $1 version | sed 's/-.*//' )
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
version=0
|
||||
else
|
||||
ifs=$IFS
|
||||
IFS=.
|
||||
temp=$(echo $temp)
|
||||
IFS=$ifs
|
||||
digits=0
|
||||
|
||||
for temp in $temp; do
|
||||
version=${version}$(printf '%02d' $temp)
|
||||
digits=$(($digits + 1))
|
||||
[ $digits -eq 3 ] && break
|
||||
done
|
||||
fi
|
||||
|
||||
echo $version
|
||||
}
|
||||
|
||||
#
|
||||
# Do required exports and create the required option string and run the passed script using
|
||||
# $SHOREWALL_SHELL
|
||||
#
|
||||
run_it() {
|
||||
local script
|
||||
local options
|
||||
local version
|
||||
|
||||
export VARDIR
|
||||
|
||||
script=$1
|
||||
shift
|
||||
|
||||
version=$(get_script_version $script)
|
||||
|
||||
if [ $version -lt 040408 ]; then
|
||||
#
|
||||
# Old script that doesn't understand 4.4.8 script options
|
||||
#
|
||||
export RESTOREFILE=
|
||||
export VERBOSITY
|
||||
export NOROUTES=$g_noroutes
|
||||
export PURGE=$g_purge
|
||||
export TIMESTAMP=$g_timestamp
|
||||
export RECOVERING=$g_recovering
|
||||
|
||||
if [ "$g_product" != Shorewall6 ]; then
|
||||
#
|
||||
# Shorewall6 Lite
|
||||
#
|
||||
export LOGFORMAT
|
||||
export IP6TABLES
|
||||
fi
|
||||
else
|
||||
#
|
||||
# 4.4.8 or later -- no additional exports required
|
||||
#
|
||||
options='-'
|
||||
|
||||
[ -n "$g_noroutes" ] && options=${options}n
|
||||
[ -n "$g_timestamp" ] && options=${options}t
|
||||
[ -n "$g_purge" ] && options=${options}p
|
||||
[ -n "$g_recovering" ] && options=${options}r
|
||||
|
||||
options="${options}V $VERBOSITY"
|
||||
|
||||
[ -n "$RESTOREFILE" ] && options="${options} -R $RESTOREFILE"
|
||||
fi
|
||||
|
||||
$SHOREWALL_SHELL $script $options $@
|
||||
}
|
||||
|
||||
#
|
||||
# Message to stderr
|
||||
#
|
||||
error_message() # $* = Error Message
|
||||
{
|
||||
echo " $@" >&2
|
||||
}
|
||||
|
||||
#
|
||||
# Split a colon-separated list into a space-separated list
|
||||
#
|
||||
split() {
|
||||
local ifs
|
||||
ifs=$IFS
|
||||
IFS=:
|
||||
echo $*
|
||||
IFS=$ifs
|
||||
}
|
||||
|
||||
#
|
||||
# Undo the effect of 'split()'
|
||||
#
|
||||
join()
|
||||
{
|
||||
local f
|
||||
local o
|
||||
o=
|
||||
|
||||
for f in $* ; do
|
||||
o="${o:+$o:}$f"
|
||||
done
|
||||
|
||||
echo $o
|
||||
}
|
||||
|
||||
#
|
||||
# Return the number of elements in a list
|
||||
#
|
||||
list_count() # $* = list
|
||||
{
|
||||
return $#
|
||||
}
|
||||
|
||||
#
|
||||
# Search a list looking for a match -- returns zero if a match found
|
||||
# 1 otherwise
|
||||
#
|
||||
list_search() # $1 = element to search for , $2-$n = list
|
||||
{
|
||||
local e
|
||||
e=$1
|
||||
|
||||
while [ $# -gt 1 ]; do
|
||||
shift
|
||||
[ "x$e" = "x$1" ] && return 0
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
#
|
||||
# Suppress all output for a command
|
||||
#
|
||||
qt()
|
||||
{
|
||||
"$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
qt1()
|
||||
{
|
||||
local status
|
||||
|
||||
while [ 1 ]; do
|
||||
"$@" >/dev/null 2>&1
|
||||
status=$?
|
||||
[ $status -ne 4 ] && return $status
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Determine if Shorewall is "running"
|
||||
#
|
||||
shorewall6_is_started() {
|
||||
qt1 $IP6TABLES -L shorewall -n
|
||||
}
|
||||
|
||||
#
|
||||
# Echos the fully-qualified name of the calling shell program
|
||||
#
|
||||
my_pathname() {
|
||||
cd $(dirname $0)
|
||||
echo $PWD/$(basename $0)
|
||||
}
|
||||
|
||||
#
|
||||
# Source a user exit file if it exists
|
||||
#
|
||||
run_user_exit() # $1 = file name
|
||||
{
|
||||
local user_exit
|
||||
user_exit=$(find_file $1)
|
||||
|
||||
if [ -f $user_exit ]; then
|
||||
progress_message "Processing $user_exit ..."
|
||||
. $user_exit
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Load a Kernel Module -- assumes that the variable 'moduledirectories' contains
|
||||
# a space-separated list of directories to search for
|
||||
# the module and that 'moduleloader' contains the
|
||||
# module loader command.
|
||||
#
|
||||
loadmodule() # $1 = module name, $2 - * arguments
|
||||
{
|
||||
local modulename
|
||||
modulename=$1
|
||||
local modulefile
|
||||
local suffix
|
||||
|
||||
if ! list_search $modulename $MODULES $DONT_LOAD ; then
|
||||
shift
|
||||
|
||||
for suffix in $MODULE_SUFFIX ; do
|
||||
for directory in $moduledirectories; do
|
||||
modulefile=$directory/${modulename}.${suffix}
|
||||
|
||||
if [ -f $modulefile ]; then
|
||||
case $moduleloader in
|
||||
insmod)
|
||||
insmod $modulefile $*
|
||||
;;
|
||||
*)
|
||||
modprobe $modulename $*
|
||||
;;
|
||||
esac
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Reload the Modules
|
||||
#
|
||||
reload_kernel_modules() {
|
||||
|
||||
local save_modules_dir
|
||||
save_modules_dir=$MODULESDIR
|
||||
local directory
|
||||
local moduledirectories
|
||||
moduledirectories=
|
||||
local moduleloader
|
||||
moduleloader=modprobe
|
||||
|
||||
if ! qt mywhich modprobe; then
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=o gz ko o.gz ko.gz}" ]
|
||||
|
||||
[ -z "$MODULESDIR" ] && MODULESDIR=/lib/modules/$(uname -r)/kernel/net/ipv6/netfilter:/lib/modules/$(uname -r)/kernel/net/netfilter:/lib/modules/$(uname -r)/kernel/net/sched
|
||||
MODULES=$(lsmod | cut -d ' ' -f1)
|
||||
|
||||
for directory in $(split $MODULESDIR); do
|
||||
[ -d $directory ] && moduledirectories="$moduledirectories $directory"
|
||||
done
|
||||
|
||||
[ -n "$moduledirectories" ] && while read command; do
|
||||
eval $command
|
||||
done
|
||||
|
||||
MODULESDIR=$save_modules_dir
|
||||
}
|
||||
|
||||
#
|
||||
# Load kernel modules required for Shorewall
|
||||
#
|
||||
load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
|
||||
{
|
||||
local save_modules_dir
|
||||
save_modules_dir=$MODULESDIR
|
||||
local directory
|
||||
local moduledirectories
|
||||
moduledirectories=
|
||||
local moduleloader
|
||||
moduleloader=modprobe
|
||||
local savemoduleinfo
|
||||
savemoduleinfo=${1:-Yes} # So old compiled scripts still work
|
||||
|
||||
if ! qt mywhich modprobe; then
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=o gz ko o.gz ko.gz}" ]
|
||||
|
||||
[ -z "$MODULESDIR" ] && \
|
||||
MODULESDIR=/lib/modules/$(uname -r)/kernel/net/ipv6/netfilter:/lib/modules/$(uname -r)/kernel/net/netfilter:/lib/modules/$(uname -r)/kernel/net/sched
|
||||
|
||||
for directory in $(split $MODULESDIR); do
|
||||
[ -d $directory ] && moduledirectories="$moduledirectories $directory"
|
||||
done
|
||||
|
||||
[ -n "$LOAD_HELPERS_ONLY" ] && modules=$(find_file helpers) || modules=$(find_file modules)
|
||||
|
||||
if [ -f $modules -a -n "$moduledirectories" ]; then
|
||||
MODULES=$(lsmod | cut -d ' ' -f1)
|
||||
progress_message "Loading Modules..."
|
||||
. $modules
|
||||
if [ $savemoduleinfo = Yes ]; then
|
||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||
echo MODULESDIR="$MODULESDIR" > ${VARDIR}/.modulesdir
|
||||
cp -f $modules ${VARDIR}/.modules
|
||||
fi
|
||||
elif [ $savemoduleinfo = Yes ]; then
|
||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||
> ${VARDIR}/.modulesdir
|
||||
> ${VARDIR}/.modules
|
||||
fi
|
||||
|
||||
MODULESDIR=$save_modules_dir
|
||||
}
|
||||
|
||||
#
|
||||
# Query NetFilter about the existence of a filter chain
|
||||
#
|
||||
chain_exists() # $1 = chain name
|
||||
{
|
||||
qt1 $IP6TABLES -L $1 -n
|
||||
}
|
||||
|
||||
#
|
||||
# Find the interface with the passed MAC address
|
||||
#
|
||||
|
||||
find_interface_by_mac() {
|
||||
local mac
|
||||
mac=$1
|
||||
local first
|
||||
local second
|
||||
local rest
|
||||
local dev
|
||||
|
||||
$IP link list | while read first second rest; do
|
||||
case $first in
|
||||
*:)
|
||||
dev=$second
|
||||
;;
|
||||
*)
|
||||
if [ "$second" = $mac ]; then
|
||||
echo ${dev%:}
|
||||
return
|
||||
fi
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Find interface address--returns the first IP address assigned to the passed
|
||||
# device
|
||||
#
|
||||
find_first_interface_address() # $1 = interface
|
||||
{
|
||||
#
|
||||
# get the line of output containing the first IP address
|
||||
#
|
||||
addr=$($IP -f inet6 addr show $1 2> /dev/null | grep 'inet6 .* global' | head -n1)
|
||||
#
|
||||
# If there wasn't one, bail out now
|
||||
#
|
||||
[ -n "$addr" ] || startup_error "Can't determine the IPv6 address of $1"
|
||||
#
|
||||
# Strip off the trailing VLSM mask (or the peer IP in case of a P-t-P link)
|
||||
# along with everything else on the line
|
||||
#
|
||||
echo $addr | sed 's/\s*inet6 //;s/\/.*//;s/ peer.*//'
|
||||
}
|
||||
|
||||
find_first_interface_address_if_any() # $1 = interface
|
||||
{
|
||||
#
|
||||
# get the line of output containing the first IP address
|
||||
#
|
||||
addr=$($IP -f inet6 addr show $1 2> /dev/null | grep 'inet6 2.* global' | head -n1)
|
||||
#
|
||||
# Strip off the trailing VLSM mask (or the peer IP in case of a P-t-P link)
|
||||
# along with everything else on the line
|
||||
#
|
||||
[ -n "$addr" ] && echo $addr | sed 's/\s*inet6 //;s/\/.*//;s/ peer.*//' || echo ::
|
||||
}
|
||||
|
||||
#
|
||||
# Internal version of 'which'
|
||||
#
|
||||
mywhich() {
|
||||
local dir
|
||||
|
||||
for dir in $(split $PATH); do
|
||||
if [ -x $dir/$1 ]; then
|
||||
echo $dir/$1
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 2
|
||||
}
|
||||
|
||||
#
|
||||
# Find a File -- For relative file name, look in each ${CONFIG_PATH} then ${CONFDIR}
|
||||
#
|
||||
find_file()
|
||||
{
|
||||
local saveifs
|
||||
saveifs=
|
||||
local directory
|
||||
|
||||
case $1 in
|
||||
/*)
|
||||
echo $1
|
||||
;;
|
||||
*)
|
||||
for directory in $(split $CONFIG_PATH); do
|
||||
if [ -f $directory/$1 ]; then
|
||||
echo $directory/$1
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
echo ${CONFDIR}/$1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
# Set the Shorewall state
|
||||
#
|
||||
set_state () # $1 = state
|
||||
{
|
||||
echo "$1 ($(date))" > ${VARDIR}/state
|
||||
}
|
||||
|
||||
#
|
||||
# Perform variable substitution on the passed argument and echo the result
|
||||
#
|
||||
expand() # $@ = contents of variable which may be the name of another variable
|
||||
{
|
||||
eval echo \"$@\"
|
||||
}
|
||||
|
||||
#
|
||||
# Function for including one file into another
|
||||
#
|
||||
INCLUDE() {
|
||||
. $(find_file $(expand $@))
|
||||
}
|
||||
|
||||
# Function to truncate a string -- It uses 'cut -b -<n>'
|
||||
# rather than ${v:first:last} because light-weight shells like ash and
|
||||
# dash do not support that form of expansion.
|
||||
#
|
||||
|
||||
truncate() # $1 = length
|
||||
{
|
||||
cut -b -${1}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user