forked from extern/shorewall_code
Compare commits
467 Commits
4.6.0.1
...
4.6.10-bas
Author | SHA1 | Date | |
---|---|---|---|
|
9a3c43b6d3 | ||
|
0a45c7a646 | ||
|
f227250959 | ||
|
29a0c92918 | ||
|
cfc6b7405f | ||
|
4edd6026f0 | ||
|
f629d574e6 | ||
|
18348ef6f1 | ||
|
93c7e2c2f7 | ||
|
602315938c | ||
|
f3d32e0023 | ||
|
19ab4472c9 | ||
|
425094de18 | ||
|
ca35f565e0 | ||
|
bbdbdf7c47 | ||
|
631ebdecb8 | ||
|
c851e03313 | ||
|
df4d6f1f92 | ||
|
c7ca3119ef | ||
|
ba7afcaeae | ||
|
809e56cef6 | ||
|
e3805b0ada | ||
|
f1b6e71e56 | ||
|
f77d649ac7 | ||
|
267637f139 | ||
|
acd921cd08 | ||
|
9329e7c36c | ||
|
86ef3d3e35 | ||
|
cccf6b4657 | ||
|
7195ee708e | ||
|
50d1a719f9 | ||
|
4b27c72c79 | ||
|
548c0558c1 | ||
|
7a9270136c | ||
|
a508bcf6d7 | ||
|
3bb1f74283 | ||
|
87eca92b10 | ||
|
b58aadad01 | ||
|
6dcd8174ee | ||
|
fe37844455 | ||
|
e248c0a3d7 | ||
|
3f17a8cf24 | ||
|
2cea78e6df | ||
|
0abd51c796 | ||
|
86e053be7a | ||
|
864dba2e62 | ||
|
75d18139f7 | ||
|
bebb41674a | ||
|
42f75f7ba2 | ||
|
2c9b7fbb07 | ||
|
119299421f | ||
|
aef019e16d | ||
|
3ae243b882 | ||
|
0fc58f81cc | ||
|
7db99832ca | ||
|
0e8b427778 | ||
|
ccccd847c8 | ||
|
6cb3004a39 | ||
|
f5aa0373cb | ||
|
057ad45fd9 | ||
|
ade24e6299 | ||
|
65394b9f8c | ||
|
b128c30813 | ||
|
194252afd3 | ||
|
3cb45f234e | ||
|
16e3cb1b43 | ||
|
27c1ffc5fb | ||
|
23137e5e8a | ||
|
0e54a86e82 | ||
|
4fd8aa692d | ||
|
8c3dda80a3 | ||
|
9f96f58a0d | ||
|
77165326f2 | ||
|
eb3a162560 | ||
|
a8026999a5 | ||
|
44142ed457 | ||
|
659e9d550c | ||
|
7442c2189d | ||
|
551be3ed39 | ||
|
468167f9e5 | ||
|
6921270c77 | ||
|
50bbf9499a | ||
|
b00a7af619 | ||
|
0c11870e46 | ||
|
fdc36747ad | ||
|
79d8d73e02 | ||
|
ecaae1f644 | ||
|
52e7efc666 | ||
|
c5ef3fd905 | ||
|
86d6d6900e | ||
|
9a5cc5e51c | ||
|
d7a1ca41f9 | ||
|
d3552346b0 | ||
|
1e6c266b51 | ||
|
d6f8cda2d5 | ||
|
4cc866cd81 | ||
|
095e523c9f | ||
|
2817060edb | ||
|
30e750608b | ||
|
a85fdc45ac | ||
|
79b6b7cf08 | ||
|
5f2a8dd9cb | ||
|
a28cd7371c | ||
|
e9bb447537 | ||
|
cdc2d52208 | ||
|
18c8f1f835 | ||
|
aff8623a44 | ||
|
361f5af3e0 | ||
|
b14e7c54f9 | ||
|
30a5f508be | ||
|
9ad0b297e2 | ||
|
40104d0c86 | ||
|
5d110616a5 | ||
|
a2b8069ee3 | ||
|
c7cd0060f0 | ||
|
e3b96862ef | ||
|
a060f683cc | ||
|
01220d58ea | ||
|
c2b6d974e7 | ||
|
7ab055e61e | ||
|
758f3cf955 | ||
|
08a184d95b | ||
|
50a0103e89 | ||
|
6f2308e0fa | ||
|
a7cacdfee3 | ||
|
28ac76bde4 | ||
|
83431514fb | ||
|
111c454193 | ||
|
b06ba536e9 | ||
|
3f32afe371 | ||
|
740e19968b | ||
|
97846e14de | ||
|
07c21b8968 | ||
|
668759edad | ||
|
0f1f54b57b | ||
|
60d5a177a3 | ||
|
3ed5ced581 | ||
|
086f8b6073 | ||
|
fa377df9dc | ||
|
7dd9ccd06b | ||
|
33e2e19193 | ||
|
4a4bfe77ce | ||
|
3890b8a884 | ||
|
551a16d18f | ||
|
d1b597394f | ||
|
15a2fd14f9 | ||
|
f96baca780 | ||
|
1b5f439609 | ||
|
1655054de2 | ||
|
89877ed3f7 | ||
|
9649107a8e | ||
|
33eb47a48a | ||
|
93285e2798 | ||
|
2430796495 | ||
|
06ef7596cd | ||
|
227db0cfa7 | ||
|
c0f7d0e65d | ||
|
ba806379f4 | ||
|
6a15cead52 | ||
|
f925358872 | ||
|
52d2e62274 | ||
|
56e8068f3d | ||
|
35fc7b34b8 | ||
|
fdf513fba6 | ||
|
79430673b8 | ||
|
695db284c0 | ||
|
807b9ca627 | ||
|
62f480897e | ||
|
685825a336 | ||
|
8edb86ccdd | ||
|
2d7025dcc3 | ||
|
23e869ad50 | ||
|
a833815b31 | ||
|
664e3bb0a8 | ||
|
3a64ef7d3a | ||
|
b746c9319f | ||
|
6f81bb5c8e | ||
|
9241552c52 | ||
|
16c1809ef2 | ||
|
ec0ff7f305 | ||
|
7100af5380 | ||
|
f9932d2b08 | ||
|
2bf80ee3d9 | ||
|
22ac37b51e | ||
|
c4171a92f6 | ||
|
a5b2886ae9 | ||
|
9a6047b3c4 | ||
|
6f5de7ef3f | ||
|
5b4e3bc07c | ||
|
dc3f163e71 | ||
|
2f545012a6 | ||
|
c97226c46c | ||
|
8c0c1bd1e0 | ||
|
8b825c4c4c | ||
|
4493b2ab6b | ||
|
9598ac6fad | ||
|
8fb73026c8 | ||
|
4546cbaff7 | ||
|
a83c146636 | ||
|
2ffc97867c | ||
|
f08803e293 | ||
|
b7ab82dba4 | ||
|
113f95c11e | ||
|
3454e10525 | ||
|
edc30fcc8d | ||
|
85e5669fc7 | ||
|
055fceb82f | ||
|
f5bdc9e7f4 | ||
|
54461a9a90 | ||
|
b60d6dd6e5 | ||
|
4bc91e89db | ||
|
2784e93307 | ||
|
90d1e41dcb | ||
|
20c8bf02b1 | ||
|
38d4b1c5a9 | ||
|
e3a332ec27 | ||
|
49218a4d28 | ||
|
3236cd2660 | ||
|
e3b10343a5 | ||
|
286bc50bb3 | ||
|
a5086f785f | ||
|
19482ac197 | ||
|
42363da458 | ||
|
c5074bddb2 | ||
|
4b9d8ad5f6 | ||
|
8e9d769723 | ||
|
77015ebb4d | ||
|
12458d111a | ||
|
815e93e80c | ||
|
7771e5d48f | ||
|
0cd694370e | ||
|
5fd7c573fc | ||
|
80c024c4aa | ||
|
3bae6e61cf | ||
|
5204cbc95f | ||
|
ea1b8ac63a | ||
|
a31fd20f22 | ||
|
2c7ffb525d | ||
|
316866482b | ||
|
6c6a1d82d9 | ||
|
a72a1ef7a6 | ||
|
4398fb23d1 | ||
|
e3a7a4fc98 | ||
|
e36b34ce15 | ||
|
178d1fbc26 | ||
|
c9fd390782 | ||
|
3206021278 | ||
|
8571e0dca0 | ||
|
9dc2bba025 | ||
|
2fce05b3ab | ||
|
70bb9147cd | ||
|
00b0489047 | ||
|
f9a21bd90e | ||
|
5e81bdfe19 | ||
|
f2cc68b93b | ||
|
8a5e71a56f | ||
|
483ea3e437 | ||
|
2ec3adcc44 | ||
|
205dd6e250 | ||
|
770a505cd2 | ||
|
4071b9d337 | ||
|
820c769499 | ||
|
e6b0666ac9 | ||
|
2a463e06aa | ||
|
3174454300 | ||
|
ce1c367d1d | ||
|
3e2c903a41 | ||
|
b053cab630 | ||
|
6f7d063921 | ||
|
cbcb1ff7e1 | ||
|
3858683e94 | ||
|
38a18ac9ac | ||
|
a09484356c | ||
|
bc8588a68e | ||
|
10df9d31c4 | ||
|
4989f694cd | ||
|
b84a9e16e6 | ||
|
053df2a5fb | ||
|
976a1f3deb | ||
|
ea40068c10 | ||
|
56649e2183 | ||
|
520d21c056 | ||
|
540eff24aa | ||
|
580e00dabd | ||
|
4815f7eba3 | ||
|
a7b57ad32c | ||
|
ba7f88c912 | ||
|
7481514a97 | ||
|
20c68dddf2 | ||
|
35e60aa10c | ||
|
1f5439257a | ||
|
4495ed687b | ||
|
d97d45f4ad | ||
|
a69cec5228 | ||
|
a03f00bf0f | ||
|
8f05d0f16d | ||
|
f9d98b74a2 | ||
|
0d23b9c542 | ||
|
a7bdfcc47b | ||
|
988ee64621 | ||
|
9947f4d968 | ||
|
feb747260d | ||
|
fc58dab66d | ||
|
9e039e30e5 | ||
|
771e487b02 | ||
|
0b66c475a7 | ||
|
8727a6f1d8 | ||
|
f9a62e1650 | ||
|
6851744cb7 | ||
|
f963adccf5 | ||
|
48549b35ac | ||
|
9001643996 | ||
|
4bacfced82 | ||
|
7c1bbd4dc7 | ||
|
4347190f82 | ||
|
fa8c3b3b6c | ||
|
045d5ac048 | ||
|
e4a8cb31ba | ||
|
9e6fffc231 | ||
|
aaa561c831 | ||
|
3030219740 | ||
|
602ecad712 | ||
|
96102623ee | ||
|
aa6bd2819c | ||
|
8236ce572e | ||
|
bf5be7198b | ||
|
6f777098d7 | ||
|
e545329eb9 | ||
|
aedd9b5a76 | ||
|
cf33bac318 | ||
|
0005bb697b | ||
|
c5549ff21e | ||
|
427f38109e | ||
|
0e1a1a3f44 | ||
|
b6161b8be7 | ||
|
d3209ca624 | ||
|
34ecbb9074 | ||
|
beb70854ef | ||
|
7030fad572 | ||
|
c653a04a43 | ||
|
5ef5aa8cdb | ||
|
0ca12bd86f | ||
|
a2f1c57246 | ||
|
fd42fa9f74 | ||
|
e49832f4b5 | ||
|
0bf80c15d8 | ||
|
4e9a0b989d | ||
|
31e5aeeaea | ||
|
eb5026d3b7 | ||
|
a799d74901 | ||
|
7a41981487 | ||
|
aae23d7a9e | ||
|
a7b18ca875 | ||
|
ad6c91bcbd | ||
|
8c0fe063a7 | ||
|
dbf78d7dd0 | ||
|
bea2b49eb0 | ||
|
3b4012b60a | ||
|
21209504c5 | ||
|
44a34ceb95 | ||
|
848078873d | ||
|
3e6f57e699 | ||
|
461f7b10ba | ||
|
2c9eda9cee | ||
|
64fc3d2e43 | ||
|
d0aed87546 | ||
|
56fa6bd78a | ||
|
b207f64a85 | ||
|
9f381209d5 | ||
|
29e6bc9379 | ||
|
4b3196b959 | ||
|
6771dc54ad | ||
|
ba69708092 | ||
|
417bd0138e | ||
|
a1cc4847c7 | ||
|
0ec4cfd18d | ||
|
d5ea667c61 | ||
|
3e6e0b4a09 | ||
|
a97e2fd3d9 | ||
|
53dda803e2 | ||
|
cc935009ce | ||
|
a0ab9f6ab2 | ||
|
a7856e4dd6 | ||
|
4a4cea46c0 | ||
|
cf626b58da | ||
|
2ed523101c | ||
|
c72265667f | ||
|
77513da27e | ||
|
c663a14c4d | ||
|
c17a196838 | ||
|
8bfff55ed2 | ||
|
7184c9aa58 | ||
|
b1a6ec7f03 | ||
|
9f71791919 | ||
|
1a7cc9b86d | ||
|
a8f6d2f438 | ||
|
b8777c0fd5 | ||
|
cad8443e01 | ||
|
2ad81f1a81 | ||
|
166e1a3df9 | ||
|
84437ea689 | ||
|
20a567fea7 | ||
|
7082bf1971 | ||
|
87b5751a49 | ||
|
49aada0f9c | ||
|
7fdc398a5e | ||
|
1165b2689c | ||
|
2701b0a756 | ||
|
9c7fcd09fd | ||
|
380a159c8c | ||
|
80c09c4747 | ||
|
824b14b714 | ||
|
122d58b122 | ||
|
61bb73fd8c | ||
|
ff8d354c1c | ||
|
0b1dda2a31 | ||
|
50736fb8ae | ||
|
a2e514c0ab | ||
|
7b0cf2b665 | ||
|
6ad9b95351 | ||
|
ac4bf15606 | ||
|
4e5d24fd9b | ||
|
e6132b5630 | ||
|
041e8c445e | ||
|
a0bb7ca018 | ||
|
a8885844ae | ||
|
2610dd4744 | ||
|
b3acb4d30d | ||
|
e6372a3e04 | ||
|
41ab0d20c9 | ||
|
36e31ed839 | ||
|
b55b6a913c | ||
|
9c9ae04c86 | ||
|
1892cbf218 | ||
|
c0c6bedb17 | ||
|
c898129ad6 | ||
|
7adc16ace9 | ||
|
7b38bc9558 | ||
|
2cd5c41ec0 | ||
|
bea5434de6 | ||
|
8657dd97f7 | ||
|
ef038d5eab | ||
|
b6ea20e7df | ||
|
6632afaf6a | ||
|
0f55863076 | ||
|
9f9d9fd8d1 | ||
|
ec4fc4ee8f | ||
|
4e33948844 | ||
|
954cddc37a | ||
|
e64a7feda2 | ||
|
24721e01b6 | ||
|
5a22b14947 | ||
|
df738025a3 | ||
|
d49d352d77 | ||
|
0f6bd0e2af | ||
|
89c5d5080b | ||
|
66b3d9aeb5 | ||
|
b088ea77cd | ||
|
966926fac5 | ||
|
dcc2fb27c5 | ||
|
2859b1aa6e | ||
|
6d3b1d80d4 | ||
|
d5e83a5295 | ||
|
670c33d20b | ||
|
58700b2301 | ||
|
72869adcd6 | ||
|
0c8365001d |
8
Shorewall-core/configure
vendored
8
Shorewall-core/configure
vendored
@@ -98,7 +98,7 @@ if [ -z "$vendor" ]; then
|
||||
eval $(cat /etc/os-release | grep ^ID=)
|
||||
|
||||
case $ID in
|
||||
fedora)
|
||||
fedora|rhel)
|
||||
vendor=redhat
|
||||
;;
|
||||
debian|ubuntu)
|
||||
@@ -195,6 +195,10 @@ elif [ -n "${options[VARDIR]}" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${options[SERVICEDIR]}" ]; then
|
||||
options[SERVICEDIR]="${options[SYSTEMD]}"
|
||||
fi
|
||||
|
||||
for on in \
|
||||
HOST \
|
||||
PREFIX \
|
||||
@@ -209,7 +213,7 @@ for on in \
|
||||
INITFILE \
|
||||
AUXINITSOURCE \
|
||||
AUXINITFILE \
|
||||
SYSTEMD \
|
||||
SERVICEDIR \
|
||||
SERVICEFILE \
|
||||
SYSCONFFILE \
|
||||
SYSCONFDIR \
|
||||
|
@@ -64,7 +64,7 @@ unless ( defined $vendor ) {
|
||||
|
||||
$id =~ s/ID=//;
|
||||
|
||||
if ( $id eq 'fedora' ) {
|
||||
if ( $id eq 'fedora' || $id eq 'rhel' ) {
|
||||
$vendor = 'redhat';
|
||||
} elsif ( $id eq 'opensuse' ) {
|
||||
$vendor = 'suse';
|
||||
@@ -100,7 +100,7 @@ if ( defined $vendor ) {
|
||||
} elsif ( `uname` =~ '^Darwin' ) {
|
||||
$vendor = 'apple';
|
||||
$rcfilename = 'shorewallrc.apple';
|
||||
} elsif ( `uname` =~ '^Cygwin' ) {
|
||||
} elsif ( `uname` =~ /^Cygwin/i ) {
|
||||
$vendor = 'cygwin';
|
||||
$rcfilename = 'shorewallrc.cygwin';
|
||||
} else {
|
||||
@@ -154,6 +154,8 @@ if ( $options{VARLIB} ) {
|
||||
$options{VARDIR} = '${VARLIB}/${PRODUCT}';
|
||||
}
|
||||
|
||||
$options{SERVICEDIR}=$options{SYSTEMD} unless $options{SERVICEDIR};
|
||||
|
||||
for ( qw/ HOST
|
||||
PREFIX
|
||||
SHAREDIR
|
||||
@@ -167,8 +169,8 @@ for ( qw/ HOST
|
||||
INITFILE
|
||||
AUXINITSOURCE
|
||||
AUXINITFILE
|
||||
SYSTEMD
|
||||
SERVICEFILE
|
||||
SERVICEDIR
|
||||
SERVICEFILE
|
||||
SYSCONFFILE
|
||||
SYSCONFDIR
|
||||
SPARSE
|
||||
|
@@ -187,7 +187,7 @@ INSTALLD='-D'
|
||||
|
||||
if [ -z "$BUILD" ]; then
|
||||
case $(uname) in
|
||||
cygwin*)
|
||||
cygwin*|CYGWIN*)
|
||||
BUILD=cygwin
|
||||
;;
|
||||
Darwin)
|
||||
@@ -198,7 +198,7 @@ if [ -z "$BUILD" ]; then
|
||||
eval $(cat /etc/os-release | grep ^ID)
|
||||
|
||||
case $ID in
|
||||
fedora)
|
||||
fedora|rhel|centos|foobar)
|
||||
BUILD=redhat
|
||||
;;
|
||||
debian)
|
||||
@@ -329,9 +329,13 @@ if [ -n "${SYSCONFDIR}" ]; then
|
||||
chmod 755 ${DESTDIR}${SYSCONFDIR}
|
||||
fi
|
||||
|
||||
if [ -n "${SYSTEMD}" ]; then
|
||||
mkdir -p ${DESTDIR}${SYSTEMD}
|
||||
chmod 755 ${DESTDIR}${SYSTEMD}
|
||||
if [ -z "${SERVICEDIR}" ]; then
|
||||
SERVICEDIR="$SYSTEMD"
|
||||
fi
|
||||
|
||||
if [ -n "${SERVICEDIR}" ]; then
|
||||
mkdir -p ${DESTDIR}${SERVICEDIR}
|
||||
chmod 755 ${DESTDIR}${SERVICEDIR}
|
||||
fi
|
||||
|
||||
mkdir -p ${DESTDIR}${SBINDIR}
|
||||
|
@@ -25,7 +25,7 @@
|
||||
# loaded after this one and replaces some of the functions declared here.
|
||||
#
|
||||
|
||||
SHOREWALL_CAPVERSION=40600
|
||||
SHOREWALL_CAPVERSION=40609
|
||||
|
||||
[ -n "${g_program:=shorewall}" ]
|
||||
|
||||
@@ -42,16 +42,6 @@ fi
|
||||
|
||||
. ${SHAREDIR}/shorewall/lib.base
|
||||
|
||||
|
||||
#
|
||||
# Fatal Error
|
||||
#
|
||||
fatal_error() # $@ = Message
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Issue an error message and die
|
||||
#
|
||||
@@ -252,7 +242,15 @@ show_classifiers() {
|
||||
|
||||
if [ -n "$qdisc" ]; then
|
||||
echo Device $device:
|
||||
tc -s filter ls dev $device
|
||||
qt tc -s filter ls root dev $device && tc -s filter ls root dev $device | grep -v '^$'
|
||||
tc filter show dev $device
|
||||
tc class show dev $device | fgrep 'leaf ' | fgrep -v ' hfsc' | sed 's/^.*leaf //;s/ .*//' | while read class; do
|
||||
if [ -n "$class" ]; then
|
||||
echo
|
||||
echo Node $class
|
||||
tc filter show dev $device parent $class
|
||||
fi
|
||||
done
|
||||
echo
|
||||
fi
|
||||
}
|
||||
@@ -263,6 +261,19 @@ show_classifiers() {
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# Display blacklist chains
|
||||
#
|
||||
show_bl() {
|
||||
$g_tool -L $g_ipt_options | \
|
||||
awk 'BEGIN {prnt=0; };
|
||||
/^$/ {if (prnt == 1) print ""; prnt=0; };
|
||||
/Chain .*~ / {prnt=1; };
|
||||
/Chain dynamic / {prnt=1; };
|
||||
{if (prnt == 1) print; };
|
||||
END {if (prnt == 1 ) print "" };'
|
||||
}
|
||||
|
||||
#
|
||||
# Watch the Firewall Log
|
||||
#
|
||||
@@ -346,6 +357,28 @@ resolve_arptables() {
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
# Try to run the 'savesets' command
|
||||
#
|
||||
savesets() {
|
||||
local supported
|
||||
|
||||
supported=$(run_it ${VARDIR}/firewall help | fgrep savesets )
|
||||
|
||||
[ -n "$supported" ] && run_it ${VARDIR}/firewall savesets ${g_restorepath}-ipsets
|
||||
}
|
||||
|
||||
#
|
||||
# Proactive save of the current ipset contents
|
||||
#
|
||||
savesets1() {
|
||||
local supported
|
||||
|
||||
supported=$(run_it ${VARDIR}/firewall help | fgrep savesets )
|
||||
|
||||
[ -n "$supported" ] && run_it ${VARDIR}/firewall savesets ${VARDIR}/ipsets.save && progress_message3 "The ipsets have been saved to ${VARDIR}/ipsets.save"
|
||||
}
|
||||
|
||||
#
|
||||
# Save currently running configuration
|
||||
#
|
||||
@@ -355,7 +388,7 @@ do_save() {
|
||||
status=0
|
||||
|
||||
if [ -f ${VARDIR}/firewall ]; then
|
||||
if $iptables_save | iptablesbug > ${VARDIR}/restore-$$; then
|
||||
if $iptables_save | iptablesbug | grep -v -- '-A dynamic.* -j ACCEPT' > ${VARDIR}/restore-$$; then
|
||||
cp -f ${VARDIR}/firewall $g_restorepath
|
||||
mv -f ${VARDIR}/restore-$$ ${g_restorepath}-iptables
|
||||
chmod +x $g_restorepath
|
||||
@@ -407,45 +440,47 @@ do_save() {
|
||||
;;
|
||||
esac
|
||||
|
||||
case ${SAVE_IPSETS:=No} in
|
||||
[Yy]es)
|
||||
case ${IPSET:=ipset} in
|
||||
*/*)
|
||||
if [ ! -x "$IPSET" ]; then
|
||||
error_message "ERROR: IPSET=$IPSET does not exist or is not executable - ipsets are not saved"
|
||||
IPSET=
|
||||
if ! savesets; then
|
||||
case ${SAVE_IPSETS:=No} in
|
||||
[Yy]es)
|
||||
case ${IPSET:=ipset} in
|
||||
*/*)
|
||||
if [ ! -x "$IPSET" ]; then
|
||||
error_message "ERROR: IPSET=$IPSET does not exist or is not executable - ipsets are not saved"
|
||||
IPSET=
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
IPSET="$(mywhich $IPSET)"
|
||||
[ -n "$IPSET" ] || error_message "ERROR: The ipset utility cannot be located - ipsets are not saved"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$IPSET" ]; then
|
||||
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
|
||||
;;
|
||||
*)
|
||||
IPSET="$(mywhich $IPSET)"
|
||||
[ -n "$IPSET" ] || error_message "ERROR: The ipset utility cannot be located - ipsets are not saved"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$IPSET" ]; then
|
||||
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=
|
||||
if eval $IPSET -S $hack > ${VARDIR}/ipsets.tmp; then
|
||||
#
|
||||
# Don't save an 'empty' file
|
||||
#
|
||||
grep -qE -- '^(-N|create )' ${VARDIR}/ipsets.tmp && mv -f ${VARDIR}/ipsets.tmp ${g_restorepath}-ipsets
|
||||
fi
|
||||
fi
|
||||
|
||||
if eval $IPSET -S $hack > ${VARDIR}/ipsets.tmp; then
|
||||
#
|
||||
# Don't save an 'empty' file
|
||||
#
|
||||
grep -qE -- '^(-N|create )' ${VARDIR}/ipsets.tmp && mv -f ${VARDIR}/ipsets.tmp ${g_restorepath}-ipsets
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
[Nn]o)
|
||||
;;
|
||||
*)
|
||||
error_message "WARNING: Invalid value ($SAVE_IPSETS) for SAVE_IPSETS"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
[Nn]o|ipv4|ipv6)
|
||||
;;
|
||||
*)
|
||||
error_message "WARNING: Invalid value ($SAVE_IPSETS) for SAVE_IPSETS"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
return $status
|
||||
}
|
||||
@@ -459,6 +494,8 @@ save_config() {
|
||||
|
||||
[ -x $iptables_save ] || echo "$iptables-save does not exist or is not executable" >&2
|
||||
|
||||
[ -n "$g_counters" ] && iptables_save="$iptables_save --counters"
|
||||
|
||||
if product_is_started ; then
|
||||
[ -d ${VARDIR} ] || mkdir -p ${VARDIR}
|
||||
|
||||
@@ -1181,7 +1218,23 @@ show_command() {
|
||||
echo "$g_product $SHOREWALL_VERSION events at $g_hostname - $(date)"
|
||||
echo
|
||||
show_events
|
||||
;;
|
||||
;;
|
||||
bl|blacklists)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
echo "$g_product $SHOREWALL_VERSION blacklist chains at $g_hostname - $(date)"
|
||||
echo
|
||||
show_bl;
|
||||
;;
|
||||
opens)
|
||||
[ $# -gt 1 ] && usage 1
|
||||
echo "$g_product $SHOREWALL_VERSION Temporarily opened connections at $g_hostname - $(date)"
|
||||
|
||||
if chain_exists dynamic; then
|
||||
g_ipt_options="$g_ipt_options --line-numbers"
|
||||
$g_tool -t filter -L dynamic $g_ipt_options | head -n2
|
||||
$g_tool -t filter -L dynamic $g_ipt_options | fgrep ACCEPT | $output_filter
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
case "$g_program" in
|
||||
*-lite)
|
||||
@@ -1443,10 +1496,22 @@ do_dump_command() {
|
||||
$g_tool -t rawpost -L $g_ipt_options
|
||||
fi
|
||||
|
||||
local count=$(cat /proc/sys/net/netfilter/nf_conntrack_count)
|
||||
local max=$(cat /proc/sys/net/netfilter/nf_conntrack_max)
|
||||
local count
|
||||
local max
|
||||
|
||||
heading "Conntrack Table ($count out of $max)"
|
||||
if [ -f /proc/sys/net/netfilter/nf_conntrack_count ]; then
|
||||
count=$(cat /proc/sys/net/netfilter/nf_conntrack_count)
|
||||
max=$(cat /proc/sys/net/netfilter/nf_conntrack_max)
|
||||
|
||||
heading "Conntrack Table ($count out of $max)"
|
||||
elif [ -f /proc/sys/net/ipv4/netfilter/ip_conntrack_count ]; then
|
||||
count=$(cat /proc/sys/net/ipv4/netfilter/ip_conntrack_count)
|
||||
max=$(cat /proc/sys/net/ipv4/netfilter/ip_conntrack_max)
|
||||
|
||||
heading "Conntrack Table ($count out of $max)"
|
||||
else
|
||||
heading "Conntrack Table"
|
||||
fi
|
||||
|
||||
if [ $g_family -eq 4 ]; then
|
||||
[ -f /proc/net/ip_conntrack ] && cat /proc/net/ip_conntrack || grep -v '^ipv6' /proc/net/nf_conntrack
|
||||
@@ -1572,6 +1637,15 @@ restore_command() {
|
||||
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"
|
||||
g_purge=Yes
|
||||
option=${option%p}
|
||||
;;
|
||||
C*)
|
||||
g_counters=Yes
|
||||
option=${option#C}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@@ -1599,7 +1673,7 @@ restore_command() {
|
||||
|
||||
if [ -z "$STARTUP_ENABLED" ]; then
|
||||
error_message "ERROR: Startup is disabled"
|
||||
exit 2
|
||||
exit 6
|
||||
fi
|
||||
|
||||
g_restorepath=${VARDIR}/$RESTOREFILE
|
||||
@@ -1896,7 +1970,7 @@ add_command() {
|
||||
ipset=6_${zone}_${interface};
|
||||
fi
|
||||
|
||||
ipset=$(echo $ipset | sed 's/./_/g');
|
||||
ipset=$(echo $ipset | sed 's/\./_/g');
|
||||
|
||||
if ! qt $IPSET -L $ipset; then
|
||||
fatal_error "Zone $zone, interface $interface does not have a dynamic host list"
|
||||
@@ -2013,6 +2087,166 @@ delete_command() {
|
||||
fi
|
||||
}
|
||||
|
||||
open_close_command() {
|
||||
local command
|
||||
local desc
|
||||
local proto
|
||||
local icmptype
|
||||
|
||||
open_close_setup() {
|
||||
[ -n "$g_nolock" ] || mutex_on
|
||||
|
||||
if ! product_is_started ; then
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
fatal_error "The $COMMAND command requires the firewall to be running"
|
||||
fi
|
||||
|
||||
if ! chain_exists dynamic; then
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
fatal_error "The $COMMAND command requires DYNAMIC_BLACKLIST=Yes in the running configuration"
|
||||
fi
|
||||
}
|
||||
|
||||
[ $# -le 4 ] || fatal_error "Too many parameters"
|
||||
|
||||
if [ $COMMAND = open ]; then
|
||||
[ $# -ge 2 ] || fatal_error "Too few parameters"
|
||||
else
|
||||
[ $# -ge 1 ] || fatal_error "Too few parameters"
|
||||
fi
|
||||
|
||||
if [ $# -eq 1 ]; then
|
||||
#
|
||||
# close <rule number>
|
||||
#
|
||||
case $1 in
|
||||
[1-9]|[1-9][0-9]|[1-9][0-9][0-9]*)
|
||||
;;
|
||||
*)
|
||||
fatal_error "$1 is not a valid temporary open number"
|
||||
;;
|
||||
esac
|
||||
|
||||
open_close_setup #Conditionally acquires mutex
|
||||
|
||||
if $g_tool -L dynamic --line-numbers | grep -q "^$1 .* ACCEPT "; then
|
||||
if $g_tool -D dynamic $1; then
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
echo "Temporary open #$1 closed"
|
||||
return 0
|
||||
fi
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
return 2
|
||||
else
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
fatal_error "$1 is not a valid temporary open number"
|
||||
fi
|
||||
else
|
||||
if [ $1 = all ]; then
|
||||
command=dynamic
|
||||
else
|
||||
command="dynamic -s $1"
|
||||
fi
|
||||
|
||||
if [ $2 != all ]; then
|
||||
command="$command -d $2"
|
||||
fi
|
||||
|
||||
desc="from $1 to $2"
|
||||
|
||||
if [ $# -ge 3 ]; then
|
||||
proto=$3
|
||||
|
||||
[ $proto = icmp -a $g_family -eq 6 ] && proto=58
|
||||
|
||||
command="$command -p $proto"
|
||||
|
||||
case $3 in
|
||||
[0-9]*)
|
||||
desc="$desc protocol $3"
|
||||
;;
|
||||
*)
|
||||
desc="$desc $3"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $g_family -eq 4 ]; then
|
||||
if [ $proto = 6 -o $proto = icmp ]; then
|
||||
proto=icmp
|
||||
icmptype='--icmp-type'
|
||||
fi
|
||||
else
|
||||
if [ $proto = 58 -o $proto = ipv6-icmp ]; then
|
||||
proto=icmp
|
||||
icmptype='--icmpv6-type'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $# -eq 4 ]; then
|
||||
if [ $proto = icmp ]; then
|
||||
case $4 in
|
||||
*,*)
|
||||
fatal_error "Only a single ICMP type may be specified"
|
||||
;;
|
||||
[0-9]*)
|
||||
desc="$desc type $4"
|
||||
;;
|
||||
*)
|
||||
desc="$desc $4"
|
||||
;;
|
||||
esac
|
||||
|
||||
command="$command $icmptype $4"
|
||||
else
|
||||
case $4 in
|
||||
*,*)
|
||||
command="$command -m multiport --dports $4"
|
||||
;;
|
||||
*)
|
||||
command="$command --dport $4"
|
||||
;;
|
||||
esac
|
||||
|
||||
case $4 in
|
||||
[0-9]*,)
|
||||
desc="$desc ports $4"
|
||||
;;
|
||||
[0-9]*)
|
||||
desc="$desc port $4"
|
||||
;;
|
||||
*)
|
||||
desc="$desc $4"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
command="$command -j ACCEPT"
|
||||
|
||||
open_close_setup #Conditionally acquires mutex
|
||||
|
||||
if [ $COMMAND = open ]; then
|
||||
if $g_tool -I $command ; then
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
echo "Firewall dynamically opened for connections $desc"
|
||||
return 0
|
||||
fi
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
return 2
|
||||
fi
|
||||
|
||||
if $g_tool -D $command 2> /dev/null; then
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
echo "Firewall dynamically closed for connections $desc (may still be permitted by rules/policies)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
fatal_error "Connections $desc are not currently opened"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# 'hits' commmand executor
|
||||
#
|
||||
@@ -2231,6 +2465,7 @@ determine_capabilities() {
|
||||
local chain
|
||||
local chain1
|
||||
local arptables
|
||||
local helper
|
||||
|
||||
if [ -z "$g_tool" ]; then
|
||||
[ $g_family -eq 4 ] && tool=iptables || tool=ip6tables
|
||||
@@ -2329,6 +2564,9 @@ determine_capabilities() {
|
||||
MASQUERADE_TGT=
|
||||
UDPLITEREDIRECT=
|
||||
NEW_TOS_MATCH=
|
||||
TARPIT_TARGET=
|
||||
IFACE_MATCH=
|
||||
TCPMSS_TARGET=
|
||||
|
||||
AMANDA_HELPER=
|
||||
FTP_HELPER=
|
||||
@@ -2482,6 +2720,12 @@ determine_capabilities() {
|
||||
qt $NFACCT del $chain
|
||||
fi
|
||||
|
||||
qt $g_tool -A $chain -p tcp -j TARPIT && TARPIT_TARGET=Yes
|
||||
|
||||
qt $g_tool -A $chain -m iface --iface lo --loopback && IFACE_MATCH=Yes
|
||||
|
||||
qt $g_tool -A $chain -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu && TCPMSS_TARGET=Yes
|
||||
|
||||
if [ -n "$MANGLE_ENABLED" ]; then
|
||||
qt $g_tool -t mangle -N $chain
|
||||
|
||||
@@ -2523,21 +2767,44 @@ determine_capabilities() {
|
||||
if qt $g_tool -t raw -A $chain -j CT --notrack; then
|
||||
CT_TARGET=Yes;
|
||||
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 10080 -j CT --helper amanda && AMANDA_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p tcp --dport 21 -j CT --helper ftp && FTP_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p tcp --dport 21 -j CT --helper ftp-0 && FTP0_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 1719 -j CT --helper RAS && H323_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p tcp --dport 6667 -j CT --helper irc && IRC_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p tcp --dport 6667 -j CT --helper irc-0 && IRC0_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 137 -j CT --helper netbios-ns && NETBIOS_NS_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p tcp --dport 1729 -j CT --helper pptp && PPTP_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p tcp --dport 6566 -j CT --helper sane && SANE_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p tcp --dport 6566 -j CT --helper sane-0 && SANE0_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 5060 -j CT --helper sip && SIP_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 5060 -j CT --helper sip-0 && SIP0_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 161 -j CT --helper snmp && SNMP_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 69 -j CT --helper tftp && TFTP_HELPER=Yes
|
||||
qt $g_tool -t raw -A $chain -p udp --dport 69 -j CT --helper tftp-0 && TFTP0_HELPER=Yes
|
||||
for helper in amanda ftp ftp0 h323 irc irc0 netbios_ns pptp sane sane0 sip sip0 snmp tftp tftp0; do
|
||||
eval ${helper}_ENABLED=''
|
||||
done
|
||||
|
||||
if [ -n "$HELPERS" ]; then
|
||||
for helper in $(split_list "$HELPERS"); do
|
||||
case $helper in
|
||||
none)
|
||||
;;
|
||||
amanda|ftp|ftp0|h323|irc|irc0|netbios_ns|pptp|sane|sane0|sip|sip0|snmp|tftp|tftp0)
|
||||
eval ${helper}_ENABLED=Yes
|
||||
;;
|
||||
*)
|
||||
error_message "WARNING: Invalid helper ($helper) ignored"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
for helper in amanda ftp ftp0 h323 irc irc0 netbios_ns pptp sane sane0 sip sip0 snmp tftp tftp0; do
|
||||
eval ${helper}_ENABLED=Yes
|
||||
done
|
||||
fi
|
||||
|
||||
[ -n "$amanda_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 10080 -j CT --helper amanda && AMANDA_HELPER=Yes
|
||||
[ -n "$ftp_ENABLED" ] && qt $g_tool -t raw -A $chain -p tcp --dport 21 -j CT --helper ftp && FTP_HELPER=Yes
|
||||
[ -n "$ftp0_ENABLED" ] && qt $g_tool -t raw -A $chain -p tcp --dport 21 -j CT --helper ftp-0 && FTP0_HELPER=Yes
|
||||
[ -n "$h323_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 1719 -j CT --helper RAS && H323_HELPER=Yes
|
||||
[ -n "$irc_ENABLED" ] && qt $g_tool -t raw -A $chain -p tcp --dport 6667 -j CT --helper irc && IRC_HELPER=Yes
|
||||
[ -n "$irc0_ENABLED" ] && qt $g_tool -t raw -A $chain -p tcp --dport 6667 -j CT --helper irc-0 && IRC0_HELPER=Yes
|
||||
[ -n "$netbios_ns_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 137 -j CT --helper netbios-ns && NETBIOS_NS_HELPER=Yes
|
||||
[ -n "$pptp_ENABLED" ] && qt $g_tool -t raw -A $chain -p tcp --dport 1729 -j CT --helper pptp && PPTP_HELPER=Yes
|
||||
[ -n "$sane_ENABLED" ] && qt $g_tool -t raw -A $chain -p tcp --dport 6566 -j CT --helper sane && SANE_HELPER=Yes
|
||||
[ -n "$sane0_ENABLED" ] && qt $g_tool -t raw -A $chain -p tcp --dport 6566 -j CT --helper sane-0 && SANE0_HELPER=Yes
|
||||
[ -n "$sip_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 5060 -j CT --helper sip && SIP_HELPER=Yes
|
||||
[ -n "$sip0_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 5060 -j CT --helper sip-0 && SIP0_HELPER=Yes
|
||||
[ -n "$snmp_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 161 -j CT --helper snmp && SNMP_HELPER=Yes
|
||||
[ -n "$tftp_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 69 -j CT --helper tftp && TFTP_HELPER=Yes
|
||||
[ -n "$tftp0_ENABLED" ] && qt $g_tool -t raw -A $chain -p udp --dport 69 -j CT --helper tftp-0 && TFTP0_HELPER=Yes
|
||||
fi
|
||||
|
||||
qt $g_tool -t raw -F $chain
|
||||
@@ -2751,14 +3018,17 @@ report_capabilities_unsorted() {
|
||||
report_capability "IMQ Target (IMQ_TARGET)" $IMQ_TARGET
|
||||
report_capability "DSCP Match (DSCP_MATCH)" $DSCP_MATCH
|
||||
report_capability "DSCP Target (DSCP_TARGET)" $DSCP_TARGET
|
||||
report_capability "Geo IP match" $GEOIP_MATCH
|
||||
report_capability "RPFilter match" $RPFILTER_MATCH
|
||||
report_capability "NFAcct match" $NFACCT_MATCH
|
||||
report_capability "Checksum Target" $CHECKSUM_TARGET
|
||||
report_capability "Arptables JF" $ARPTABLESJF
|
||||
report_capability "MASQUERADE Target" $MASQUERADE_TGT
|
||||
report_capability "UDPLITE Port Redirection" $UDPLITEREDIRECT
|
||||
report_capability "New tos Match" $NEW_TOS_MATCH
|
||||
report_capability "Geo IP Match (GEOIP_MATCH)" $GEOIP_MATCH
|
||||
report_capability "RPFilter Match (RPFILTER_MATCH)" $RPFILTER_MATCH
|
||||
report_capability "NFAcct Match" $NFACCT_MATCH
|
||||
report_capability "Checksum Target (CHECKSUM_TARGET)" $CHECKSUM_TARGET
|
||||
report_capability "Arptables JF (ARPTABLESJF)" $ARPTABLESJF
|
||||
report_capability "MASQUERADE Target (MASQUERADE_TGT)" $MASQUERADE_TGT
|
||||
report_capability "UDPLITE Port Redirection (UDPLITEREDIRECT)" $UDPLITEREDIRECT
|
||||
report_capability "New tos Match (NEW_TOS_MATCH)" $NEW_TOS_MATCH
|
||||
report_capability "TARPIT Target (TARPIT_TARGET)" $TARPIT_TARGET
|
||||
report_capability "Iface Match (IFACE_MATCH)" $IFACE_MATCH
|
||||
report_capability "TCPMSS Target (TCPMSS_TARGET)" $TCPMSS_TARGET
|
||||
|
||||
report_capability "Amanda Helper" $AMANDA_HELPER
|
||||
report_capability "FTP Helper" $FTP_HELPER
|
||||
@@ -2886,6 +3156,9 @@ report_capabilities_unsorted1() {
|
||||
report_capability1 MASQUERADE_TGT
|
||||
report_capability1 UDPLITEREDIRECT
|
||||
report_capability1 NEW_TOS_MATCH
|
||||
report_capability1 TARPIT_TARGET
|
||||
report_capability1 IFACE_MATCH
|
||||
report_capability1 TCPMSS_TARGET
|
||||
|
||||
report_capability1 AMANDA_HELPER
|
||||
report_capability1 FTP_HELPER
|
||||
@@ -2944,9 +3217,74 @@ show_status() {
|
||||
|
||||
}
|
||||
|
||||
interface_status() {
|
||||
case $(cat $1) in
|
||||
0)
|
||||
echo Enabled
|
||||
;;
|
||||
1)
|
||||
echo Disabled
|
||||
;;
|
||||
*)
|
||||
echo Unknown
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
show_interfaces() {
|
||||
local f
|
||||
local interface
|
||||
local printed
|
||||
|
||||
for f in ${VARDIR}/*.status; do
|
||||
interface=$(basename $f)
|
||||
echo " Interface ${interface%.status} is $(interface_status $f)"
|
||||
printed=Yes
|
||||
done
|
||||
|
||||
[ -n "$printed" ] && echo
|
||||
}
|
||||
|
||||
status_command() {
|
||||
local finished
|
||||
finished=0
|
||||
local option
|
||||
local interfaces
|
||||
|
||||
while [ $finished -eq 0 -a $# -gt 0 ]; do
|
||||
option=$1
|
||||
case $option in
|
||||
-*)
|
||||
option=${option#-}
|
||||
|
||||
while [ -n "$option" ]; do
|
||||
case $option in
|
||||
-)
|
||||
finished=1
|
||||
option=
|
||||
;;
|
||||
i*)
|
||||
interfaces=Yes
|
||||
option=${option#i}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
finished=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ $# -eq 0 ] || usage 1
|
||||
|
||||
[ $VERBOSITY -ge 1 ] && echo "${g_product}-$SHOREWALL_VERSION Status at $g_hostname - $(date)" && echo
|
||||
show_status
|
||||
[ -n "$interfaces" ] && show_interfaces
|
||||
exit $status
|
||||
}
|
||||
|
||||
@@ -2991,11 +3329,45 @@ reject_command() {
|
||||
}
|
||||
|
||||
save_command() {
|
||||
local finished
|
||||
finished=0
|
||||
|
||||
shift
|
||||
|
||||
while [ $finished -eq 0 -a $# -gt 0 ]; do
|
||||
option=$1
|
||||
case $option in
|
||||
-*)
|
||||
option=${option#-}
|
||||
|
||||
while [ -n "$option" ]; do
|
||||
case $option in
|
||||
-)
|
||||
finished=1
|
||||
option=
|
||||
;;
|
||||
C*)
|
||||
g_counters=Yes
|
||||
option=${option#C}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
finished=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
case $# in
|
||||
1)
|
||||
0)
|
||||
;;
|
||||
2)
|
||||
RESTOREFILE="$2"
|
||||
1)
|
||||
RESTOREFILE="$1"
|
||||
validate_restorefile '<restore file>'
|
||||
;;
|
||||
*)
|
||||
@@ -3228,11 +3600,6 @@ get_config() {
|
||||
|
||||
g_hostname=$(hostname 2> /dev/null)
|
||||
|
||||
IP=$(mywhich ip 2> /dev/null)
|
||||
if [ -z "$IP" ] ; then
|
||||
fatal_error "Can't find ip executable"
|
||||
fi
|
||||
|
||||
if [ -n "$IPSET" ]; then
|
||||
case "$IPSET" in
|
||||
*/*)
|
||||
@@ -3254,6 +3621,10 @@ get_config() {
|
||||
|
||||
TC=tc
|
||||
|
||||
IP=$(mywhich ip 2> /dev/null)
|
||||
|
||||
g_loopback=$(find_loopback_interfaces)
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
@@ -3290,12 +3661,16 @@ start_command() {
|
||||
[ -n "$g_nolock" ] || mutex_on
|
||||
|
||||
if [ -x ${VARDIR}/firewall ]; then
|
||||
run_it ${VARDIR}/firewall $g_debugging start
|
||||
if [ -n "$g_fast" -a -x ${VARDIR}/${RESTOREFILE} -a ! ${VARDIR}/firewall -nt ${VARDIR}/${RESTOREFILE} ]; then
|
||||
run_it ${VARDIR}/${RESTOREFILE} $g_debugging restore
|
||||
else
|
||||
run_it ${VARDIR}/firewall $g_debugging start
|
||||
fi
|
||||
rc=$?
|
||||
else
|
||||
error_message "${VARDIR}/firewall is missing or is not executable"
|
||||
logger -p kern.err "ERROR:$g_product start failed"
|
||||
rc=2
|
||||
rc=6
|
||||
fi
|
||||
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
@@ -3326,6 +3701,14 @@ start_command() {
|
||||
finished=1
|
||||
option=
|
||||
;;
|
||||
f*)
|
||||
g_fast=Yes
|
||||
option=${option#f}
|
||||
;;
|
||||
C*)
|
||||
g_counters=Yes
|
||||
option=${option#C}
|
||||
;;
|
||||
p*)
|
||||
[ -n "$(which conntrack)" ] || fatal_error "The '-p' option requires the conntrack utility which does not appear to be installed on this system"
|
||||
g_purge=Yes
|
||||
@@ -3387,6 +3770,10 @@ restart_command() {
|
||||
g_purge=Yes
|
||||
option=${option%p}
|
||||
;;
|
||||
C*)
|
||||
g_counters=Yes
|
||||
option=${option#C}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@@ -3416,13 +3803,21 @@ restart_command() {
|
||||
else
|
||||
error_message "${VARDIR}/firewall is missing or is not executable"
|
||||
logger -p kern.err "ERROR:$g_product restart failed"
|
||||
rc=2
|
||||
rc=6
|
||||
fi
|
||||
|
||||
[ -n "$g_nolock" ] || mutex_off
|
||||
return $rc
|
||||
}
|
||||
|
||||
run_command() {
|
||||
if [ -x ${VARDIR}/firewall ] ; then
|
||||
run_it ${VARDIR}/firewall $g_debugging $@
|
||||
else
|
||||
fatal_error "${VARDIR}/firewall does not exist or is not executable"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Give Usage Information
|
||||
#
|
||||
@@ -3433,6 +3828,7 @@ usage() # $1 = exit status
|
||||
echo " add <interface>[:<host-list>] ... <zone>"
|
||||
echo " allow <address> ..."
|
||||
echo " clear"
|
||||
echo " close <source> <dest> [ <protocol> [ <port> ] ]"
|
||||
echo " delete <interface>[:<host-list>] ... <zone>"
|
||||
echo " disable <interface>"
|
||||
echo " drop <address> ..."
|
||||
@@ -3450,14 +3846,19 @@ usage() # $1 = exit status
|
||||
echo " logdrop <address> ..."
|
||||
echo " logreject <address> ..."
|
||||
echo " logwatch [<refresh interval>]"
|
||||
echo " open <source> <dest> [ <protocol> [ <port> ] ]"
|
||||
echo " reject <address> ..."
|
||||
echo " reenable <interface>"
|
||||
echo " reset [ <chain> ... ]"
|
||||
echo " restart [ -n ] [ -p ] [ -f ] [ <directory> ]"
|
||||
echo " restore [ -n ] [ <file name> ]"
|
||||
echo " save [ <file name> ]"
|
||||
echo " restart [ -n ] [ -p ] [ -f ] [ -C ] [ <directory> ]"
|
||||
echo " restore [ -n ] [ -p ] [ -C ] [ <file name> ]"
|
||||
echo " run <command> [ <parameter> ... ]"
|
||||
echo " save [ -C ] [ <file name> ]"
|
||||
echo " savesets"
|
||||
echo " [ show | list | ls ] [ -b ] [ -x ] [ -t {filter|mangle|nat} ] [ {chain [<chain> [ <chain> ... ]"
|
||||
echo " [ show | list | ls ] [ -f ] capabilities"
|
||||
echo " [ show | list | ls ] arptables"
|
||||
echo " [ show | list | ls ] [ -x ] {bl|blacklists}"
|
||||
echo " [ show | list | ls ] classifiers"
|
||||
echo " [ show | list | ls ] config"
|
||||
echo " [ show | list | ls ] connections"
|
||||
@@ -3473,14 +3874,15 @@ usage() # $1 = exit status
|
||||
echo " [ show | list | ls ] [ -m ] log [<regex>]"
|
||||
echo " [ show | list | ls ] [ -x ] mangle|nat|raw|rawpost"
|
||||
echo " [ show | list | ls ] nfacct"
|
||||
echo " [ show | list | ls ] opens"
|
||||
echo " [ show | list | ls ] policies"
|
||||
echo " [ show | list | ls ] routing"
|
||||
echo " [ show | list | ls ] tc [ device ]"
|
||||
echo " [ show | list | ls ] vardir"
|
||||
echo " [ show | list | ls ] zones"
|
||||
echo " start [ -f ] [ -p ] [ <directory> ]"
|
||||
echo " start [ -f ] [ -p ] [ -C ] [ <directory> ]"
|
||||
echo " stop"
|
||||
echo " status"
|
||||
echo " status [ -i ]"
|
||||
echo " version [ -a ]"
|
||||
echo
|
||||
exit $1
|
||||
@@ -3530,6 +3932,8 @@ shorewall_cli() {
|
||||
g_directives=
|
||||
g_inline=
|
||||
g_tcrules=
|
||||
g_counters=
|
||||
g_loopback=
|
||||
|
||||
VERBOSE=
|
||||
VERBOSITY=1
|
||||
@@ -3651,10 +4055,6 @@ shorewall_cli() {
|
||||
|
||||
[ -n "${VARDIR:=/var/lib/$g_program}" ]
|
||||
|
||||
if [ ! -f ${VARDIR}/firewall ]; then
|
||||
[ -f ${VARDIR}/.restore ] && cp -f ${VARDIR}/.rstore ${VARDIR}/firewall
|
||||
fi
|
||||
|
||||
g_firewall=${VARDIR}/firewall
|
||||
|
||||
version_file=${g_sharedir}/version
|
||||
@@ -3717,7 +4117,7 @@ shorewall_cli() {
|
||||
shift
|
||||
restart_command $@
|
||||
;;
|
||||
disable|enable)
|
||||
disable|enable|reenable)
|
||||
get_config Yes
|
||||
if product_is_started; then
|
||||
run_it ${VARDIR}/firewall $g_debugging $@
|
||||
@@ -3725,16 +4125,21 @@ shorewall_cli() {
|
||||
fatal_error "$g_product is not running"
|
||||
fi
|
||||
;;
|
||||
run)
|
||||
[ $# -gt 1 ] || fatal_error "Missing function name"
|
||||
get_config Yes
|
||||
run_command $@
|
||||
;;
|
||||
show|list|ls)
|
||||
get_config Yes No Yes
|
||||
shift
|
||||
show_command $@
|
||||
;;
|
||||
status)
|
||||
[ $# -eq 1 ] || usage 1
|
||||
[ "$(id -u)" != 0 ] && fatal_error "The status command may only be run by root"
|
||||
get_config
|
||||
status_command
|
||||
shift
|
||||
status_command $@
|
||||
;;
|
||||
dump)
|
||||
get_config Yes No Yes
|
||||
@@ -3775,6 +4180,11 @@ shorewall_cli() {
|
||||
[ $# -eq 1 ] && usage 1
|
||||
reject_command $@
|
||||
;;
|
||||
open|close)
|
||||
get_config
|
||||
shift
|
||||
open_close_command $@
|
||||
;;
|
||||
allow)
|
||||
get_config
|
||||
allow_command $@
|
||||
@@ -3819,10 +4229,29 @@ shorewall_cli() {
|
||||
get_config
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
#
|
||||
# Undocumented way to call functions in the libraries directly
|
||||
# Way to call functions in the libraries directly
|
||||
#
|
||||
shift
|
||||
$@
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
#
|
||||
# First look for it here
|
||||
#
|
||||
if type $1 2> /dev/null | fgrep -q 'is a function'; then
|
||||
#
|
||||
# It's a shell function -- call it
|
||||
#
|
||||
$@
|
||||
else
|
||||
#
|
||||
# It isn't a function visible to this script -- try
|
||||
# the compiled firewall
|
||||
#
|
||||
run_it $g_firewall $g_debugging call $@
|
||||
fi
|
||||
else
|
||||
usage 1
|
||||
fi
|
||||
;;
|
||||
help)
|
||||
shift
|
||||
@@ -3838,6 +4267,12 @@ shorewall_cli() {
|
||||
shift
|
||||
noiptrace_command $@
|
||||
;;
|
||||
savesets)
|
||||
[ $# -eq 1 ] || usage 1
|
||||
get_config
|
||||
[ -n "$g_debugging" ] && set -x
|
||||
savesets1
|
||||
;;
|
||||
*)
|
||||
if [ -z "$g_lite" ]; then
|
||||
compiler_command $@
|
||||
|
@@ -70,6 +70,15 @@ startup_error() # $* = Error Message
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Fatal Error
|
||||
#
|
||||
fatal_error() # $@ = Message
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
#
|
||||
# Get the Shorewall version of the passed script
|
||||
#
|
||||
@@ -157,6 +166,7 @@ run_it() {
|
||||
[ -n "$g_timestamp" ] && options=${options}t
|
||||
[ -n "$g_purge" ] && options=${options}p
|
||||
[ -n "$g_recovering" ] && options=${options}r
|
||||
[ -n "$g_counters" ] && options=${options}c
|
||||
|
||||
options="${options}V $VERBOSITY"
|
||||
|
||||
@@ -172,6 +182,7 @@ run_it() {
|
||||
error_message() # $* = Error Message
|
||||
{
|
||||
echo " $@" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
#
|
||||
@@ -209,6 +220,17 @@ split() {
|
||||
IFS=$ifs
|
||||
}
|
||||
|
||||
#
|
||||
# Split a comma-separated list into a space-separated list
|
||||
#
|
||||
split_list() {
|
||||
local ifs
|
||||
ifs=$IFS
|
||||
IFS=,
|
||||
echo $*
|
||||
IFS=$ifs
|
||||
}
|
||||
|
||||
#
|
||||
# Search a list looking for a match -- returns zero if a match found
|
||||
# 1 otherwise
|
||||
@@ -372,7 +394,7 @@ reload_kernel_modules() {
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=ko ko.gz o o.gz gz}" ]
|
||||
[ -n "${MODULE_SUFFIX:=ko ko.gz ko.xz o o.gz o.xz gz xz}" ]
|
||||
|
||||
[ -z "$MODULESDIR" ] && \
|
||||
uname=$(uname -r) && \
|
||||
@@ -411,7 +433,7 @@ load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
|
||||
moduleloader=insmod
|
||||
fi
|
||||
|
||||
[ -n "${MODULE_SUFFIX:=o gz ko o.gz ko.gz}" ]
|
||||
[ -n "${MODULE_SUFFIX:=o gz xz ko o.gz o.xz ko.gz ko.xz}" ]
|
||||
|
||||
[ -z "$MODULESDIR" ] && \
|
||||
uname=$(uname -r) && \
|
||||
@@ -643,6 +665,24 @@ find_first_interface_address_if_any() # $1 = interface
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
#Determines if the passed interface is a loopback interface
|
||||
#
|
||||
loopback_interface() { #$1 = Interface name
|
||||
[ "$1" = lo ] || $IP link show $1 | fgrep -q LOOPBACK
|
||||
}
|
||||
|
||||
#
|
||||
# Find Loopback Interfaces
|
||||
#
|
||||
find_loopback_interfaces() {
|
||||
local interfaces
|
||||
|
||||
[ -x "$IP" ] && interfaces=$($IP link show | fgrep LOOPBACK | sed 's/://g' | cut -d ' ' -f 2)
|
||||
|
||||
[ -n "$interfaces" ] && echo $interfaces || echo lo
|
||||
}
|
||||
|
||||
#
|
||||
# Internal version of 'which'
|
||||
#
|
||||
|
@@ -14,7 +14,7 @@ INITDIR= #Unused on OS X
|
||||
INITFILE= #Unused on OS X
|
||||
INITSOURCE= #Unused on OS X
|
||||
ANNOTATED= #Unused on OS X
|
||||
SYSTEMD= #Unused on OS X
|
||||
SERVICEDIR= #Unused on OS X
|
||||
SERVICEFILE= #Unused on OS X
|
||||
SYSCONFDIR= #Unused on OS X
|
||||
SPARSE=Yes #Only install $PRODUCT/$PRODUCT.conf in $CONFDIR.
|
||||
|
@@ -8,14 +8,14 @@ SHAREDIR=${PREFIX}/share #Directory for arch-neutral files.
|
||||
LIBEXECDIR=${PREFIX}/share #Directory for executable scripts.
|
||||
PERLLIBDIR=${PREFIX}/share/shorewall #Directory to install Shorewall Perl module directory
|
||||
CONFDIR=/etc #Directory where subsystem configurations are installed
|
||||
SBINDIR=/usr/sbin #Directory where system administration programs are installed
|
||||
SBINDIR=/usr/bin #Directory where system administration programs are installed
|
||||
MANDIR=${SHAREDIR}/man #Directory where manpages are installed.
|
||||
INITDIR= #Directory where SysV init scripts are installed.
|
||||
INITFILE= #Name of the product's installed SysV init script
|
||||
INITSOURCE= #Name of the distributed file to be installed as the SysV init script
|
||||
ANNOTATED= #If non-zero, annotated configuration files are installed
|
||||
SYSCONFDIR= #Directory where SysV init parameter files are installed
|
||||
SYSTEMD=/usr/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEDIR=/usr/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
|
||||
SPARSE= #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR
|
||||
VARLIB=/var/lib #Directory where product variable data is stored.
|
||||
|
@@ -14,7 +14,7 @@ INITDIR=/etc/init.d #Unused on Cygwin
|
||||
INITFILE= #Unused on Cygwin
|
||||
INITSOURCE= #Unused on Cygwin
|
||||
ANNOTATED= #Unused on Cygwin
|
||||
SYSTEMD= #Unused on Cygwin
|
||||
SERVICEDIR= #Unused on Cygwin
|
||||
SERVICEFILE= #Unused on Cygwin
|
||||
SYSCONFDIR= #Unused on Cygwin
|
||||
SPARSE=Yes #Only install $PRODUCT/$PRODUCT.conf in $CONFDIR.
|
||||
|
@@ -17,7 +17,7 @@ ANNOTATED= #If non-zero, annotated configuration fi
|
||||
SYSCONFFILE=default.debian #Name of the distributed file to be installed in $SYSCONFDIR
|
||||
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
|
||||
SYSCONFDIR=/etc/default #Directory where SysV init parameter files are installed
|
||||
SYSTEMD= #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEDIR= #Directory where .service files are installed (systems running systemd only)
|
||||
SPARSE=Yes #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR
|
||||
VARLIB=/var/lib #Directory where product variable data is stored.
|
||||
VARDIR=${VARLIB}/$PRODUCT #Directory where product variable data is stored.
|
||||
|
@@ -14,7 +14,7 @@ INITDIR=/etc/init.d #Directory where SysV init scripts are i
|
||||
INITFILE=$PRODUCT #Name of the product's installed SysV init script
|
||||
INITSOURCE=init.sh #Name of the distributed file to be installed as the SysV init script
|
||||
ANNOTATED= #If non-zero, annotated configuration files are installed
|
||||
SYSTEMD= #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEDIR= #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
|
||||
SYSCONFFILE= #Name of the distributed file to be installed in $SYSCONFDIR
|
||||
SYSCONFDIR= #Directory where SysV init parameter files are installed
|
||||
|
@@ -14,7 +14,7 @@ INITDIR=/etc/rc.d/init.d #Directory where SysV init scripts are i
|
||||
INITFILE=$PRODUCT #Name of the product's installed SysV init script
|
||||
INITSOURCE=init.fedora.sh #Name of the distributed file to be installed as the SysV init script
|
||||
ANNOTATED= #If non-zero, annotated configuration files are installed
|
||||
SYSTEMD=/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEDIR=/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
|
||||
SYSCONFFILE=sysconfig #Name of the distributed file to be installed as $SYSCONFDIR/$PRODUCT
|
||||
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
|
||||
SYSCONFDIR=/etc/sysconfig/ #Directory where SysV init parameter files are installed
|
||||
|
@@ -15,7 +15,7 @@ AUXINITSOURCE=init.slackware.firewall.sh #Name of the distributed file to be i
|
||||
AUXINITFILE=rc.firewall #Name of the product's installed SysV init script
|
||||
INITSOURCE=init.slackware.$PRODUCT.sh #Name of the distributed file to be installed as a second SysV init script
|
||||
INITFILE=rc.$PRODUCT #Name of the product's installed second init script
|
||||
SYSTEMD= #Name of the directory where .service files are installed (systems running systemd only)
|
||||
SERVICEDIR= #Name of the directory where .service files are installed (systems running systemd only)
|
||||
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
|
||||
SYSCONFFILE= #Name of the distributed file to be installed in $SYSCONFDIR
|
||||
SYSCONFDIR= #Name of the directory where SysV init parameter files are installed.
|
||||
|
@@ -8,13 +8,13 @@ CONFDIR=/etc #Directory where subsystem
|
||||
SHAREDIR=${PREFIX}/share #Directory for arch-neutral files.
|
||||
LIBEXECDIR=${PREFIX}/lib #Directory for executable scripts.
|
||||
PERLLIBDIR=${PREFIX}/lib/perl5/vendor_perl/5.14.2 #Directory to install Shorewall Perl module directory
|
||||
SBINDIR=/sbin #Directory where system administration programs are installed
|
||||
SBINDIR=/usr/sbin #Directory where system administration programs are installed
|
||||
MANDIR=${SHAREDIR}/man/ #Directory where manpages are installed.
|
||||
INITDIR=/etc/init.d #Directory where SysV init scripts are installed.
|
||||
INITFILE=$PRODUCT #Name of the product's SysV init script
|
||||
INITSOURCE=init.suse.sh #Name of the distributed file to be installed as the SysV init script
|
||||
ANNOTATED= #If non-zero, annotated configuration files are installed
|
||||
SYSTEMD= #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEDIR= #Directory where .service files are installed (systems running systemd only)
|
||||
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
|
||||
SYSCONFFILE=sysconfig #Name of the distributed file to be installed in $SYSCONFDIR
|
||||
SYSCONFDIR=/etc/sysconfig/ #Directory where SysV init parameter files are installed
|
||||
|
@@ -35,6 +35,12 @@ usage() # $1 = exit status
|
||||
exit $1
|
||||
}
|
||||
|
||||
fatal_error()
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
qt()
|
||||
{
|
||||
"$@" >/dev/null 2>&1
|
||||
|
@@ -28,7 +28,7 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ ! -x $STATEDIR/firewall ]; then
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
|
@@ -31,7 +31,7 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ ! -x "$STATEDIR/firewall" ]; then
|
||||
if [ $PRODUCT == shorewall -o $PRODUCT == shorewall6 ]; then
|
||||
|
@@ -28,7 +28,7 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ ! -x $STATEDIR/firewall ]; then
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
|
@@ -71,10 +71,12 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c || echo_notdone
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -103,26 +105,33 @@ shorewall_start () {
|
||||
echo -n "Initializing \"Shorewall-based firewalls\": "
|
||||
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
|
||||
if [ -x ${STATEDIR}/$PRODUCT/firewall ]; then
|
||||
#
|
||||
# Run in a sub-shell to avoid name collisions
|
||||
#
|
||||
(
|
||||
if ! ${STATEDIR}/$PRODUCT/firewall status > /dev/null 2>&1; then
|
||||
${STATEDIR}/$PRODUCT/firewall ${OPTIONS} stop || echo_notdone
|
||||
else
|
||||
echo_notdone
|
||||
fi
|
||||
)
|
||||
else
|
||||
echo echo_notdone
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
#
|
||||
# Run in a sub-shell to avoid name collisions
|
||||
#
|
||||
(
|
||||
if ! ${STATEDIR}/firewall status > /dev/null 2>&1; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop
|
||||
fi
|
||||
)
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "done."
|
||||
|
||||
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
|
||||
|
||||
echo -n "Restoring ipsets: "
|
||||
|
||||
if ! ipset -R < "$SAVE_IPSETS"; then
|
||||
echo_notdone
|
||||
fi
|
||||
|
||||
echo "done."
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -133,15 +142,29 @@ shorewall_stop () {
|
||||
|
||||
echo -n "Clearing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
|
||||
if [ -x ${STATEDIR}/$PRODUCT/firewall ]; then
|
||||
${STATEDIR}/$PRODUCT/firewall ${OPTIONS} clear || echo_notdone
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "done."
|
||||
|
||||
if [ -n "$SAVE_IPSETS" ]; then
|
||||
|
||||
echo "Saving ipsets: "
|
||||
|
||||
mkdir -p $(dirname "$SAVE_IPSETS")
|
||||
if ipset -S > "${SAVE_IPSETS}.tmp"; then
|
||||
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS"
|
||||
else
|
||||
echo_notdone
|
||||
fi
|
||||
|
||||
echo "done."
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@@ -42,7 +42,7 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ $PRODUCT == shorewall -o $PRODUCT == shorewall6 ]; then
|
||||
${SBINDIR}/$PRODUCT $OPTIONS compile -c
|
||||
|
@@ -67,12 +67,12 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ ! -x $STATEDIR/firewall ]; then
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile $STATEDIR/firewall
|
||||
fi
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile $STATEDIR/firewall
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -83,11 +83,11 @@ shorewall_start () {
|
||||
|
||||
echo -n "Initializing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop || exit 1
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
@@ -106,10 +106,10 @@ shorewall_stop () {
|
||||
|
||||
echo -n "Clearing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear || exit 1
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
@@ -77,10 +77,12 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c || exit
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -91,14 +93,12 @@ shorewall_start () {
|
||||
|
||||
echo -n "Initializing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
|
||||
if [ -x $STATEDIR/firewall ]; then
|
||||
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
|
||||
$STATEDIR/$PRODUCT/firewall ${OPTIONS} stop || exit
|
||||
if setstatedir; then
|
||||
if [ -x $STATEDIR/firewall ]; then
|
||||
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
|
||||
$STATEDIR/$PRODUCT/firewall ${OPTIONS} stop
|
||||
fi
|
||||
fi
|
||||
else
|
||||
exit 6
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -114,12 +114,10 @@ shorewall_stop () {
|
||||
|
||||
echo -n "Clearing \"Shorewall-based firewalls\": "
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear || exit
|
||||
else
|
||||
exit 6
|
||||
if setstatedir; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
@@ -35,6 +35,7 @@ usage() # $1 = exit status
|
||||
echo "usage: $ME [ <configuration-file> ]"
|
||||
echo " $ME -v"
|
||||
echo " $ME -h"
|
||||
echo " $ME -n"
|
||||
exit $1
|
||||
}
|
||||
|
||||
@@ -105,9 +106,12 @@ PRODUCT=shorewall-init
|
||||
T='-T'
|
||||
|
||||
finished=0
|
||||
configure=1
|
||||
|
||||
while [ $finished -eq 0 ] ; do
|
||||
case "$1" in
|
||||
option="$1"
|
||||
|
||||
case "$option" in
|
||||
-*)
|
||||
option=${option#-}
|
||||
|
||||
@@ -120,6 +124,10 @@ while [ $finished -eq 0 ] ; do
|
||||
echo "Shorewall-init Firewall Installer Version $VERSION"
|
||||
exit 0
|
||||
;;
|
||||
n*)
|
||||
configure=0
|
||||
option=${option#n}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@@ -176,8 +184,12 @@ for var in SHAREDIR LIBEXECDIR CONFDIR SBINDIR VARLIB VARDIR; do
|
||||
require $var
|
||||
done
|
||||
|
||||
[ -n "$SANDBOX" ] && configure=0
|
||||
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
||||
|
||||
[ $configure -eq 1 ] && ETC=/etc || ETC="${CONFDIR}"
|
||||
|
||||
if [ -z "$BUILD" ]; then
|
||||
case $(uname) in
|
||||
cygwin*)
|
||||
@@ -191,7 +203,7 @@ if [ -z "$BUILD" ]; then
|
||||
eval $(cat /etc/os-release | grep ^ID=)
|
||||
|
||||
case $ID in
|
||||
fedora)
|
||||
fedora|rhel|centos|foobar)
|
||||
BUILD=redhat
|
||||
;;
|
||||
debian|ubuntu)
|
||||
@@ -306,6 +318,7 @@ fi
|
||||
# Install the Firewall Script
|
||||
#
|
||||
if [ -n "$INITFILE" ]; then
|
||||
mkdir -p ${DESTDIR}${INITDIR}
|
||||
install_file $INITSOURCE ${DESTDIR}${INITDIR}/$INITFILE 0544
|
||||
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${INITDIR}/$INITFILE
|
||||
|
||||
@@ -319,13 +332,17 @@ fi
|
||||
#
|
||||
# Install the .service file
|
||||
#
|
||||
if [ -n "$SYSTEMD" ]; then
|
||||
mkdir -p ${DESTDIR}${SYSTEMD}
|
||||
if [ -z "${SERVICEDIR}" ]; then
|
||||
SERVICEDIR="$SYSTEMD"
|
||||
fi
|
||||
|
||||
if [ -n "$SERVICEDIR" ]; then
|
||||
mkdir -p ${DESTDIR}${SERVICEDIR}
|
||||
[ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service
|
||||
run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SYSTEMD}/$PRODUCT.service
|
||||
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SYSTEMD}/$PRODUCT.service
|
||||
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SYSTEMD}/$PRODUCT.service"
|
||||
if [ -n "$DESTDIR" ]; then
|
||||
run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
|
||||
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
|
||||
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SERVICEDIR}/$PRODUCT.service"
|
||||
if [ -n "$DESTDIR" -o $configure -eq 0 ]; then
|
||||
mkdir -p ${DESTDIR}${SBINDIR}
|
||||
chmod 755 ${DESTDIR}${SBINDIR}
|
||||
fi
|
||||
@@ -364,16 +381,22 @@ fi
|
||||
|
||||
if [ $HOST = debian ]; then
|
||||
if [ -n "${DESTDIR}" ]; then
|
||||
mkdir -p ${DESTDIR}/etc/network/if-up.d/
|
||||
mkdir -p ${DESTDIR}/etc/network/if-down.d/
|
||||
mkdir -p ${DESTDIR}${ETC}/network/if-up.d/
|
||||
mkdir -p ${DESTDIR}${ETC}/network/if-down.d/
|
||||
mkdir -p ${DESTDIR}${ETC}/network/if-post-down.d/
|
||||
elif [ $configure -eq 0 ]; then
|
||||
mkdir -p ${DESTDIR}${CONFDIR}/network/if-up.d/
|
||||
mkdir -p ${DESTDIR}${CONFDIR}/network/if-down.d/
|
||||
mkdir -p ${DESTDIR}${CONFDIR}/network/if-post-down.d/
|
||||
fi
|
||||
|
||||
if [ ! -f ${DESTDIR}/etc/default/shorewall-init ]; then
|
||||
if [ ! -f ${DESTDIR}${CONFDIR}/default/shorewall-init ]; then
|
||||
if [ -n "${DESTDIR}" ]; then
|
||||
mkdir ${DESTDIR}/etc/default
|
||||
mkdir ${DESTDIR}${ETC}/default
|
||||
fi
|
||||
|
||||
install_file sysconfig ${DESTDIR}/etc/default/shorewall-init 0644
|
||||
[ $configure -eq 1 ] || mkdir -p ${DESTDIR}${CONFDIR}/default
|
||||
install_file sysconfig ${DESTDIR}${ETC}/default/shorewall-init 0644
|
||||
fi
|
||||
|
||||
IFUPDOWN=ifupdown.debian.sh
|
||||
@@ -383,13 +406,13 @@ else
|
||||
|
||||
if [ -z "$RPM" ]; then
|
||||
if [ $HOST = suse ]; then
|
||||
mkdir -p ${DESTDIR}/etc/sysconfig/network/if-up.d
|
||||
mkdir -p ${DESTDIR}${SYSCONFDIR}/network/if-down.d
|
||||
mkdir -p ${DESTDIR}${ETC}/sysconfig/network/if-up.d
|
||||
mkdir -p ${DESTDIR}${ETC}/sysconfig/network/if-down.d
|
||||
elif [ $HOST = gentoo ]; then
|
||||
# Gentoo does not support if-{up,down}.d
|
||||
/bin/true
|
||||
else
|
||||
mkdir -p ${DESTDIR}/etc/NetworkManager/dispatcher.d
|
||||
mkdir -p ${DESTDIR}/${ETC}/NetworkManager/dispatcher.d
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -415,17 +438,29 @@ mkdir -p ${DESTDIR}${LIBEXECDIR}/shorewall-init
|
||||
install_file ifupdown ${DESTDIR}${LIBEXECDIR}/shorewall-init/ifupdown 0544
|
||||
|
||||
if [ -d ${DESTDIR}/etc/NetworkManager ]; then
|
||||
install_file ifupdown ${DESTDIR}/etc/NetworkManager/dispatcher.d/01-shorewall 0544
|
||||
[ $configure -eq 1 ] || mkdir -p ${DESTDIR}${CONFDIR}/NetworkManager/dispatcher.d/
|
||||
install_file ifupdown ${DESTDIR}${ETC}/NetworkManager/dispatcher.d/01-shorewall 0544
|
||||
fi
|
||||
|
||||
case $HOST in
|
||||
debian)
|
||||
install_file ifupdown ${DESTDIR}/etc/network/if-up.d/shorewall 0544
|
||||
install_file ifupdown ${DESTDIR}/etc/network/if-down.d/shorewall 0544
|
||||
install_file ifupdown ${DESTDIR}/etc/network/if-post-down.d/shorewall 0544
|
||||
if [ $configure -eq 1 ]; then
|
||||
install_file ifupdown ${DESTDIR}/etc/network/if-up.d/shorewall 0544
|
||||
install_file ifupdown ${DESTDIR}/etc/network/if-down.d/shorewall 0544
|
||||
install_file ifupdown ${DESTDIR}/etc/network/if-post-down.d/shorewall 0544
|
||||
else
|
||||
install_file ifupdown ${DESTDIR}${CONFDIR}/network/if-up.d/shorewall 0544
|
||||
install_file ifupdown ${DESTDIR}${CONFDIR}/network/if-down.d/shorewall 0544
|
||||
install_file ifupdown ${DESTDIR}${CONFDIR}/network/if-post-down.d/shorewall 0544
|
||||
fi
|
||||
;;
|
||||
suse)
|
||||
if [ -z "$RPM" ]; then
|
||||
if [ $configure -eq 0 ]; then
|
||||
mkdir -p ${DESTDIR}${SYSCONFDIR}/network/if-up.d/
|
||||
mkdir -p ${DESTDIR}${SYSCONFDIR}/network/if-down.d/
|
||||
fi
|
||||
|
||||
install_file ifupdown ${DESTDIR}${SYSCONFDIR}/network/if-up.d/shorewall 0544
|
||||
install_file ifupdown ${DESTDIR}${SYSCONFDIR}/network/if-down.d/shorewall 0544
|
||||
fi
|
||||
@@ -453,7 +488,7 @@ case $HOST in
|
||||
esac
|
||||
|
||||
if [ -z "$DESTDIR" ]; then
|
||||
if [ -n "$first_install" ]; then
|
||||
if [ $configure -eq 1 -a -n "$first_install" ]; then
|
||||
if [ $HOST = debian ]; then
|
||||
if mywhich insserv; then
|
||||
if insserv ${INITDIR}/shorewall-init; then
|
||||
@@ -476,7 +511,7 @@ if [ -z "$DESTDIR" ]; then
|
||||
# not by the installer
|
||||
/bin/true
|
||||
else
|
||||
if [ -n "$SYSTEMD" ]; then
|
||||
if [ -n "$SERVICEDIR" ]; then
|
||||
if systemctl enable shorewall-init.service; then
|
||||
echo "Shorewall Init will start automatically at boot"
|
||||
fi
|
||||
@@ -505,7 +540,7 @@ if [ -z "$DESTDIR" ]; then
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [ -n "$first_install" ]; then
|
||||
if [ $configure -eq 1 -a -n "$first_install" ]; then
|
||||
if [ $HOST = debian ]; then
|
||||
if [ -n "${DESTDIR}" ]; then
|
||||
mkdir -p ${DESTDIR}/etc/rcS.d
|
||||
|
@@ -30,7 +30,7 @@ setstatedir() {
|
||||
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
|
||||
fi
|
||||
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT}
|
||||
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
|
||||
|
||||
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
|
||||
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c || exit 1
|
||||
@@ -63,18 +63,19 @@ shorewall_start () {
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
|
||||
if [ -x ${STATEDIR}/$PRODUCT/firewall ]; then
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
#
|
||||
# Run in a sub-shell to avoid name collisions
|
||||
#
|
||||
(
|
||||
if ! ${STATEDIR}/$PRODUCT/firewall status > /dev/null 2>&1; then
|
||||
${STATEDIR}/$PRODUCT/firewall ${OPTIONS} stop || exit 1
|
||||
if ! ${STATEDIR}/firewall status > /dev/null 2>&1; then
|
||||
${STATEDIR}/firewall ${OPTIONS} stop || exit 1
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
)
|
||||
else
|
||||
echo ERROR: ${STATEDIR}/firewall does not exist or is not executable!
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
@@ -95,8 +96,8 @@ shorewall_stop () {
|
||||
for PRODUCT in $PRODUCTS; do
|
||||
setstatedir
|
||||
|
||||
if [ -x ${STATEDIR}/$PRODUCT/firewall ]; then
|
||||
${STATEDIR}/$PRODUCT/firewall ${OPTIONS} clear || exit 1
|
||||
if [ -x ${STATEDIR}/firewall ]; then
|
||||
${STATEDIR}/firewall ${OPTIONS} clear || exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
|
@@ -1,20 +1,20 @@
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.4
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
|
||||
#
|
||||
# Copyright 2011 Jonathan Underwood (jonathan.underwood@gmail.com)
|
||||
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
|
||||
#
|
||||
[Unit]
|
||||
Description=Shorewall IPv4 firewall
|
||||
After=syslog.target
|
||||
Description=Shorewall firewall (bootup security)
|
||||
Before=network.target
|
||||
Conflicts=iptables.service ip6tables.service firewalld.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=-/etc/sysconfig/shorewall-init
|
||||
StandardOutput=syslog
|
||||
ExecStart=/sbin/shorewall-init $OPTIONS start
|
||||
ExecStop=/sbin/shorewall-init $OPTIONS stop
|
||||
ExecStart=/sbin/shorewall-init start
|
||||
ExecStop=/sbin/shorewall-init stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
WantedBy=basic.target
|
||||
|
21
Shorewall-init/shorewall-init.service.214
Normal file
21
Shorewall-init/shorewall-init.service.214
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
|
||||
#
|
||||
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
|
||||
#
|
||||
[Unit]
|
||||
Description=Shorewall firewall (bootup security)
|
||||
Before=network-pre.target
|
||||
Wants=network-pre.target
|
||||
Conflicts=iptables.service firewalld.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=-/etc/sysconfig/shorewall-init
|
||||
StandardOutput=syslog
|
||||
ExecStart=/sbin/shorewall-init start
|
||||
ExecStop=/sbin/shorewall-init stop
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
@@ -1,4 +1,4 @@
|
||||
\#!/bin/sh
|
||||
#!/bin/sh
|
||||
#
|
||||
# Script to back uninstall Shoreline Firewall
|
||||
#
|
||||
@@ -35,6 +35,12 @@ usage() # $1 = exit status
|
||||
exit $1
|
||||
}
|
||||
|
||||
fatal_error()
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
qt()
|
||||
{
|
||||
"$@" >/dev/null 2>&1
|
||||
@@ -69,6 +75,42 @@ remove_file() # $1 = file to restore
|
||||
fi
|
||||
}
|
||||
|
||||
finished=0
|
||||
configure=1
|
||||
|
||||
while [ $finished -eq 0 ]; do
|
||||
option=$1
|
||||
|
||||
case "$option" in
|
||||
-*)
|
||||
option=${option#-}
|
||||
|
||||
while [ -n "$option" ]; do
|
||||
case $option in
|
||||
h)
|
||||
usage 0
|
||||
;;
|
||||
v)
|
||||
echo "$Product Firewall Installer Version $VERSION"
|
||||
exit 0
|
||||
;;
|
||||
n*)
|
||||
configure=0
|
||||
option=${option#n}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
finished=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
#
|
||||
# Read the RC file
|
||||
#
|
||||
@@ -114,22 +156,29 @@ fi
|
||||
|
||||
echo "Uninstalling Shorewall Init $VERSION"
|
||||
|
||||
[ -n "$SANDBOX" ] && configure=0
|
||||
|
||||
INITSCRIPT=${CONFDIR}/init.d/shorewall-init
|
||||
|
||||
if [ -f "$INITSCRIPT" ]; then
|
||||
if mywhich updaterc.d ; then
|
||||
updaterc.d shorewall-init remove
|
||||
elif mywhich insserv ; then
|
||||
insserv -r $INITSCRIPT
|
||||
elif mywhich chkconfig ; then
|
||||
chkconfig --del $(basename $INITSCRIPT)
|
||||
elif mywhich systemctl ; then
|
||||
systemctl disable shorewall-init
|
||||
if [ $configure -eq 1 ]; then
|
||||
if mywhich updaterc.d ; then
|
||||
updaterc.d shorewall-init remove
|
||||
elif mywhich insserv ; then
|
||||
insserv -r $INITSCRIPT
|
||||
elif mywhich chkconfig ; then
|
||||
chkconfig --del $(basename $INITSCRIPT)
|
||||
fi
|
||||
fi
|
||||
|
||||
remove_file $INITSCRIPT
|
||||
fi
|
||||
|
||||
if [ -n "$SYSTEMD" ]; then
|
||||
[ $configure -eq 1 ] && systemctl disable shorewall-init.service
|
||||
rm -f $SYSTEMD/shorewall-init.service
|
||||
fi
|
||||
|
||||
[ "$(readlink -m -q ${SBINDIR}/ifup-local)" = ${SHAREDIR}/shorewall-init ] && remove_file ${SBINDIR}/ifup-local
|
||||
[ "$(readlink -m -q ${SBINDIR}/ifdown-local)" = ${SHAREDIR}/shorewall-init ] && remove_file ${SBINDIR}/ifdown-local
|
||||
|
||||
@@ -159,8 +208,9 @@ if [ -d ${CONFDIR}/ppp ]; then
|
||||
done
|
||||
fi
|
||||
|
||||
rm -f ${SBINDIR}/shorewall-init
|
||||
rm -rf ${SHAREDIR}/shorewall-init
|
||||
rm -rf ${LIBEXEC}/shorewall-init
|
||||
rm -rf ${LIBEXECDIR}/shorewall-init
|
||||
|
||||
echo "Shorewall Init Uninstalled"
|
||||
|
||||
|
@@ -39,7 +39,7 @@ fi
|
||||
|
||||
start() {
|
||||
echo -n $"Starting Shorewall: "
|
||||
$shorewall $OPTIONS start 2>&1 | $logger
|
||||
$shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
|
||||
retval=${PIPESTATUS[0]}
|
||||
if [[ $retval == 0 ]]; then
|
||||
touch $lockfile
|
||||
@@ -69,7 +69,7 @@ restart() {
|
||||
# Note that we don't simply stop and start since shorewall has a built in
|
||||
# restart which stops the firewall if running and then starts it.
|
||||
echo -n $"Restarting Shorewall: "
|
||||
$shorewall $OPTIONS restart 2>&1 | $logger
|
||||
$shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
|
||||
retval=${PIPESTATUS[0]}
|
||||
if [[ $retval == 0 ]]; then
|
||||
touch $lockfile
|
||||
|
@@ -30,6 +30,7 @@ usage() # $1 = exit status
|
||||
echo "usage: $ME [ <configuration-file> ]"
|
||||
echo " $ME -v"
|
||||
echo " $ME -h"
|
||||
echo " $ME -n"
|
||||
exit $1
|
||||
}
|
||||
|
||||
@@ -113,9 +114,13 @@ fi
|
||||
# Parse the run line
|
||||
#
|
||||
finished=0
|
||||
configure=1
|
||||
|
||||
while [ $finished -eq 0 ] ; do
|
||||
case "$1" in
|
||||
|
||||
option=$1
|
||||
|
||||
case "$option" in
|
||||
-*)
|
||||
option=${option#-}
|
||||
|
||||
@@ -128,6 +133,10 @@ while [ $finished -eq 0 ] ; do
|
||||
echo "$Product Firewall Installer Version $VERSION"
|
||||
exit 0
|
||||
;;
|
||||
n*)
|
||||
configure=0
|
||||
option=${option#n}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
@@ -186,6 +195,8 @@ done
|
||||
|
||||
PATH=${SBINDIR}:/bin:/usr${SBINDIR}:/usr/bin:/usr/local/bin:/usr/local${SBINDIR}
|
||||
|
||||
[ -n "$SANDBOX" ] && configure=0
|
||||
|
||||
#
|
||||
# Determine where to install the firewall script
|
||||
#
|
||||
@@ -195,7 +206,7 @@ T='-T'
|
||||
|
||||
if [ -z "$BUILD" ]; then
|
||||
case $(uname) in
|
||||
cygwin*)
|
||||
cygwin*|CYGWIN*)
|
||||
BUILD=cygwin
|
||||
;;
|
||||
Darwin)
|
||||
@@ -206,7 +217,7 @@ if [ -z "$BUILD" ]; then
|
||||
eval $(cat /etc/os-release | grep ^ID)
|
||||
|
||||
case $ID in
|
||||
fedora)
|
||||
fedora|rhel|centos|foobar)
|
||||
BUILD=redhat
|
||||
;;
|
||||
debian)
|
||||
@@ -242,7 +253,7 @@ if [ -z "$BUILD" ]; then
|
||||
fi
|
||||
|
||||
case $BUILD in
|
||||
cygwin*)
|
||||
cygwin*|CYGWIN*)
|
||||
OWNER=$(id -un)
|
||||
GROUP=$(id -gn)
|
||||
;;
|
||||
@@ -346,6 +357,7 @@ fi
|
||||
delete_file ${DESTDIR}/usr/share/$PRODUCT/xmodules
|
||||
|
||||
install_file $PRODUCT ${DESTDIR}${SBINDIR}/$PRODUCT 0544
|
||||
[ -n "${INITFILE}" ] && install -d $OWNERSHIP -m 755 ${DESTDIR}${INITDIR}
|
||||
|
||||
echo "$Product control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT"
|
||||
|
||||
@@ -358,7 +370,7 @@ mkdir -p ${DESTDIR}${LIBEXECDIR}/$PRODUCT
|
||||
mkdir -p ${DESTDIR}${VARDIR}
|
||||
|
||||
chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT
|
||||
chmod 755 ${DESTDIR}/usr/share/$PRODUCT
|
||||
chmod 755 ${DESTDIR}${SHAREDIR}/$PRODUCT
|
||||
|
||||
if [ -n "$DESTDIR" ]; then
|
||||
mkdir -p ${DESTDIR}${CONFDIR}/logrotate.d
|
||||
@@ -369,7 +381,7 @@ fi
|
||||
|
||||
if [ -n "$INITFILE" ]; then
|
||||
if [ -f "${INITSOURCE}" ]; then
|
||||
initfile="${DESTDIR}/${INITDIR}/${INITFILE}"
|
||||
initfile="${DESTDIR}${INITDIR}/${INITFILE}"
|
||||
install_file ${INITSOURCE} "$initfile" 0544
|
||||
|
||||
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' "$initfile"
|
||||
@@ -380,12 +392,16 @@ fi
|
||||
#
|
||||
# Install the .service file
|
||||
#
|
||||
if [ -n "$SYSTEMD" ]; then
|
||||
mkdir -p ${DESTDIR}${SYSTEMD}
|
||||
if [ -z "${SERVICEDIR}" ]; then
|
||||
SERVICEDIR="$SYSTEMD"
|
||||
fi
|
||||
|
||||
if [ -n "$SERVICEDIR" ]; then
|
||||
mkdir -p ${DESTDIR}${SERVICEDIR}
|
||||
[ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service
|
||||
run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SYSTEMD}/$PRODUCT.service
|
||||
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SYSTEMD}/$PRODUCT.service
|
||||
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SYSTEMD}/$PRODUCT.service"
|
||||
run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
|
||||
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
|
||||
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SERVICEDIR}/$PRODUCT.service"
|
||||
fi
|
||||
#
|
||||
# Install the config file
|
||||
@@ -466,18 +482,18 @@ done
|
||||
if [ -d manpages ]; then
|
||||
cd manpages
|
||||
|
||||
[ -n "$INSTALLD" ] || mkdir -p ${DESTDIR}${SHAREDIR}/man/man5/ ${DESTDIR}${SHAREDIR}/man/man8/
|
||||
[ -n "$INSTALLD" ] || mkdir -p ${DESTDIR}${MANDIR}/man5/ ${DESTDIR}${MANDIR}/man8/
|
||||
|
||||
for f in *.5; do
|
||||
gzip -c $f > $f.gz
|
||||
run_install $T $INSTALLD $OWNERSHIP -m 0644 $f.gz ${DESTDIR}${SHAREDIR}/man/man5/$f.gz
|
||||
echo "Man page $f.gz installed to ${DESTDIR}${SHAREDIR}/man/man5/$f.gz"
|
||||
run_install $T $INSTALLD $OWNERSHIP -m 0644 $f.gz ${DESTDIR}${MANDIR}/man5/$f.gz
|
||||
echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man5/$f.gz"
|
||||
done
|
||||
|
||||
for f in *.8; do
|
||||
gzip -c $f > $f.gz
|
||||
run_install $T $INSTALLD $OWNERSHIP -m 0644 $f.gz ${DESTDIR}${SHAREDIR}/man/man8/$f.gz
|
||||
echo "Man page $f.gz installed to ${DESTDIR}${SHAREDIR}/man/man8/$f.gz"
|
||||
run_install $T $INSTALLD $OWNERSHIP -m 0644 $f.gz ${DESTDIR}${MANDIR}/man8/$f.gz
|
||||
echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man8/$f.gz"
|
||||
done
|
||||
|
||||
cd ..
|
||||
@@ -499,7 +515,7 @@ chmod 644 ${DESTDIR}${SHAREDIR}/$PRODUCT/version
|
||||
# Remove and create the symbolic link to the init script
|
||||
#
|
||||
|
||||
if [ -z "$DESTDIR" ]; then
|
||||
if [ -z "${DESTDIR}" -a -n "${INITFILE}" ]; then
|
||||
rm -f ${SHAREDIR}/$PRODUCT/init
|
||||
ln -s ${INITDIR}/${INITFILE} ${SHAREDIR}/$PRODUCT/init
|
||||
fi
|
||||
@@ -526,8 +542,8 @@ if [ ${SHAREDIR} != /usr/share ]; then
|
||||
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${SBINDIR}/$PRODUCT
|
||||
fi
|
||||
|
||||
if [ -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
|
||||
if [ -n "$SYSTEMD" ]; then
|
||||
if [ $configure -eq 1 -a -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
|
||||
if [ -n "$SERVICEDIR" ]; then
|
||||
if systemctl enable ${PRODUCT}.service; then
|
||||
echo "$Product will start automatically at boot"
|
||||
fi
|
||||
|
@@ -47,6 +47,19 @@
|
||||
<arg choice="plain"><replaceable>address</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
<arg
|
||||
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="plain"><option>allow</option></arg>
|
||||
|
||||
<arg choice="plain"><replaceable>address</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
@@ -59,6 +72,21 @@
|
||||
choice="plain"><option>clear</option><arg><option>-f</option></arg></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
<arg
|
||||
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="plain"><option>close</option><arg choice="req">
|
||||
<replaceable>open-number</replaceable> |
|
||||
<replaceable>source</replaceable><replaceable>dest</replaceable><arg><replaceable>protocol</replaceable><arg>
|
||||
<replaceable>port</replaceable> </arg></arg></arg><replaceable>
|
||||
</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
@@ -116,6 +144,8 @@
|
||||
<arg><option>-l</option></arg>
|
||||
|
||||
<arg><option>-m</option></arg>
|
||||
|
||||
<arg><option>-c</option></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
@@ -263,6 +293,29 @@
|
||||
expression</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
<arg choice="plain"><option>open</option><replaceable>
|
||||
source</replaceable><replaceable> dest</replaceable><arg>
|
||||
<replaceable>protocol</replaceable><arg> <replaceable>port</replaceable>
|
||||
</arg> </arg></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
<arg
|
||||
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="plain"><option>reenable</option></arg>
|
||||
|
||||
<arg choice="plain">{ <replaceable>interface</replaceable> |
|
||||
<replaceable>provider</replaceable> }</arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
@@ -299,9 +352,7 @@
|
||||
|
||||
<arg><option>-n</option></arg>
|
||||
|
||||
<arg><option>-p</option></arg>
|
||||
|
||||
<arg><replaceable>directory</replaceable></arg>
|
||||
<arg><option>-p</option><arg><option>-C</option></arg></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
@@ -314,6 +365,8 @@
|
||||
|
||||
<arg choice="plain"><option>restore</option></arg>
|
||||
|
||||
<arg><option>-C</option></arg>
|
||||
|
||||
<arg><replaceable>filename</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
@@ -325,11 +378,38 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="plain"><option>save</option></arg>
|
||||
<arg choice="plain"><option>run</option></arg>
|
||||
|
||||
<arg choice="plain">function</arg>
|
||||
|
||||
<arg><replaceable>parameter ...</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
<arg
|
||||
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg
|
||||
choice="plain"><option>save</option><arg><option>-C</option></arg></arg>
|
||||
|
||||
<arg choice="opt"><replaceable>filename</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
<arg
|
||||
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="plain"><option>savesets</option></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
@@ -337,7 +417,7 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg><option>-b</option></arg>
|
||||
|
||||
@@ -359,7 +439,21 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg><option>-x</option></arg>
|
||||
|
||||
<arg choice="plain"><option>{bl|blacklists}</option></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
<arg choice="opt"><option>trace</option>|<option>debug</option></arg>
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg><option>-f</option></arg>
|
||||
|
||||
@@ -373,7 +467,7 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg
|
||||
choice="req"><option>classifiers|connections|config|events|filters|ip|ipa|zones|policies|marks</option></arg>
|
||||
@@ -386,7 +480,7 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg choice="plain"><option>event</option><arg
|
||||
choice="plain"><replaceable>event</replaceable></arg></arg>
|
||||
@@ -399,11 +493,11 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg><option>-x</option></arg>
|
||||
<arg><option>-c</option></arg>
|
||||
|
||||
<arg choice="req"><option>mangle|nat|routing|raw|rawpost</option></arg>
|
||||
<arg choice="plain"><option>routing</option></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
@@ -413,7 +507,21 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg><option>-x</option></arg>
|
||||
|
||||
<arg choice="req"><option>mangle|nat|raw|rawpost</option></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
<command>shorewall-lite</command>
|
||||
|
||||
<arg choice="opt"><option>trace</option>|<option>debug</option></arg>
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg choice="plain"><option>tc</option></arg>
|
||||
</cmdsynopsis>
|
||||
@@ -425,7 +533,7 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="opt"><option>show | list | ls </option></arg>
|
||||
<arg choice="req"><option>show | list | ls </option></arg>
|
||||
|
||||
<arg><option>-m</option></arg>
|
||||
|
||||
@@ -445,6 +553,10 @@
|
||||
<arg><option>-n</option></arg>
|
||||
|
||||
<arg><option>-p</option></arg>
|
||||
|
||||
<arg><option>-f</option></arg>
|
||||
|
||||
<arg><option>-C</option></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
@@ -465,7 +577,8 @@
|
||||
|
||||
<arg>-<replaceable>options</replaceable></arg>
|
||||
|
||||
<arg choice="plain"><option>status</option></arg>
|
||||
<arg choice="plain"><arg
|
||||
choice="plain"><option>status</option><arg><option>-i</option></arg></arg></arg>
|
||||
</cmdsynopsis>
|
||||
|
||||
<cmdsynopsis>
|
||||
@@ -496,8 +609,9 @@
|
||||
|
||||
<para>The nolock <option>option</option> prevents the command from
|
||||
attempting to acquire the Shorewall-lite lockfile. It is useful if you
|
||||
need to include <command>shorewall</command> commands in
|
||||
<filename>/etc/shorewall/started</filename>.</para>
|
||||
need to include <command>shorewall</command> commands in the
|
||||
<filename>started</filename> <ulink
|
||||
url="../shorewall_extension_scripts.html">extension script</ulink>.</para>
|
||||
|
||||
<para>The <emphasis>options</emphasis> control the amount of output that
|
||||
the command produces. They consist of a sequence of the letters <emphasis
|
||||
@@ -508,8 +622,8 @@
|
||||
role="bold">v</emphasis> adds one to the effective verbosity and each
|
||||
<emphasis role="bold">q</emphasis> subtracts one from the effective
|
||||
VERBOSITY. Alternately, <emphasis role="bold">v</emphasis> may be followed
|
||||
immediately with one of -1,0,1,2 to specify a specify VERBOSITY. There may
|
||||
be no white-space between <emphasis role="bold">v</emphasis> and the
|
||||
immediately with one of -1,0,1,2 to specify VERBOSITY. There may be no
|
||||
white-space between <emphasis role="bold">v</emphasis> and the
|
||||
VERBOSITY.</para>
|
||||
|
||||
<para>The <emphasis>options</emphasis> may also include the letter
|
||||
@@ -524,7 +638,10 @@
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">add</emphasis></term>
|
||||
<term><emphasis role="bold">add </emphasis>{
|
||||
<replaceable>interface</replaceable>[:<replaceable>host-list</replaceable>]...
|
||||
<replaceable>zone</replaceable> | <replaceable>zone</replaceable>
|
||||
<replaceable>host-list</replaceable> }</term>
|
||||
|
||||
<listitem>
|
||||
<para>Adds a list of hosts or subnets to a dynamic zone usually used
|
||||
@@ -549,7 +666,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">allow</emphasis></term>
|
||||
<term><emphasis role="bold">allow
|
||||
</emphasis><replaceable>address</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Re-enables receipt of packets from hosts previously
|
||||
@@ -561,7 +679,25 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">clear</emphasis></term>
|
||||
<term><emphasis role="bold">call <replaceable>function</replaceable> [
|
||||
<replaceable>parameter</replaceable> ... ]</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.10. Allows you to call a function in
|
||||
one of the Shorewall libraries or in your compiled script. function
|
||||
must name the shell function to be called. The listed parameters are
|
||||
passed to the function.</para>
|
||||
|
||||
<para>The function is first searched for in
|
||||
<filename>lib.base</filename>, <filename>lib.common</filename> and
|
||||
<filename>lib.cli</filename>. If it is not found, the call command
|
||||
is passed to the generated script to be executed.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">clear
|
||||
</emphasis>[-<option>f</option>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Clear will remove all rules and chains installed by
|
||||
@@ -578,7 +714,31 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">delete</emphasis></term>
|
||||
<term><emphasis role="bold">close</emphasis> {
|
||||
<replaceable>open-number</replaceable> |
|
||||
<replaceable>source</replaceable> <replaceable>dest</replaceable> [
|
||||
<replaceable>protocol</replaceable> [ <replaceable>port</replaceable>
|
||||
] ] }</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.5.8. This command closes a temporary open
|
||||
created by the <command>open</command> command. In the first form,
|
||||
an <replaceable>open-number</replaceable> specifies the open to be
|
||||
closed. Open numbers are displayed in the <emphasis
|
||||
role="bold">num</emphasis> column of the output of the
|
||||
<command>shorewall-lite show opens </command>command.</para>
|
||||
|
||||
<para>When the second form of the command is used, the parameters
|
||||
must match those given in the earlier <command>open</command>
|
||||
command.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">delete </emphasis>{
|
||||
<replaceable>interface</replaceable>[:<replaceable>host-list</replaceable>]...
|
||||
<replaceable>zone</replaceable> | <replaceable>zone</replaceable>
|
||||
<replaceable>host-list</replaceable> }</term>
|
||||
|
||||
<listitem>
|
||||
<para>The delete command reverses the effect of an earlier <emphasis
|
||||
@@ -593,7 +753,9 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">disable</emphasis></term>
|
||||
<term><emphasis role="bold">disable </emphasis>{
|
||||
<replaceable>interface</replaceable> |
|
||||
<replaceable>provider</replaceable> }</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.4.26. Disables the optional provider
|
||||
@@ -605,7 +767,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">drop</emphasis></term>
|
||||
<term><emphasis role="bold">drop
|
||||
</emphasis><replaceable>address</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Causes traffic from the listed <emphasis>address</emphasis>es
|
||||
@@ -614,7 +777,9 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">dump</emphasis></term>
|
||||
<term><emphasis role="bold">dump </emphasis>[-<option>x</option>]
|
||||
[-<option>l</option>] [-<option>m</option>]
|
||||
[-<option>c</option>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Produces a verbose report about the firewall configuration for
|
||||
@@ -628,11 +793,16 @@
|
||||
|
||||
<para>The <emphasis role="bold">-l</emphasis> option causes the rule
|
||||
number for each Netfilter rule to be displayed.</para>
|
||||
|
||||
<para>The <option>-c</option> option causes the route cache to be
|
||||
dumped in addition to the other routing information.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">enable</emphasis></term>
|
||||
<term><emphasis role="bold">enable </emphasis>{
|
||||
<replaceable>interface</replaceable> |
|
||||
<replaceable>provider</replaceable> }</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.4.26. Enables the optional provider
|
||||
@@ -644,7 +814,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">forget</emphasis></term>
|
||||
<term><emphasis role="bold">forget </emphasis>[
|
||||
<replaceable>filename</replaceable> ]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Deletes /var/lib/shorewall-lite/<emphasis>filename</emphasis>
|
||||
@@ -665,7 +836,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">hits</emphasis></term>
|
||||
<term><emphasis role="bold">hits </emphasis>
|
||||
[-<option>t</option>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Generates several reports from Shorewall-lite log messages in
|
||||
@@ -675,7 +847,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">ipcalc</emphasis></term>
|
||||
<term><emphasis role="bold">ipcalc </emphasis>{ address mask |
|
||||
address/vlsm }</term>
|
||||
|
||||
<listitem>
|
||||
<para>Ipcalc displays the network address, broadcast address,
|
||||
@@ -685,7 +858,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">iprange</emphasis></term>
|
||||
<term><emphasis role="bold">iprange
|
||||
</emphasis><replaceable>address1</replaceable>-<replaceable>address2</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Iprange decomposes the specified range of IP addresses into
|
||||
@@ -694,7 +868,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">iptrace</emphasis></term>
|
||||
<term><emphasis role="bold">iptrace </emphasis><replaceable>iptables
|
||||
match expression</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>This is a low-level debugging command that causes iptables
|
||||
@@ -713,7 +888,17 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">logdrop</emphasis></term>
|
||||
<term><emphasis role="bold">list</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para><command>list</command> is a synonym for
|
||||
<command>show</command> -- please see below.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">logdrop
|
||||
</emphasis><replaceable>address</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Causes traffic from the listed <emphasis>address</emphasis>es
|
||||
@@ -724,7 +909,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">logwatch</emphasis></term>
|
||||
<term><emphasis role="bold">logwatch </emphasis>[-<option>m</option>]
|
||||
[<replaceable>refresh-interval</replaceable>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Monitors the log file specified by the LOGFILE option in
|
||||
@@ -743,7 +929,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">logreject</emphasis></term>
|
||||
<term><emphasis role="bold">logreject
|
||||
</emphasis><replaceable>address</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Causes traffic from the listed <emphasis>address</emphasis>es
|
||||
@@ -754,7 +941,17 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">noiptrace</emphasis></term>
|
||||
<term><emphasis role="bold">ls</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para><command>ls</command> is a synonym for <command>show</command>
|
||||
-- please see below.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">noiptrace </emphasis><replaceable>iptables
|
||||
match expression</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>This is a low-level debugging command that cancels a trace
|
||||
@@ -767,16 +964,83 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">reset</emphasis></term>
|
||||
<term><emphasis role="bold">open</emphasis>
|
||||
<replaceable>source</replaceable> <replaceable>dest</replaceable> [
|
||||
<replaceable>protocol</replaceable> [ <replaceable>port</replaceable>
|
||||
] ]</term>
|
||||
|
||||
<listitem>
|
||||
<para>All the packet and byte counters in the firewall are
|
||||
reset.</para>
|
||||
<para>Added in Shorewall 4.6.8. This command requires that the
|
||||
firewall be in the started state and that DYNAMIC_BLACKLIST=Yes in
|
||||
<ulink url="/manpages/shorewall.conf.html">shorewall.conf
|
||||
(5)</ulink>. The effect of the command is to temporarily open the
|
||||
firewall for connections matching the parameters.</para>
|
||||
|
||||
<para>The <replaceable>source</replaceable> and
|
||||
<replaceable>dest</replaceable> parameters may each be specified as
|
||||
<emphasis role="bold">all</emphasis> if you don't wish to restrict
|
||||
the connection source or destination respectively. Otherwise, each
|
||||
must contain a host or network address or a valid DNS name.</para>
|
||||
|
||||
<para>The <replaceable>protocol</replaceable> may be specified
|
||||
either as a number or as a name listed in /etc/protocols. The
|
||||
<replaceable>port</replaceable> may be specified numerically or as a
|
||||
name listed in /etc/services.</para>
|
||||
|
||||
<para>To reverse the effect of a successful <command>open</command>
|
||||
command, use the <command>close</command> command with the same
|
||||
parameters or simply restart the firewall.</para>
|
||||
|
||||
<para>Example: To open the firewall for SSH connections to address
|
||||
192.168.1.1, the command would be:</para>
|
||||
|
||||
<programlisting> shorewall-lite open all 192.168.1.1 tcp 22</programlisting>
|
||||
|
||||
<para>To reverse that command, use:</para>
|
||||
|
||||
<screen> shorewall-lite close all 192.168.1.1 tcp 22</screen>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">restart</emphasis></term>
|
||||
<term><emphasis role="bold">reenable</emphasis>{
|
||||
<replaceable>interface</replaceable> |
|
||||
<replaceable>provider</replaceable> }</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.9. This is equivalent to a
|
||||
<command>disable</command> command followed by an
|
||||
<command>enable</command> command on the specified
|
||||
<replaceable>interface</replaceable> or
|
||||
<replaceable>provider</replaceable>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">reject</emphasis><replaceable>
|
||||
address</replaceable></term>
|
||||
|
||||
<listitem>
|
||||
<para>Causes traffic from the listed <emphasis>address</emphasis>es
|
||||
to be silently rejected.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">reset [<replaceable>chain</replaceable>,
|
||||
...]</emphasis><acronym/></term>
|
||||
|
||||
<listitem>
|
||||
<para>Resets the packet and byte counters in the specified
|
||||
<replaceable>chain</replaceable>(s). If no
|
||||
<replaceable>chain</replaceable> is specified, all the packet and
|
||||
byte counters in the firewall are reset.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">restart </emphasis>[-n] [-p]
|
||||
[-<option>C</option>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Restart is similar to <emphasis role="bold">shorewall-lite
|
||||
@@ -789,11 +1053,19 @@
|
||||
<para>The <option>-p</option> option causes the connection tracking
|
||||
table to be flushed; the <command>conntrack</command> utility must
|
||||
be installed to use this option.</para>
|
||||
|
||||
<para>The <option>-C</option> option was added in Shorewall 4.6.5.
|
||||
If the specified (or implicit) firewall script is the one that
|
||||
generated the current running configuration, then the running
|
||||
netfilter configuration will be reloaded as is so as to preserve the
|
||||
iptables packet and byte counters.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">restore</emphasis></term>
|
||||
<term><emphasis role="bold">restore </emphasis>[-<option>n</option>]
|
||||
[-<option>p</option>] [-<option>C</option>] [
|
||||
<replaceable>filename</replaceable> ]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Restore Shorewall-lite to a state saved using the <emphasis
|
||||
@@ -804,11 +1076,52 @@
|
||||
<emphasis>filename</emphasis> is given then Shorewall-lite will be
|
||||
restored from the file specified by the RESTOREFILE option in <ulink
|
||||
url="shorewall.conf.html">shorewall.conf</ulink>(5).</para>
|
||||
|
||||
<caution>
|
||||
<para>If your iptables ruleset depends on variables that are
|
||||
detected at run-time, either in your params file or by
|
||||
Shorewall-generated code, <command>restore</command> will use the
|
||||
values that were current when the ruleset was saved, which may be
|
||||
different from the current values.</para>
|
||||
</caution>
|
||||
|
||||
<para>The <option>-n</option> option causes Shorewall to avoid
|
||||
updating the routing table(s).</para>
|
||||
|
||||
<para>The <option>-p</option> option, added in Shorewall 4.6.5,
|
||||
causes the connection tracking table to be flushed; the
|
||||
<command>conntrack</command> utility must be installed to use this
|
||||
option.</para>
|
||||
|
||||
<para>The <option>-C</option> option was added in Shorewall 4.6.5.
|
||||
If the <option>-C</option> option was specified during <emphasis
|
||||
role="bold">shorewall save</emphasis>, then the counters saved by
|
||||
that operation will be restored.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">save</emphasis></term>
|
||||
<term><emphasis role="bold">run
|
||||
</emphasis><replaceable>command</replaceable> [
|
||||
<replaceable>parameter</replaceable> ... ]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.3. Executes
|
||||
<replaceable>command</replaceable> in the context of the generated
|
||||
script passing the supplied <replaceable>parameter</replaceable>s.
|
||||
Normally, the <replaceable>command</replaceable> will be a function
|
||||
declared in <filename>lib.private</filename>.</para>
|
||||
|
||||
<para>Before executing the <replaceable>command</replaceable>, the
|
||||
script will detect the configuration, setting all SW_* variables and
|
||||
will run your <filename>init</filename> extension script with
|
||||
$COMMAND = 'run'.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">save </emphasis>[-<option>C</option>] [
|
||||
<replaceable>filename</replaceable> ]</term>
|
||||
|
||||
<listitem>
|
||||
<para>The dynamic blacklist is stored in
|
||||
@@ -818,6 +1131,24 @@
|
||||
<emphasis>filename</emphasis> is not given then the state is saved
|
||||
in the file specified by the RESTOREFILE option in <ulink
|
||||
url="shorewall.conf.html">shorewall.conf</ulink>(5).</para>
|
||||
|
||||
<para>The <option>-C</option> option, added in Shorewall 4.6.5,
|
||||
causes the iptables packet and byte counters to be saved along with
|
||||
the chains and rules.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">savesets</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in shorewall 4.6.8. Performs the same action as the
|
||||
<command>stop</command> command with respect to saving ipsets (see
|
||||
the SAVE_IPSETS option in <ulink
|
||||
url="/manpages/shorewall.conf.html">shorewall.conf</ulink> (5)).
|
||||
This command may be used to proactively save your ipset contents in
|
||||
the event that a system failure occurs prior to issuing a
|
||||
<command>stop</command> command.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -830,7 +1161,22 @@
|
||||
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">capabilities</emphasis></term>
|
||||
<term><emphasis role="bold">bl|blacklists
|
||||
</emphasis>[-<option>x</option>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.6.2. Displays the dynamic chain
|
||||
along with any chains produced by entries in
|
||||
shorewall-blrules(5).The <emphasis role="bold">-x</emphasis>
|
||||
option is passed directly through to iptables and causes
|
||||
actual packet and byte counts to be displayed. Without this
|
||||
option, those counts are abbreviated.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>[-<option>f</option>] <emphasis
|
||||
role="bold">capabilities</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Displays your kernel/iptables capabilities. The
|
||||
@@ -841,8 +1187,10 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>[ [ <option>chain</option> ] <emphasis>chain</emphasis>...
|
||||
]</term>
|
||||
<term>[-<option>b</option>] [-<option>x</option>]
|
||||
[-<option>l</option>] [-<option>t</option>
|
||||
{<option>filter</option>|<option>mangle</option>|<option>nat</option>|<option>raw</option>|<option>rawpost</option>}]
|
||||
[ <emphasis>chain</emphasis>... ]</term>
|
||||
|
||||
<listitem>
|
||||
<para>The rules in each <emphasis>chain</emphasis> are
|
||||
@@ -941,7 +1289,8 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">log</emphasis></term>
|
||||
<term>[-<option>m</option>] <emphasis
|
||||
role="bold">log</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Displays the last 20 Shorewall-lite messages from the
|
||||
@@ -953,6 +1302,20 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>[-<option>x</option>] <emphasis
|
||||
role="bold">mangle</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Displays the Netfilter mangle table using the command
|
||||
<emphasis role="bold">iptables -t mangle -L -n -v</emphasis>.
|
||||
The <emphasis role="bold">-x</emphasis> option is passed
|
||||
directly through to iptables and causes actual packet and byte
|
||||
counts to be displayed. Without this option, those counts are
|
||||
abbreviated.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">marks</emphasis></term>
|
||||
|
||||
@@ -976,6 +1339,16 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">opens</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Added in Shorewall 4.5.8. Displays the iptables rules in
|
||||
the 'dynamic' chain created through use of the <command>open
|
||||
</command>command..</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">policies</emphasis></term>
|
||||
|
||||
@@ -992,7 +1365,9 @@
|
||||
<term><emphasis role="bold">routing</emphasis></term>
|
||||
|
||||
<listitem>
|
||||
<para>Displays the system's IPv4 routing configuration.</para>
|
||||
<para>Displays the system's IPv4 routing configuration. The -c
|
||||
option causes the route cache to be displayed in addition to
|
||||
the other routing information.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -1031,7 +1406,9 @@
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><emphasis role="bold">start</emphasis></term>
|
||||
<term><emphasis role="bold">start</emphasis> [-<option>p</option>]
|
||||
[-<option>n</option>] [<option>-f</option>]
|
||||
[-<option>C</option>]</term>
|
||||
|
||||
<listitem>
|
||||
<para>Start Shorewall Lite. Existing connections through
|
||||
@@ -1042,6 +1419,22 @@
|
||||
<para>The <option>-p</option> option causes the connection tracking
|
||||
table to be flushed; the <command>conntrack</command> utility must
|
||||
be installed to use this option.</para>
|
||||
|
||||
<para>The <option>-n</option> option prevents the firewall script
|
||||
from modifying the current routing configuration.</para>
|
||||
|
||||
<para>The <option>-f</option> option was added in Shorewall 4.6.5.
|
||||
If the RESTOREFILE named in <ulink
|
||||
url="shorewall.conf.html">shorewall.conf</ulink>(5) exists, is
|
||||
executable and is not older than the current filewall script, then
|
||||
that saved configuration is restored.</para>
|
||||
|
||||
<para>The <option>-C</option> option was added in Shorewall 4.6.5
|
||||
and is only meaningful when the <option>-f</option> option is also
|
||||
specified. If the previously-saved configuration is restored, and if
|
||||
the <option>-C</option> option was also specified in the <emphasis
|
||||
role="bold">save</emphasis> command, then the packet and byte
|
||||
counters will be restored.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -1073,6 +1466,10 @@
|
||||
<listitem>
|
||||
<para>Produces a short report about the state of the
|
||||
Shorewall-configured firewall.</para>
|
||||
|
||||
<para>The <option>-i </option>option was added in Shorewall 4.6.2
|
||||
and causes the status of each optional or provider interface to be
|
||||
displayed.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@@ -38,7 +38,7 @@
|
||||
#
|
||||
# IPTABLES - iptables
|
||||
# MODULESDIR - /lib/modules/$(uname -r)/kernel/net/ipv4/netfilter
|
||||
# MODULE_SUFFIX - "o gz ko o.gz ko.gz"
|
||||
# MODULE_SUFFIX - "o gz xz ko o.gz o.xz ko.gz ko.xz"
|
||||
#
|
||||
# Shorewall need not be installed on the target system to run shorecap. If the '-e' flag is
|
||||
# used during firewall compilation, then the generated firewall program will likewise not
|
||||
|
@@ -1,20 +1,21 @@
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.4
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
|
||||
#
|
||||
# Copyright 2011 Jonathan Underwood (jonathan.underwood@gmail.com)
|
||||
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
|
||||
#
|
||||
[Unit]
|
||||
Description=Shorewall IPv4 firewall (lite)
|
||||
After=syslog.target
|
||||
After=network.target
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
Conflicts=iptables.service firewalld.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=-/etc/sysconfig/shorewall-lite
|
||||
StandardOutput=syslog
|
||||
ExecStart=/sbin/shorewall-lite $OPTIONS start
|
||||
ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS
|
||||
ExecStop=/sbin/shorewall-lite $OPTIONS stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
WantedBy=basic.target
|
||||
|
21
Shorewall-lite/shorewall-lite.service.214
Normal file
21
Shorewall-lite/shorewall-lite.service.214
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
|
||||
#
|
||||
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
|
||||
#
|
||||
[Unit]
|
||||
Description=Shorewall IPv4 firewall (lite)
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
Conflicts=iptables.service firewalld.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=-/etc/sysconfig/shorewall-lite
|
||||
StandardOutput=syslog
|
||||
ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS
|
||||
ExecStop=/sbin/shorewall-lite $OPTIONS stop
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
@@ -27,14 +27,25 @@
|
||||
# shown below. Simply run this script to remove Shorewall Firewall
|
||||
|
||||
VERSION=xxx #The Build script inserts the actual version
|
||||
PRODUCT=shorewall-lite
|
||||
|
||||
usage() # $1 = exit status
|
||||
{
|
||||
ME=$(basename $0)
|
||||
echo "usage: $ME [ <shorewallrc file> ]"
|
||||
echo "usage: $ME [ <option> ] [ <shorewallrc file> ]"
|
||||
echo "where <option> is one of"
|
||||
echo " -h"
|
||||
echo " -v"
|
||||
echo " -n"
|
||||
exit $1
|
||||
}
|
||||
|
||||
fatal_error()
|
||||
{
|
||||
echo " ERROR: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
qt()
|
||||
{
|
||||
"$@" >/dev/null 2>&1
|
||||
@@ -69,6 +80,42 @@ remove_file() # $1 = file to restore
|
||||
fi
|
||||
}
|
||||
|
||||
finished=0
|
||||
configure=1
|
||||
|
||||
while [ $finished -eq 0 ]; do
|
||||
option=$1
|
||||
|
||||
case "$option" in
|
||||
-*)
|
||||
option=${option#-}
|
||||
|
||||
while [ -n "$option" ]; do
|
||||
case $option in
|
||||
h)
|
||||
usage 0
|
||||
;;
|
||||
v)
|
||||
echo "$Product Firewall Installer Version $VERSION"
|
||||
exit 0
|
||||
;;
|
||||
n*)
|
||||
configure=0
|
||||
option=${option#n}
|
||||
;;
|
||||
*)
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
finished=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
#
|
||||
# Read the RC file
|
||||
#
|
||||
@@ -112,8 +159,12 @@ fi
|
||||
|
||||
echo "Uninstalling Shorewall Lite $VERSION"
|
||||
|
||||
if qt iptables -L shorewall -n && [ ! -f ${SBINDIR}/shorewall ]; then
|
||||
shorewall-lite clear
|
||||
[ -n "$SANDBOX" ] && configure=0
|
||||
|
||||
if [ $configure -eq 1 ]; then
|
||||
if qt iptables -L shorewall -n && [ ! -f ${SBINDIR}/shorewall ]; then
|
||||
shorewall-lite clear
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -L ${SHAREDIR}/shorewall-lite/init ]; then
|
||||
@@ -123,28 +174,34 @@ elif [ -n "$INITFILE" ]; then
|
||||
fi
|
||||
|
||||
if [ -f "$FIREWALL" ]; then
|
||||
if mywhich updaterc.d ; then
|
||||
updaterc.d shorewall-lite remove
|
||||
elif mywhich insserv ; then
|
||||
insserv -r $FIREWALL
|
||||
elif [ mywhich chkconfig ; then
|
||||
chkconfig --del $(basename $FIREWALL)
|
||||
elif mywhich systemctl ; then
|
||||
systemctl disable shorewall-lite
|
||||
if [ $configure -eq 1 ]; then
|
||||
if mywhich updaterc.d ; then
|
||||
updaterc.d shorewall-lite remove
|
||||
elif mywhich insserv ; then
|
||||
insserv -r $FIREWALL
|
||||
elif mywhich chkconfig ; then
|
||||
chkconfig --del $(basename $FIREWALL)
|
||||
fi
|
||||
fi
|
||||
|
||||
remove_file $FIREWALL
|
||||
fi
|
||||
|
||||
if [ -n "$SYSTEMD" ]; then
|
||||
[ $configure -eq 1 ] && systemctl disable ${PRODUCT}
|
||||
rm -f $SYSTEMD/shorewall-lite.service
|
||||
fi
|
||||
|
||||
rm -f ${SBINDIR}/shorewall-lite
|
||||
|
||||
rm -rf ${SBINDIR}/shorewall-lite
|
||||
rm -rf ${CONFDIR}/shorewall-lite
|
||||
rm -rf ${VARDIR}/shorewall-lite
|
||||
rm -rf ${SHAREDIR}/shorewall-lite
|
||||
rm -rf ${LIBEXEC}/shorewall-lite
|
||||
rm -rf ${LIBEXECDIR}/shorewall-lite
|
||||
rm -f ${CONFDIR}/logrotate.d/shorewall-lite
|
||||
[ -n "$SYSTEMD" ] && rm -f ${SYSTEMD}/shorewall-lite.service
|
||||
|
||||
rm -f ${MANDIR}/man5/shorewall-lite*
|
||||
rm -f ${MANDIR}/man8/shorewall-lite*
|
||||
|
||||
echo "Shorewall Lite Uninstalled"
|
||||
|
||||
|
||||
|
14
Shorewall/Macros/macro.AMQP
Normal file
14
Shorewall/Macros/macro.AMQP
Normal file
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Shorewall version 4 - AMQP Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.AMQP
|
||||
#
|
||||
# This macro handles AMQP traffic.
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 5672
|
||||
PARAM - - udp 5672
|
@@ -7,10 +7,12 @@
|
||||
#
|
||||
# You can comment out the ports you do not want open
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
# PORT(S) PORT(S) LIMIT GROUP
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 389 #LDAP services
|
||||
PARAM - - udp 389
|
||||
PARAM - - tcp 636 #LDAP SSL
|
||||
|
@@ -14,7 +14,7 @@
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
|
||||
?if ( __CT_TARGET && ! $AUTOHELPERS && __AMANDA_HELPER )
|
||||
PARAM - - udp 10080 ; helper=amanda
|
||||
PARAM - - udp 10080 { helper=amanda }
|
||||
?else
|
||||
PARAM - - udp 10080
|
||||
?endif
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
?if ( __CT_TARGET && ! $AUTOHELPERS && __FTP_HELPER )
|
||||
PARAM - - tcp 21 ; helper=ftp
|
||||
PARAM - - tcp 21 { helper=ftp }
|
||||
?else
|
||||
PARAM - - tcp 21
|
||||
?endif
|
||||
|
14
Shorewall/Macros/macro.Goto-Meeting
Normal file
14
Shorewall/Macros/macro.Goto-Meeting
Normal file
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Shorewall version 4 - Citrix/Goto Meeting macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.Goto-Meeting
|
||||
# by Eric Teeter
|
||||
# This macro handles Citrix/Goto Meeting
|
||||
# Assumes that ports 80 and 443 are already open
|
||||
# If needed, use the macros that open Http and Https to reduce redundancy
|
||||
####################################################################################
|
||||
?FORMAT 2
|
||||
####################################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 8200 # Goto Meeting only needed (TCP outbound)
|
23
Shorewall/Macros/macro.ILO
Normal file
23
Shorewall/Macros/macro.ILO
Normal file
@@ -0,0 +1,23 @@
|
||||
#
|
||||
# Shorewall version 4 - ILO Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.ILO
|
||||
#
|
||||
# This macro handles console redirection with HP ILO 2+,
|
||||
# Use this macro to open access to your ILO interface from management
|
||||
# workstations.
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 3002 # Raw serial data
|
||||
PARAM - - tcp 9300 # Shared Remote Console
|
||||
PARAM - - tcp 17988 # Virtual Media
|
||||
PARAM - - tcp 17990 # Console Replay
|
||||
HTTP
|
||||
HTTPS
|
||||
RDP
|
||||
SSH
|
||||
Telnet # Remote Console/Telnet
|
26
Shorewall/Macros/macro.IPMI
Normal file
26
Shorewall/Macros/macro.IPMI
Normal file
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Shorewall version 4 - IPMI Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.IPMI
|
||||
#
|
||||
# This macro handles IPMI console redirection with Asus (AMI),
|
||||
# Dell DRAC5+ (Avocent), and Supermicro (Aten or AMI).
|
||||
# Use this macro to open access to your IPMI interface from management
|
||||
# workstations.
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 623 # RMCP
|
||||
PARAM - - tcp 3668,3669 # Virtual Media, Secure (Dell)
|
||||
PARAM - - tcp 5120,5123 # CD, floppy (Asus, Aten)
|
||||
PARAM - - tcp 5900,5901 # Remote Console (Aten, Dell)
|
||||
PARAM - - tcp 7578 # Remote Console (AMI)
|
||||
PARAM - - udp 623 # RMCP
|
||||
HTTP
|
||||
HTTPS
|
||||
SNMP
|
||||
SSH # Serial over Lan
|
||||
Telnet
|
@@ -12,7 +12,7 @@
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
|
||||
?if ( __CT_TARGET && ! $AUTOHELPERS && __IRC_HELPER )
|
||||
PARAM - - tcp 6667 ; helper=irc
|
||||
PARAM - - tcp 6667 { helper=irc }
|
||||
?else
|
||||
PARAM - - tcp 6667
|
||||
?endif
|
||||
|
13
Shorewall/Macros/macro.Jabber
Normal file
13
Shorewall/Macros/macro.Jabber
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Shorewall version 4 - Jabber Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.Jabber
|
||||
#
|
||||
# This macro accepts Jabber traffic.
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 5222
|
@@ -1,13 +1,14 @@
|
||||
#
|
||||
# Shorewall version 3.4 - JabberPlain Macro
|
||||
# Shorewall version 4 - JabberPlain Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.JabberPlain
|
||||
#
|
||||
# This macro accepts Jabber traffic (plaintext).
|
||||
# This macro accepts Jabber traffic (plaintext). This macro is
|
||||
# deprecated - use of macro.Jabber instead is recommended.
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 5222
|
||||
Jabber
|
||||
|
@@ -1,9 +1,11 @@
|
||||
#
|
||||
# Shorewall version 3.4 - JabberSecure (ssl) Macro
|
||||
# Shorewall version 4 - JabberSecure (SSL) Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.JabberSecure
|
||||
#
|
||||
# This macro accepts Jabber traffic (ssl).
|
||||
# This macro accepts Jabber traffic (SSL). Use of Jabber with SSL
|
||||
# is deprecated, please configure Jabber with STARTTLS and use
|
||||
# Jabber macro instead.
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
|
13
Shorewall/Macros/macro.MongoDB
Normal file
13
Shorewall/Macros/macro.MongoDB
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Shorewall version 4 - MongoDB Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.MongoDB
|
||||
#
|
||||
# This macro handles MongoDB Daemon/Router traffic.
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 27017
|
@@ -14,7 +14,7 @@ PARAM - - 47
|
||||
PARAM DEST SOURCE 47
|
||||
|
||||
?if ( __CT_TARGET && ! $AUTOHELPERS && __PPTP_HELPER )
|
||||
PARAM - - tcp 1723 ; helper=pptp
|
||||
PARAM - - tcp 1723 { helper=pptp }
|
||||
?else
|
||||
PARAM - - tcp 1723
|
||||
?endif
|
||||
|
13
Shorewall/Macros/macro.QUIC
Normal file
13
Shorewall/Macros/macro.QUIC
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Shorewall version 4 - QUIC Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.QUIC
|
||||
#
|
||||
# This macro handles QUIC (Quick UDP Internet Connections).
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - udp 80,443
|
13
Shorewall/Macros/macro.Redis
Normal file
13
Shorewall/Macros/macro.Redis
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Shorewall version 4 - Redis Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.Redis
|
||||
#
|
||||
# This macro handles Redis traffic.
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 6379
|
@@ -12,7 +12,7 @@
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
|
||||
?if ( __CT_TARGET && ! $AUTOHELPERS && __SANE_HELPER )
|
||||
PARAM - - tcp 6566 ; helper=sane
|
||||
PARAM - - tcp 6566 { helper=sane }
|
||||
?else
|
||||
PARAM - - tcp 6566
|
||||
?endif
|
||||
|
@@ -12,7 +12,7 @@
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
|
||||
?if ( __CT_TARGET && ! $AUTOHELPERS && __SIP_HELPER )
|
||||
PARAM - - udp 5060 ; helper=sip
|
||||
PARAM - - udp 5060 { helper=sip }
|
||||
?else
|
||||
PARAM - - udp 5060
|
||||
?endif
|
||||
|
@@ -17,7 +17,7 @@
|
||||
PARAM - - udp 135,445
|
||||
|
||||
?if ( __CT_TARGET && ! $AUTOHELPERS && __NETBIOS_NS_HELPER )
|
||||
PARAM - - udp 137 ; helper=netbios-ns
|
||||
PARAM - - udp 137 { helper=netbios-ns }
|
||||
PARAM - - udp 138:139
|
||||
?else
|
||||
PARAM - - udp 137:139
|
||||
|
@@ -17,7 +17,7 @@
|
||||
PARAM - - udp 135,445
|
||||
|
||||
?if ( __CT_TARGET && ! $AUTOHELPERS && __NETBIOS_NS_HELPER )
|
||||
PARAM - - udp 137 ; helper=netbios-ns
|
||||
PARAM - - udp 137 { helper=netbios-ns }
|
||||
PARAM - - udp 138:139
|
||||
?else
|
||||
PARAM - - udp 137:139
|
||||
@@ -28,7 +28,7 @@ PARAM - - tcp 135,139,445
|
||||
PARAM DEST SOURCE udp 135,445
|
||||
|
||||
?if ( __CT_TARGET && ! $AUTOHELPERS && __NETBIOS_NS_HELPER )
|
||||
PARAM DEST SOURCE udp 137 ; helper=netbios-ns
|
||||
PARAM DEST SOURCE udp 137 { helper=netbios-ns }
|
||||
PARAM DEST SOURCE udp 138:139
|
||||
?else
|
||||
PARAM DEST SOURCE udp 137:139
|
||||
|
@@ -14,7 +14,7 @@
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
|
||||
?if ( __CT_TARGET && ! $AUTOHELPERS && __SNMP_HELPER )
|
||||
PARAM - - udp 161 ; helper=snmp
|
||||
PARAM - - udp 161 { helper=snmp }
|
||||
?else
|
||||
PARAM - - udp 161
|
||||
?endif
|
||||
|
13
Shorewall/Macros/macro.Sieve
Normal file
13
Shorewall/Macros/macro.Sieve
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Shorewall version 4 - Sieve Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.Sieve
|
||||
#
|
||||
# This macro handles sieve aka ManageSieve protocol.
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 4190
|
@@ -14,7 +14,7 @@
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
|
||||
?if ( __CT_TARGET && ! $AUTOHELPERS && __TFTP_HELPER )
|
||||
PARAM - - udp 69 ; helper=tftp
|
||||
PARAM - - udp 69 { helper=tftp }
|
||||
?else
|
||||
PARAM - - udp 69
|
||||
?endif
|
||||
|
11
Shorewall/Macros/macro.Tinc
Normal file
11
Shorewall/Macros/macro.Tinc
Normal file
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Shorewall version 4 - tinc Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.Tinc Macro
|
||||
#
|
||||
# This macro handles tinc traffic.
|
||||
#
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
|
||||
# PORT(S) PORT(S) LIMIT GROUP
|
||||
PARAM - - udp 655
|
15
Shorewall/Macros/macro.Zabbix
Normal file
15
Shorewall/Macros/macro.Zabbix
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# Shorewall version 4 - Zabbix Macro
|
||||
#
|
||||
# /usr/share/shorewall/macro.Zabbix
|
||||
#
|
||||
# This macro handles Zabbix monitoring software server traffic to agent
|
||||
# and trap traffic from agent to zabbix server.
|
||||
#
|
||||
###############################################################################
|
||||
?FORMAT 2
|
||||
###############################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
|
||||
# PORT(S) PORT(S) DEST LIMIT GROUP
|
||||
PARAM - - tcp 10050 # zabbix_agent
|
||||
PARAM DEST SOURCE tcp 10051 # zabbix_trap
|
@@ -34,6 +34,7 @@ use strict;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = ( qw( process_arprules create_arptables_load preview_arptables_load ) );
|
||||
our $VERSION = 'MODULEVERSION';
|
||||
|
||||
our %arp_table;
|
||||
our $arp_input;
|
||||
|
@@ -155,8 +155,6 @@ sub process_accounting_rule1( $$$$$$$$$$$ ) {
|
||||
|
||||
my ($action, $chain, $source, $dest, $proto, $ports, $sports, $user, $mark, $ipsec, $headers ) = @_;
|
||||
|
||||
$acctable = $config{ACCOUNTING_TABLE};
|
||||
|
||||
$jumpchainref = 0;
|
||||
|
||||
$asection = LEGACY if $asection < 0;
|
||||
@@ -453,6 +451,8 @@ sub setup_accounting() {
|
||||
|
||||
set_section_function( &process_section );
|
||||
|
||||
$acctable = $config{ACCOUNTING_TABLE};
|
||||
|
||||
first_entry "$doing $fn...";
|
||||
|
||||
my $nonEmpty = 0;
|
||||
|
@@ -30,7 +30,7 @@ package Shorewall::Chains;
|
||||
require Exporter;
|
||||
|
||||
use Scalar::Util 'reftype';
|
||||
use Digest::SHA qw(sha1);
|
||||
use Digest::SHA qw(sha1_hex);
|
||||
use File::Basename;
|
||||
use Shorewall::Config qw(:DEFAULT :internal);
|
||||
use Shorewall::Zones;
|
||||
@@ -73,6 +73,7 @@ our @EXPORT = ( qw(
|
||||
allow_optimize
|
||||
allow_delete
|
||||
allow_move
|
||||
make_terminating
|
||||
set_optflags
|
||||
reset_optflags
|
||||
has_return
|
||||
@@ -104,12 +105,12 @@ our @EXPORT = ( qw(
|
||||
AUDIT
|
||||
HELPER
|
||||
INLINE
|
||||
TERMINATING
|
||||
STATEMATCH
|
||||
USERBUILTIN
|
||||
INLINERULE
|
||||
OPTIONS
|
||||
IPTABLES
|
||||
TARPIT
|
||||
FILTER_TABLE
|
||||
NAT_TABLE
|
||||
MANGLE_TABLE
|
||||
@@ -259,9 +260,11 @@ our %EXPORT_TAGS = (
|
||||
get_interface_gateway
|
||||
get_interface_mac
|
||||
have_global_variables
|
||||
have_address_variables
|
||||
set_global_variables
|
||||
save_dynamic_chains
|
||||
load_ipsets
|
||||
create_save_ipsets
|
||||
validate_nfobject
|
||||
create_nfobjects
|
||||
create_netfilter_load
|
||||
@@ -277,7 +280,7 @@ our %EXPORT_TAGS = (
|
||||
|
||||
Exporter::export_ok_tags('internal');
|
||||
|
||||
our $VERSION = '4.5_18';
|
||||
our $VERSION = 'MODULEVERSION';
|
||||
|
||||
#
|
||||
# Chain Table
|
||||
@@ -315,7 +318,7 @@ our $VERSION = '4.5_18';
|
||||
# restriction => Restrictions on further rules in this chain.
|
||||
# audit => Audit the result.
|
||||
# filtered => Number of filter rules at the front of an interface forward chain
|
||||
# digest => string representation of the chain's rules for use in optimization
|
||||
# digest => SHA1 digest of the string representation of the chain's rules for use in optimization
|
||||
# level 8.
|
||||
# complete => The last rule in the chain is a -g or a simple -j to a terminating target
|
||||
# Suppresses adding additional rules to the chain end of the chain
|
||||
@@ -425,6 +428,7 @@ use constant { STANDARD => 0x1, #defined by Netfilter
|
||||
INLINERULE => 0x40000, #INLINE
|
||||
OPTIONS => 0x80000, #Target Accepts Options
|
||||
IPTABLES => 0x100000, #IPTABLES or IP6TABLES
|
||||
TARPIT => 0x200000, #TARPIT
|
||||
|
||||
FILTER_TABLE => 0x1000000,
|
||||
MANGLE_TABLE => 0x2000000,
|
||||
@@ -646,6 +650,7 @@ our %opttype = ( rule => CONTROL,
|
||||
simple => CONTROL,
|
||||
matches => CONTROL,
|
||||
complex => CONTROL,
|
||||
t => CONTROL,
|
||||
|
||||
i => UNIQUE,
|
||||
s => UNIQUE,
|
||||
@@ -760,7 +765,6 @@ sub initialize( $$$ ) {
|
||||
RETURN => 1,
|
||||
QUEUE => 1,
|
||||
CLASSIFY => 1,
|
||||
CT => 1,
|
||||
DNAT => 1,
|
||||
MASQUERADE => 1,
|
||||
NETMAP => 1,
|
||||
@@ -793,6 +797,13 @@ sub decr_cmd_level( $ ) {
|
||||
assert( --$_[0]->{cmdlevel} >= 0, $_[0] );
|
||||
}
|
||||
|
||||
#
|
||||
# Mark an action as terminating
|
||||
#
|
||||
sub make_terminating( $ ) {
|
||||
$terminating{$_[0]} = 1;
|
||||
}
|
||||
|
||||
#
|
||||
# Transform the passed iptables rule into an internal-form hash reference.
|
||||
# Most of the compiler has been converted to use the new form natively.
|
||||
@@ -881,6 +892,8 @@ sub set_rule_option( $$$ ) {
|
||||
}
|
||||
} elsif ( $opttype == EXCLUSIVE ) {
|
||||
$ruleref->{$option} .= ",$value";
|
||||
} elsif ( $opttype == CONTROL ) {
|
||||
$ruleref->{$option} = $value;
|
||||
} elsif ( $opttype == UNIQUE ) {
|
||||
#
|
||||
# Shorewall::Rules::perl_action_tcp_helper() can produce rules that have two -p specifications.
|
||||
@@ -915,7 +928,7 @@ sub transform_rule( $;\$ ) {
|
||||
my $option;
|
||||
my $invert = '';
|
||||
|
||||
if ( $input =~ s/^(!\s+)?-([psdjgiom])\s+// ) {
|
||||
if ( $input =~ s/^(!\s+)?-([psdjgiomt])\s+// ) {
|
||||
#
|
||||
# Normal case of single-character
|
||||
$invert = '!' if $1;
|
||||
@@ -945,7 +958,7 @@ sub transform_rule( $;\$ ) {
|
||||
|
||||
PARAM:
|
||||
{
|
||||
while ( $input ne '' && $input !~ /^(?:!|-[psdjgiom])\s/ ) {
|
||||
while ( $input ne '' && $input !~ /^(?:!|-[psdjgiomt])\s/ ) {
|
||||
last PARAM if $input =~ /^--([^\s]+)/ && $aliases{$1 || '' };
|
||||
$input =~ s/^([^\s]+)\s*//;
|
||||
my $token = $1;
|
||||
@@ -1654,7 +1667,8 @@ sub insert_rule($$$) {
|
||||
sub insert_irule( $$$$;@ ) {
|
||||
my ( $chainref, $jump, $target, $number, @matches ) = @_;
|
||||
|
||||
my $ruleref = {};
|
||||
my $rulesref = $chainref->{rules};
|
||||
my $ruleref = {};
|
||||
|
||||
$ruleref->{mode} = ( $ruleref->{cmdlevel} = $chainref->{cmdlevel} ) ? CMD_MODE : CAT_MODE;
|
||||
|
||||
@@ -1673,7 +1687,15 @@ sub insert_irule( $$$$;@ ) {
|
||||
|
||||
$ruleref->{comment} = shortlineinfo( $chainref->{origin} ) || $ruleref->{comment} || $comment;
|
||||
|
||||
splice( @{$chainref->{rules}}, $number, 0, $ruleref );
|
||||
if ( $number >= @$rulesref ) {
|
||||
#
|
||||
# Avoid failure in spice if we insert beyond the end of the chain
|
||||
#
|
||||
$number = @$rulesref;
|
||||
push @$rulesref, $ruleref;
|
||||
} else {
|
||||
splice( @$rulesref, $number, 0, $ruleref );
|
||||
}
|
||||
|
||||
trace( $chainref, 'I', ++$number, format_rule( $chainref, $ruleref ) ) if $debug;
|
||||
|
||||
@@ -1967,6 +1989,10 @@ sub zone_forward_chain($) {
|
||||
#
|
||||
sub use_forward_chain($$) {
|
||||
my ( $interface, $chainref ) = @_;
|
||||
my @loopback_zones = loopback_zones;
|
||||
|
||||
return 0 if $interface eq loopback_interface && ! @loopback_zones;
|
||||
|
||||
my $interfaceref = find_interface($interface);
|
||||
my $nets = $interfaceref->{nets};
|
||||
|
||||
@@ -2841,6 +2867,7 @@ sub initialize_chain_table($) {
|
||||
'HELPER' => STANDARD + HELPER + NATONLY, #Actually RAWONLY
|
||||
'INLINE' => INLINERULE,
|
||||
'IPTABLES' => IPTABLES,
|
||||
'TARPIT' => STANDARD + TARPIT + OPTIONS,
|
||||
);
|
||||
|
||||
for my $chain ( qw(OUTPUT PREROUTING) ) {
|
||||
@@ -2906,6 +2933,7 @@ sub initialize_chain_table($) {
|
||||
'HELPER' => STANDARD + HELPER + NATONLY, #Actually RAWONLY
|
||||
'INLINE' => INLINERULE,
|
||||
'IP6TABLES' => IPTABLES,
|
||||
'TARPIT' => STANDARD + TARPIT + OPTIONS,
|
||||
);
|
||||
|
||||
for my $chain ( qw(OUTPUT PREROUTING) ) {
|
||||
@@ -3037,7 +3065,7 @@ sub calculate_digest( $ ) {
|
||||
}
|
||||
}
|
||||
|
||||
$chainref->{digest} = sha1 $digest;
|
||||
$chainref->{digest} = sha1_hex $digest;
|
||||
}
|
||||
|
||||
#
|
||||
@@ -3503,7 +3531,7 @@ sub optimize_level8( $$$ ) {
|
||||
%renamed = ();
|
||||
|
||||
while ( $progress ) {
|
||||
my @chains = ( sort level8_compare grep $_->{referenced} && ! $_->{builtin}, values %{$tableref} );
|
||||
my @chains = ( sort { level8_compare($a, $b) } ( grep $_->{referenced} && ! $_->{builtin}, values %{$tableref} ) );
|
||||
my @chains1 = @chains;
|
||||
my $chains = @chains;
|
||||
my %rename;
|
||||
@@ -4420,6 +4448,7 @@ sub do_proto( $$$;$ )
|
||||
|
||||
if ( $ports =~ /^\+/ ) {
|
||||
$output .= $invert;
|
||||
$output .= '-m set ';
|
||||
$output .= get_set_flags( $ports, 'dst' );
|
||||
} else {
|
||||
$sports = '', require_capability( 'MULTIPORT', "'=' in the SOURCE PORT(S) column", 's' ) if ( $srcndst = $sports eq '=' );
|
||||
@@ -4459,7 +4488,8 @@ sub do_proto( $$$;$ )
|
||||
|
||||
if ( $ports =~ /^\+/ ) {
|
||||
$output .= $invert;
|
||||
$output .= get_set_flags( $ports, 'dst' );
|
||||
$output .= '-m set ';
|
||||
$output .= get_set_flags( $ports, 'src' );
|
||||
} elsif ( $multiport ) {
|
||||
if ( port_count( $sports ) > 15 ) {
|
||||
if ( $restricted ) {
|
||||
@@ -4624,30 +4654,35 @@ sub do_iproto( $$$ )
|
||||
|
||||
if ( $ports ne '' ) {
|
||||
$invert = $ports =~ s/^!// ? '! ' : '';
|
||||
$sports = '', require_capability( 'MULTIPORT', "'=' in the SOURCE PORT(S) column", 's' ) if ( $srcndst = $sports eq '=' );
|
||||
|
||||
if ( $multiport || $ports =~ tr/,/,/ > 0 || $sports =~ tr/,/,/ > 0 ) {
|
||||
fatal_error "Port lists require Multiport support in your kernel/iptables" unless have_capability( 'MULTIPORT' , 1 );
|
||||
if ( $ports =~ /^\+/ ) {
|
||||
push @output , set => ${invert} . get_set_flags( $ports, 'dst' );
|
||||
} else {
|
||||
$sports = '', require_capability( 'MULTIPORT', "'=' in the SOURCE PORT(S) column", 's' ) if ( $srcndst = $sports eq '=' );
|
||||
|
||||
if ( port_count ( $ports ) > 15 ) {
|
||||
if ( $restricted ) {
|
||||
fatal_error "A port list in this file may only have up to 15 ports";
|
||||
} elsif ( $invert ) {
|
||||
fatal_error "An inverted port list may only have up to 15 ports";
|
||||
if ( $multiport || $ports =~ tr/,/,/ > 0 || $sports =~ tr/,/,/ > 0 ) {
|
||||
fatal_error "Port lists require Multiport support in your kernel/iptables" unless have_capability( 'MULTIPORT' , 1 );
|
||||
|
||||
if ( port_count ( $ports ) > 15 ) {
|
||||
if ( $restricted ) {
|
||||
fatal_error "A port list in this file may only have up to 15 ports";
|
||||
} elsif ( $invert ) {
|
||||
fatal_error "An inverted port list may only have up to 15 ports";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ports = validate_port_list $pname , $ports;
|
||||
push @output, multiport => ( $srcndst ? "${invert}--ports ${ports} " : "${invert}--dports ${ports} " );
|
||||
$multiport = 1;
|
||||
} else {
|
||||
fatal_error "Missing DEST PORT" unless supplied $ports;
|
||||
$ports = validate_portpair $pname , $ports;
|
||||
$ports = validate_port_list $pname , $ports;
|
||||
push @output, multiport => ( $srcndst ? "${invert}--ports ${ports} " : "${invert}--dports ${ports} " );
|
||||
$multiport = 1;
|
||||
} else {
|
||||
fatal_error "Missing DEST PORT" unless supplied $ports;
|
||||
$ports = validate_portpair $pname , $ports;
|
||||
|
||||
if ( $srcndst ) {
|
||||
push @output, multiport => "${invert}--ports ${ports}";
|
||||
} else {
|
||||
push @output, dport => "${invert}${ports}";
|
||||
if ( $srcndst ) {
|
||||
push @output, multiport => "${invert}--ports ${ports}";
|
||||
} else {
|
||||
push @output, dport => "${invert}${ports}";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -4657,8 +4692,10 @@ sub do_iproto( $$$ )
|
||||
if ( $sports ne '' ) {
|
||||
fatal_error "'=' in the SOURCE PORT(S) column requires one or more ports in the DEST PORT(S) column" if $sports eq '=';
|
||||
$invert = $sports =~ s/^!// ? '! ' : '';
|
||||
if ( $multiport ) {
|
||||
|
||||
if ( $ports =~ /^\+/ ) {
|
||||
push @output, set => ${invert} . get_set_flags( $ports, 'src' );
|
||||
} elsif ( $multiport ) {
|
||||
if ( port_count( $sports ) > 15 ) {
|
||||
if ( $restricted ) {
|
||||
fatal_error "A port list in this file may only have up to 15 ports";
|
||||
@@ -4859,62 +4896,79 @@ my %norate = ( DROP => 1, REJECT => 1 );
|
||||
# Create a "-m limit" match for the passed LIMIT/BURST
|
||||
#
|
||||
sub do_ratelimit( $$ ) {
|
||||
my ( $rate, $action ) = @_;
|
||||
my ( $rates, $action ) = @_;
|
||||
|
||||
return '' unless $rate and $rate ne '-';
|
||||
return '' unless $rates and $rates ne '-';
|
||||
|
||||
fatal_error "Rate Limiting not available with $action" if $norate{$action};
|
||||
#
|
||||
# "-m hashlimit" match for the passed LIMIT/BURST
|
||||
#
|
||||
if ( $rate =~ /^[sd]:{1,2}/ ) {
|
||||
require_capability 'HASHLIMIT_MATCH', 'Per-ip rate limiting' , 's';
|
||||
|
||||
my $limit = "-m hashlimit ";
|
||||
my $match = have_capability( 'OLD_HL_MATCH' ) ? 'hashlimit' : 'hashlimit-upto';
|
||||
my $units;
|
||||
my @rates = split_list $rates, 'rate';
|
||||
|
||||
if ( $rate =~ /^[sd]:((\w*):)?((\d+)(\/(sec|min|hour|day))?):(\d+)$/ ) {
|
||||
fatal_error "Invalid Rate ($3)" unless $4;
|
||||
fatal_error "Invalid Burst ($7)" unless $7;
|
||||
$limit .= "--$match $3 --hashlimit-burst $7 --hashlimit-name ";
|
||||
$limit .= $2 ? $2 : 'shorewall' . $hashlimitset++;
|
||||
$limit .= ' --hashlimit-mode ';
|
||||
$units = $6;
|
||||
} elsif ( $rate =~ /^[sd]:((\w*):)?((\d+)(\/(sec|min|hour|day))?)$/ ) {
|
||||
fatal_error "Invalid Rate ($3)" unless $4;
|
||||
$limit .= "--$match $3 --hashlimit-name ";
|
||||
$limit .= $2 ? $2 : 'shorewall' . $hashlimitset++;
|
||||
$limit .= ' --hashlimit-mode ';
|
||||
$units = $6;
|
||||
} else {
|
||||
fatal_error "Invalid rate ($rate)";
|
||||
}
|
||||
if ( @rates == 2 ) {
|
||||
$rates[0] = 's:' . $rates[0];
|
||||
$rates[1] = 'd:' . $rates[1];
|
||||
} elsif ( @rates > 2 ) {
|
||||
fatal error "Only two rates may be specified";
|
||||
}
|
||||
|
||||
$limit .= $rate =~ /^s:/ ? 'srcip ' : 'dstip ';
|
||||
my $limit = '';
|
||||
|
||||
if ( $units && $units ne 'sec' ) {
|
||||
my $expire = 60000; # 1 minute in milliseconds
|
||||
for my $rate ( @rates ) {
|
||||
#
|
||||
# "-m hashlimit" match for the passed LIMIT/BURST
|
||||
#
|
||||
if ( $rate =~ /^([sd]):{1,2}/ ) {
|
||||
require_capability 'HASHLIMIT_MATCH', 'Per-ip rate limiting' , 's';
|
||||
|
||||
if ( $units ne 'min' ) {
|
||||
$expire *= 60; #At least an hour
|
||||
$expire *= 24 if $units eq 'day';
|
||||
my $match = have_capability( 'OLD_HL_MATCH' ) ? 'hashlimit' : 'hashlimit-upto';
|
||||
my $units;
|
||||
|
||||
$limit .= "-m hashlimit ";
|
||||
|
||||
if ( $rate =~ /^[sd]:((\w*):)?((\d+)(\/(sec|min|hour|day))?):(\d+)$/ ) {
|
||||
fatal_error "Invalid Rate ($3)" unless $4;
|
||||
fatal_error "Invalid Burst ($7)" unless $7;
|
||||
$limit .= "--$match $3 --hashlimit-burst $7 --hashlimit-name ";
|
||||
$limit .= $2 ? $2 : 'shorewall' . $hashlimitset++;
|
||||
$limit .= ' --hashlimit-mode ';
|
||||
$units = $6;
|
||||
} elsif ( $rate =~ /^[sd]:((\w*):)?((\d+)(\/(sec|min|hour|day))?)$/ ) {
|
||||
fatal_error "Invalid Rate ($3)" unless $4;
|
||||
$limit .= "--$match $3 --hashlimit-name ";
|
||||
$limit .= $2 ? $2 : 'shorewall' . $hashlimitset++;
|
||||
$limit .= ' --hashlimit-mode ';
|
||||
$units = $6;
|
||||
} else {
|
||||
fatal_error "Invalid rate ($rate)";
|
||||
}
|
||||
|
||||
$limit .= "--hashlimit-htable-expire $expire ";
|
||||
}
|
||||
$limit .= $rate =~ /^s:/ ? 'srcip ' : 'dstip ';
|
||||
|
||||
$limit;
|
||||
} elsif ( $rate =~ /^((\d+)(\/(sec|min|hour|day))?):(\d+)$/ ) {
|
||||
fatal_error "Invalid Rate ($1)" unless $2;
|
||||
fatal_error "Invalid Burst ($5)" unless $5;
|
||||
"-m limit --limit $1 --limit-burst $5 ";
|
||||
} elsif ( $rate =~ /^(\d+)(\/(sec|min|hour|day))?$/ ) {
|
||||
fatal_error "Invalid Rate (${1}${2})" unless $1;
|
||||
"-m limit --limit $rate ";
|
||||
} else {
|
||||
fatal_error "Invalid rate ($rate)";
|
||||
if ( $units && $units ne 'sec' ) {
|
||||
my $expire = 60000; # 1 minute in milliseconds
|
||||
|
||||
if ( $units ne 'min' ) {
|
||||
$expire *= 60; #At least an hour
|
||||
$expire *= 24 if $units eq 'day';
|
||||
}
|
||||
|
||||
$limit .= "--hashlimit-htable-expire $expire ";
|
||||
}
|
||||
} else {
|
||||
if ( $rate =~ /^((\d+)(\/(sec|min|hour|day))?):(\d+)$/ ) {
|
||||
fatal_error "Invalid Rate ($1)" unless $2;
|
||||
fatal_error "Invalid Burst ($5)" unless $5;
|
||||
$limit = "-m limit --limit $1 --limit-burst $5 ";
|
||||
} elsif ( $rate =~ /^(\d+)(\/(sec|min|hour|day))?$/ ) {
|
||||
fatal_error "Invalid Rate (${1}${2})" unless $1;
|
||||
$limit = "-m limit --limit $rate ";
|
||||
} else {
|
||||
fatal_error "Invalid rate ($rate)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$limit;
|
||||
}
|
||||
|
||||
#
|
||||
@@ -5459,7 +5513,7 @@ sub get_set_flags( $$ ) {
|
||||
|
||||
my $rest = '';
|
||||
|
||||
if ( $setname =~ /^(.*)\[([1-6])(?:,(.*))\]$/ ) {
|
||||
if ( $setname =~ /^(.*)\[([1-6])(?:,(.+))?\]$/ ) {
|
||||
$setname = $1;
|
||||
my $count = $2;
|
||||
$rest = $3;
|
||||
@@ -5484,7 +5538,7 @@ sub get_set_flags( $$ ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $rest ) {
|
||||
if ( supplied $rest ) {
|
||||
my @extensions = split_list($rest, 'ipset option');
|
||||
|
||||
for ( @extensions ) {
|
||||
@@ -5550,6 +5604,8 @@ sub have_ipset_rules() {
|
||||
|
||||
sub get_interface_address( $ );
|
||||
|
||||
sub get_interface_gateway ( $;$ );
|
||||
|
||||
sub record_runtime_address( $$;$ ) {
|
||||
my ( $addrtype, $interface, $protect ) = @_;
|
||||
|
||||
@@ -6487,7 +6543,6 @@ sub set_chain_variables() {
|
||||
|
||||
emit( 'IPTABLES_RESTORE=${IPTABLES}-restore',
|
||||
'[ -x "$IPTABLES_RESTORE" ] || startup_error "$IPTABLES_RESTORE does not exist or is not executable"' );
|
||||
|
||||
emit( 'g_tool=$IPTABLES' );
|
||||
} else {
|
||||
if ( $config{IP6TABLES} ) {
|
||||
@@ -6502,7 +6557,6 @@ sub set_chain_variables() {
|
||||
|
||||
emit( 'IP6TABLES_RESTORE=${IP6TABLES}-restore',
|
||||
'[ -x "$IP6TABLES_RESTORE" ] || startup_error "$IP6TABLES_RESTORE does not exist or is not executable"' );
|
||||
|
||||
emit( 'g_tool=$IP6TABLES' );
|
||||
}
|
||||
|
||||
@@ -6641,11 +6695,10 @@ sub get_interface_gateway ( $;$ ) {
|
||||
$global_variables |= ALL_COMMANDS;
|
||||
|
||||
if ( interface_is_optional $logical ) {
|
||||
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$($routine $interface)\n);
|
||||
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$($routine $interface));
|
||||
} else {
|
||||
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$($routine $interface)
|
||||
[ -n "\$$variable" ] || startup_error "Unable to detect the gateway through interface $interface"
|
||||
);
|
||||
[ -n "\$$variable" ] || startup_error "Unable to detect the gateway through interface $interface");
|
||||
}
|
||||
|
||||
$protect ? "\${$variable:-" . NILIP . '}' : "\$$variable";
|
||||
@@ -6723,20 +6776,25 @@ sub interface_mac( $$ ) {
|
||||
#
|
||||
# Record the fact that the ruleset requires MAC address of the passed gateway IP routed out of the passed interface for the passed provider number
|
||||
#
|
||||
sub get_interface_mac( $$$ ) {
|
||||
my ( $ipaddr, $logical , $table ) = @_;
|
||||
sub get_interface_mac( $$$$ ) {
|
||||
my ( $ipaddr, $logical , $table, $mac ) = @_;
|
||||
|
||||
my $interface = get_physical( $logical );
|
||||
my $variable = interface_mac( $interface , $table );
|
||||
|
||||
$global_variables |= NOT_RESTORE;
|
||||
|
||||
if ( interface_is_optional $logical ) {
|
||||
$interfacemacs{$table} = qq($variable=\$(find_mac $ipaddr $interface)\n);
|
||||
|
||||
if ( $mac ) {
|
||||
$interfacemacs{$table} = qq($variable=$mac);
|
||||
} else {
|
||||
$interfacemacs{$table} = qq($variable=\$(find_mac $ipaddr $interface)
|
||||
if ( interface_is_optional $logical ) {
|
||||
$interfacemacs{$table} = qq($variable=\$(find_mac $ipaddr $interface)\n);
|
||||
} else {
|
||||
$interfacemacs{$table} = qq($variable=\$(find_mac $ipaddr $interface)
|
||||
[ -n "\$$variable" ] || startup_error "Unable to determine the MAC address of $ipaddr through interface \\"$interface\\""
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
"\$$variable";
|
||||
@@ -6746,16 +6804,40 @@ sub have_global_variables() {
|
||||
have_capability( 'ADDRTYPE' ) ? $global_variables : $global_variables | NOT_RESTORE;
|
||||
}
|
||||
|
||||
sub have_address_variables() {
|
||||
( keys %interfaceaddr || keys %interfacemacs || keys %interfacegateways );
|
||||
}
|
||||
|
||||
#
|
||||
# Generate setting of run-time global shell variables
|
||||
#
|
||||
sub set_global_variables( $ ) {
|
||||
sub set_global_variables( $$ ) {
|
||||
|
||||
my $setall = shift;
|
||||
my ( $setall, $conditional ) = @_;
|
||||
|
||||
emit $_ for values %interfaceaddr;
|
||||
emit $_ for values %interfacegateways;
|
||||
emit $_ for values %interfacemacs;
|
||||
if ( $conditional ) {
|
||||
my ( $interface, $code );
|
||||
|
||||
while ( ( $interface, $code ) = each %interfaceaddr ) {
|
||||
emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $code) );
|
||||
}
|
||||
|
||||
while ( ( $interface, $code ) = each %interfacegateways ) {
|
||||
emit( qq(if [ -z "\$interface" -o "\$interface" = "$interface" ]; then) );
|
||||
push_indent;
|
||||
emit( $code );
|
||||
pop_indent;
|
||||
emit( qq(fi\n) );
|
||||
}
|
||||
|
||||
while ( ( $interface, $code ) = each %interfacemacs ) {
|
||||
emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $code) );
|
||||
}
|
||||
} else {
|
||||
emit $_ for values %interfaceaddr;
|
||||
emit "$_\n" for values %interfacegateways;
|
||||
emit $_ for values %interfacemacs;
|
||||
}
|
||||
|
||||
if ( $setall ) {
|
||||
emit $_ for values %interfaceaddrs;
|
||||
@@ -7565,7 +7647,7 @@ sub expand_rule( $$$$$$$$$$$;$ )
|
||||
$exceptionrule,
|
||||
$actparms{disposition} || $disposition,
|
||||
$target ),
|
||||
$terminating{$basictarget} || ( $targetref || $targetref->{complete} ),
|
||||
$terminating{$basictarget} || ( $targetref && $targetref->{complete} ),
|
||||
$matches );
|
||||
}
|
||||
|
||||
@@ -7628,7 +7710,7 @@ sub add_interface_options( $ ) {
|
||||
}
|
||||
}
|
||||
|
||||
$chainref->{digest} = sha1 $digest;
|
||||
$chainref->{digest} = sha1_hex $digest;
|
||||
}
|
||||
#
|
||||
# Insert jumps to the interface chains into the rules chains
|
||||
@@ -7870,14 +7952,18 @@ sub emitr1( $$ ) {
|
||||
|
||||
sub save_dynamic_chains() {
|
||||
|
||||
my $tool;
|
||||
my $tool = $family == F_IPV4 ? '${IPTABLES}' : '${IP6TABLES}';
|
||||
my $utility = $family == F_IPV4 ? 'iptables-restore' : 'ip6tables-restore';
|
||||
|
||||
emit ( 'if [ "$COMMAND" = restart -o "$COMMAND" = refresh ]; then' );
|
||||
push_indent;
|
||||
|
||||
if ( have_capability 'IPTABLES_S' ) {
|
||||
$tool = $family == F_IPV4 ? '${IPTABLES}' : '${IP6TABLES}';
|
||||
emit( 'if [ -n "$g_counters" ]; then' ,
|
||||
" ${tool}-save --counters | grep -vE '[ :]shorewall ' > \${VARDIR}/.${utility}-input",
|
||||
"fi\n"
|
||||
);
|
||||
|
||||
if ( have_capability 'IPTABLES_S' ) {
|
||||
emit <<"EOF";
|
||||
if chain_exists 'UPnP -t nat'; then
|
||||
$tool -t nat -S UPnP | tail -n +2 > \${VARDIR}/.UPnP
|
||||
@@ -7892,11 +7978,12 @@ else
|
||||
fi
|
||||
|
||||
if chain_exists dynamic; then
|
||||
$tool -S dynamic | tail -n +2 > \${VARDIR}/.dynamic
|
||||
$tool -S dynamic | tail -n +2 | fgrep -v -- '-j ACCEPT' > \${VARDIR}/.dynamic
|
||||
else
|
||||
rm -f \${VARDIR}/.dynamic
|
||||
fi
|
||||
EOF
|
||||
|
||||
} else {
|
||||
$tool = $family == F_IPV4 ? '${IPTABLES}-save' : '${IP6TABLES}-save';
|
||||
|
||||
@@ -7974,11 +8061,106 @@ sub ensure_ipset( $ ) {
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Generate the save_ipsets() function
|
||||
#
|
||||
sub create_save_ipsets() {
|
||||
my @ipsets = all_ipsets;
|
||||
|
||||
emit( "#\n#Save the ipsets specified by the SAVE_IPSETS setting and by dynamic zones\n#",
|
||||
'save_ipsets() {' );
|
||||
|
||||
if ( @ipsets || @{$globals{SAVED_IPSETS}} || ( $config{SAVE_IPSETS} && have_ipset_rules ) ) {
|
||||
emit( ' local file' ,
|
||||
'',
|
||||
' file=${1:-${VARDIR}/save.ipsets}'
|
||||
);
|
||||
|
||||
if ( @ipsets ) {
|
||||
emit '';
|
||||
ensure_ipset( $_ ) for @ipsets;
|
||||
}
|
||||
|
||||
if ( $config{SAVE_IPSETS} ) {
|
||||
if ( $family == F_IPV6 || $config{SAVE_IPSETS} eq 'ipv4' ) {
|
||||
my $select = $family == F_IPV4 ? '^create.*family inet ' : 'create.*family inet6 ';
|
||||
|
||||
emit( '' ,
|
||||
' rm -f $file' ,
|
||||
' touch $file' ,
|
||||
' local set' ,
|
||||
);
|
||||
|
||||
if ( @ipsets ) {
|
||||
emit '';
|
||||
emit( " \$IPSET -S $_ >> \$file" ) for @ipsets;
|
||||
}
|
||||
|
||||
emit( '',
|
||||
" for set in \$(\$IPSET save | grep '$select' | cut -d' ' -f2); do" ,
|
||||
" \$IPSET save \$set >> \$file" ,
|
||||
" done" ,
|
||||
'',
|
||||
);
|
||||
} else {
|
||||
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 -qE -- \"^(-N|create )\" \${VARDIR}/ipsets.tmp && mv -f \${VARDIR}/ipsets.tmp \$file" ,
|
||||
' fi' );
|
||||
}
|
||||
|
||||
emit( " return 0",
|
||||
'',
|
||||
"}\n" );
|
||||
} elsif ( @ipsets || $globals{SAVED_IPSETS} ) {
|
||||
emit( '' ,
|
||||
' rm -f ${VARDIR}/ipsets.tmp' ,
|
||||
' touch ${VARDIR}/ipsets.tmp' ,
|
||||
);
|
||||
|
||||
if ( @ipsets ) {
|
||||
emit '';
|
||||
emit( " \$IPSET -S $_ >> \${VARDIR}/ipsets.tmp" ) for @ipsets;
|
||||
}
|
||||
|
||||
emit( '' ,
|
||||
" if qt \$IPSET list $_; then" ,
|
||||
" \$IPSET save $_ >> \${VARDIR}/ipsets.tmp" ,
|
||||
' else' ,
|
||||
" error_message 'ipset $_ not saved (not found)'" ,
|
||||
" fi\n" ) for @{$globals{SAVED_IPSETS}};
|
||||
|
||||
emit( '' ,
|
||||
" grep -qE -- \"(-N|^create )\" \${VARDIR}/ipsets.tmp && cat \${VARDIR}/ipsets.tmp >> \$file\n" ,
|
||||
'' ,
|
||||
' return 0',
|
||||
'' ,
|
||||
"}\n" );
|
||||
}
|
||||
} elsif ( $config{SAVE_IPSETS} ) {
|
||||
emit( ' error_message "WARNING: No ipsets were saved"',
|
||||
' return 1',
|
||||
"}\n" );
|
||||
} else {
|
||||
emit( ' true',
|
||||
"}\n" );
|
||||
}
|
||||
}
|
||||
|
||||
sub load_ipsets() {
|
||||
|
||||
my @ipsets = all_ipsets;
|
||||
|
||||
if ( @ipsets || ( $config{SAVE_IPSETS} && have_ipset_rules ) ) {
|
||||
if ( @ipsets || @{$globals{SAVED_IPSETS}} || ( $config{SAVE_IPSETS} && have_ipset_rules ) ) {
|
||||
emit ( '',
|
||||
'local hack',
|
||||
'',
|
||||
@@ -8005,9 +8187,25 @@ sub load_ipsets() {
|
||||
emit ( '' );
|
||||
ensure_ipset( $_ ) for @ipsets;
|
||||
emit ( '' );
|
||||
|
||||
emit ( ' if [ -f ${VARDIR}/ipsets.save ]; then' ,
|
||||
' $IPSET flush' ,
|
||||
' $IPSET destroy' ,
|
||||
' $IPSET restore < ${VARDIR}/ipsets.save' ,
|
||||
" fi\n" ) for @{$globals{SAVED_IPSETS}};
|
||||
}
|
||||
} else {
|
||||
ensure_ipset( $_ ) for @ipsets;
|
||||
|
||||
if ( @{$globals{SAVED_IPSETS}} ) {
|
||||
emit ( '' );
|
||||
|
||||
emit ( ' if [ -f ${VARDIR}/ipsets.save ]; then' ,
|
||||
' $IPSET flush' ,
|
||||
' $IPSET destroy' ,
|
||||
' $IPSET restore < ${VARDIR}/ipsets.save' ,
|
||||
" fi\n" ) for @{$globals{SAVED_IPSETS}};
|
||||
}
|
||||
}
|
||||
|
||||
emit ( 'elif [ "$COMMAND" = restore -a -z "$g_recovering" ]; then' );
|
||||
@@ -8031,6 +8229,12 @@ sub load_ipsets() {
|
||||
}
|
||||
} else {
|
||||
ensure_ipset( $_ ) for @ipsets;
|
||||
|
||||
emit ( ' if [ -f ${VARDIR}/ipsets.save ]; then' ,
|
||||
' $IPSET flush' ,
|
||||
' $IPSET destroy' ,
|
||||
' $IPSET restore < ${VARDIR}/ipsets.save' ,
|
||||
" fi\n" ) for @{$globals{SAVED_IPSETS}};
|
||||
}
|
||||
|
||||
if ( @ipsets ) {
|
||||
@@ -8038,36 +8242,14 @@ sub load_ipsets() {
|
||||
ensure_ipset( $_ ) for @ipsets;
|
||||
}
|
||||
|
||||
emit( 'elif [ "$COMMAND" = stop ]; then' );
|
||||
|
||||
if ( @ipsets ) {
|
||||
ensure_ipset( $_ ) for @ipsets;
|
||||
emit( '' );
|
||||
}
|
||||
|
||||
if ( $family == F_IPV4 ) {
|
||||
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 -qE -- "^(-N|create )" ${VARDIR}/ipsets.tmp && mv -f ${VARDIR}/ipsets.tmp ${VARDIR}/ipsets.save' ,
|
||||
' fi' );
|
||||
} else {
|
||||
emit ( ' if eval $IPSET -S > ${VARDIR}/ipsets.tmp; then' ,
|
||||
' grep -qE -- "^(-N|create )" ${VARDIR}/ipsets.tmp && mv -f ${VARDIR}/ipsets.tmp ${VARDIR}/ipsets.save' ,
|
||||
' fi' );
|
||||
}
|
||||
emit( 'elif [ "$COMMAND" = stop ]; then' ,
|
||||
' save_ipsets'
|
||||
);
|
||||
|
||||
if ( @ipsets ) {
|
||||
emit( 'elif [ "$COMMAND" = refresh ]; then' );
|
||||
ensure_ipset( $_ ) for @ipsets;
|
||||
}
|
||||
};
|
||||
|
||||
emit ( 'fi' ,
|
||||
'' );
|
||||
@@ -8113,17 +8295,29 @@ sub create_netfilter_load( $ ) {
|
||||
'# Create the input to iptables-restore/ip6tables-restore and pass that input to the utility',
|
||||
'#',
|
||||
'setup_netfilter()',
|
||||
'{'
|
||||
);
|
||||
'{',
|
||||
' local option',
|
||||
);
|
||||
|
||||
push_indent;
|
||||
|
||||
my $utility = $family == F_IPV4 ? 'iptables-restore' : 'ip6tables-restore';
|
||||
my $UTILITY = $family == F_IPV4 ? 'IPTABLES_RESTORE' : 'IP6TABLES_RESTORE';
|
||||
|
||||
save_progress_message "Preparing $utility input...";
|
||||
emit( '',
|
||||
'if [ "$COMMAND" = restart -a -n "$g_counters" ] && chain_exists $g_sha1sum1 && chain_exists $g_sha1sum2 ; then',
|
||||
' option="--counters"',
|
||||
'',
|
||||
' progress_message "Reusing existing ruleset..."',
|
||||
'',
|
||||
'else'
|
||||
);
|
||||
|
||||
emit '';
|
||||
push_indent;
|
||||
|
||||
emit 'option=';
|
||||
|
||||
save_progress_message "Preparing $utility input...";
|
||||
|
||||
emit "exec 3>\${VARDIR}/.${utility}-input";
|
||||
|
||||
@@ -8163,6 +8357,14 @@ sub create_netfilter_load( $ ) {
|
||||
push @chains, $chainref;
|
||||
}
|
||||
}
|
||||
#
|
||||
# SHA1SUM chains for handling 'restart -s'
|
||||
#
|
||||
if ( $table eq 'filter' ) {
|
||||
emit_unindented ':$g_sha1sum1 - [0:0]';
|
||||
emit_unindented ':$g_sha1sum2 - [0:0]';
|
||||
}
|
||||
|
||||
#
|
||||
# Then emit the rules
|
||||
#
|
||||
@@ -8177,20 +8379,24 @@ sub create_netfilter_load( $ ) {
|
||||
}
|
||||
|
||||
enter_cmd_mode;
|
||||
|
||||
pop_indent, emit "fi\n";
|
||||
#
|
||||
# Now generate the actual ip[6]tables-restore command
|
||||
#
|
||||
emit( 'exec 3>&-',
|
||||
'',
|
||||
'[ -n "$g_debug_iptables" ] && command=debug_restore_input || command=$' . $UTILITY,
|
||||
'',
|
||||
'progress_message2 "Running $command..."',
|
||||
'',
|
||||
"cat \${VARDIR}/.${utility}-input | \$command # Use this nonsensical form to appease SELinux",
|
||||
'if [ $? != 0 ]; then',
|
||||
qq( fatal_error "iptables-restore Failed. Input is in \${VARDIR}/.${utility}-input"),
|
||||
"fi\n"
|
||||
);
|
||||
'' );
|
||||
|
||||
emit( '[ -n "$g_debug_iptables" ] && command=debug_restore_input || command="$' . $UTILITY . ' $option"' );
|
||||
|
||||
emit( '',
|
||||
'progress_message2 "Running $command..."',
|
||||
'',
|
||||
"cat \${VARDIR}/.${utility}-input | \$command # Use this nonsensical form to appease SELinux",
|
||||
'if [ $? != 0 ]; then',
|
||||
qq( fatal_error "iptables-restore Failed. Input is in \${VARDIR}/.${utility}-input"),
|
||||
"fi\n"
|
||||
);
|
||||
|
||||
pop_indent;
|
||||
|
||||
@@ -8529,7 +8735,7 @@ sub get_inline_matches( $ ) {
|
||||
# Split the passed target into the basic target and parameter
|
||||
#
|
||||
sub get_target_param( $ ) {
|
||||
my ( $target, $param ) = split '/', $_[0];
|
||||
my ( $target, $param ) = split '/', $_[0], 2;
|
||||
|
||||
unless ( defined $param ) {
|
||||
( $target, $param ) = ( $1, $2 ) if $target =~ /^(.*?)[(](.*)[)]$/;
|
||||
|
@@ -274,48 +274,60 @@ sub generate_script_2() {
|
||||
'detect_configuration()',
|
||||
'{' );
|
||||
|
||||
my $global_variables = have_global_variables;
|
||||
my $global_variables = have_global_variables;
|
||||
my $optional_interfaces = find_interfaces_by_option( 'optional' );
|
||||
|
||||
push_indent;
|
||||
|
||||
if ( have_address_variables || @$optional_interfaces ) {
|
||||
emit( 'local interface',
|
||||
'',
|
||||
'interface="$1"',
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
map_provider_to_interface if have_providers;
|
||||
|
||||
if ( $global_variables ) {
|
||||
|
||||
emit( 'case $COMMAND in' );
|
||||
|
||||
push_indent;
|
||||
|
||||
if ( $global_variables & NOT_RESTORE ) {
|
||||
emit( 'start|restart|refresh|disable|enable)' );
|
||||
} else {
|
||||
emit( 'start|restart|refresh|disable|enable|restore)' );
|
||||
}
|
||||
|
||||
push_indent;
|
||||
emit( 'case $COMMAND in' );
|
||||
|
||||
set_global_variables(1);
|
||||
|
||||
handle_optional_interfaces(0);
|
||||
|
||||
emit ';;';
|
||||
|
||||
if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) {
|
||||
pop_indent;
|
||||
push_indent;
|
||||
|
||||
emit 'restore)';
|
||||
|
||||
push_indent;
|
||||
|
||||
set_global_variables(0);
|
||||
if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) {
|
||||
|
||||
handle_optional_interfaces(0);
|
||||
set_global_variables(0, 0);
|
||||
|
||||
handle_optional_interfaces(0);
|
||||
}
|
||||
|
||||
emit ';;';
|
||||
|
||||
pop_indent;
|
||||
|
||||
emit '*)';
|
||||
|
||||
push_indent;
|
||||
}
|
||||
|
||||
pop_indent;
|
||||
pop_indent;
|
||||
set_global_variables(1,1);
|
||||
|
||||
emit ( 'esac' ) ,
|
||||
if ( $global_variables & NOT_RESTORE ) {
|
||||
handle_optional_interfaces(1);
|
||||
emit ';;';
|
||||
pop_indent;
|
||||
pop_indent;
|
||||
emit ( 'esac' );
|
||||
} else {
|
||||
handle_optional_interfaces(1);
|
||||
}
|
||||
} else {
|
||||
emit( 'true' ) unless handle_optional_interfaces(1);
|
||||
}
|
||||
@@ -347,10 +359,12 @@ sub generate_script_3($) {
|
||||
create_netfilter_load( $test );
|
||||
create_arptables_load( $test ) if $have_arptables;
|
||||
create_chainlist_reload( $_[0] );
|
||||
create_save_ipsets;
|
||||
|
||||
emit "#\n# Start/Restart the Firewall\n#";
|
||||
|
||||
emit 'define_firewall() {';
|
||||
emit( 'define_firewall() {',
|
||||
' local options' );
|
||||
|
||||
push_indent;
|
||||
|
||||
@@ -468,10 +482,12 @@ sub generate_script_3($) {
|
||||
emit( '',
|
||||
'if [ $COMMAND = restore ]; then',
|
||||
' iptables_save_file=${VARDIR}/$(basename $0)-iptables',
|
||||
' if [ -f $iptables_save_file ]; then' );
|
||||
' if [ -f $iptables_save_file ]; then',
|
||||
' [ -n "$g_counters" ] && options=--counters'
|
||||
);
|
||||
|
||||
if ( $family == F_IPV4 ) {
|
||||
emit( ' cat $iptables_save_file | $IPTABLES_RESTORE # Use this nonsensical form to appease SELinux' );
|
||||
emit( ' cat $iptables_save_file | $IPTABLES_RESTORE $options # Use this nonsensical form to appease SELinux' );
|
||||
|
||||
emit( '',
|
||||
' arptables_save_file=${VARDIR}/$(basename $0)-arptables',
|
||||
@@ -481,7 +497,7 @@ sub generate_script_3($) {
|
||||
if $config{SAVE_ARPTABLES};
|
||||
|
||||
} else {
|
||||
emit ' cat $iptables_save_file | $IP6TABLES_RESTORE # Use this nonsensical form to appease SELinux'
|
||||
emit ' cat $iptables_save_file | $IP6TABLES_RESTORE $options # Use this nonsensical form to appease SELinux'
|
||||
}
|
||||
|
||||
emit( ' else',
|
||||
@@ -510,45 +526,41 @@ EOF
|
||||
#
|
||||
# Use a parameter list rather than 'here documents' to avoid an extra blank line
|
||||
#
|
||||
emit(
|
||||
' run_refreshed_exit',
|
||||
' do_iptables -N shorewall' );
|
||||
emit( ' run_refreshed_exit',
|
||||
' do_iptables -N shorewall' );
|
||||
|
||||
emit ( ' do_iptables -A shorewall -m recent --set --name %CURRENTTIME' ) if have_capability 'RECENT_MATCH';
|
||||
|
||||
emit(
|
||||
" set_state Started $config_dir",
|
||||
' [ $0 = ${VARDIR}/firewall ] || cp -f $(my_pathname) ${VARDIR}/firewall',
|
||||
'else',
|
||||
' setup_netfilter'
|
||||
" set_state Started $config_dir",
|
||||
' [ $0 = ${VARDIR}/firewall ] || cp -f $(my_pathname) ${VARDIR}/firewall',
|
||||
'else',
|
||||
' setup_netfilter'
|
||||
);
|
||||
|
||||
push_indent;
|
||||
emit 'setup_arptables' if $have_arptables;
|
||||
setup_load_distribution;
|
||||
pop_indent;
|
||||
|
||||
emit<<'EOF';
|
||||
conditionally_flush_conntrack
|
||||
EOF
|
||||
emit( " conditionally_flush_conntrack\n" );
|
||||
|
||||
push_indent;
|
||||
initialize_switches;
|
||||
setup_forwarding( $family , 0 );
|
||||
pop_indent;
|
||||
|
||||
emit<<"EOF";
|
||||
run_start_exit
|
||||
do_iptables -N shorewall
|
||||
EOF
|
||||
emit( ' run_start_exit',
|
||||
' do_iptables -N shorewall',
|
||||
'' );
|
||||
|
||||
emit ( ' do_iptables -A shorewall -m recent --set --name %CURRENTTIME' ) if have_capability 'RECENT_MATCH';
|
||||
emit( ' do_iptables -A shorewall -m recent --set --name %CURRENTTIME' ) if have_capability 'RECENT_MATCH';
|
||||
|
||||
emit<<"EOF";
|
||||
set_state Started $config_dir
|
||||
my_pathname=\$(my_pathname)
|
||||
[ \$my_pathname = \${VARDIR}/firewall ] || cp -f \$my_pathname \${VARDIR}/firewall
|
||||
run_started_exit
|
||||
fi
|
||||
EOF
|
||||
emit( " set_state Started $config_dir",
|
||||
' my_pathname=$(my_pathname)',
|
||||
' [ $my_pathname = ${VARDIR}/firewall ] || cp -f $my_pathname ${VARDIR}/firewall',
|
||||
' run_started_exit',
|
||||
"fi\n" );
|
||||
|
||||
emit<<'EOF';
|
||||
date > ${VARDIR}/restarted
|
||||
@@ -648,10 +660,7 @@ sub compiler {
|
||||
|
||||
set_config_path( $config_path ) if $config_path;
|
||||
|
||||
if ( $directory ne '' ) {
|
||||
fatal_error "$directory is not an existing directory" unless -d $directory;
|
||||
set_shorewall_dir( $directory );
|
||||
}
|
||||
set_shorewall_dir( $directory ) if $directory ne '';
|
||||
|
||||
$verbosity = 1 if $debug && $verbosity < 1;
|
||||
|
||||
@@ -664,15 +673,6 @@ sub compiler {
|
||||
#
|
||||
get_configuration( $export , $update , $annotate , $directives , $inline );
|
||||
#
|
||||
# Create a temp file to hold the script
|
||||
#
|
||||
if ( $scriptfilename ) {
|
||||
set_command( 'compile', 'Compiling', 'Compiled' );
|
||||
create_temp_script( $scriptfilename , $export );
|
||||
} else {
|
||||
set_command( 'check', 'Checking', 'Checked' );
|
||||
}
|
||||
#
|
||||
# Chain table initialization depends on shorewall.conf and capabilities. So it must be deferred until
|
||||
# now when shorewall.conf has been processed and the capabilities have been determined.
|
||||
#
|
||||
@@ -682,6 +682,15 @@ sub compiler {
|
||||
#
|
||||
run_user_exit1 'compile';
|
||||
#
|
||||
# Create a temp file to hold the script
|
||||
#
|
||||
if ( $scriptfilename ) {
|
||||
set_command( 'compile', 'Compiling', 'Compiled' );
|
||||
create_temp_script( $scriptfilename , $export );
|
||||
} else {
|
||||
set_command( 'check', 'Checking', 'Checked' );
|
||||
}
|
||||
#
|
||||
# Z O N E D E F I N I T I O N
|
||||
# (Produces no output to the compiled script)
|
||||
#
|
||||
@@ -730,7 +739,7 @@ sub compiler {
|
||||
#
|
||||
# Do all of the zone-independent stuff (mostly /proc)
|
||||
#
|
||||
add_common_rules( $convert );
|
||||
add_common_rules( $convert, $tcrules );
|
||||
#
|
||||
# More /proc
|
||||
#
|
||||
@@ -741,6 +750,8 @@ sub compiler {
|
||||
}
|
||||
|
||||
setup_source_routing($family);
|
||||
|
||||
setup_log_backend($family);
|
||||
#
|
||||
# Proxy Arp/Ndp
|
||||
#
|
||||
@@ -819,7 +830,7 @@ sub compiler {
|
||||
#
|
||||
# Setup Nat
|
||||
#
|
||||
setup_nat if $family == F_IPV4;
|
||||
setup_nat;
|
||||
#
|
||||
# Setup NETMAP
|
||||
#
|
||||
@@ -851,7 +862,7 @@ sub compiler {
|
||||
#
|
||||
# Apply Policies
|
||||
#
|
||||
apply_policy_rules;
|
||||
complete_policy_chains;
|
||||
#
|
||||
# Reject Action
|
||||
#
|
||||
@@ -974,8 +985,7 @@ sub compiler {
|
||||
# compile_stop_firewall() also validates the routestopped file. Since we don't
|
||||
# call that function during normal 'check', we must validate routestopped here.
|
||||
#
|
||||
process_routestopped;
|
||||
process_stoppedrules;
|
||||
process_routestopped unless process_stoppedrules;
|
||||
}
|
||||
#
|
||||
# Report used/required capabilities
|
||||
|
@@ -40,6 +40,7 @@ use Cwd qw(abs_path getcwd);
|
||||
use autouse 'Carp' => qw(longmess confess);
|
||||
use Scalar::Util 'reftype';
|
||||
use FindBin;
|
||||
use Digest::SHA qw(sha1_hex);
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
#
|
||||
@@ -88,6 +89,7 @@ our @EXPORT = qw(
|
||||
our @EXPORT_OK = qw( $shorewall_dir initialize shorewall);
|
||||
|
||||
our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
|
||||
generate_sha1
|
||||
finalize_script
|
||||
enable_script
|
||||
disable_script
|
||||
@@ -230,7 +232,7 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
|
||||
|
||||
Exporter::export_ok_tags('internal');
|
||||
|
||||
our $VERSION = '4.6.0-Beta1';
|
||||
our $VERSION = 'MODULEVERSION';
|
||||
|
||||
#
|
||||
# describe the current command, it's present progressive, and it's completion.
|
||||
@@ -299,7 +301,7 @@ our %renamed = ( AUTO_COMMENT => 'AUTOCOMMENT', BLACKLIST_LOGLEVEL => 'BLACKLIST
|
||||
#
|
||||
# Config options and global settings that are to be copied to output script
|
||||
#
|
||||
our @propagateconfig = qw/ DISABLE_IPV6 MODULESDIR MODULE_SUFFIX LOAD_HELPERS_ONLY SUBSYSLOCK LOG_VERBOSITY/;
|
||||
our @propagateconfig = qw/ DISABLE_IPV6 MODULESDIR MODULE_SUFFIX LOAD_HELPERS_ONLY LOCKFILE SUBSYSLOCK LOG_VERBOSITY/;
|
||||
#
|
||||
# From parsing the capabilities file or detecting capabilities
|
||||
#
|
||||
@@ -392,6 +394,9 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
|
||||
MASQUERADE_TGT => 'MASQUERADE Target',
|
||||
UDPLITEREDIRECT => 'UDPLITE Port Redirection',
|
||||
NEW_TOS_MATCH => 'New tos Match',
|
||||
TARPIT_TARGET => 'TARPIT Target',
|
||||
IFACE_MATCH => 'Iface Match',
|
||||
TCPMSS_TARGET => 'TCPMSS Target',
|
||||
|
||||
AMANDA_HELPER => 'Amanda Helper',
|
||||
FTP_HELPER => 'FTP Helper',
|
||||
@@ -408,7 +413,7 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
|
||||
SIP0_HELPER => 'SIP-0 Helper',
|
||||
SNMP_HELPER => 'SNMP Helper',
|
||||
TFTP_HELPER => 'TFTP Helper',
|
||||
TFTP0_HELPER => 'TFTP-0 Helper',
|
||||
TFTP0_HELPER => 'TFTP-0 Helper',
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
@@ -710,7 +715,7 @@ sub initialize( $;$$) {
|
||||
EXPORT => 0,
|
||||
KLUDGEFREE => '',
|
||||
VERSION => "4.5.19-Beta1",
|
||||
CAPVERSION => 40600 ,
|
||||
CAPVERSION => 40609 ,
|
||||
);
|
||||
#
|
||||
# From shorewall.conf file
|
||||
@@ -741,6 +746,7 @@ sub initialize( $;$$) {
|
||||
RPFILTER_LOG_LEVEL => undef,
|
||||
INVALID_LOG_LEVEL => undef,
|
||||
UNTRACKED_LOG_LEVEL => undef,
|
||||
LOG_BACKEND => undef,
|
||||
#
|
||||
# Location of Files
|
||||
#
|
||||
@@ -874,9 +880,6 @@ sub initialize( $;$$) {
|
||||
#
|
||||
# Valid log levels
|
||||
#
|
||||
# Note that we don't include LOGMARK; that is so we can default its
|
||||
# priority to 'info' (LOGMARK itself defaults to 'warn').
|
||||
#
|
||||
%validlevels = ( DEBUG => 7,
|
||||
INFO => 6,
|
||||
NOTICE => 5,
|
||||
@@ -976,6 +979,9 @@ sub initialize( $;$$) {
|
||||
UDPLITEREDIRECT => undef,
|
||||
NEW_TOS_MATCH => undef,
|
||||
REAP_OPTION => undef,
|
||||
TARPIT_TARGET => undef,
|
||||
IFACE_MATCH => undef,
|
||||
TCPMSS_TARGET => undef,
|
||||
|
||||
AMANDA_HELPER => undef,
|
||||
FTP_HELPER => undef,
|
||||
@@ -1105,7 +1111,8 @@ sub initialize( $;$$) {
|
||||
$family == F_IPV4 ? 'shorewall' : 'shorewall6'
|
||||
) if defined $shorewallrc;
|
||||
|
||||
$globals{SHAREDIRPL} = "$shorewallrc{SHAREDIR}/shorewall/";
|
||||
$globals{SHAREDIRPL} = "$shorewallrc{SHAREDIR}/shorewall/";
|
||||
$globals{SAVED_IPSETS} = [];
|
||||
|
||||
if ( $family == F_IPV4 ) {
|
||||
$globals{SHAREDIR} = "$shorewallrc{SHAREDIR}/shorewall";
|
||||
@@ -1264,9 +1271,7 @@ sub cleanup_iptables() {
|
||||
qt1( "$iptables $iptablesw -t raw -X $sillyname" );
|
||||
}
|
||||
|
||||
$sillyname = $sillyname1 = undef;
|
||||
|
||||
$sillyname = '';
|
||||
$sillyname = $sillyname1 = '';
|
||||
}
|
||||
|
||||
#
|
||||
@@ -1587,7 +1592,7 @@ sub set_command( $$$ ) {
|
||||
#
|
||||
# Print the current TOD to STDOUT.
|
||||
#
|
||||
sub timestamp() {
|
||||
sub get_localtime() {
|
||||
our @localtime = localtime;
|
||||
printf '%02d:%02d:%02d ', @localtime[2,1,0];
|
||||
}
|
||||
@@ -1604,7 +1609,7 @@ sub progress_message {
|
||||
$line =~ s/\s+/ /g;
|
||||
|
||||
if ( $verbosity > 1 ) {
|
||||
timestamp, $havelocaltime = 1 if $timestamp;
|
||||
get_localtime, $havelocaltime = 1 if $timestamp;
|
||||
#
|
||||
# We use this function to display messages containing raw config file images which may contains tabs (including multiple tabs in succession).
|
||||
# The following makes such messages look more readable and uniform
|
||||
@@ -1627,7 +1632,7 @@ sub progress_message_nocompress {
|
||||
my $havelocaltime = 0;
|
||||
|
||||
if ( $verbosity > 1 ) {
|
||||
timestamp, $havelocaltime = 1 if $timestamp;
|
||||
get_localtime, $havelocaltime = 1 if $timestamp;
|
||||
print "@_\n";
|
||||
}
|
||||
|
||||
@@ -1648,7 +1653,7 @@ sub progress_message2 {
|
||||
my $havelocaltime = 0;
|
||||
|
||||
if ( $verbosity > 0 ) {
|
||||
timestamp, $havelocaltime = 1 if $timestamp;
|
||||
get_localtime, $havelocaltime = 1 if $timestamp;
|
||||
print "@_\n";
|
||||
}
|
||||
|
||||
@@ -1669,7 +1674,7 @@ sub progress_message3 {
|
||||
my $havelocaltime = 0;
|
||||
|
||||
if ( $verbosity >= 0 ) {
|
||||
timestamp, $havelocaltime = 1 if $timestamp;
|
||||
get_localtime, $havelocaltime = 1 if $timestamp;
|
||||
print "@_\n";
|
||||
}
|
||||
|
||||
@@ -1758,6 +1763,13 @@ sub create_temp_script( $$ ) {
|
||||
|
||||
}
|
||||
|
||||
# Generate the SHA1 digest of the (incomplete) script
|
||||
#
|
||||
sub generate_sha1() {
|
||||
my $data = `cat $tempfile`;
|
||||
sha1_hex $data;
|
||||
}
|
||||
|
||||
#
|
||||
# Finalize the script file
|
||||
#
|
||||
@@ -1767,6 +1779,19 @@ sub finalize_script( $ ) {
|
||||
$script = 0;
|
||||
|
||||
if ( $file ne '-' ) {
|
||||
my $sha1sum = generate_sha1;
|
||||
my $sha1sum1 = join( '-', 'sha-lh', substr( $sha1sum, 0, 20 ) );
|
||||
my $sha1sum2 = join( '-', 'sha-rh', substr( $sha1sum, -20 ) );
|
||||
|
||||
@ARGV = ( $tempfile );
|
||||
$^I = '';
|
||||
|
||||
while ( <> ) {
|
||||
s/g_sha1sum1=/g_sha1sum1=$sha1sum1/;
|
||||
s/g_sha1sum2=/g_sha1sum2=$sha1sum2/;
|
||||
print;
|
||||
}
|
||||
|
||||
rename $tempfile, $file or fatal_error "Cannot Rename $tempfile to $file: $!";
|
||||
chmod 0700, $file or fatal_error "Cannot secure $file for execute access";
|
||||
progress_message3 "Shorewall configuration compiled to $file" unless $export;
|
||||
@@ -1816,7 +1841,7 @@ sub set_config_path( $ ) {
|
||||
}
|
||||
|
||||
#
|
||||
# Set $debug
|
||||
# Set $debug and $confess
|
||||
#
|
||||
sub set_debug( $$ ) {
|
||||
$debug = shift;
|
||||
@@ -1841,6 +1866,9 @@ sub find_file($)
|
||||
"$config_path[0]$filename";
|
||||
}
|
||||
|
||||
#
|
||||
# Split a comma-separated list into a Perl array
|
||||
#
|
||||
sub split_list( $$;$ ) {
|
||||
my ($list, $type, $origlist ) = @_;
|
||||
|
||||
@@ -1849,6 +1877,9 @@ sub split_list( $$;$ ) {
|
||||
split /,/, $list;
|
||||
}
|
||||
|
||||
#
|
||||
# This version handles parenthetical list elements with embedded commas. It removes the parentheses
|
||||
#
|
||||
sub split_list1( $$;$ ) {
|
||||
my ($list, $type, $keepparens ) = @_;
|
||||
|
||||
@@ -2000,6 +2031,9 @@ sub split_list3( $$ ) {
|
||||
@list2;
|
||||
}
|
||||
|
||||
#
|
||||
# Splits the columns of a config file record
|
||||
#
|
||||
sub split_columns( $ ) {
|
||||
my ($list) = @_;
|
||||
|
||||
@@ -3259,7 +3293,11 @@ sub expand_variables( \$ ) {
|
||||
fatal_error "Variable Expansion Loop" if ++$count > 100;
|
||||
}
|
||||
|
||||
if ( $actparms{0} ) {
|
||||
if ( $chain ) {
|
||||
#
|
||||
# We're in an action body -- allow escaping at signs (@) for u32
|
||||
#
|
||||
$$lineref =~ s/\\@/??/g;
|
||||
# $1 $2 $3 - $4
|
||||
while ( $$lineref =~ m( ^(.*?) \@({)? (\d+|[a-zA-Z_]\w*) (?(2)}) (.*)$ )x ) {
|
||||
my ( $first, $var, $rest ) = ( $1, $3, $4);
|
||||
@@ -3268,6 +3306,8 @@ sub expand_variables( \$ ) {
|
||||
$$lineref = join( '', $first , $val , $rest );
|
||||
fatal_error "Variable Expansion Loop" if ++$count > 100;
|
||||
}
|
||||
|
||||
$$lineref =~ s/\?\?/@/g;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3358,7 +3398,7 @@ sub read_a_line($) {
|
||||
# Must check for shell/perl before doing variable expansion
|
||||
#
|
||||
if ( $options & EMBEDDED_ENABLED ) {
|
||||
if ( $currentline =~ s/^\s*\??(BEGIN\s+)SHELL\s*;?//i || $currentline =~ s/^\s*\??SHELL\s*//i ) {
|
||||
if ( $currentline =~ s/^\s*\??(BEGIN\s+)SHELL\s*;?//i || $currentline =~ s/^\s*\?SHELL\s*//i || $currentline =~ s/^\s*SHELL\s+// ) {
|
||||
handle_first_entry if $first_entry;
|
||||
embedded_shell( $1 );
|
||||
next;
|
||||
@@ -3496,8 +3536,9 @@ sub default ( $$ ) {
|
||||
#
|
||||
# Provide a default value for a yes/no configuration variable.
|
||||
#
|
||||
sub default_yes_no ( $$ ) {
|
||||
my ( $var, $val ) = @_;
|
||||
sub default_yes_no ( $$;$ ) {
|
||||
my ( $var, $val, $other ) = @_;
|
||||
my $result = 1;
|
||||
|
||||
my $curval = $config{$var};
|
||||
|
||||
@@ -3506,12 +3547,31 @@ sub default_yes_no ( $$ ) {
|
||||
|
||||
if ( $curval eq 'no' ) {
|
||||
$config{$var} = '';
|
||||
} elsif ( defined( $other ) ) {
|
||||
if ( $other eq '*' ) {
|
||||
if ( $curval eq 'yes' ) {
|
||||
$config{$var} = 'Yes';
|
||||
} else {
|
||||
$result = 0;
|
||||
}
|
||||
} elsif ( $curval eq $other ) {
|
||||
#
|
||||
# Downshift value for later comparison
|
||||
#
|
||||
$config{$var} = $curval;
|
||||
}
|
||||
} else {
|
||||
fatal_error "Invalid value for $var ($curval)" unless $curval eq 'yes';
|
||||
#
|
||||
# Make Case same as default
|
||||
#
|
||||
$config{$var} = 'Yes';
|
||||
}
|
||||
} else {
|
||||
$config{$var} = $val;
|
||||
}
|
||||
|
||||
$result;
|
||||
}
|
||||
|
||||
sub default_yes_no_ipv4 ( $$ ) {
|
||||
@@ -3801,7 +3861,7 @@ sub load_kernel_modules( ) {
|
||||
|
||||
close LSMOD;
|
||||
|
||||
$config{MODULE_SUFFIX} = 'o gz ko o.gz ko.gz' unless $config{MODULE_SUFFIX};
|
||||
$config{MODULE_SUFFIX} = 'o gz xz ko o.gz o.xz ko.gz ko.xz' unless $config{MODULE_SUFFIX};
|
||||
|
||||
my @suffixes = split /\s+/ , $config{MODULE_SUFFIX};
|
||||
|
||||
@@ -4118,7 +4178,7 @@ sub IPSet_Match() {
|
||||
if ( $ipset && -x $ipset ) {
|
||||
qt( "$ipset -X $sillyname" );
|
||||
|
||||
if ( qt( "$ipset -N $sillyname iphash" ) || qt( "$ipset -N $sillyname hash:ip family $fam") ) {
|
||||
if ( qt( "$ipset -N $sillyname hash:ip family $fam" ) || qt( "$ipset -N $sillyname iphash" ) ) {
|
||||
if ( qt1( "$iptables $iptablesw -A $sillyname -m set --match-set $sillyname src -j ACCEPT" ) ) {
|
||||
$capabilities{IPSET_MATCH_NOMATCH} = qt1( "$iptables $iptablesw -A $sillyname -m set --match-set $sillyname src --return-nomatch -j ACCEPT" );
|
||||
$capabilities{IPSET_MATCH_COUNTERS} = qt1( "$iptables $iptablesw -A $sillyname -m set --match-set $sillyname src --packets-lt 100 -j ACCEPT" );
|
||||
@@ -4140,7 +4200,7 @@ sub IPSet_Match_Nomatch() {
|
||||
}
|
||||
|
||||
sub IPSet_Match_Counters() {
|
||||
have_capability 'IPSET_MATCH' && $capabilities{IPSET_MATCH_COUNTGERS};
|
||||
have_capability 'IPSET_MATCH' && $capabilities{IPSET_MATCH_COUNTERS};
|
||||
}
|
||||
|
||||
sub IPSET_V5() {
|
||||
@@ -4169,6 +4229,10 @@ sub Addrtype() {
|
||||
qt1( "$iptables $iptablesw -A $sillyname -m addrtype --src-type BROADCAST -j ACCEPT" );
|
||||
}
|
||||
|
||||
sub Tarpit_Target() {
|
||||
qt1( "$iptables $iptablesw -A $sillyname -p tcp -j TARPIT" );
|
||||
}
|
||||
|
||||
sub Tcpmss_Match() {
|
||||
qt1( "$iptables $iptablesw -A $sillyname -p tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1000:1500 -j ACCEPT" );
|
||||
}
|
||||
@@ -4399,6 +4463,14 @@ sub Arptables_JF() {
|
||||
}
|
||||
}
|
||||
|
||||
sub Iface_Match() {
|
||||
qt1( "$iptables $iptablesw -A $sillyname -m iface --iface lo --loopback" );
|
||||
}
|
||||
|
||||
sub Tcpmss_Target() {
|
||||
qt1( "$iptables $iptablesw -A $sillyname -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu" );
|
||||
}
|
||||
|
||||
our %detect_capability =
|
||||
( ACCOUNT_TARGET =>\&Account_Target,
|
||||
AMANDA_HELPER => \&Amanda_Helper,
|
||||
@@ -4431,6 +4503,7 @@ our %detect_capability =
|
||||
HASHLIMIT_MATCH => \&Hashlimit_Match,
|
||||
HEADER_MATCH => \&Header_Match,
|
||||
HELPER_MATCH => \&Helper_Match,
|
||||
IFACE_MATCH => \&Iface_Match,
|
||||
IMQ_TARGET => \&Imq_Target,
|
||||
IPMARK_TARGET => \&IPMark_Target,
|
||||
IPP2P_MATCH => \&Ipp2p_Match,
|
||||
@@ -4483,7 +4556,9 @@ our %detect_capability =
|
||||
SIP0_HELPER => \&SIP0_Helper,
|
||||
SNMP_HELPER => \&SNMP_Helper,
|
||||
STATISTIC_MATCH => \&Statistic_Match,
|
||||
TARPIT_TARGET => \&Tarpit_Target,
|
||||
TCPMSS_MATCH => \&Tcpmss_Match,
|
||||
TCPMSS_TARGET => \&Tcpmss_Target,
|
||||
TFTP_HELPER => \&TFTP_Helper,
|
||||
TFTP0_HELPER => \&TFTP0_Helper,
|
||||
TIME_MATCH => \&Time_Match,
|
||||
@@ -4615,6 +4690,7 @@ sub determine_capabilities() {
|
||||
$capabilities{FWMARK_RT_MASK} = detect_capability( 'FWMARK_RT_MASK' );
|
||||
$capabilities{MARK_ANYWHERE} = detect_capability( 'MARK_ANYWHERE' );
|
||||
$capabilities{ACCOUNT_TARGET} = detect_capability( 'ACCOUNT_TARGET' );
|
||||
$capabilities{HEADER_MATCH} = detect_capability( 'HEADER_MATCH' );
|
||||
$capabilities{AUDIT_TARGET} = detect_capability( 'AUDIT_TARGET' );
|
||||
$capabilities{IPSET_V5} = detect_capability( 'IPSET_V5' );
|
||||
$capabilities{CONDITION_MATCH} = detect_capability( 'CONDITION_MATCH' );
|
||||
@@ -4630,9 +4706,13 @@ sub determine_capabilities() {
|
||||
$capabilities{RPFILTER_MATCH} = detect_capability( 'RPFILTER_MATCH' );
|
||||
$capabilities{NFACCT_MATCH} = detect_capability( 'NFACCT_MATCH' );
|
||||
$capabilities{CHECKSUM_TARGET} = detect_capability( 'CHECKSUM_TARGET' );
|
||||
$capabilities{ARPTABLESJF} = detect_capability( 'ARPTABLESJF' );
|
||||
$capabilities{MASQUERADE_TGT} = detect_capability( 'MASQUERADE_TGT' );
|
||||
$capabilities{UDPLITEREDIRECT} = detect_capability( 'UDPLITEREDIRECT' );
|
||||
$capabilities{NEW_TOS_MATCH} = detect_capability( 'NEW_TOS_MATCH' );
|
||||
$capabilities{TARPIT_TARGET} = detect_capability( 'TARPIT_TARGET' );
|
||||
$capabilities{IFACE_MATCH} = detect_capability( 'IFACE_MATCH' );
|
||||
$capabilities{TCPMSS_TARGET} = detect_capability( 'TCPMSS_TARGET' );
|
||||
|
||||
unless ( have_capability 'CT_TARGET' ) {
|
||||
$capabilities{HELPER_MATCH} = detect_capability 'HELPER_MATCH';
|
||||
@@ -4700,6 +4780,7 @@ sub ensure_config_path() {
|
||||
#
|
||||
sub set_shorewall_dir( $ ) {
|
||||
$shorewall_dir = shift;
|
||||
fatal_error "$shorewall_dir is not an existing directory" unless -d $shorewall_dir;
|
||||
ensure_config_path;
|
||||
}
|
||||
|
||||
@@ -4936,6 +5017,10 @@ sub read_capabilities() {
|
||||
warning_message "Your capabilities file does not contain a Kernel Version -- using 2.6.30";
|
||||
$capabilities{KERNELVERSION} = 20630;
|
||||
}
|
||||
#
|
||||
# Assume that this is available when using an old capabilities files
|
||||
#
|
||||
$capabilities{TCPMSS_TARGET} = 1 if ( ( $capabilities{CAPVERSION} || 0 ) < 40609 );
|
||||
|
||||
$helpers_aliases{ftp} = 'ftp-0', $capabilities{FTP_HELPER} = 1 if $capabilities{FTP0_HELPER};
|
||||
$helpers_aliases{irc} = 'irc-0', $capabilities{IRC_HELPER} = 1 if $capabilities{IRC0_HELPER};
|
||||
@@ -5026,15 +5111,23 @@ sub unsupported_yes_no_warning( $ ) {
|
||||
#
|
||||
# Process the params file
|
||||
#
|
||||
sub get_params() {
|
||||
sub get_params( $ ) {
|
||||
my $export = $_[0];
|
||||
|
||||
my $fn = find_file 'params';
|
||||
|
||||
my %reserved = ( COMMAND => 1, CONFDIR => 1, SHAREDIR => 1, VARDIR => 1 );
|
||||
|
||||
if ( -f $fn ) {
|
||||
my $shellpath = $export ? '/bin/sh' : $config{SHOREWALL_SHELL} || '/bin/sh';
|
||||
|
||||
$shellpath = which( $shellpath ) unless $shellpath =~ '/';
|
||||
|
||||
fatal_error "SHOREWALL_SHELL ($shellpath) is not found or is not executable" unless -x $shellpath;
|
||||
|
||||
progress_message2 "Processing $fn ...";
|
||||
|
||||
my $command = "$FindBin::Bin/getparams $fn " . join( ':', @config_path ) . " $family";
|
||||
my $command = "$shellpath $FindBin::Bin/getparams $fn " . join( ':', @config_path ) . " $family";
|
||||
#
|
||||
# getparams silently sources the params file under 'set -a', then executes 'export -p'
|
||||
#
|
||||
@@ -5304,7 +5397,7 @@ sub get_configuration( $$$$$ ) {
|
||||
|
||||
ensure_config_path;
|
||||
|
||||
get_params;
|
||||
get_params( $export );
|
||||
|
||||
process_shorewall_conf( $update, $annotate, $directives );
|
||||
|
||||
@@ -5522,8 +5615,9 @@ sub get_configuration( $$$$$ ) {
|
||||
default_yes_no 'DETECT_DNAT_IPADDRS' , '';
|
||||
default_yes_no 'CLEAR_TC' , $family == F_IPV4 ? 'Yes' : '';
|
||||
|
||||
if ( supplied $config{CLAMPMSS} ) {
|
||||
default_yes_no 'CLAMPMSS' , '' unless $config{CLAMPMSS} =~ /^\d+$/;
|
||||
if ( supplied( $val = $config{CLAMPMSS} ) ) {
|
||||
default_yes_no 'CLAMPMSS' , '' unless $val =~ /^\d+$/;
|
||||
require_capability 'TCPMSS_TARGET', "CLAMPMSS=$val", 's' if $config{CLAMPMSS};
|
||||
} else {
|
||||
$config{CLAMPMSS} = '';
|
||||
}
|
||||
@@ -5541,7 +5635,16 @@ sub get_configuration( $$$$$ ) {
|
||||
unsupported_yes_no 'BRIDGING';
|
||||
unsupported_yes_no_warning 'RFC1918_STRICT';
|
||||
|
||||
default_yes_no 'SAVE_IPSETS' , '';
|
||||
unless (default_yes_no 'SAVE_IPSETS', '', '*' ) {
|
||||
$val = $config{SAVE_IPSETS};
|
||||
unless ( $val eq 'ipv4' ) {
|
||||
my @sets = split_list( $val , 'ipset' );
|
||||
$globals{SAVED_IPSETS} = \@sets;
|
||||
require_capability 'IPSET_V5', 'A saved ipset list', 's';
|
||||
$config{SAVE_IPSETS} = '';
|
||||
}
|
||||
}
|
||||
|
||||
default_yes_no 'SAVE_ARPTABLES' , '';
|
||||
default_yes_no 'STARTUP_ENABLED' , 'Yes';
|
||||
default_yes_no 'DELAYBLACKLISTLOAD' , '';
|
||||
@@ -5739,6 +5842,20 @@ sub get_configuration( $$$$$ ) {
|
||||
default_log_level 'INVALID_LOG_LEVEL', '';
|
||||
default_log_level 'UNTRACKED_LOG_LEVEL', '';
|
||||
|
||||
if ( supplied( $val = $config{LOG_BACKEND} ) ) {
|
||||
if ( $family == F_IPV4 && $val eq 'ULOG' ) {
|
||||
$val = 'ipt_ULOG';
|
||||
} elsif ( $val eq 'netlink' ) {
|
||||
$val = 'nfnetlink_log';
|
||||
} elsif ( $val eq 'LOG' ) {
|
||||
$val = $family == F_IPV4 ? 'ipt_LOG' : 'ip6t_LOG';
|
||||
} else {
|
||||
fatal_error "Invalid LOG Backend ($val)";
|
||||
}
|
||||
|
||||
$config{LOG_BACKEND} = $val;
|
||||
}
|
||||
|
||||
warning_message "RFC1918_LOG_LEVEL=$config{RFC1918_LOG_LEVEL} ignored. The 'norfc1918' interface/host option is no longer supported" if $config{RFC1918_LOG_LEVEL};
|
||||
|
||||
default_log_level 'SMURF_LOG_LEVEL', '';
|
||||
|
@@ -690,11 +690,10 @@ sub process_stoppedrules() {
|
||||
my $result;
|
||||
|
||||
if ( my $fn = open_file 'stoppedrules' , 1, 1 ) {
|
||||
first_entry sub() {
|
||||
progress_message2("$doing $fn...");
|
||||
first_entry sub () {
|
||||
progress_message2( "$doing $fn..." );
|
||||
unless ( $config{ADMINISABSENTMINDED} ) {
|
||||
warning_message("Entries in the routestopped file are processed as if ADMINISABSENTMINDED=Yes");
|
||||
$config{ADMINISABSENTMINDED} = 'Yes';
|
||||
insert_ijump $filter_table ->{$_}, j => 'ACCEPT', 0, state_imatch 'ESTABLISHED,RELATED' for qw/INPUT FORWARD/;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -775,8 +774,8 @@ sub process_stoppedrules() {
|
||||
|
||||
sub setup_mss();
|
||||
|
||||
sub add_common_rules ( $ ) {
|
||||
my $upgrade = shift;
|
||||
sub add_common_rules ( $$ ) {
|
||||
my ( $upgrade_blacklist, $upgrade_tcrules ) = @_;
|
||||
my $interface;
|
||||
my $chainref;
|
||||
my $target;
|
||||
@@ -855,7 +854,7 @@ sub add_common_rules ( $ ) {
|
||||
|
||||
my $interfaceref = find_interface $interface;
|
||||
|
||||
unless ( $interfaceref->{physical} eq 'lo' ) {
|
||||
unless ( $interfaceref->{physical} eq loopback_interface ) {
|
||||
unless ( $interfaceref->{options}{ignore} & NO_SFILTER || $interfaceref->{options}{rpfilter} ) {
|
||||
|
||||
my @filters = @{$interfaceref->{filter}};
|
||||
@@ -929,8 +928,8 @@ sub add_common_rules ( $ ) {
|
||||
|
||||
run_user_exit1 'initdone';
|
||||
|
||||
if ( $upgrade ) {
|
||||
exit 0 unless convert_blacklist;
|
||||
if ( $upgrade_blacklist ) {
|
||||
exit 0 unless convert_blacklist || $upgrade_tcrules;
|
||||
} else {
|
||||
setup_blacklist;
|
||||
}
|
||||
@@ -994,7 +993,7 @@ sub add_common_rules ( $ ) {
|
||||
for my $hostref ( @$list ) {
|
||||
$interface = $hostref->[0];
|
||||
my $ipsec = $hostref->[1];
|
||||
my @policy = have_ipsec ? ( policy => "--pol $ipsec --dir in" ) : ();
|
||||
my @policy = $ipsec && have_ipsec ? ( policy => "--pol $ipsec --dir in" ) : ();
|
||||
my $target = source_exclusion( $hostref->[3], $chainref );
|
||||
|
||||
for $chain ( option_chains $interface ) {
|
||||
@@ -1118,7 +1117,8 @@ sub add_common_rules ( $ ) {
|
||||
for my $hostref ( @$list ) {
|
||||
my $interface = $hostref->[0];
|
||||
my $target = source_exclusion( $hostref->[3], $chainref );
|
||||
my @policy = have_ipsec ? ( policy => "--pol $hostref->[1] --dir in" ) : ();
|
||||
my $ipsec = $hostref->[1];
|
||||
my @policy = $ipsec && have_ipsec ? ( policy => "--pol $ipsec --dir in" ) : ();
|
||||
|
||||
for $chain ( option_chains $interface ) {
|
||||
add_ijump( $filter_table->{$chain} , j => $target, p => 'tcp', imatch_source_net( $hostref->[2] ), @policy );
|
||||
@@ -1289,7 +1289,7 @@ sub setup_mac_lists( $ ) {
|
||||
for my $hostref ( @$maclist_hosts ) {
|
||||
my $interface = $hostref->[0];
|
||||
my $ipsec = $hostref->[1];
|
||||
my @policy = have_ipsec ? ( policy => "--pol $ipsec --dir in" ) : ();
|
||||
my @policy = $ipsec && have_ipsec ? ( policy => "--pol $ipsec --dir in" ) : ();
|
||||
my @source = imatch_source_net $hostref->[2];
|
||||
|
||||
my @state = have_capability( 'RAW_TABLE' ) ? state_imatch 'NEW,UNTRACKED' : state_imatch 'NEW';
|
||||
@@ -1452,7 +1452,7 @@ sub handle_loopback_traffic() {
|
||||
my $rawout = $raw_table->{OUTPUT};
|
||||
my $rulenum = 0;
|
||||
my $loopback = loopback_zones;
|
||||
my $loref = known_interface('lo');
|
||||
my $loref = known_interface(loopback_interface);
|
||||
|
||||
my $unmanaged;
|
||||
my $outchainref;
|
||||
@@ -1463,17 +1463,29 @@ sub handle_loopback_traffic() {
|
||||
# We have a vserver zone -- route output through a separate chain
|
||||
#
|
||||
$outchainref = new_standard_chain 'loopback';
|
||||
add_ijump $filter_table->{OUTPUT}, j => $outchainref, o => 'lo';
|
||||
|
||||
if ( have_capability 'IFACE_MATCH' ) {
|
||||
add_ijump $filter_table->{OUTPUT}, j => $outchainref, iface => '--dev-out --loopback';
|
||||
} else {
|
||||
add_ijump $filter_table->{OUTPUT}, j => $outchainref, o => loopback_interface;
|
||||
}
|
||||
} else {
|
||||
#
|
||||
# Only the firewall -- just use the OUTPUT chain
|
||||
#
|
||||
if ( $unmanaged = $loref && $loref->{options}{unmanaged} ) {
|
||||
add_ijump( $filter_table->{INPUT}, j => 'ACCEPT', i => 'lo' );
|
||||
add_ijump( $filter_table->{OUTPUT}, j => 'ACCEPT', o => 'lo' );
|
||||
if ( have_capability 'IFACE_MATCH' ) {
|
||||
add_ijump( $filter_table->{OUTPUT}, j => 'ACCEPT', iface => '--dev-out --loopback' );
|
||||
} else {
|
||||
add_ijump( $filter_table->{OUTPUT}, j => 'ACCEPT', o => loopback_interface );
|
||||
}
|
||||
} else {
|
||||
$outchainref = $filter_table->{OUTPUT};
|
||||
@rule = ( o => 'lo');
|
||||
if ( have_capability 'IFACE_MATCH' ) {
|
||||
@rule = ( iface => '--dev-out --loopback' );
|
||||
} else {
|
||||
@rule = ( o => loopback_interface );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1552,7 +1564,7 @@ sub add_interface_jumps {
|
||||
our %forward_jump_added;
|
||||
my @interfaces = grep $_ ne '%vserver%', @_;
|
||||
my $dummy;
|
||||
my $lo_jump_added = interface_zone( 'lo' ) && ! get_interface_option( 'lo', 'destonly' );
|
||||
my $lo_jump_added = interface_zone( loopback_interface ) && ! get_interface_option( loopback_interface, 'destonly' );
|
||||
#
|
||||
# Add Nat jumps
|
||||
#
|
||||
@@ -1582,7 +1594,13 @@ sub add_interface_jumps {
|
||||
my $outputref = $filter_table->{output_chain $interface};
|
||||
my $interfaceref = find_interface($interface);
|
||||
|
||||
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', i => 'lo' if $interfaceref->{physical} eq '+' && ! $lo_jump_added++;
|
||||
if ( $interfaceref->{physical} eq '+' && ! $lo_jump_added++ ) {
|
||||
if ( have_capability 'IFACE_MATCH' ) {
|
||||
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', iface => '--dev-in --loopback';
|
||||
} else {
|
||||
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', i => loopback_interface;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $interfaceref->{options}{port} ) {
|
||||
my $bridge = $interfaceref->{bridge};
|
||||
@@ -1621,7 +1639,13 @@ sub add_interface_jumps {
|
||||
}
|
||||
}
|
||||
|
||||
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', i => 'lo' unless $lo_jump_added++;
|
||||
unless ( $lo_jump_added++ ) {
|
||||
if ( have_capability 'IFACE_MATCH' ) {
|
||||
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', iface => '--dev-in --loopback';
|
||||
} else {
|
||||
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', i => loopback_interface;
|
||||
}
|
||||
}
|
||||
|
||||
handle_loopback_traffic;
|
||||
}
|
||||
@@ -2394,7 +2418,7 @@ EOF
|
||||
case $COMMAND in
|
||||
stop|clear|restore)
|
||||
if chain_exists dynamic; then
|
||||
${IPTABLES}-save -t filter | grep '^-A dynamic' > ${VARDIR}/.dynamic
|
||||
${IPTABLES}-save -t filter | grep '^-A dynamic' | fgrep -v -- '-j ACCEPT' > ${VARDIR}/.dynamic
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
@@ -2409,7 +2433,7 @@ EOF
|
||||
case $COMMAND in
|
||||
stop|clear|restore)
|
||||
if chain_exists dynamic; then
|
||||
${IP6TABLES}-save -t filter | grep '^-A dynamic' > ${VARDIR}/.dynamic
|
||||
${IP6TABLES}-save -t filter | grep '^-A dynamic' | fgrep -v -- '-j ACCEPT' > ${VARDIR}/.dynamic
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
@@ -2551,8 +2575,13 @@ EOF
|
||||
|
||||
process_routestopped unless process_stoppedrules;
|
||||
|
||||
add_ijump $input, j => 'ACCEPT', i => 'lo';
|
||||
add_ijump $output, j => 'ACCEPT', o => 'lo' unless $config{ADMINISABSENTMINDED};
|
||||
if ( have_capability 'IFACE_MATCH' ) {
|
||||
add_ijump $input, j => 'ACCEPT', iface => '--dev-in --loopback';
|
||||
add_ijump $output, j => 'ACCEPT', iface => '--dev-out --loopback' unless $config{ADMINISABSENTMINDED};
|
||||
} else {
|
||||
add_ijump $input, j => 'ACCEPT', i => loopback_interface;
|
||||
add_ijump $output, j => 'ACCEPT', o => loopback_interface unless $config{ADMINISABSENTMINDED};
|
||||
}
|
||||
|
||||
my $interfaces = find_interfaces_by_option 'dhcp';
|
||||
|
||||
@@ -2606,42 +2635,11 @@ EOF
|
||||
|
||||
my @ipsets = all_ipsets;
|
||||
|
||||
if ( @ipsets || ( $config{SAVE_IPSETS} && have_ipset_rules ) ) {
|
||||
emit <<'EOF';
|
||||
|
||||
case $IPSET in
|
||||
*/*)
|
||||
if [ ! -x "$IPSET" ]; then
|
||||
error_message "ERROR: IPSET=$IPSET does not exist or is not executable - ipsets are not saved"
|
||||
IPSET=
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
IPSET="$(mywhich $IPSET)"
|
||||
[ -n "$IPSET" ] || error_message "ERROR: The ipset utility cannot be located - ipsets are not saved"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$IPSET" ]; then
|
||||
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
|
||||
#
|
||||
# Don't save an 'empty' file
|
||||
#
|
||||
grep -qE '^(-N|create )' ${VARDIR}/ipsets.tmp && mv -f ${VARDIR}/ipsets.tmp ${VARDIR}/ipsets.save
|
||||
fi
|
||||
fi
|
||||
EOF
|
||||
if ( @ipsets || @{$globals{SAVED_IPSETS}} || ( $config{SAVE_IPSETS} && have_ipset_rules ) ) {
|
||||
emit( '',
|
||||
' save_ipsets ${VARDIR}/ipsets.save' );
|
||||
}
|
||||
|
||||
|
||||
emit '
|
||||
|
||||
set_state "Stopped"
|
||||
|
@@ -633,7 +633,7 @@ sub setup_netmap() {
|
||||
}
|
||||
|
||||
#
|
||||
# Called from process_rule1 to add a rule to the NAT table
|
||||
# Called from process_rule to add a rule to the NAT table
|
||||
#
|
||||
sub handle_nat_rule( $$$$$$$$$$$$$ ) {
|
||||
my ( $dest, # <server>[:port]
|
||||
@@ -687,6 +687,11 @@ sub handle_nat_rule( $$$$$$$$$$$$$ ) {
|
||||
#
|
||||
$server = $dest;
|
||||
}
|
||||
|
||||
#
|
||||
# Check for list in $server
|
||||
#
|
||||
fatal_error "An address list ($server) is not allowed in the DEST column of a $action RULE" if $server =~ /,/;
|
||||
#
|
||||
# Generate the target
|
||||
#
|
||||
|
@@ -42,6 +42,7 @@ our @EXPORT = qw(
|
||||
setup_source_routing
|
||||
setup_accept_ra
|
||||
setup_forwarding
|
||||
setup_log_backend
|
||||
);
|
||||
our @EXPORT_OK = qw( setup_interface_proc );
|
||||
our $VERSION = 'MODULEVERSION';
|
||||
@@ -348,5 +349,43 @@ sub setup_interface_proc( $ ) {
|
||||
}
|
||||
}
|
||||
|
||||
sub setup_log_backend($) {
|
||||
if ( my $setting = $config{LOG_BACKEND} ) {
|
||||
my $family = shift;
|
||||
my $file = '/proc/sys/net/netfilter/nf_log/' . ( $family == F_IPV4 ? '2' : '10' );
|
||||
|
||||
emit( 'progress_message2 "Setting up log backend"',
|
||||
'',
|
||||
"if [ -f $file ]; then"
|
||||
);
|
||||
|
||||
if ( $setting =~ /ip6?t_log/i ) {
|
||||
my $alternative = 'nf_log_ipv' . $family;
|
||||
|
||||
emit( " setting=$setting",
|
||||
'',
|
||||
" fgrep -q $setting /proc/net/netfilter/nf_log || setting=$alternative",
|
||||
'',
|
||||
" if echo \$setting > $file; then",
|
||||
' progress_message "Log Backend set to $setting"',
|
||||
' else',
|
||||
' error_message "WARNING: Unable to set log backend to $setting"',
|
||||
' fi',
|
||||
'else',
|
||||
" error_message 'WARNING: $file does not exist - log backend not set'",
|
||||
"fi\n"
|
||||
);
|
||||
} else {
|
||||
emit( " if echo $setting > $file; then",
|
||||
" progress_message 'Log Backend set to $setting'",
|
||||
' else',
|
||||
" error_message 'WARNING: Unable to set log backend to $setting'",
|
||||
' fi',
|
||||
'else',
|
||||
" error_message 'WARNING: $file does not exist - log backend not set'",
|
||||
"fi\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
@@ -44,9 +44,10 @@ our @EXPORT = qw( process_providers
|
||||
compile_updown
|
||||
setup_load_distribution
|
||||
have_providers
|
||||
map_provider_to_interface
|
||||
);
|
||||
our @EXPORT_OK = qw( initialize provider_realm );
|
||||
our $VERSION = '4.4_24';
|
||||
our $VERSION = 'MODULEVERSION';
|
||||
|
||||
use constant { LOCAL_TABLE => 255,
|
||||
MAIN_TABLE => 254,
|
||||
@@ -258,7 +259,7 @@ sub copy_and_edit_table( $$$$$ ) {
|
||||
emit '';
|
||||
|
||||
if ( $realm ) {
|
||||
emit ( "\$IP -$family -o route show table $duplicate | sed -r 's/ realm [[:alnum:]]+//' | ${filter}while read net route; do" )
|
||||
emit ( "\$IP -$family -o route show table $duplicate | sed -r 's/ realm [[:alnum:]_]+//' | ${filter}while read net route; do" )
|
||||
} else {
|
||||
emit ( "\$IP -$family -o route show table $duplicate | ${filter}while read net route; do" )
|
||||
}
|
||||
@@ -442,10 +443,11 @@ sub process_a_provider( $ ) {
|
||||
|
||||
fatal_error 'INTERFACE must be specified' if $interface eq '-';
|
||||
|
||||
( $interface, my $address ) = split /:/, $interface;
|
||||
( $interface, my $address ) = split /:/, $interface, 2;
|
||||
|
||||
my $shared = 0;
|
||||
my $noautosrc = 0;
|
||||
my $mac = '';
|
||||
|
||||
if ( defined $address ) {
|
||||
validate_address $address, 0;
|
||||
@@ -453,10 +455,33 @@ sub process_a_provider( $ ) {
|
||||
require_capability 'REALM_MATCH', "Configuring multiple providers through one interface", "s";
|
||||
}
|
||||
|
||||
fatal_error "Unknown Interface ($interface)" unless known_interface( $interface );
|
||||
my $interfaceref = known_interface( $interface );
|
||||
|
||||
fatal_error "Unknown Interface ($interface)" unless $interfaceref;
|
||||
|
||||
fatal_error "A bridge port ($interface) may not be configured as a provider interface" if port_to_bridge $interface;
|
||||
|
||||
my $physical = get_physical $interface;
|
||||
#
|
||||
# Switch to the logical name if a physical name was passed
|
||||
#
|
||||
my $physical;
|
||||
|
||||
if ( $interface eq $interfaceref->{name} ) {
|
||||
#
|
||||
# The logical interface name was specified
|
||||
#
|
||||
$physical = $interfaceref->{physical};
|
||||
} else {
|
||||
#
|
||||
# A Physical name was specified
|
||||
#
|
||||
$physical = $interface;
|
||||
#
|
||||
# Switch to the logical name unless it is a wildcard
|
||||
#
|
||||
$interface = $interfaceref->{name} unless $interfaceref->{wildcard};
|
||||
}
|
||||
|
||||
my $gatewaycase = '';
|
||||
|
||||
if ( $physical =~ /\+$/ ) {
|
||||
@@ -469,7 +494,17 @@ sub process_a_provider( $ ) {
|
||||
$gateway = get_interface_gateway $interface;
|
||||
$gatewaycase = 'detect';
|
||||
} elsif ( $gateway && $gateway ne '-' ) {
|
||||
( $gateway, $mac ) = split_host_list( $gateway, 0 );
|
||||
validate_address $gateway, 0;
|
||||
|
||||
if ( defined $mac ) {
|
||||
$mac =~ tr/-/:/;
|
||||
$mac =~ s/^~//;
|
||||
fatal_error "Invalid MAC address ($mac)" unless $mac =~ /^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$/;
|
||||
} else {
|
||||
$mac = '';
|
||||
}
|
||||
|
||||
$gatewaycase = 'specified';
|
||||
} else {
|
||||
$gatewaycase = 'none';
|
||||
@@ -496,8 +531,9 @@ sub process_a_provider( $ ) {
|
||||
$track = 0;
|
||||
} elsif ( $option =~ /^balance=(\d+)$/ ) {
|
||||
fatal_error q('balance=<weight>' is not available in IPv6) if $family == F_IPV6;
|
||||
fatal_error 'The balance setting must be non-zero' unless $1;
|
||||
$balance = $1;
|
||||
} elsif ( $option eq 'balance' ) {
|
||||
} elsif ( $option eq 'balance' || $option eq 'primary') {
|
||||
$balance = 1;
|
||||
} elsif ( $option eq 'loose' ) {
|
||||
$loose = 1;
|
||||
@@ -532,8 +568,8 @@ sub process_a_provider( $ ) {
|
||||
$track = 0 if $config{TRACK_PROVIDERS};
|
||||
$default_balance = 0 if $config{USE_DEFAULT_RT};
|
||||
} elsif ( $option =~ /^load=(0?\.\d{1,8})/ ) {
|
||||
$load = $1;
|
||||
require_capability 'STATISTIC_MATCH', "load=$load", 's';
|
||||
$load = sprintf "%1.8f", $1;
|
||||
require_capability 'STATISTIC_MATCH', "load=$1", 's';
|
||||
} elsif ( $option eq 'autosrc' ) {
|
||||
$noautosrc = 0;
|
||||
} elsif ( $option eq 'noautosrc' ) {
|
||||
@@ -644,6 +680,7 @@ sub process_a_provider( $ ) {
|
||||
loose => $loose ,
|
||||
duplicate => $duplicate ,
|
||||
address => $address ,
|
||||
mac => $mac ,
|
||||
local => $local ,
|
||||
tproxy => $tproxy ,
|
||||
load => $load ,
|
||||
@@ -658,8 +695,6 @@ sub process_a_provider( $ ) {
|
||||
$provider_interfaces{$interface} = $table unless $shared;
|
||||
|
||||
if ( $track ) {
|
||||
fatal_error "The 'track' option requires a numeric value in the MARK column" if $mark eq '-';
|
||||
|
||||
if ( $routemarked_interfaces{$interface} ) {
|
||||
fatal_error "Interface $interface is tracked through an earlier provider" if $routemarked_interfaces{$interface} == ROUTEMARKED_UNSHARED;
|
||||
fatal_error "Multiple providers through the same interface must their IP address specified in the INTERFACES" unless $shared;
|
||||
@@ -720,6 +755,7 @@ sub add_a_provider( $$ ) {
|
||||
my $loose = $providerref->{loose};
|
||||
my $duplicate = $providerref->{duplicate};
|
||||
my $address = $providerref->{address};
|
||||
my $mac = $providerref->{mac};
|
||||
my $local = $providerref->{local};
|
||||
my $tproxy = $providerref->{tproxy};
|
||||
my $load = $providerref->{load};
|
||||
@@ -733,7 +769,7 @@ sub add_a_provider( $$ ) {
|
||||
my $realm = '';
|
||||
|
||||
if ( $shared ) {
|
||||
my $variable = $providers{$table}{mac} = get_interface_mac( $gateway, $interface , $table );
|
||||
my $variable = $providers{$table}{mac} = get_interface_mac( $gateway, $interface , $table, $mac );
|
||||
$realm = "realm $number";
|
||||
start_provider( $label , $table, $number, $id, qq(if interface_is_usable $physical && [ -n "$variable" ]; then) );
|
||||
} elsif ( $pseudo ) {
|
||||
@@ -1049,10 +1085,8 @@ CEOF
|
||||
}
|
||||
}
|
||||
|
||||
sub add_an_rtrule( ) {
|
||||
my ( $source, $dest, $provider, $priority, $originalmark ) =
|
||||
split_line( 'rtrules file',
|
||||
{ source => 0, dest => 1, provider => 2, priority => 3 , mark => 4 } );
|
||||
sub add_an_rtrule1( $$$$$ ) {
|
||||
my ( $source, $dest, $provider, $priority, $originalmark ) = @_;
|
||||
|
||||
our $current_if;
|
||||
|
||||
@@ -1141,6 +1175,17 @@ sub add_an_rtrule( ) {
|
||||
progress_message " Routing rule \"$currentline\" $done";
|
||||
}
|
||||
|
||||
sub add_an_rtrule( ) {
|
||||
my ( $sources, $dests, $provider, $priority, $originalmark ) =
|
||||
split_line( 'rtrules file',
|
||||
{ source => 0, dest => 1, provider => 2, priority => 3 , mark => 4 } );
|
||||
for my $source ( split_list( $sources, "source" ) ) {
|
||||
for my $dest (split_list( $dests , "dest" ) ) {
|
||||
add_an_rtrule1( $source, $dest, $provider, $priority, $originalmark );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub add_a_route( ) {
|
||||
my ( $provider, $dest, $gateway, $device ) =
|
||||
split_line( 'routes file',
|
||||
@@ -1260,9 +1305,11 @@ sub start_providers() {
|
||||
emit_unindented "$providers{$_}{number}\t$_" unless $providers{$_}{pseudo};
|
||||
}
|
||||
|
||||
emit_unindented "EOF\n";
|
||||
emit_unindented 'EOF';
|
||||
|
||||
emit "fi\n";
|
||||
emit( 'else',
|
||||
' error_message "WARNING: /etc/iproute2/rt_tables is missing or is not writeable"',
|
||||
"fi\n" );
|
||||
}
|
||||
|
||||
emit ( '#',
|
||||
@@ -1467,7 +1514,7 @@ EOF
|
||||
" start_provider_$provider" );
|
||||
}
|
||||
|
||||
emit ( ' else',
|
||||
emit ( ' elif [ -z "$2" ]; then',
|
||||
" startup_error \"Interface $providerref->{physical} is already enabled\"",
|
||||
' fi',
|
||||
' ;;'
|
||||
@@ -1515,7 +1562,7 @@ EOF
|
||||
}
|
||||
|
||||
emit( " stop_$providerref->{what}_$provider",
|
||||
' else',
|
||||
' elif [ -z "$2" ]; then',
|
||||
" startup_error \"Interface $providerref->{physical} is already disabled\"",
|
||||
' fi',
|
||||
' ;;'
|
||||
@@ -1540,10 +1587,44 @@ sub have_providers() {
|
||||
return our $providers;
|
||||
}
|
||||
|
||||
sub map_provider_to_interface() {
|
||||
|
||||
my $haveoptional;
|
||||
|
||||
for my $providerref ( values %providers ) {
|
||||
if ( $providerref->{optional} ) {
|
||||
unless ( $haveoptional++ ) {
|
||||
emit( 'if [ -n "$interface" ]; then',
|
||||
' case $interface in' );
|
||||
|
||||
push_indent;
|
||||
push_indent;
|
||||
}
|
||||
|
||||
emit( $providerref->{provider} . ')',
|
||||
' interface=' . $providerref->{physical},
|
||||
' ;;' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $haveoptional ) {
|
||||
pop_indent;
|
||||
pop_indent;
|
||||
emit( ' esac',
|
||||
"fi\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
sub setup_providers() {
|
||||
our $providers;
|
||||
|
||||
if ( $providers ) {
|
||||
if ( $maxload ) {
|
||||
warning_message "The sum of the provider interface loads exceeds 1.000000" if $maxload > 1;
|
||||
warning_message "The sum of the provider interface loads is less than 1.000000" if $maxload < 1;
|
||||
}
|
||||
|
||||
emit "\nif [ -z \"\$g_noroutes\" ]; then";
|
||||
|
||||
push_indent;
|
||||
@@ -1681,12 +1762,12 @@ sub compile_updown() {
|
||||
q( if [ "$COMMAND" = up ]; then) ,
|
||||
q( progress_message3 "Attempting enable on interface $1") ,
|
||||
q( COMMAND=enable) ,
|
||||
q( detect_configuration),
|
||||
q( detect_configuration $1),
|
||||
q( enable_provider $1),
|
||||
q( elif [ "$PHASE" != post-down ]; then # pre-down or not Debian) ,
|
||||
q( progress_message3 "Attempting disable on interface $1") ,
|
||||
q( COMMAND=disable) ,
|
||||
q( detect_configuration),
|
||||
q( detect_configuration $1),
|
||||
q( disable_provider $1) ,
|
||||
q( fi) ,
|
||||
q(elif [ "$COMMAND" = up ]; then) ,
|
||||
@@ -1859,8 +1940,10 @@ sub handle_optional_interfaces( $ ) {
|
||||
|
||||
if ( @$interfaces ) {
|
||||
my $require = $config{REQUIRE_INTERFACE};
|
||||
my $gencase = shift;
|
||||
|
||||
verify_required_interfaces( shift );
|
||||
verify_required_interfaces( $gencase );
|
||||
emit '' if $gencase;
|
||||
|
||||
emit( 'HAVE_INTERFACE=', '' ) if $require;
|
||||
#
|
||||
@@ -1891,6 +1974,19 @@ sub handle_optional_interfaces( $ ) {
|
||||
|
||||
emit( "$physical)" ), push_indent if $wildcards;
|
||||
|
||||
if ( $provider eq $physical ) {
|
||||
#
|
||||
# Just an optional interface, or provider and interface are the same
|
||||
#
|
||||
emit qq(if [ -z "\$interface" -o "\$interface" = "$physical" ]; then);
|
||||
} else {
|
||||
#
|
||||
# Provider
|
||||
#
|
||||
emit qq(if [ -z "\$interface" -o "\$interface" = "$physical" ]; then);
|
||||
}
|
||||
|
||||
push_indent;
|
||||
if ( $providerref->{gatewaycase} eq 'detect' ) {
|
||||
emit qq(if interface_is_usable $physical && [ -n "$providerref->{gateway}" ]; then);
|
||||
} else {
|
||||
@@ -1902,6 +1998,10 @@ sub handle_optional_interfaces( $ ) {
|
||||
emit( " SW_${base}_IS_USABLE=Yes" ,
|
||||
'fi' );
|
||||
|
||||
pop_indent;
|
||||
|
||||
emit( "fi\n" );
|
||||
|
||||
emit( ';;' ), pop_indent if $wildcards;
|
||||
}
|
||||
|
||||
@@ -2008,7 +2108,7 @@ sub handle_stickiness( $ ) {
|
||||
$rule1 = clone_irule( $_ );
|
||||
|
||||
set_rule_target( $rule1, 'MARK', "--set-mark $mark" );
|
||||
set_rule_option( $rule1, 'recent', "--name $list --update --seconds 300 --reap" );
|
||||
set_rule_option( $rule1, 'recent', "--name $list --update --seconds $rule1->{t} --reap" );
|
||||
|
||||
$rule2 = clone_irule( $_ );
|
||||
|
||||
@@ -2043,7 +2143,7 @@ sub handle_stickiness( $ ) {
|
||||
$rule1 = clone_irule $_;
|
||||
|
||||
set_rule_target( $rule1, 'MARK', "--set-mark $mark" );
|
||||
set_rule_option( $rule1, 'recent', " --name $list --rdest --update --seconds 300 --reap" );
|
||||
set_rule_option( $rule1, 'recent', " --name $list --rdest --update --seconds $rule1->{t} --reap" );
|
||||
|
||||
$rule2 = clone_irule $_;
|
||||
|
||||
|
@@ -113,7 +113,7 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
|
||||
$action = $1;
|
||||
$disposition = $1;
|
||||
}
|
||||
} elsif ( $action =~ /^IP(6)?TABLES\((.+)\)(:(.*))$/ ) {
|
||||
} elsif ( $action =~ /^IP(6)?TABLES\((.+)\)(:(.*))?$/ ) {
|
||||
if ( $family == F_IPV4 ) {
|
||||
fatal_error 'Invalid conntrack ACTION (IP6TABLES)' if $1;
|
||||
} else {
|
||||
@@ -125,8 +125,8 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
|
||||
fatal_error "Unknown target ($tgt)" unless $target_type;
|
||||
fatal_error "The $tgt TARGET is not allowed in the raw table" unless $target_type & RAW_TABLE;
|
||||
$disposition = $tgt;
|
||||
$action = 2;
|
||||
validate_level( $level = $3 ) if supplied $3;
|
||||
$action = $2;
|
||||
validate_level( $level = $4 ) if supplied $4;
|
||||
} else {
|
||||
( $disposition, my ( $option, $args ), $level ) = split ':', $action, 4;
|
||||
|
||||
@@ -146,7 +146,7 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
|
||||
if ( $option eq 'helper' ) {
|
||||
my $modifiers = '';
|
||||
|
||||
$disposition = "helper";
|
||||
$disposition = 'helper';
|
||||
|
||||
if ( $args =~ /^([-\w.]+)\((.+)\)$/ ) {
|
||||
$args = $1;
|
||||
@@ -156,8 +156,9 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
|
||||
fatal_error "Invalid helper' ($args)" if $args =~ /,/;
|
||||
validate_helper( $args, $proto );
|
||||
$action = "CT --helper $helpers_aliases{$args}";
|
||||
$exception_rule = do_proto( $proto, '-', '-' );
|
||||
|
||||
$exception_rule = do_proto( $proto, '-', '-' );
|
||||
|
||||
for my $mod ( split_list1( $modifiers, 'ctevents' ) ) {
|
||||
fatal_error "Invalid helper option ($mod)" unless $mod =~ /^(\w+)=(.+)$/;
|
||||
$mod = $1;
|
||||
@@ -176,6 +177,17 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
|
||||
fatal_error "Invalid helper option ($mod)";
|
||||
}
|
||||
}
|
||||
} elsif ( $option eq 'ctevents' ) {
|
||||
$disposition = 'helper';
|
||||
|
||||
for ( split_list( $args, 'ctevents' ) ) {
|
||||
fatal_error "Invalid 'ctevents' event ($_)" unless $valid_ctevent{$_};
|
||||
}
|
||||
|
||||
$action = "CT --ctevents $args";
|
||||
} elsif ( $option eq 'expevents' ) {
|
||||
fatal_error "Invalid expevent argument ($args)" unless $args eq 'new';
|
||||
$action = 'CT --expevents new';
|
||||
} else {
|
||||
fatal_error "Invalid CT option ($option)";
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ use strict;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(
|
||||
process_policies
|
||||
apply_policy_rules
|
||||
complete_policy_chains
|
||||
complete_standard_chain
|
||||
setup_syn_flood_chains
|
||||
save_policies
|
||||
@@ -224,6 +224,7 @@ sub initialize( $ ) {
|
||||
$family = shift;
|
||||
#
|
||||
# Chains created as a result of entries in the policy file
|
||||
#
|
||||
@policy_chains = ();
|
||||
#
|
||||
# This is updated from the *_DEFAULT settings in shorewall.conf. Those settings were stored
|
||||
@@ -348,44 +349,44 @@ sub new_policy_chain($$$$$)
|
||||
#
|
||||
sub set_policy_chain($$$$$$)
|
||||
{
|
||||
my ($source, $dest, $chain1, $chainref, $policy, $intrazone) = @_;
|
||||
my ( $chain, $source, $dest, $polchainref, $policy, $intrazone ) = @_;
|
||||
|
||||
my $chainref1 = $filter_table->{$chain1};
|
||||
my $chainref = $filter_table->{$chain};
|
||||
|
||||
if ( $chainref1 ) {
|
||||
if ( $intrazone && $source eq $dest && $chainref1->{provisional} ) {
|
||||
$chainref1->{policychain} = '';
|
||||
$chainref1->{provisional} = '';
|
||||
if ( $chainref ) {
|
||||
if ( $intrazone && $source eq $dest && $chainref->{provisional} ) {
|
||||
$chainref->{policychain} = '';
|
||||
$chainref->{provisional} = '';
|
||||
}
|
||||
} else {
|
||||
$chainref1 = new_rules_chain $chain1;
|
||||
$chainref = new_rules_chain $chain;
|
||||
}
|
||||
|
||||
unless ( $chainref1->{policychain} ) {
|
||||
unless ( $chainref->{policychain} ) {
|
||||
if ( $config{EXPAND_POLICIES} ) {
|
||||
#
|
||||
# We convert the canonical chain into a policy chain, using the settings of the
|
||||
# passed policy chain.
|
||||
#
|
||||
$chainref1->{policychain} = $chain1;
|
||||
$chainref1->{loglevel} = $chainref->{loglevel} if defined $chainref->{loglevel};
|
||||
$chainref1->{audit} = $chainref->{audit} if defined $chainref->{audit};
|
||||
$chainref->{policychain} = $chain;
|
||||
$chainref->{loglevel} = $polchainref->{loglevel} if defined $polchainref->{loglevel};
|
||||
$chainref->{audit} = $polchainref->{audit} if defined $polchainref->{audit};
|
||||
|
||||
if ( defined $chainref->{synparams} ) {
|
||||
$chainref1->{synparams} = $chainref->{synparams};
|
||||
$chainref1->{synchain} = $chainref->{synchain};
|
||||
if ( defined $polchainref->{synparams} ) {
|
||||
$chainref->{synparams} = $polchainref->{synparams};
|
||||
$chainref->{synchain} = $polchainref->{synchain};
|
||||
}
|
||||
|
||||
$chainref1->{default} = $chainref->{default} if defined $chainref->{default};
|
||||
$chainref1->{is_policy} = 1;
|
||||
push @policy_chains, $chainref1;
|
||||
$chainref->{default} = $polchainref->{default} if defined $polchainref->{default};
|
||||
$chainref->{is_policy} = 1;
|
||||
push @policy_chains, $chainref;
|
||||
} else {
|
||||
$chainref1->{policychain} = $chainref->{name};
|
||||
$chainref->{policychain} = $polchainref->{name};
|
||||
}
|
||||
|
||||
$chainref1->{policy} = $policy;
|
||||
$chainref1->{policypair} = [ $source, $dest ];
|
||||
$chainref1->{origin} = $chainref->{origin};
|
||||
$chainref->{policy} = $policy;
|
||||
$chainref->{policypair} = [ $source, $dest ];
|
||||
$chainref->{origin} = $polchainref->{origin};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,6 +469,64 @@ sub process_default_action( $$$$ ) {
|
||||
$default;
|
||||
}
|
||||
|
||||
#
|
||||
# Verify an NFQUEUE specification and return the appropriate ip[6]tables target
|
||||
#
|
||||
sub handle_nfqueue( $$ ) {
|
||||
my ($params, $allow_bypass ) = @_;
|
||||
my ( $action, $bypass );
|
||||
my ( $queue1, $queue2, $queuenum1, $queuenum2 );
|
||||
|
||||
require_capability( 'NFQUEUE_TARGET', 'NFQUEUE Rules and Policies', '' );
|
||||
|
||||
if ( supplied( $params ) ) {
|
||||
( my $queue, $bypass, my $junk ) = split ',', $params, 3;
|
||||
|
||||
fatal_error "Invalid NFQUEUE parameter list ($params)" if defined $junk;
|
||||
|
||||
if ( supplied $queue ) {
|
||||
if ( $queue eq 'bypass' ) {
|
||||
fatal_error "'bypass' is not allowed in this context" unless $allow_bypass;
|
||||
fatal_error "Invalid NFQUEUE options (bypass,$bypass)" if supplied $bypass;
|
||||
return 'NFQUEUE --queue-bypass';
|
||||
}
|
||||
|
||||
( $queue1, $queue2 ) = split ':', $queue, 2;
|
||||
|
||||
fatal_error "Invalid NFQUEUE parameter list ($params)" unless supplied $queue1;
|
||||
|
||||
$queuenum1 = numeric_value( $queue1 );
|
||||
|
||||
fatal_error "Invalid NFQUEUE queue number ($queue1)" unless defined( $queuenum1) && $queuenum1 >= 0 && $queuenum1 <= 65535;
|
||||
|
||||
if ( supplied $queue2 ) {
|
||||
$queuenum2 = numeric_value( $queue2 );
|
||||
|
||||
fatal_error "Invalid NFQUEUE queue number ($queue2)" unless defined( $queuenum2) && $queuenum2 >= 0 && $queuenum2 <= 65535 && $queuenum1 < $queuenum2;
|
||||
}
|
||||
} else {
|
||||
$queuenum1 = 0;
|
||||
}
|
||||
} else {
|
||||
$queuenum1 = 0;
|
||||
}
|
||||
|
||||
if ( supplied $bypass ) {
|
||||
fatal_error "Invalid NFQUEUE option ($bypass)" if $bypass ne 'bypass';
|
||||
fatal_error "'bypass' is not allowed in this context" unless $allow_bypass;
|
||||
|
||||
$bypass =' --queue-bypass';
|
||||
} else {
|
||||
$bypass = '';
|
||||
}
|
||||
|
||||
if ( supplied $queue2 ) {
|
||||
return "NFQUEUE --queue-balance ${queuenum1}:${queuenum2}${bypass}";
|
||||
} else {
|
||||
return "NFQUEUE --queue-num ${queuenum1}${bypass}";
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Process an entry in the policy file.
|
||||
#
|
||||
@@ -518,11 +577,9 @@ sub process_a_policy() {
|
||||
$default = process_default_action( $originalpolicy, $policy, $default, $level );
|
||||
|
||||
if ( defined $queue ) {
|
||||
fatal_error "Invalid policy ($policy($queue))" unless $policy eq 'NFQUEUE';
|
||||
require_capability( 'NFQUEUE_TARGET', 'An NFQUEUE Policy', 's' );
|
||||
my $queuenum = numeric_value( $queue );
|
||||
fatal_error "Invalid NFQUEUE queue number ($queue)" unless defined( $queuenum) && $queuenum <= 65535;
|
||||
$policy = "NFQUEUE --queue-num $queuenum";
|
||||
$policy = handle_nfqueue( $queue,
|
||||
0 # Don't allow 'bypass'
|
||||
);
|
||||
} elsif ( $policy eq 'NONE' ) {
|
||||
fatal_error "NONE policy not allowed with \"all\""
|
||||
if $clientwild || $serverwild;
|
||||
@@ -548,10 +605,10 @@ sub process_a_policy() {
|
||||
$chainref->{provisional} = 0;
|
||||
$chainref->{policy} = $policy;
|
||||
} else {
|
||||
fatal_error qq(Policy "$client $server $policy" duplicates earlier policy "@{$chainref->{policypair}} $chainref->{policy}");
|
||||
fatal_error qq(Policy "$client $server $originalpolicy" duplicates earlier policy "@{$chainref->{policypair}} $chainref->{policy}");
|
||||
}
|
||||
} elsif ( $chainref->{policy} ) {
|
||||
fatal_error qq(Policy "$client $server $policy" duplicates earlier policy "@{$chainref->{policypair}} $chainref->{policy}");
|
||||
fatal_error qq(Policy "$client $server $originalpolicy" duplicates earlier policy "@{$chainref->{policypair}} $chainref->{policy}");
|
||||
} else {
|
||||
convert_to_policy_chain( $chainref, $client, $server, $policy, 0 , $audit );
|
||||
push @policy_chains, ( $chainref ) unless $config{EXPAND_POLICIES} && ( $clientwild || $serverwild );
|
||||
@@ -582,24 +639,24 @@ sub process_a_policy() {
|
||||
if ( $serverwild ) {
|
||||
for my $zone ( @zonelist ) {
|
||||
for my $zone1 ( @zonelist ) {
|
||||
set_policy_chain $client, $server, rules_chain( ${zone}, ${zone1} ), $chainref, $policy, $intrazone;
|
||||
print_policy $zone, $zone1, $policy, $chain;
|
||||
set_policy_chain rules_chain( ${zone}, ${zone1} ), $client, $server, $chainref, $policy, $intrazone;
|
||||
print_policy $zone, $zone1, $originalpolicy, $chain;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for my $zone ( all_zones ) {
|
||||
set_policy_chain $client, $server, rules_chain( ${zone}, ${server} ), $chainref, $policy, $intrazone;
|
||||
print_policy $zone, $server, $policy, $chain;
|
||||
set_policy_chain rules_chain( ${zone}, ${server} ), $client, $server, $chainref, $policy, $intrazone;
|
||||
print_policy $zone, $server, $originalpolicy, $chain;
|
||||
}
|
||||
}
|
||||
} elsif ( $serverwild ) {
|
||||
for my $zone ( @zonelist ) {
|
||||
set_policy_chain $client, $server, rules_chain( ${client}, ${zone} ), $chainref, $policy, $intrazone;
|
||||
print_policy $client, $zone, $policy, $chain;
|
||||
set_policy_chain rules_chain( ${client}, ${zone} ), $client, $server, $chainref, $policy, $intrazone;
|
||||
print_policy $client, $zone, $originalpolicy, $chain;
|
||||
}
|
||||
|
||||
} else {
|
||||
print_policy $client, $server, $policy, $chain;
|
||||
print_policy $client, $server, $originalpolicy, $chain;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,8 +727,8 @@ sub process_policies()
|
||||
unless ( $zone eq $zone1 ) {
|
||||
my $name = rules_chain( $zone, $zone1 );
|
||||
my $name1 = rules_chain( $zone1, $zone );
|
||||
set_policy_chain( $zone, $zone1, $name, ensure_rules_chain( $name ), 'NONE', 0 );
|
||||
set_policy_chain( $zone1, $zone, $name1, ensure_rules_chain( $name1 ), 'NONE', 0 );
|
||||
set_policy_chain( $name, $zone, $zone1, ensure_rules_chain( $name ), 'NONE', 0 );
|
||||
set_policy_chain( $name1, $zone1, $zone, ensure_rules_chain( $name1 ), 'NONE', 0 );
|
||||
}
|
||||
}
|
||||
} elsif ( $type == LOOPBACK ) {
|
||||
@@ -679,8 +736,8 @@ sub process_policies()
|
||||
unless ( $zone eq $zone1 || zone_type( $zone1 ) == LOOPBACK ) {
|
||||
my $name = rules_chain( $zone, $zone1 );
|
||||
my $name1 = rules_chain( $zone1, $zone );
|
||||
set_policy_chain( $zone, $zone1, $name, ensure_rules_chain( $name ), 'NONE', 0 );
|
||||
set_policy_chain( $zone1, $zone, $name1, ensure_rules_chain( $name1 ), 'NONE', 0 );
|
||||
set_policy_chain( $name, $zone, $zone1, ensure_rules_chain( $name ), 'NONE', 0 );
|
||||
set_policy_chain( $name1, $zone1, $zone, ensure_rules_chain( $name1 ), 'NONE', 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -712,9 +769,9 @@ sub process_policies()
|
||||
#
|
||||
# Policy Rule application
|
||||
#
|
||||
sub process_inline ($$$$$$$$$$$$$$$$$$$$$);
|
||||
sub process_inline ($$$$$$$$$$$$$$$$$$$$$$);
|
||||
|
||||
sub policy_rules( $$$$$ ) {
|
||||
sub add_policy_rules( $$$$$ ) {
|
||||
my ( $chainref , $target, $loglevel, $default, $dropmulticast ) = @_;
|
||||
|
||||
unless ( $target eq 'NONE' ) {
|
||||
@@ -737,6 +794,7 @@ sub policy_rules( $$$$$ ) {
|
||||
process_inline( $action, #Inline
|
||||
$chainref, #Chain
|
||||
'', #Matches
|
||||
'', #Matches1
|
||||
$loglevel, #Log Level and Tag
|
||||
$default, #Target
|
||||
$param || '', #Param
|
||||
@@ -774,7 +832,7 @@ sub report_syn_flood_protection() {
|
||||
#
|
||||
# Complete a policy chain - Add policy-enforcing rules and syn flood, if specified
|
||||
#
|
||||
sub default_policy( $$$ ) {
|
||||
sub complete_policy_chain( $$$ ) { #Chainref, Source Zone, Destination Zone
|
||||
my $chainref = $_[0];
|
||||
my $policyref = $filter_table->{$chainref->{policychain}};
|
||||
my $synparams = $policyref->{synparams};
|
||||
@@ -785,20 +843,20 @@ sub default_policy( $$$ ) {
|
||||
assert( $policyref );
|
||||
|
||||
if ( $chainref eq $policyref ) {
|
||||
policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
|
||||
add_policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
|
||||
} else {
|
||||
if ( $policy eq 'ACCEPT' || $policy eq 'QUEUE' || $policy =~ /^NFQUEUE/ ) {
|
||||
if ( $synparams ) {
|
||||
report_syn_flood_protection;
|
||||
policy_rules $chainref , $policy , $loglevel , $default, $config{MULTICAST};
|
||||
add_policy_rules $chainref , $policy , $loglevel , $default, $config{MULTICAST};
|
||||
} else {
|
||||
add_ijump $chainref, g => $policyref;
|
||||
$chainref = $policyref;
|
||||
policy_rules( $chainref, $policy, $loglevel, $default, $config{MULTICAST} ) if $default =~/^macro\./;
|
||||
add_policy_rules( $chainref, $policy, $loglevel, $default, $config{MULTICAST} ) if $default =~/^macro\./;
|
||||
}
|
||||
} elsif ( $policy eq 'CONTINUE' ) {
|
||||
report_syn_flood_protection if $synparams;
|
||||
policy_rules $chainref , $policy , $loglevel , $default, $config{MULTICAST};
|
||||
add_policy_rules $chainref , $policy , $loglevel , $default, $config{MULTICAST};
|
||||
} else {
|
||||
report_syn_flood_protection if $synparams;
|
||||
add_ijump $chainref , g => $policyref;
|
||||
@@ -814,13 +872,11 @@ sub ensure_rules_chain( $ );
|
||||
#
|
||||
# Finish all policy Chains
|
||||
#
|
||||
sub apply_policy_rules() {
|
||||
sub complete_policy_chains() {
|
||||
progress_message2 'Applying Policies...';
|
||||
|
||||
for my $chainref ( @policy_chains ) {
|
||||
my $policy = $chainref->{policy};
|
||||
|
||||
unless ( $policy eq 'NONE' ) {
|
||||
unless ( ( my $policy = $chainref->{policy} ) eq 'NONE' ) {
|
||||
my $loglevel = $chainref->{loglevel};
|
||||
my $provisional = $chainref->{provisional};
|
||||
my $default = $chainref->{default};
|
||||
@@ -847,7 +903,7 @@ sub apply_policy_rules() {
|
||||
|
||||
if ( $name =~ /^all[-2]|[-2]all$/ ) {
|
||||
run_user_exit $chainref;
|
||||
policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
|
||||
add_policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -858,7 +914,7 @@ sub apply_policy_rules() {
|
||||
|
||||
if ( $chainref->{referenced} ) {
|
||||
run_user_exit $chainref;
|
||||
default_policy $chainref, $zone, $zone1;
|
||||
complete_policy_chain $chainref, $zone, $zone1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -892,7 +948,7 @@ sub complete_standard_chain ( $$$$ ) {
|
||||
}
|
||||
|
||||
|
||||
policy_rules $stdchainref , $policy , $loglevel, $defaultaction, 0;
|
||||
add_policy_rules $stdchainref , $policy , $loglevel, $defaultaction, 0;
|
||||
}
|
||||
|
||||
#
|
||||
@@ -1142,7 +1198,7 @@ sub normalize_action_name( $ ) {
|
||||
#
|
||||
# Produce a recognizable target from a normalized action
|
||||
#
|
||||
sub externalize( $ ) {
|
||||
sub external_name( $ ) {
|
||||
my ( $target, $level, $tag, $params ) = split /:/, shift, 4;
|
||||
|
||||
$target = join( '', $target, '(', $params , ')' ) if $params;
|
||||
@@ -1624,7 +1680,7 @@ my %builtinops = ( 'dropBcast' => \&dropBcast,
|
||||
'Limit' => \&Limit,
|
||||
);
|
||||
|
||||
sub process_rule ( $$$$$$$$$$$$$$$$$$$ );
|
||||
sub process_rule ( $$$$$$$$$$$$$$$$$$$$ );
|
||||
|
||||
#
|
||||
# Populate an action invocation chain. As new action tuples are encountered,
|
||||
@@ -1673,9 +1729,11 @@ sub process_action($$) {
|
||||
$origdest = $connlimit = $time = $headers = $condition = $helper = '-';
|
||||
} else {
|
||||
($target, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper )
|
||||
= split_line1( 'action file',
|
||||
= split_line2( 'action file',
|
||||
\%rulecolumns,
|
||||
$action_commands );
|
||||
$action_commands,
|
||||
undef,
|
||||
1 );
|
||||
}
|
||||
|
||||
fatal_error 'TARGET must be specified' if $target eq '-';
|
||||
@@ -1686,6 +1744,7 @@ sub process_action($$) {
|
||||
}
|
||||
|
||||
process_rule( $chainref,
|
||||
'',
|
||||
'',
|
||||
$nolog ? $target : merge_levels( join(':', @actparms{'chain','loglevel','logtag'}), $target ),
|
||||
'',
|
||||
@@ -1748,14 +1807,31 @@ sub process_actions() {
|
||||
undef, #Columns
|
||||
1 ); #Allow inline matches
|
||||
|
||||
my $type = ( $action eq $config{REJECT_ACTION} ? INLINE : ACTION );
|
||||
my $noinline = 0;
|
||||
my $nolog = ( $type == INLINE ) || 0;
|
||||
my $builtin = 0;
|
||||
my $raw = 0;
|
||||
my $mangle = 0;
|
||||
my $filter = 0;
|
||||
my $nat = 0;
|
||||
my $type = ( $action eq $config{REJECT_ACTION} ? INLINE : ACTION );
|
||||
|
||||
use constant { INLINE_OPT => 1 ,
|
||||
NOINLINE_OPT => 2 ,
|
||||
NOLOG_OPT => 4 ,
|
||||
BUILTIN_OPT => 8 ,
|
||||
RAW_OPT => 16 ,
|
||||
MANGLE_OPT => 32 ,
|
||||
FILTER_OPT => 64 ,
|
||||
NAT_OPT => 128 ,
|
||||
TERMINATING_OPT => 256 ,
|
||||
};
|
||||
|
||||
my %options = ( inline => INLINE_OPT ,
|
||||
noinline => NOINLINE_OPT ,
|
||||
nolog => NOLOG_OPT ,
|
||||
builtin => BUILTIN_OPT ,
|
||||
raw => RAW_OPT ,
|
||||
mangle => MANGLE_OPT ,
|
||||
filter => FILTER_OPT ,
|
||||
nat => NAT_OPT ,
|
||||
terminating => TERMINATING_OPT ,
|
||||
);
|
||||
|
||||
my $opts = $type == INLINE ? NOLOG_OPT : 0;
|
||||
|
||||
if ( $action =~ /:/ ) {
|
||||
warning_message 'Default Actions are now specified in /etc/shorewall/shorewall.conf';
|
||||
@@ -1766,29 +1842,14 @@ sub process_actions() {
|
||||
|
||||
if ( $options ne '-' ) {
|
||||
for ( split_list( $options, 'option' ) ) {
|
||||
if ( $_ eq 'inline' ) {
|
||||
$type = INLINE;
|
||||
} elsif ( $_ eq 'noinline' ) {
|
||||
$noinline = 1;
|
||||
} elsif ( $_ eq 'nolog' ) {
|
||||
$nolog = 1;
|
||||
} elsif ( $_ eq 'builtin' ) {
|
||||
$builtin = 1;
|
||||
} elsif ( $_ eq 'mangle' ) {
|
||||
$mangle = 1;
|
||||
} elsif ( $_ eq 'raw' ) {
|
||||
$raw = 1;
|
||||
} elsif ( $_ eq 'filter' ) {
|
||||
$filter = 1;
|
||||
} elsif ( $_ eq 'nat' ) {
|
||||
$nat = 1;
|
||||
} else {
|
||||
fatal_error "Invalid option ($_)";
|
||||
}
|
||||
fatal_error "Invalid option ($_)" unless $options{$_};
|
||||
$opts |= $options{$_};
|
||||
}
|
||||
|
||||
$type = INLINE if $opts & INLINE_OPT;
|
||||
}
|
||||
|
||||
fatal_error "Conflicting OPTIONS ($options)" if $noinline && $type == INLINE;
|
||||
fatal_error "Conflicting OPTIONS ($options)" if ( $opts & NOINLINE_OPT && $type == INLINE ) || ( $opts & INLINE_OPT && $opts & BUILTIN_OPT );
|
||||
|
||||
if ( my $actiontype = $targets{$action} ) {
|
||||
if ( ( $actiontype & ACTION ) && ( $type == INLINE ) ) {
|
||||
@@ -1805,15 +1866,15 @@ sub process_actions() {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $builtin ) {
|
||||
if ( $opts & BUILTIN_OPT ) {
|
||||
my $actiontype = USERBUILTIN | OPTIONS;
|
||||
$actiontype |= MANGLE_TABLE if $mangle;
|
||||
$actiontype |= RAW_TABLE if $raw;
|
||||
$actiontype |= NAT_TABLE if $nat;
|
||||
$actiontype |= MANGLE_TABLE if $opts & MANGLE_OPT;
|
||||
$actiontype |= RAW_TABLE if $opts & RAW_OPT;
|
||||
$actiontype |= NAT_TABLE if $opts & NAT_OPT;
|
||||
#
|
||||
# For backward compatibility, we assume that user-defined builtins are valid in the filter table
|
||||
#
|
||||
$actiontype |= FILTER_TABLE if $filter || ! ($mangle || $raw || $nat);
|
||||
$actiontype |= FILTER_TABLE if $opts & FILTER_OPT || ! ( $opts & ( MANGLE_OPT | RAW_OPT | NAT_OPT ) );
|
||||
|
||||
if ( $builtin_target{$action} ) {
|
||||
$builtin_target{$action} |= $actiontype;
|
||||
@@ -1822,15 +1883,18 @@ sub process_actions() {
|
||||
}
|
||||
|
||||
$targets{$action} = $actiontype;
|
||||
|
||||
make_terminating( $action ) if $opts & TERMINATING_OPT
|
||||
} else {
|
||||
fatal_error "Table names are only allowed for builtin actions" if $mangle || $raw || $nat || $filter;
|
||||
new_action $action, $type, $noinline, $nolog;
|
||||
fatal_error "Table names are only allowed for builtin actions" if $opts & ( MANGLE_OPT | RAW_OPT | NAT_OPT | FILTER_OPT );
|
||||
|
||||
new_action $action, $type, ( $opts & NOINLINE_OPT ) != 0 , ( $opts & NOLOG_OPT ) != 0;
|
||||
|
||||
my $actionfile = find_file( "action.$action" );
|
||||
|
||||
fatal_error "Missing Action File ($actionfile)" unless -f $actionfile;
|
||||
|
||||
$inlines{$action} = { file => $actionfile, nolog => $nolog } if $type == INLINE;
|
||||
$inlines{$action} = { file => $actionfile, nolog => $opts & NOLOG_OPT } if $type == INLINE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1869,6 +1933,7 @@ sub process_reject_action() {
|
||||
process_inline( $action, #Inline
|
||||
$rejectref, #Chain
|
||||
'', #Matches
|
||||
'', #Matches1
|
||||
'', #Log Level and Tag
|
||||
$action, #Target
|
||||
'', #Param
|
||||
@@ -1897,8 +1962,8 @@ sub process_reject_action() {
|
||||
#
|
||||
# Expand a macro rule from the rules file
|
||||
#
|
||||
sub process_macro ($$$$$$$$$$$$$$$$$$$$) {
|
||||
my ($macro, $chainref, $matches, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_;
|
||||
sub process_macro ($$$$$$$$$$$$$$$$$$$$$) {
|
||||
my ($macro, $chainref, $matches, $matches1, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_;
|
||||
|
||||
my $generated = 0;
|
||||
|
||||
@@ -1997,7 +2062,8 @@ sub process_macro ($$$$$$$$$$$$$$$$$$$$) {
|
||||
|
||||
$generated |= process_rule(
|
||||
$chainref,
|
||||
$matches,
|
||||
$matches,
|
||||
$matches1,
|
||||
$mtarget,
|
||||
$param,
|
||||
$msource,
|
||||
@@ -2030,8 +2096,8 @@ sub process_macro ($$$$$$$$$$$$$$$$$$$$) {
|
||||
#
|
||||
# Expand an inline action rule from the rules file
|
||||
#
|
||||
sub process_inline ($$$$$$$$$$$$$$$$$$$$$) {
|
||||
my ($inline, $chainref, $matches, $loglevel, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_;
|
||||
sub process_inline ($$$$$$$$$$$$$$$$$$$$$$) {
|
||||
my ($inline, $chainref, $matches, $matches1, $loglevel, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_;
|
||||
|
||||
my $generated = 0;
|
||||
|
||||
@@ -2121,7 +2187,8 @@ sub process_inline ($$$$$$$$$$$$$$$$$$$$$) {
|
||||
|
||||
$generated |= process_rule(
|
||||
$chainref,
|
||||
$matches,
|
||||
$matches,
|
||||
$matches1,
|
||||
$mtarget,
|
||||
$param,
|
||||
$msource,
|
||||
@@ -2174,9 +2241,10 @@ sub verify_audit($;$$) {
|
||||
# reference is also passed when rules are being generated during processing of a macro used as a default action.
|
||||
#
|
||||
|
||||
sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
|
||||
my ( $chainref, #reference to Action Chain if we are being called from process_action(); undef otherwise
|
||||
$rule, #Matches
|
||||
$matches1, #Matches after the ones generated by the columns
|
||||
$target,
|
||||
$current_param,
|
||||
$source,
|
||||
@@ -2206,6 +2274,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
my $blacklist = ( $section == BLACKLIST_SECTION );
|
||||
my $matches = $rule;
|
||||
my $raw_matches = '';
|
||||
my $exceptionrule = '';
|
||||
|
||||
if ( $inchain = defined $chainref ) {
|
||||
( $inaction, undef, undef, undef ) = split /:/, $normalized_action = $chainref->{action}, 4 if $chainref->{action};
|
||||
@@ -2240,6 +2309,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
my $generated = process_macro( $basictarget,
|
||||
$chainref,
|
||||
$rule . $raw_matches,
|
||||
$matches1,
|
||||
$target,
|
||||
$current_param,
|
||||
$source,
|
||||
@@ -2263,10 +2333,9 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
return $generated;
|
||||
|
||||
} elsif ( $actiontype & NFQ ) {
|
||||
require_capability( 'NFQUEUE_TARGET', 'NFQUEUE Rules', '' );
|
||||
my $paramval = $param eq '' ? 0 : numeric_value( $param );
|
||||
fatal_error "Invalid value ($param) for NFQUEUE queue number" unless defined($paramval) && $paramval <= 65535;
|
||||
$action = "NFQUEUE --queue-num $paramval";
|
||||
$action = handle_nfqueue( $param,
|
||||
1 # Allow 'bypass'
|
||||
);
|
||||
} elsif ( $actiontype & SET ) {
|
||||
require_capability( 'IPSET_MATCH', 'SET and UNSET rules', '' );
|
||||
fatal_error "$action rules require a set name parameter" unless $param;
|
||||
@@ -2279,7 +2348,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
validate_level( $action );
|
||||
$loglevel = supplied $loglevel ? join( ':', $action, $loglevel ) : $action;
|
||||
$action = 'LOG';
|
||||
} elsif ( ! ( $actiontype & (ACTION | INLINE | IPTABLES ) ) ) {
|
||||
} elsif ( ! ( $actiontype & (ACTION | INLINE | IPTABLES | TARPIT ) ) ) {
|
||||
fatal_error "'builtin' actions may only be used in INLINE rules" if $actiontype == USERBUILTIN;
|
||||
fatal_error "The $basictarget TARGET does not accept a parameter" unless $param eq '';
|
||||
}
|
||||
@@ -2289,7 +2358,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
#
|
||||
fatal_error "The +, - and ! modifiers are not allowed in the blrules file" if $action =~ s/[-+!]$// && $blacklist;
|
||||
|
||||
unless ( $actiontype & ( ACTION | INLINE | IPTABLES ) ) {
|
||||
unless ( $actiontype & ( ACTION | INLINE | IPTABLES | TARPIT ) ) {
|
||||
#
|
||||
# Catch empty parameter list
|
||||
#
|
||||
@@ -2374,7 +2443,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
my ( $tgt, $options ) = split / /, $param;
|
||||
my $target_type = $builtin_target{$tgt};
|
||||
fatal_error "Unknown target ($tgt)" unless $target_type;
|
||||
fatal_error "The $tgt TARGET is now allowed in the filter table" unless $target_type & FILTER_TABLE;
|
||||
fatal_error "The $tgt TARGET is not allowed in the filter table" unless $target_type & FILTER_TABLE;
|
||||
$action = $param;
|
||||
} else {
|
||||
$action = '';
|
||||
@@ -2387,12 +2456,28 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
my ( $tgt, $options ) = split / /, $param;
|
||||
my $target_type = $builtin_target{$tgt};
|
||||
fatal_error "Unknown target ($tgt)" unless $target_type;
|
||||
fatal_error "The $tgt TARGET is now allowed in the filter table" unless $target_type & FILTER_TABLE;
|
||||
fatal_error "The $tgt TARGET is not allowed in the filter table" unless $target_type & FILTER_TABLE;
|
||||
$action = $param;
|
||||
} else {
|
||||
$action = '';
|
||||
}
|
||||
},
|
||||
|
||||
TARPIT => sub {
|
||||
require_capability 'TARPIT_TARGET', 'TARPIT', 's';
|
||||
|
||||
fatal_error "TARPIT is only valid with PROTO tcp (6)" if ( resolve_proto( $proto ) || 0 ) != TCP;
|
||||
|
||||
if ( supplied $param ) {
|
||||
fatal_error "TARPIT Parameter must be 'tarpit', 'honeypot' or 'reset'" unless $param =~ /^(tarpit|honeypot|reset)$/;
|
||||
$action = "TARPIT --$param";
|
||||
$log_action = 'TARPIT';
|
||||
} else {
|
||||
$action = $log_action = 'TARPIT';
|
||||
}
|
||||
|
||||
$exceptionrule = '-p 6 ';
|
||||
},
|
||||
);
|
||||
|
||||
my $function = $functions{ $bt };
|
||||
@@ -2461,11 +2546,9 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
$destzone = '';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unless ( $inchain ) {
|
||||
fatal_error "Missing destination zone" if $destzone eq '-' || $destzone eq '';
|
||||
fatal_error "Unknown destination zone ($destzone)" unless $destref = defined_zone( $destzone );
|
||||
}
|
||||
} elsif ( ! $inchain ) {
|
||||
fatal_error "Missing destination zone" if $destzone eq '-' || $destzone eq '';
|
||||
fatal_error "Unknown destination zone ($destzone)" unless $destref = defined_zone( $destzone );
|
||||
}
|
||||
|
||||
my $restriction = NO_RESTRICT;
|
||||
@@ -2585,7 +2668,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
#
|
||||
$normalized_target = normalize_action( $basictarget, $loglevel, $param );
|
||||
|
||||
fatal_error( "Action $basictarget invoked Recursively (" . join( '->', map( externalize( $_ ), @actionstack , $normalized_target ) ) . ')' ) if $active{$basictarget};
|
||||
fatal_error( "Action $basictarget invoked Recursively (" . join( '->', map( external_name( $_ ), @actionstack , $normalized_target ) ) . ')' ) if $active{$basictarget};
|
||||
|
||||
if ( my $ref = use_action( $normalized_target ) ) {
|
||||
#
|
||||
@@ -2629,6 +2712,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
my $generated = process_inline( $basictarget,
|
||||
$chainref,
|
||||
$rule . $raw_matches,
|
||||
$matches1,
|
||||
$loglevel,
|
||||
$target,
|
||||
$current_param,
|
||||
@@ -2683,7 +2767,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
do_headers( $headers ) ,
|
||||
do_condition( $condition , $chain ) ,
|
||||
do_helper( $helper ) ,
|
||||
$raw_matches ,
|
||||
$matches1 . $raw_matches ,
|
||||
);
|
||||
} else {
|
||||
$rule .= join( '',
|
||||
@@ -2695,7 +2779,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
do_time( $time ) ,
|
||||
do_headers( $headers ) ,
|
||||
do_condition( $condition , $chain ) ,
|
||||
$raw_matches ,
|
||||
$matches1 . $raw_matches ,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2828,7 +2912,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
|
||||
$action ,
|
||||
$loglevel ,
|
||||
$log_action ,
|
||||
'' )
|
||||
$exceptionrule )
|
||||
unless unreachable_warning( $wildcard || $section == DEFAULTACTION_SECTION, $chainref );
|
||||
}
|
||||
|
||||
@@ -2940,8 +3024,8 @@ sub merge_target( $$ ) {
|
||||
#
|
||||
# May be called by Perl code in action bodies (regular and inline) to generate a rule.
|
||||
#
|
||||
sub perl_action_helper($$;$) {
|
||||
my ( $target, $matches, $isstatematch ) = @_;
|
||||
sub perl_action_helper($$;$$) {
|
||||
my ( $target, $matches, $isstatematch , $matches1 ) = @_;
|
||||
my $action = $actparms{action};
|
||||
my $chainref = $actparms{0};
|
||||
my $result;
|
||||
@@ -2950,7 +3034,13 @@ sub perl_action_helper($$;$) {
|
||||
|
||||
$matches .= ' ' unless $matches =~ /^(?:.+\s)?$/;
|
||||
|
||||
set_inline_matches $matches if $target =~ /^INLINE(?::.*)?$/;
|
||||
if ( $matches1 ) {
|
||||
$matches1 .= ' ' unless $matches1 =~ /^(?:.+\s)?$/;
|
||||
} else {
|
||||
$matches1 = '';
|
||||
}
|
||||
|
||||
set_inline_matches( $target =~ /^INLINE(?::.*)?$/ ? $matches : '' );
|
||||
|
||||
if ( $isstatematch ) {
|
||||
if ( $statematch ) {
|
||||
@@ -2973,6 +3063,7 @@ sub perl_action_helper($$;$) {
|
||||
if ( my $ref = $inlines{$action} ) {
|
||||
$result = &process_rule( $chainref,
|
||||
$matches,
|
||||
$matches1,
|
||||
merge_target( $ref, $target ),
|
||||
'', # CurrentParam
|
||||
@columns );
|
||||
@@ -2981,6 +3072,7 @@ sub perl_action_helper($$;$) {
|
||||
|
||||
$result = process_rule( $chainref,
|
||||
$matches,
|
||||
$matches1,
|
||||
merge_target( $actions{$action}, $target ),
|
||||
'', # Current Param
|
||||
'-', # Source
|
||||
@@ -3023,6 +3115,8 @@ sub perl_action_tcp_helper($$) {
|
||||
|
||||
$proto .= ' ' unless $proto =~ /^(?:.+\s)?$/;
|
||||
|
||||
set_inline_matches( '' ) if $config{INLINE_MATCHES};
|
||||
|
||||
if ( $passedproto eq '-' || $passedproto eq 'tcp' || $passedproto eq '6' ) {
|
||||
#
|
||||
# For other protos, a 'no rule generated' warning will be issued
|
||||
@@ -3030,6 +3124,7 @@ sub perl_action_tcp_helper($$) {
|
||||
if ( my $ref = $inlines{$action} ) {
|
||||
$result = &process_rule( $chainref,
|
||||
$proto,
|
||||
'',
|
||||
merge_target( $ref, $target ),
|
||||
'',
|
||||
@columns[0,1],
|
||||
@@ -3039,6 +3134,7 @@ sub perl_action_tcp_helper($$) {
|
||||
} else {
|
||||
$result = process_rule( $chainref,
|
||||
$proto,
|
||||
'',
|
||||
merge_target( $actions{$action}, $target ),
|
||||
'', # Current Param
|
||||
'-', # Source
|
||||
@@ -3232,6 +3328,7 @@ sub process_raw_rule ( ) {
|
||||
for my $proto ( @protos ) {
|
||||
for my $user ( @users ) {
|
||||
if ( process_rule( undef,
|
||||
'',
|
||||
'',
|
||||
$target,
|
||||
'',
|
||||
|
@@ -174,8 +174,8 @@ sub initialize( $ ) {
|
||||
#
|
||||
# Process a rule from the tcrules or mangle file
|
||||
#
|
||||
sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
|
||||
our ( $file, $action, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state ) = @_;
|
||||
sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
|
||||
our ( $file, $action, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time ) = @_;
|
||||
|
||||
use constant {
|
||||
PREROUTING => 1, #Actually tcpre
|
||||
@@ -225,11 +225,12 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
|
||||
my $device = '';
|
||||
our $cmd;
|
||||
our $designator;
|
||||
our $ttl = 0;
|
||||
my $fw = firewall_zone;
|
||||
|
||||
sub handle_mark_param( $$ ) {
|
||||
my ( $option, $marktype ) = @_;
|
||||
my $and_or = $1 if $params =~ s/^([|&])//;
|
||||
my $and_or = $params =~ s/^([|&])// ? $1 : '';
|
||||
|
||||
if ( $params =~ /-/ ) {
|
||||
#
|
||||
@@ -260,6 +261,8 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
|
||||
$chain ||= $designator;
|
||||
$chain ||= $default_chain;
|
||||
|
||||
$option ||= ( $and_or eq '|' ? '--or-mark' : $and_or ? '--and-mark' : '--set-mark' );
|
||||
|
||||
my $chainref = ensure_chain( 'mangle', $chain = $chainnames{$chain} );
|
||||
|
||||
for ( my $packet = 0; $packet < $marks; $packet++, $markval += $increment ) {
|
||||
@@ -331,7 +334,31 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
|
||||
}
|
||||
}
|
||||
|
||||
sub ipset_command() {
|
||||
my %xlate = ( ADD => 'add-set' , DEL => 'del-set' );
|
||||
|
||||
require_capability( 'IPSET_MATCH', "$cmd rules", '' );
|
||||
fatal_error "$cmd rules require a set name parameter" unless $params;
|
||||
|
||||
my ( $setname, $flags, $rest ) = split ':', $params, 3;
|
||||
fatal_error "Invalid ADD/DEL parameter ($params)" if $rest;
|
||||
$setname =~ s/^\+//;
|
||||
fatal_error "Expected ipset name ($setname)" unless $setname =~ /^(6_)?[a-zA-Z][-\w]*$/;
|
||||
fatal_error "Invalid flags ($flags)" unless defined $flags && $flags =~ /^(dst|src)(,(dst|src)){0,5}$/;
|
||||
$target = join( ' ', 'SET --' . $xlate{$cmd} , $setname , $flags );
|
||||
}
|
||||
|
||||
my %commands = (
|
||||
ADD => {
|
||||
defaultchain => PREROUTING,
|
||||
allowedchains => ALLCHAINS,
|
||||
minparams => 1,
|
||||
maxparams => 1,
|
||||
function => sub() {
|
||||
ipset_command();
|
||||
}
|
||||
},
|
||||
|
||||
CHECKSUM => {
|
||||
defaultchain => 0,
|
||||
allowedchains => ALLCHAINS,
|
||||
@@ -394,6 +421,16 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
|
||||
},
|
||||
},
|
||||
|
||||
DEL => {
|
||||
defaultchain => PREROUTING,
|
||||
allowedchains => ALLCHAINS,
|
||||
minparams => 1,
|
||||
maxparams => 1,
|
||||
function => sub() {
|
||||
ipset_command();
|
||||
}
|
||||
},
|
||||
|
||||
DIVERT => {
|
||||
defaultchain => REALPREROUTING,
|
||||
allowedchains => PREROUTING | REALPREROUTING,
|
||||
@@ -423,7 +460,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
|
||||
function => sub () {
|
||||
require_capability 'DSCP_TARGET', 'The DSCP action', 's';
|
||||
my $dscp = numeric_value( $params );
|
||||
$dscp = $dscpmap{$1} unless defined $dscp;
|
||||
$dscp = $dscpmap{$params} unless defined $dscp;
|
||||
fatal_error( "Invalid DSCP ($params)" ) unless defined $dscp && $dscp <= 0x38 && ! ( $dscp & 1 );
|
||||
$target = 'DSCP --set-dscp ' . in_hex( $dscp );
|
||||
},
|
||||
@@ -556,13 +593,13 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
|
||||
mask => in_hex( $globals{TC_MASK} ),
|
||||
function => sub () {
|
||||
$target = 'MARK';
|
||||
handle_mark_param('--set-mark', , HIGHMARK );
|
||||
handle_mark_param('', , HIGHMARK );
|
||||
},
|
||||
},
|
||||
|
||||
RESTORE => {
|
||||
defaultchain => 0,
|
||||
allowedchains => PREROUTING | FORWARD | POSTROUTING,
|
||||
allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING,
|
||||
minparams => 0,
|
||||
maxparams => 1,
|
||||
function => sub () {
|
||||
@@ -585,13 +622,20 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
|
||||
$target = ( $chain == OUTPUT ? 'sticko' : 'sticky' );
|
||||
$restriction = DESTIFACE_DISALLOW;
|
||||
ensure_mangle_chain( $target );
|
||||
if (supplied $params) {
|
||||
$ttl = numeric_value( $params );
|
||||
fatal_error "The SAME timeout must be positive" unless $ttl;
|
||||
} else {
|
||||
$ttl = 300;
|
||||
}
|
||||
|
||||
$sticky++;
|
||||
},
|
||||
},
|
||||
|
||||
SAVE => {
|
||||
defaultchain => 0,
|
||||
allowedchains => PREROUTING | FORWARD | POSTROUTING,
|
||||
allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING,
|
||||
minparams => 0,
|
||||
maxparams => 1,
|
||||
function => sub () {
|
||||
@@ -599,7 +643,6 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
|
||||
if ( supplied $params ) {
|
||||
handle_mark_param( '--save-mark --mask ' ,
|
||||
$config{TC_EXPERT} ? HIGHMARK : SMALLMARK );
|
||||
|
||||
} else {
|
||||
$target .= '--save-mark --mask ' . in_hex( $globals{TC_MASK} );
|
||||
}
|
||||
@@ -763,7 +806,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
|
||||
|
||||
for ( @state ) {
|
||||
fatal_error "Invalid STATE ($_)" unless exists $state{$_};
|
||||
fatal_error "Duplicate STATE ($_)" if $state{$_};
|
||||
fatal_error "Duplicate STATE ($_)" if $state{$_}++;
|
||||
}
|
||||
} else {
|
||||
$state = 'ALL';
|
||||
@@ -798,6 +841,8 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$ ) {
|
||||
do_probability( $probability ) .
|
||||
do_dscp( $dscp ) .
|
||||
state_match( $state ) .
|
||||
do_time( $time ) .
|
||||
( $ttl ? "-t $ttl " : '' ) .
|
||||
$raw_matches ,
|
||||
$source ,
|
||||
$dest ,
|
||||
@@ -849,13 +894,17 @@ sub process_tc_rule1( $$$$$$$$$$$$$$$$ ) {
|
||||
our %tccmd;
|
||||
|
||||
unless ( %tccmd ) {
|
||||
%tccmd = ( SAVE => { match => sub ( $ ) { $_[0] eq 'SAVE' } ,
|
||||
%tccmd = ( ADD => { match => sub ( $ ) { $_[0] =~ /^ADD/ }
|
||||
},
|
||||
DEL => { match => sub ( $ ) { $_[0] =~ /^DEL/ }
|
||||
},
|
||||
SAVE => { match => sub ( $ ) { $_[0] eq 'SAVE' } ,
|
||||
} ,
|
||||
RESTORE => { match => sub ( $ ) { $_[0] eq 'RESTORE' },
|
||||
} ,
|
||||
CONTINUE => { match => sub ( $ ) { $_[0] eq 'CONTINUE' },
|
||||
} ,
|
||||
SAME => { match => sub ( $ ) { $_[0] eq 'SAME' },
|
||||
SAME => { match => sub ( $ ) { $_[0] =~ /^SAME(?:\(d+\))?$/ },
|
||||
} ,
|
||||
IPMARK => { match => sub ( $ ) { $_[0] =~ /^IPMARK/ },
|
||||
} ,
|
||||
@@ -926,21 +975,22 @@ sub process_tc_rule1( $$$$$$$$$$$$$$$$ ) {
|
||||
$designator = '';
|
||||
}
|
||||
|
||||
my ( $cmd, $rest );
|
||||
|
||||
if ( $mark =~ /^TOS/ ) {
|
||||
$cmd = $mark;
|
||||
$rest = '';
|
||||
} else {
|
||||
($cmd, $rest) = split( '/', $mark, 2 );
|
||||
}
|
||||
|
||||
unless ( $command ) {
|
||||
{
|
||||
if ( $cmd =~ /^([A-Z]+)/ ) {
|
||||
my ( $cmd, $rest ) = split( '/', $mark, 2 );
|
||||
|
||||
if ( $cmd =~ /^([A-Z]+)(?:\((.+)\))?/ ) {
|
||||
if ( my $tccmd = $tccmd{$1} ) {
|
||||
fatal_error "Invalid $1 ACTION ($originalmark)" unless $tccmd->{match}($cmd);
|
||||
$command = $tccmd->{command} if $tccmd->{command};
|
||||
$command = $1;
|
||||
if ( supplied $rest ) {
|
||||
fatal_error "Invalid $1 ACTION ($originalmark)" if supplied $2;
|
||||
$mark = $rest;
|
||||
} elsif ( supplied $2 ) {
|
||||
$mark = $2;
|
||||
} else {
|
||||
$mark = '';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$command = 'MARK';
|
||||
@@ -986,7 +1036,9 @@ sub process_tc_rule1( $$$$$$$$$$$$$$$$ ) {
|
||||
$headers,
|
||||
$probability,
|
||||
$dscp,
|
||||
$state );
|
||||
$state,
|
||||
'-',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1046,10 +1098,10 @@ sub process_tc_rule( ) {
|
||||
}
|
||||
|
||||
sub process_mangle_rule( ) {
|
||||
my ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state );
|
||||
my ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time );
|
||||
if ( $family == F_IPV4 ) {
|
||||
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp, $state ) =
|
||||
split_line2( 'tcrules file',
|
||||
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp, $state, $time ) =
|
||||
split_line2( 'mangle file',
|
||||
{ mark => 0,
|
||||
action => 0,
|
||||
source => 1,
|
||||
@@ -1065,14 +1117,16 @@ sub process_mangle_rule( ) {
|
||||
helper => 11,
|
||||
probability => 12 ,
|
||||
scp => 13,
|
||||
state => 14 },
|
||||
state => 14,
|
||||
time => 15,
|
||||
},
|
||||
{},
|
||||
15,
|
||||
16,
|
||||
1 );
|
||||
$headers = '-';
|
||||
} else {
|
||||
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp, $state ) =
|
||||
split_line2( 'tcrules file',
|
||||
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp, $state, $time ) =
|
||||
split_line2( 'mangle file',
|
||||
{ mark => 0,
|
||||
action => 0,
|
||||
source => 1,
|
||||
@@ -1089,14 +1143,16 @@ sub process_mangle_rule( ) {
|
||||
headers => 12,
|
||||
probability => 13,
|
||||
dscp => 14,
|
||||
state => 15 },
|
||||
state => 15,
|
||||
time => 16,
|
||||
},
|
||||
{},
|
||||
16,
|
||||
17,
|
||||
1 );
|
||||
}
|
||||
|
||||
for my $proto (split_list( $protos, 'Protocol' ) ) {
|
||||
process_mangle_rule1( 'Mangle', $originalmark, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state );
|
||||
process_mangle_rule1( 'Mangle', $originalmark, $source, $dest, $proto, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -132,6 +132,13 @@ sub setup_tunnels() {
|
||||
add_tunnel_rule $inchainref, p => 'tcp --dport 1723', @$source
|
||||
}
|
||||
|
||||
sub setup_one_tinc {
|
||||
my ( $inchainref, $outchainref, $kind, $source, $dest ) = @_;
|
||||
|
||||
add_tunnel_rule $inchainref, p => 'udp --dport 655', @$source;
|
||||
add_tunnel_rule $outchainref, p => 'udp --dport 655', @$dest;
|
||||
}
|
||||
|
||||
sub setup_one_openvpn {
|
||||
my ($inchainref, $outchainref, $kind, $source, $dest) = @_;
|
||||
|
||||
@@ -154,7 +161,7 @@ sub setup_tunnels() {
|
||||
}
|
||||
|
||||
add_tunnel_rule $inchainref, p => "$protocol --dport $port", @$source;
|
||||
add_tunnel_rule $outchainref, p => "$protocol --dport $port", @$dest;;
|
||||
add_tunnel_rule $outchainref, p => "$protocol --dport $port", @$dest;
|
||||
}
|
||||
|
||||
sub setup_one_openvpn_client {
|
||||
@@ -263,6 +270,7 @@ sub setup_tunnels() {
|
||||
'6in4' => { function => \&setup_one_other, params => [ \@source, \@dest , 41 ] } ,
|
||||
'pptpclient' => { function => \&setup_pptp_client, params => [ $kind, \@source, \@dest ] } ,
|
||||
'pptpserver' => { function => \&setup_pptp_server, params => [ $kind, \@source, \@dest ] } ,
|
||||
'tinc' => { function => \&setup_one_tinc, params => [ $kind, \@source, \@dest ] } ,
|
||||
'openvpn' => { function => \&setup_one_openvpn, params => [ $kind, \@source, \@dest ] } ,
|
||||
'openvpnclient' => { function => \&setup_one_openvpn_client, params => [ $kind, \@source, \@dest ] } ,
|
||||
'openvpnserver' => { function => \&setup_one_openvpn_server, params => [ $kind, \@source, \@dest ] } ,
|
||||
|
@@ -55,6 +55,7 @@ our @EXPORT = ( qw( NOTHING
|
||||
find_zone
|
||||
firewall_zone
|
||||
loopback_zones
|
||||
loopback_interface
|
||||
local_zones
|
||||
defined_zone
|
||||
zone_type
|
||||
@@ -193,6 +194,7 @@ our %reservedName = ( all => 1,
|
||||
# physical => <physical interface name>
|
||||
# base => <shell variable base representing this interface>
|
||||
# provider => <Provider Name, if interface is associated with a provider>
|
||||
# wildcard => undef|1 # Wildcard Name
|
||||
# zones => { zone1 => 1, ... }
|
||||
# }
|
||||
# }
|
||||
@@ -218,6 +220,7 @@ our $minroot;
|
||||
our $zonemark;
|
||||
our $zonemarkincr;
|
||||
our $zonemarklimit;
|
||||
our $loopback_interface;
|
||||
|
||||
use constant { FIREWALL => 1,
|
||||
IP => 2,
|
||||
@@ -328,6 +331,7 @@ sub initialize( $$ ) {
|
||||
%mapbase1 = ();
|
||||
$baseseq = 0;
|
||||
$minroot = 0;
|
||||
$loopback_interface = '';
|
||||
|
||||
if ( $family == F_IPV4 ) {
|
||||
%validinterfaceoptions = (arp_filter => BINARY_IF_OPTION,
|
||||
@@ -340,6 +344,7 @@ sub initialize( $$ ) {
|
||||
ignore => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
|
||||
maclist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
logmartians => BINARY_IF_OPTION,
|
||||
loopback => BINARY_IF_OPTION,
|
||||
nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER,
|
||||
norfc1918 => OBSOLETE_IF_OPTION,
|
||||
nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
@@ -385,6 +390,7 @@ sub initialize( $$ ) {
|
||||
destonly => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
dhcp => SIMPLE_IF_OPTION,
|
||||
ignore => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
|
||||
loopback => BINARY_IF_OPTION,
|
||||
maclist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER,
|
||||
nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST,
|
||||
@@ -459,6 +465,7 @@ sub parse_zone_option_list($$\$$)
|
||||
} else {
|
||||
fatal_error "Missing value for option \"$e\"" unless defined $val;
|
||||
fatal_error "Invalid value ($val) for option \"$e\"" unless $val =~ /^($fmt)$/;
|
||||
require_capability 'TCPMSS_TARGET', "mss=$val", 's' if $e eq 'mss';
|
||||
}
|
||||
|
||||
my $key = $zonekey{$e};
|
||||
@@ -1252,6 +1259,7 @@ sub process_interface( $$ ) {
|
||||
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 && $numval <= $maxoptionvalue{$option};
|
||||
require_capability 'TCPMSS_TARGET', "mss=$value", 's' if $option eq 'mss';
|
||||
$options{$option} = $numval;
|
||||
$hostoptions{$option} = $numval if $hostopt;
|
||||
} elsif ( $type == IPLIST_IF_OPTION ) {
|
||||
@@ -1352,8 +1360,15 @@ sub process_interface( $$ ) {
|
||||
$options{ignore} ||= 0;
|
||||
}
|
||||
|
||||
$options{loopback} ||= ( $physical eq 'lo' );
|
||||
|
||||
if ( $options{loopback} ) {
|
||||
fatal_error "Only one 'loopback' interface is allowed" if $loopback_interface;
|
||||
$loopback_interface = $physical;
|
||||
}
|
||||
|
||||
if ( $options{unmanaged} ) {
|
||||
fatal_error "The 'lo' interface may not be unmanaged when there are vserver zones" if $physical eq 'lo' && vserver_zones;
|
||||
fatal_error "The loopback interface ($loopback_interface) may not be unmanaged when there are vserver zones" if $options{loopback} && vserver_zones;
|
||||
|
||||
while ( my ( $option, $value ) = each( %options ) ) {
|
||||
fatal_error "The $option option may not be specified with 'unmanaged'" if $prohibitunmanaged{$option};
|
||||
@@ -1375,14 +1390,15 @@ sub process_interface( $$ ) {
|
||||
base => var_base( $physical ),
|
||||
zones => {},
|
||||
origin => shortlineinfo(''),
|
||||
wildcard => $wildcard,
|
||||
};
|
||||
|
||||
if ( $zone ) {
|
||||
fatal_error "Unmanaged interfaces may not be associated with a zone" if $options{unmanaged};
|
||||
|
||||
if ( $physical eq 'lo' ) {
|
||||
fatal_error "Only a loopback zone may be assigned to 'lo'" unless $zoneref->{type} == LOOPBACK;
|
||||
fatal_error "Invalid definition of 'lo'" if $bridge ne $interface;
|
||||
if ( $options{loopback} ) {
|
||||
fatal_error "Only a loopback zone may be assigned to '$physical'" unless $zoneref->{type} == LOOPBACK;
|
||||
fatal_error "Invalid definition of '$physical'" if $bridge ne $interface;
|
||||
|
||||
for ( qw/arp_filter
|
||||
arp_ignore
|
||||
@@ -1404,10 +1420,10 @@ sub process_interface( $$ ) {
|
||||
upnpclient
|
||||
mss
|
||||
/ ) {
|
||||
fatal_error "The 'lo' interface may not specify the '$_' option" if supplied $options{$_};
|
||||
fatal_error "The '$config{LOOPBACK}' interface may not specify the '$_' option" if supplied $options{$_};
|
||||
}
|
||||
} else {
|
||||
fatal_error "A loopback zone may only be assigned to 'lo'" if $zoneref->{type} == LOOPBACK;
|
||||
fatal_error "A loopback zone may only be assigned to the loopback interface" if $zoneref->{type} == LOOPBACK;
|
||||
}
|
||||
|
||||
$netsref ||= [ allip ];
|
||||
@@ -1464,6 +1480,22 @@ sub validate_interfaces_file( $ ) {
|
||||
#
|
||||
fatal_error "No network interfaces defined" unless @interfaces;
|
||||
|
||||
#
|
||||
# Define the loopback interface if it hasn't been already
|
||||
#
|
||||
unless ( $loopback_interface ) {
|
||||
$interfaces{lo} = { name => 'lo',
|
||||
bridge => 'lo',
|
||||
nets => 0,
|
||||
number => $nextinum++,
|
||||
root => 'lo',
|
||||
broadcasts => undef,
|
||||
options => { loopback => 1 , ignore => 1 },
|
||||
zone => '',
|
||||
physical => 'lo' };
|
||||
push @interfaces, $loopback_interface = 'lo';
|
||||
}
|
||||
|
||||
if ( vserver_zones ) {
|
||||
#
|
||||
# While the user thinks that vservers are associated with a particular interface, they really are not.
|
||||
@@ -1479,7 +1511,7 @@ sub validate_interfaces_file( $ ) {
|
||||
broadcasts => undef ,
|
||||
options => {} ,
|
||||
zone => '',
|
||||
physical => 'lo',
|
||||
physical => $loopback_interface,
|
||||
};
|
||||
|
||||
push @interfaces, $interface;
|
||||
@@ -1497,7 +1529,7 @@ sub map_physical( $$ ) {
|
||||
|
||||
$physical =~ s/\+$//;
|
||||
|
||||
$physical . substr( $name, length $interfaceref->{root} );
|
||||
$physical . substr( $name, length( $interfaceref->{root} ) );
|
||||
}
|
||||
|
||||
#
|
||||
@@ -1531,6 +1563,7 @@ sub known_interface($)
|
||||
number => $interfaceref->{number} ,
|
||||
physical => $physical ,
|
||||
base => var_base( $physical ) ,
|
||||
wildcard => $interfaceref->{wildcard} ,
|
||||
zones => $interfaceref->{zones} ,
|
||||
};
|
||||
}
|
||||
@@ -1540,6 +1573,13 @@ sub known_interface($)
|
||||
$physical{$interface} || 0;
|
||||
}
|
||||
|
||||
#
|
||||
# Return the loopback interface physical name
|
||||
#
|
||||
sub loopback_interface() {
|
||||
$loopback_interface;
|
||||
}
|
||||
|
||||
#
|
||||
# Return interface number
|
||||
#
|
||||
@@ -1586,7 +1626,7 @@ sub managed_interfaces() {
|
||||
# Return a list of unmanaged interfaces (skip 'lo' since it is implicitly unmanaged when there are no loopback zones).
|
||||
#
|
||||
sub unmanaged_interfaces() {
|
||||
grep ( $interfaces{$_}{options}{unmanaged} && $_ ne 'lo', @interfaces );
|
||||
grep ( $interfaces{$_}{options}{unmanaged} && ! $interfaces{$_}{options}{loopback}, @interfaces );
|
||||
}
|
||||
|
||||
#
|
||||
@@ -1768,7 +1808,7 @@ sub find_interfaces_by_option1( $ ) {
|
||||
my $optionsref = $interfaceref->{options};
|
||||
|
||||
if ( $optionsref && defined $optionsref->{$option} ) {
|
||||
$wild ||= ( $interfaceref->{physical} =~ /\+$/ );
|
||||
$wild ||= $interfaceref->{wildcard};
|
||||
push @ints , $interface
|
||||
}
|
||||
}
|
||||
@@ -1986,10 +2026,10 @@ sub process_host( ) {
|
||||
fatal_error "Unknown interface ($interface)" unless ($interfaceref = $interfaces{$interface}) && $interfaceref->{root};
|
||||
fatal_error "Unmanaged interfaces may not be associated with a zone" if $interfaceref->{unmanaged};
|
||||
|
||||
if ( $interfaceref->{name} eq 'lo' ) {
|
||||
fatal_error "Only a loopback zone may be associated with the loopback interface (lo)" if $type != LOOPBACK;
|
||||
if ( $interfaceref->{physical} eq $loopback_interface ) {
|
||||
fatal_error "Only a loopback zone may be associated with the loopback interface ($loopback_interface)" if $type != LOOPBACK;
|
||||
} else {
|
||||
fatal_error "Loopback zones may only be associated with the loopback interface (lo)" if $type == LOOPBACK;
|
||||
fatal_error "Loopback zones may only be associated with the loopback interface ($loopback_interface)" if $type == LOOPBACK;
|
||||
}
|
||||
} else {
|
||||
fatal_error "Invalid HOST(S) column contents: $hosts"
|
||||
@@ -2029,6 +2069,7 @@ sub process_host( ) {
|
||||
$zoneref->{options}{in}{blacklist} = 1;
|
||||
} elsif ( $option =~ /^mss=(\d+)$/ ) {
|
||||
fatal_error "Invalid mss ($1)" unless $1 >= 500;
|
||||
require_capability 'TCPMSS_TARGET', $option, 's';
|
||||
$options{mss} = $1;
|
||||
$zoneref->{options}{complex} = 1;
|
||||
} elsif ( $validhostoptions{$option}) {
|
||||
@@ -2118,14 +2159,26 @@ sub have_ipsec() {
|
||||
sub find_hosts_by_option( $ ) {
|
||||
my $option = $_[0];
|
||||
my @hosts;
|
||||
my %done;
|
||||
|
||||
for my $interface ( @interfaces ) {
|
||||
my $value = $interfaces{$interface}{options}{$option};
|
||||
if ( ! $interfaces{$interface}{zone} && $value ) {
|
||||
push @hosts, [ $interface, '', ALLIP , [], $value ];
|
||||
$done{$interface} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for my $zone ( grep ! ( $zones{$_}{type} & FIREWALL ) , @zones ) {
|
||||
while ( my ($type, $interfaceref) = each %{$zones{$zone}{hosts}} ) {
|
||||
while ( my ( $interface, $arrayref) = ( each %{$interfaceref} ) ) {
|
||||
for my $host ( @{$arrayref} ) {
|
||||
if ( my $value = $host->{options}{$option} ) {
|
||||
for my $net ( @{$host->{hosts}} ) {
|
||||
push @hosts, [ $interface, $host->{ipsec} , $net , $host->{exclusions}, $value ];
|
||||
my $ipsec = $host->{ipsec};
|
||||
unless ( $done{$interface} ) {
|
||||
if ( my $value = $host->{options}{$option} ) {
|
||||
for my $net ( @{$host->{hosts}} ) {
|
||||
push @hosts, [ $interface, $ipsec , $net , $host->{exclusions}, $value ];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2133,12 +2186,6 @@ sub find_hosts_by_option( $ ) {
|
||||
}
|
||||
}
|
||||
|
||||
for my $interface ( @interfaces ) {
|
||||
if ( ! $interfaces{$interface}{zone} && $interfaces{$interface}{options}{$option} ) {
|
||||
push @hosts, [ $interface, 'none', ALLIP , [] ];
|
||||
}
|
||||
}
|
||||
|
||||
\@hosts;
|
||||
}
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
# (c) 1999-2014 - Tom Eastep (teastep@shorewall.net)
|
||||
# (c) 1999-2015 - Tom Eastep (teastep@shorewall.net)
|
||||
#
|
||||
# This program is part of Shorewall.
|
||||
# This program is part of Shorewall.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation, either version 2 of the license or, at your
|
||||
# option, any later version.
|
||||
# Free Software Foundation, either version 2 of the license or, at your
|
||||
# option, any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -17,30 +17,41 @@
|
||||
#
|
||||
# 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
|
||||
# -n Do not 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:
|
||||
#
|
||||
# start Starts the firewall
|
||||
# refresh Refresh the firewall
|
||||
# restart Restarts the firewall
|
||||
# reload Reload the firewall
|
||||
# clear Removes all firewall rules
|
||||
# stop Stops the firewall
|
||||
# status Displays firewall status
|
||||
# version Displays the version of Shorewall that
|
||||
# generated this program
|
||||
# clear Removes all firewall rules
|
||||
# disable Disable an optional interface
|
||||
# down Stop an optional interface
|
||||
# enable Enable an optional interface
|
||||
# help Show command syntax
|
||||
# reenable Disable then nable an optional
|
||||
# interface
|
||||
# refresh Refresh the firewall
|
||||
# reload Reload the firewall
|
||||
# restart Restarts the firewall
|
||||
# restore Restore a saved configuration
|
||||
# reset Reset byte and packet counters
|
||||
# run Call a function in this program
|
||||
# savesets Save the ipset contents
|
||||
# status Displays firewall status
|
||||
# start Starts the firewall
|
||||
# stop Stops the firewall
|
||||
# up Start an optional interface
|
||||
# version Displays the version of Shorewall that
|
||||
# generated this program
|
||||
#
|
||||
################################################################################
|
||||
# Functions imported from /usr/share/shorewall/lib.core
|
||||
################################################################################
|
||||
# Address family-neutral Functions
|
||||
# Address family-neutral Functions
|
||||
################################################################################
|
||||
#
|
||||
# Conditionally produce message
|
||||
@@ -587,54 +598,67 @@ debug_restore_input() {
|
||||
done
|
||||
}
|
||||
|
||||
interface_up() {
|
||||
interface_enabled() {
|
||||
return $(cat ${VARDIR}/$1.status)
|
||||
}
|
||||
|
||||
distribute_load() {
|
||||
local interface
|
||||
local totalload
|
||||
local load
|
||||
local mark
|
||||
local maxload
|
||||
local currentload # Total load of enabled interfaces
|
||||
local load # Specified load of an enabled interface
|
||||
local mark # Mark of an enabled interface
|
||||
local totalload # Total load of all interfaces - usually 1.000000
|
||||
local nload # Normalized load of an enabled interface
|
||||
local var # Interface name to embed in a variable name
|
||||
|
||||
maxload=$1
|
||||
totalload=$1
|
||||
shift
|
||||
|
||||
totalload=0
|
||||
currentload=0
|
||||
|
||||
for interface in $@; do
|
||||
if interface_up $interface; then
|
||||
if interface_enabled $interface; then
|
||||
var=$(echo $interface | sed 's/[.-]/_/g')
|
||||
load=$(cat ${VARDIR}/${interface}_load)
|
||||
eval ${interface}_load=$load
|
||||
eval ${var}_load=$load
|
||||
mark=$(cat ${VARDIR}/${interface}_mark)
|
||||
eval ${interface}_mark=$mark
|
||||
totalload=$( bc <<EOF
|
||||
eval ${var}_mark=$mark
|
||||
currentload=$( bc <<EOF
|
||||
scale=8
|
||||
$totalload + $load
|
||||
$currentload + $load
|
||||
EOF
|
||||
)
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $totalload ]; then
|
||||
if [ $currentload ]; then
|
||||
for interface in $@; do
|
||||
qt $g_tool -t mangle -F ~$interface
|
||||
eval load=\$${interface}_load
|
||||
eval mark=\$${interface}_mark
|
||||
|
||||
var=$(echo $interface | sed 's/[.-]/_/g')
|
||||
eval load=\$${var}_load
|
||||
eval mark=\$${var}_mark
|
||||
|
||||
if [ -n "$load" ]; then
|
||||
load=$(bc <<EOF
|
||||
nload=$(bc <<EOF
|
||||
scale=8
|
||||
( $load / $totalload ) * $maxload
|
||||
( $load / $currentload ) * $totalload
|
||||
EOF
|
||||
)
|
||||
totalload=$(bc <<EOF
|
||||
currentload=$(bc <<EOF
|
||||
scale=8
|
||||
$totalload - $load
|
||||
$currentload - $load
|
||||
EOF
|
||||
)
|
||||
run_iptables -t mangle -A ~$interface -m statistic --mode random --probability $load -j MARK --set-mark $mark
|
||||
|
||||
case $nload in
|
||||
.*|0.*)
|
||||
run_iptables -t mangle -A ~$interface -m statistic --mode random --probability $nload -j MARK --set-mark $mark
|
||||
;;
|
||||
*)
|
||||
run_iptables -t mangle -A ~$interface -j MARK --set-mark $mark
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@@ -652,7 +676,7 @@ interface_is_usable() # $1 = interface
|
||||
local status;
|
||||
status=0
|
||||
|
||||
if [ "$1" != lo ]; then
|
||||
if ! loopback_interface $1; then
|
||||
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != 0.0.0.0 ]; then
|
||||
[ "$COMMAND" = enable ] || run_isusable_exit $1
|
||||
status=$?
|
||||
@@ -845,6 +869,7 @@ detect_dynamic_gateway() { # $1 = interface
|
||||
local GATEWAYS
|
||||
GATEWAYS=
|
||||
local gateway
|
||||
local file
|
||||
|
||||
gateway=$(run_findgw_exit $1);
|
||||
|
||||
@@ -852,14 +877,21 @@ detect_dynamic_gateway() { # $1 = interface
|
||||
gateway=$( find_peer $($IP addr list $interface ) )
|
||||
fi
|
||||
|
||||
if [ -z "$gateway" -a -f ${VARLIB}/dhcpcd/dhcpcd-${1}.info ]; then
|
||||
eval $(grep ^GATEWAYS= ${VARLIB}/dhcpcd/dhcpcd-${1}.info 2> /dev/null)
|
||||
file="${VARLIB}/dhcpcd/dhcpcd-${1}.info"
|
||||
if [ -z "$gateway" -a -f "${file}" ]; then
|
||||
eval $(grep ^GATEWAYS= "${file}" 2> /dev/null)
|
||||
[ -n "$GATEWAYS" ] && GATEWAYS=${GATEWAYS%,*} && gateway=$GATEWAYS
|
||||
fi
|
||||
|
||||
if [ -z "$gateway" -a -f ${VARLIB}/dhcp/dhclient-${1}.lease ]; then
|
||||
gateway=$(grep 'option routers' ${VARLIB}/dhcp/dhclient-${1}.lease | tail -n 1 | while read j1 j2 gateway; do echo $gateway ; return 0; done)
|
||||
fi
|
||||
for file in \
|
||||
"${VARLIB}/dhcp/dhclient-${1}.lease" \
|
||||
"${VARLIB}/dhcp/dhclient.${1}.leases"
|
||||
do
|
||||
[ -n "$gateway" ] && break
|
||||
if [ -f "${file}" ]; then
|
||||
gateway=$(grep 'option routers' "${file}" | tail -n 1 | while read j1 j2 gateway; do echo "${gateway%\;}" ; return 0; done)
|
||||
fi
|
||||
done
|
||||
|
||||
[ -n "$gateway" ] && echo $gateway
|
||||
}
|
||||
@@ -894,18 +926,21 @@ detect_gateway() # $1 = interface
|
||||
# Disable IPV6
|
||||
#
|
||||
disable_ipv6() {
|
||||
local foo
|
||||
foo="$($IP -f inet6 addr list 2> /dev/null)"
|
||||
local temp
|
||||
temp="$($IP -f inet6 addr list 2> /dev/null)"
|
||||
|
||||
if [ -n "$foo" ]; then
|
||||
if [ -n "$temp" ]; then
|
||||
if [ -x "$IP6TABLES" ]; then
|
||||
$IP6TABLES -P FORWARD DROP
|
||||
$IP6TABLES -P INPUT DROP
|
||||
$IP6TABLES -P OUTPUT DROP
|
||||
$IP6TABLES -F
|
||||
$IP6TABLES -X
|
||||
$IP6TABLES -A OUTPUT -o lo -j ACCEPT
|
||||
$IP6TABLES -A INPUT -i lo -j ACCEPT
|
||||
|
||||
for temp in $(find_loopback_interfaces); do
|
||||
$IP6TABLES -A OUTPUT -o $temp -j ACCEPT
|
||||
$IP6TABLES -A INPUT -i $temp -j ACCEPT
|
||||
done
|
||||
else
|
||||
error_message "WARNING: DISABLE_IPV6=Yes in shorewall.conf but this system does not appear to have ip6tables"
|
||||
fi
|
||||
|
@@ -15,10 +15,14 @@ usage() {
|
||||
echo " down <interface>"
|
||||
echo " enable <interface>"
|
||||
echo " reset"
|
||||
echo " reenable <interface>"
|
||||
echo " refresh"
|
||||
echo " restart"
|
||||
echo " run <command> [ <parameter> ... ]"
|
||||
echo " status"
|
||||
echo " up <interface>"
|
||||
echo " savesets <file>"
|
||||
echo " call <function> [ <parameter> ... ]"
|
||||
echo " version"
|
||||
echo
|
||||
echo "Options are:"
|
||||
@@ -27,6 +31,7 @@ usage() {
|
||||
echo " -n Don't update routing configuration"
|
||||
echo " -p Purge Conntrack Table"
|
||||
echo " -t Timestamp progress Messages"
|
||||
echo " -c Save/restore iptables counters"
|
||||
echo " -V <verbosity> Set verbosity explicitly"
|
||||
echo " -R <file> Override RESTOREFILE setting"
|
||||
exit $1
|
||||
@@ -84,6 +89,17 @@ g_purge=$PURGE
|
||||
g_noroutes=$NOROUTES
|
||||
g_timestamp=$TIMESTAMP
|
||||
g_recovering=$RECOVERING
|
||||
#
|
||||
# These two variables contain the high-order and low-order parts respectively of
|
||||
# an SHA1 digest of this file. The digest is generated before the two following
|
||||
# lines are updated to contain the value of that digest.
|
||||
#
|
||||
g_sha1sum1=
|
||||
g_sha1sum2=
|
||||
#
|
||||
# Other Globals
|
||||
#
|
||||
g_counters=
|
||||
|
||||
initialize
|
||||
|
||||
@@ -135,6 +151,10 @@ while [ $finished -eq 0 -a $# -gt 0 ]; do
|
||||
g_recovering=Yes
|
||||
option=${option#r}
|
||||
;;
|
||||
c*)
|
||||
g_counters=Yes
|
||||
option=${option#c}
|
||||
;;
|
||||
V*)
|
||||
option=${option#V}
|
||||
|
||||
@@ -355,22 +375,82 @@ case "$COMMAND" in
|
||||
[ $# -eq 1 ] && exit 0
|
||||
shift
|
||||
[ $# -ne 1 ] && usage 2
|
||||
mutex_on
|
||||
if product_is_started; then
|
||||
detect_configuration
|
||||
enable_provider $1
|
||||
detect_configuration $1
|
||||
enable_provider $1 Yes
|
||||
fi
|
||||
mutex_off
|
||||
status=0
|
||||
;;
|
||||
disable)
|
||||
[ $# -eq 1 ] && exit 0
|
||||
shift
|
||||
[ $# -ne 1 ] && usage 2
|
||||
mutex_on
|
||||
if product_is_started; then
|
||||
detect_configuration
|
||||
disable_provider $1
|
||||
detect_configuration $1
|
||||
disable_provider $1 Yes
|
||||
fi
|
||||
mutex_off
|
||||
status=0
|
||||
;;
|
||||
reenable)
|
||||
[ $# -eq 1 ] && exit 0
|
||||
shift
|
||||
[ $# -ne 1 ] && usage 2
|
||||
mutex_on
|
||||
if product_is_started; then
|
||||
detect_configuration $1
|
||||
COMMAND=enable disable_provider $1 Yes
|
||||
COMMAND=disable enable_provider $1 Yes
|
||||
fi
|
||||
mutex_off
|
||||
status=0
|
||||
;;
|
||||
run)
|
||||
if [ $# -gt 1 ]; then
|
||||
shift
|
||||
detect_configuration
|
||||
run_init_exit
|
||||
eval $@
|
||||
status=$?
|
||||
else
|
||||
error_message "ERROR: Missing command"
|
||||
fi
|
||||
;;
|
||||
savesets)
|
||||
if [ $# -eq 2 ]; then
|
||||
save_ipsets $2
|
||||
status=$?
|
||||
else
|
||||
usage 2
|
||||
fi
|
||||
;;
|
||||
call)
|
||||
#
|
||||
# Way to call functions in the generated script directly
|
||||
#
|
||||
detect_configuration
|
||||
|
||||
shift
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
#
|
||||
# See what it is
|
||||
#
|
||||
if type $1 2> /dev/null | fgrep -q 'is a function'; then
|
||||
#
|
||||
# It's a shell function -- call it
|
||||
#
|
||||
$@
|
||||
else
|
||||
fatal_error "$1 is not a known shell function"
|
||||
fi
|
||||
else
|
||||
usage 1
|
||||
fi
|
||||
;;
|
||||
version)
|
||||
[ $# -ne 1 ] && usage 2
|
||||
echo $SHOREWALL_VERSION
|
||||
|
@@ -11,4 +11,4 @@
|
||||
###############################################################################
|
||||
#ZONE INTERFACE OPTIONS
|
||||
- lo ignore
|
||||
net all dhcp,physical=+,routeback,optional
|
||||
net all dhcp,physical=+,routeback
|
||||
|
@@ -25,6 +25,8 @@ BLACKLIST_LOG_LEVEL=
|
||||
|
||||
INVALID_LOG_LEVEL=
|
||||
|
||||
LOG_BACKEND=
|
||||
|
||||
LOG_MARTIANS=Yes
|
||||
|
||||
LOG_VERBOSITY=2
|
||||
@@ -186,7 +188,7 @@ MAPOLDACTIONS=No
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX=ko
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MULTICAST=No
|
||||
|
||||
|
@@ -3,7 +3,7 @@ For instructions on using this sample configuration, please see
|
||||
http://www.shorewall.net/standalone.htm
|
||||
|
||||
Shorewall Samples
|
||||
Copyright (C) 2006 by the following authors:
|
||||
Copyright (C) 2006-2014 by the following authors:
|
||||
Thomas M. Eastep
|
||||
Paul D. Gear
|
||||
Cristian Rodriguez
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample Interfaces File for one-interface configuration.
|
||||
# Copyright (C) 2006 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample Policy File for one-interface configuration.
|
||||
# Copyright (C) 2006 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample Rules File for one-interface configuration.
|
||||
# Copyright (C) 2006 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample shorewall.conf for one-interface
|
||||
# configuration.
|
||||
# Copyright (C) 2006 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@@ -36,6 +36,8 @@ BLACKLIST_LOG_LEVEL=
|
||||
|
||||
INVALID_LOG_LEVEL=
|
||||
|
||||
LOG_BACKEND=
|
||||
|
||||
LOG_MARTIANS=Yes
|
||||
|
||||
LOG_VERBOSITY=2
|
||||
@@ -197,7 +199,7 @@ MAPOLDACTIONS=No
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX=ko
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MULTICAST=No
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample Zones File for one-interface configuration.
|
||||
# Copyright (C) 2006 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
@@ -3,7 +3,7 @@ For instructions on using these sample configurations, please see
|
||||
http://www.shorewall.net/three-interface.htm
|
||||
|
||||
Shorewall Samples
|
||||
Copyright (C) 2006 by the following authors:
|
||||
Copyright (C) 2006-2014 by the following authors:
|
||||
Thomas M. Eastep
|
||||
Paul D. Gear
|
||||
Cristian Rodriguez
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample Interfaces File for three-interface configuration.
|
||||
# Copyright (C) 2006 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall version 3.4 - Sample Masq file for three-interface configuration.
|
||||
# Copyright (C) 2006,2007 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall version 3.4 - Sample Policy File for three-interface configuration.
|
||||
# Copyright (C) 2006 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample Rules File for three-interface configuration.
|
||||
# Copyright (C) 2006,2007 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
@@ -2,8 +2,7 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample shorewall.conf for three-interface
|
||||
# configuration.
|
||||
# Copyright (C) 2006 by the Shorewall Team
|
||||
# 2011 by Thomas M. Eastep
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@@ -34,6 +33,8 @@ BLACKLIST_LOG_LEVEL=
|
||||
|
||||
INVALID_LOG_LEVEL=
|
||||
|
||||
LOG_BACKEND=
|
||||
|
||||
LOG_MARTIANS=Yes
|
||||
|
||||
LOG_VERBOSITY=2
|
||||
@@ -195,7 +196,7 @@ MAPOLDACTIONS=No
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX=ko
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MULTICAST=No
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample Zones File for three-interface configuration.
|
||||
# Copyright (C) 2006 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
@@ -3,7 +3,7 @@ For instructions on using these sample configurations, please see
|
||||
http://www.shorewall.net/two-interface.htm
|
||||
|
||||
Shorewall Samples
|
||||
Copyright (C) 2006 by the following authors:
|
||||
Copyright (C) 2006-2014 by the following authors:
|
||||
Thomas M. Eastep
|
||||
Paul D. Gear
|
||||
Cristian Rodriguez
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample Interfaces File for two-interface configuration.
|
||||
# Copyright (C) 2006 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample Masq file for two-interface configuration.
|
||||
# Copyright (C) 2006 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample Policy File for two-interface configuration.
|
||||
# Copyright (C) 2006 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample Rules File for two-interface configuration.
|
||||
# Copyright (C) 2006,2007 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014,2007 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
@@ -2,8 +2,7 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample shorewall.conf for two-interface
|
||||
# configuration.
|
||||
# Copyright (C) 2006,2007 by the Shorewall Team
|
||||
# 2011 by Thomas M. Eastep
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
@@ -37,6 +36,8 @@ BLACKLIST_LOG_LEVEL=
|
||||
|
||||
INVALID_LOG_LEVEL=
|
||||
|
||||
LOG_BACKEND=
|
||||
|
||||
LOG_MARTIANS=Yes
|
||||
|
||||
LOG_VERBOSITY=2
|
||||
@@ -198,7 +199,7 @@ MAPOLDACTIONS=No
|
||||
|
||||
MARK_IN_FORWARD_CHAIN=No
|
||||
|
||||
MODULE_SUFFIX=ko
|
||||
MODULE_SUFFIX="ko ko.xz"
|
||||
|
||||
MULTICAST=No
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Shorewall version 4.0 - Sample Zones File for two-interface configuration.
|
||||
# Copyright (C) 2006 by the Shorewall Team
|
||||
# Copyright (C) 2006-2014 by the Shorewall Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
|
34
Shorewall/action.DNSAmp
Normal file
34
Shorewall/action.DNSAmp
Normal file
@@ -0,0 +1,34 @@
|
||||
#
|
||||
# Shorewall 4 - DNS Amplification Action
|
||||
#
|
||||
# /usr/share/shorewall/action.DNSAmp
|
||||
#
|
||||
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
||||
#
|
||||
# (c) 2011,2012 - 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.
|
||||
#
|
||||
# DNSAmp[([<action>])]
|
||||
#
|
||||
# Default action is DROP
|
||||
#
|
||||
##########################################################################################
|
||||
?format 2
|
||||
|
||||
DEFAULTS DROP
|
||||
|
||||
IPTABLES(@1) - - udp 53 ; -m u32 --u32 "0>>22&0x3C\@8&0xffff=0x0100 && 0>>22&0x3C\@12&0xffff0000=0x00010000"
|
@@ -41,9 +41,9 @@ set_action_disposition( $disposition) if supplied $disposition;
|
||||
set_action_name_to_caller;
|
||||
|
||||
if ( $destination eq 'dst' ) {
|
||||
perl_action_helper( $action, "-m recent --name $event --remove --rdest" );
|
||||
perl_action_helper( $action, '', '', "-m recent --name $event --remove --rdest" );
|
||||
} else {
|
||||
perl_action_helper( $action, "-m recent --name $event --remove --rsource" );
|
||||
perl_action_helper( $action, '', '', "-m recent --name $event --remove --rsource" );
|
||||
}
|
||||
|
||||
1;
|
||||
|
@@ -41,9 +41,9 @@ set_action_disposition( $disposition) if supplied $disposition;
|
||||
set_action_name_to_caller;
|
||||
|
||||
if ( $destination eq 'dst' ) {
|
||||
perl_action_helper( $action, "-m recent --name $event --set --rdest" );
|
||||
perl_action_helper( $action, '', '', "-m recent --name $event --set --rdest" );
|
||||
} else {
|
||||
perl_action_helper( $action, "-m recent --name $event --set --rsource" );
|
||||
perl_action_helper( $action, '', '', "-m recent --name $event --set --rsource" );
|
||||
}
|
||||
|
||||
1;
|
||||
|
@@ -31,6 +31,7 @@ allowInvalid inline # Accepts packets in the INVALID conntrack state
|
||||
AutoBL noinline # Auto-blacklist IPs that exceed thesholds
|
||||
AutoBLL noinline # Helper for AutoBL
|
||||
Broadcast noinline # Handles Broadcast/Multicast/Anycast
|
||||
DNSAmp # Matches one-question recursive DNS queries
|
||||
Drop # Default Action for DROP policy
|
||||
dropInvalid inline # Drops packets in the INVALID conntrack state
|
||||
DropSmurfs noinline # Drop smurf packets
|
||||
|
@@ -6,7 +6,7 @@
|
||||
# Please see http://shorewall.net/blacklisting_support.htm for additional
|
||||
# information.
|
||||
#
|
||||
###################################################################################################################################################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH
|
||||
################################################################################################################################################################################################
|
||||
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH
|
||||
# PORT PORT(S) DEST LIMIT GROUP
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user