Compare commits

..

228 Commits

Author SHA1 Message Date
Tom Eastep
2673e6e60c Merge branch 'busybox-shell-fixes/v1' into 'master'
lib.cli-std: fix two shell errors when AUTOMAKE is false

See merge request shorewall/code!14
2024-04-16 03:05:57 +00:00
Tom Eastep
d1a8c19712 Merge branch 'support-SAFESTOP-under-systemd-in-debian/v1' into 'master'
Support `SAFESTOP` under systemd in Debian

See merge request shorewall/code!11
2024-04-16 02:59:32 +00:00
Tom Eastep
3c77d83260 Merge branch 'clean-test-ipset' into 'master'
Destroy the temporary IP set in the cleanup function

See merge request shorewall/code!13
2024-04-16 02:46:50 +00:00
Tom Eastep
d8e43cee2b Merge branch 'master' into 'master'
Rewrite gethostbyname2 and inet_ntop to newer getaddrinfo and getnameinfo

See merge request shorewall/code!5
2024-04-15 22:57:24 +00:00
Tom Eastep
b0839c30b2 Merge branch '11-update-always-allowed-ipv6-icmp-rules-according-rfc4890' into 'master'
Update always allowed ipv6-icmp rules according RFC4890

Closes #11

See merge request shorewall/code!16
2024-04-15 21:33:14 +00:00
Tuomo Soini
5a66c1d9d6 AllowICMPs: certificate path advertisment source must be fe80::/10
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2024-03-19 11:21:03 +02:00
Tuomo Soini
de23e641f7 AllowICMPs: certificate path solicitation source must be :: or fe80::/10
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2024-03-19 11:21:03 +02:00
Tuomo Soini
a8294ed495 AllowICMPs: listener report v2 source must be :: or fe80::/10
rfc3810 section-5

Signed-off-by: Tuomo Soini <tis@foobar.fi>
2024-03-19 11:21:03 +02:00
Tuomo Soini
393cd5043d AllowICMPs: router-advertisment source must be fe80::/10
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2024-03-19 11:21:03 +02:00
Tuomo Soini
0de5e88018 AllowICMPs: allowing redirects is a security issue and not required
Also redirect source must be fe80::/10

Signed-off-by: Tuomo Soini <tis@foobar.fi>
2024-03-19 11:21:03 +02:00
Jeremy Sowden
badf2fc9f0 Support SAFESTOP under systemd
By default, in Debian and its derivatives, stopping the Shorewall
service executes `/sbin/shorewall clear`.

The `SAFESTOP` setting in /etc/default/shorewall is intended to stop the
service by calling `/sbin/shorewall stop`.

However, the systemd service files do not support this.  Instead,
install a shell-script that sources /etc/default/shorewall and honours
`SAFESTOP` when stopping Shorewall and patch the service files to call
it.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
2023-09-09 12:48:07 +01:00
Jeremy Sowden
5e8ce7d073 lib.cli-std: fix two shell errors when AUTOMAKE is false
If `AUTOMAKE` is set to `no` in the config file, it is normalized to the
empty string.

This leads to two errors if `find` is provided by Busybox.

There is a conditional where `$AUTOMAKE` is not quoted when compared to
`recursive` leading to the following error:

  /usr/share/shorewall/lib.cli-std: line 398: [: =: unary operator expected

In contrast to the non-Busybox case, we don't check for an empty
`$AUTOMAKE` before passing it as an argument to `-maxdepth`, leading to:

  /usr/bin/find: Expected a positive decimal integer argument to -maxdepth, but got -type

Refactor the conditionals to eliminate code duplication and fix these two
bugs.

Link: https://gitlab.com/shorewall/code/-/issues/10
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
2023-09-04 21:06:30 +01:00
Glop
450a16f730 Destroy the temporary IP set in the cleanup function
In the IP set capability tests, there is a race condition which
might prevent the removal of the temporary IP set immediately
after flushing the chain that uses this IP set: even though the
rules which used the IP set were deleted, the IP set might still
appear to be “in use by a kernel component.”

In case this happens, we add an extra call to `ipset -X` in the
`cleanup_iptables()` function, just to be sure that the temporary
IP set is indeed destroyed when the compiler exits.
2023-03-03 16:12:04 +01:00
Paul Gear
aae5baedfd Merge branch 'idl0r_iptablesw' into 'master'
Improve iptables --wait check

See merge request shorewall/code!6
2023-02-01 02:47:31 +00:00
Paul Gear
95831e372f Merge branch 'tor_metrics' into 'master'
Add TorMetrics macro

See merge request shorewall/code!7
2023-02-01 02:41:22 +00:00
Paul Gear
77317c1766 Merge branch 'systemd-service-documentation' into 'master'
Document related man-pages in Debian systemd service files

See merge request shorewall/code!8
2023-02-01 02:39:27 +00:00
Paul Gear
236b06d480 Merge branch 'gfdl-text-corrections' into 'master'
Correct GFDL text embedded in document sources

See merge request shorewall/code!9
2023-02-01 02:38:53 +00:00
Paul Gear
86244d8faf Merge branch 'shorewall-man-page-stop-command-fix/v1' into 'master'
Restore omitted words from `stop` command description

See merge request shorewall/code!10
2023-02-01 02:35:57 +00:00
Paul Gear
b8ef488f64 Merge branch 'init-script-SRWL-definition-fix/v1' into 'master'
Move '-6' and '-l' options from SRWL to SRWL_OPTS in Debian init-scripts.

See merge request shorewall/code!12
2023-02-01 01:53:53 +00:00
Jeremy Sowden
b7f2d1b22e Move '-6' and '-l' options from SRWL to SRWL_OPTS in Debian init-scripts.
Changing the definitions of SRWL from /sbin/shorewall6 to
'/sbin/shorewall -6' and so on broke the init-scripts since the scripts
test whether `$SRWL` is executable:

    test -x $SRWL || exit 0

which now fails:

    sh: test: /sbin/shorewall: binary operator expected

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
2023-01-31 22:52:21 +00:00
Jeremy Sowden
c93817f30b Correct GFDL text embedded in document sources
The invariant sections clause doesn't quite match the official text.  It should
read:

  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts

not:

  with no Invariant Sections, with no Front-Cover, and with no Back-Cover Texts

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
2023-01-31 22:50:37 +00:00
Jeremy Sowden
5637385507 Document related man-pages in Debian systemd service files
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
2023-01-31 22:50:18 +00:00
Jeremy Sowden
23f66180e9 Restore omitted words from stop command description
In commit c061d87919 ("Fix links in shorewall(8)") the end of one of
the sentences in the description of the `stop` command was erroneously
truncated.

Fixes: c061d87919 ("Fix links in shorewall(8)")
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
2023-01-31 20:50:00 +00:00
Vincas Dargis
c1e58f6faf Add TorMetrics macro
Add macro for Tor metrics port.

See
https://support.torproject.org/relay-operators/relay-bridge-overloaded/
2022-09-18 15:08:54 +03:00
Christian Ruppert
8b0d829531 Check for wait option if we don't have capabilities
Only check for iptables --wait option if we don't already have existing
capabilities. If we have some and they're not up2date / don't match,
it will issue a warning anyway.
If a valid capabilities file exists, it will already cover whether we
can use --wait or not, that's what WAIT_OPTION is for.

Signed-off-by: Christian Ruppert <idl0r@qasl.de>
2022-04-02 11:52:10 +02:00
Christian Ruppert
c941cf4bb5 Run iptables -w check against a usually small chain
The iptablesw check, that's just looking for whether -w is supported or
not, previousely caused iptables to list all rules, each time you do
a shorewall check or shorewall start/reload. That might be quite
a lot, depending on the amount of rules you have. It is also no
necessary to parse each rule just to check for -w. Let's switch to the
usually much smaller INPUT chain, to reduce the overhead
2022-04-01 16:45:42 +02:00
Michal Josef Špaček
e9e73a259b Rewrite gethostbyname2 and inet_ntop to newer getaddrinfo and getnameinfo
We don't need Socket6, because Socket has IPv6 implementation now
2022-02-08 00:45:27 +01:00
Tuomo Soini
672c3420a0 support: update chat server address 2021-05-27 01:44:15 +03:00
Tom Eastep
ba87937f49 Replace StandardOutput=syslog by StandardOutput=journal in unit files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-10-30 09:24:47 -07:00
Tom Eastep
69f0d4d881 Simon Mater's patch to support gbits and gbps in rate/burst specifications
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-10-09 09:39:01 -07:00
Tom Eastep
6681191c88 Correct 'show bl|blacklists' syntax
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-10-09 09:26:41 -07:00
Tom Eastep
2ceeb2c934 Merge branch '5.2.8' 2020-09-25 10:05:35 -07:00
Tom Eastep
97165ed41e Add target file(s) 5.2.8-base
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-24 15:16:51 -07:00
Tom Eastep
5b0cacd9c4 Add NFS V1.4 macro
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-24 14:46:24 -07:00
Tom Eastep
eeec6f2396 Update shorewall-snat(5)
- Delete incorrect statement about a list of addresses in SNAT()
- Replace IPv4 Example 6 with one that uses the PROBABILITY column

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-24 11:19:46 -07:00
Tom Eastep
2e7d1ac4a3 Update shorewall-snat(5)
- Delete incorrect statement about a list of addresses in SNAT()
- Replace IPv4 Example 6 with one that uses the PROBABILITY column

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-24 11:19:12 -07:00
Tom Eastep
34c59dca32 Don't export interface_is_plain()
- It was used in a superseded change

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-19 11:38:41 -07:00
Tom Eastep
9aa2a4b704 Use less obscure code to set $call_generate_all_acasts;
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-19 11:20:10 -07:00
Tom Eastep
d363809859 Complete the table documentation at the top of the file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-18 13:44:41 -07:00
Tom Eastep
6c4383b5ce Add target file(s) 5.2.8-RC1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-17 14:47:53 -07:00
Tom Eastep
877807943d Add target file(s) 5.2.8-RC1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-17 14:47:29 -07:00
Tom Eastep
378df2861a Add target file(s) 5.2.8-RC1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-17 14:47:20 -07:00
Tom Eastep
f84be9faa4 Display consistent banner
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-17 10:46:53 -07:00
Tom Eastep
c6dea1525f Describe using a shell alias to invoke shorewall6-lite from 'shorewall6'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-15 18:04:33 -07:00
Tom Eastep
a7505f3ecb Remove ${SBINDIR}/shorewall when removing Shorewall-core
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-15 16:57:44 -07:00
Tom Eastep
8c10c96844 Revert "Move ${SBINDIR}/shorewall6 to the Shorewall-core product"
This reverts commit 1ca886abd7.
2020-09-15 16:49:19 -07:00
Tom Eastep
126c5ccd53 Include administrative host name in status output
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-15 15:16:23 -07:00
Tom Eastep
1ca886abd7 Move ${SBINDIR}/shorewall6 to the Shorewall-core product
- Default 'shorewall6' to 'shorewall6-lite' if that product is installed
  and 'shorewall6' is not.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-15 13:55:57 -07:00
Tom Eastep
ca78c0221c Don't remote ${SBINDIR}/shorewall when uninstalling Shorewall
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-15 11:58:05 -07:00
Tom Eastep
e4c2122532 Eliminate duplicate function names between lib.cli and lib.cli-std
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-15 11:45:45 -07:00
Tom Eastep
f16e666858 Redirect STDERR to STDOUT when using $PAGER
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-13 15:46:04 -07:00
Tom Eastep
b5f3294adb Set SHOREWALL_SHELL=/sbin/sh if it isn't set and export or test
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-13 15:33:01 -07:00
Tom Eastep
8d4e79650e Refactor ALL_ACASTS code
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-11 15:58:59 -07:00
Tom Eastep
b253be8a69 Localize to IPv6 the effect of generating ALL_ACASTS during 'restore'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-11 14:35:17 -07:00
Tom Eastep
4385264dc3 Revert "Delete superfuous 'use' statements"
This reverts commit fe7bb4abca.
2020-09-11 13:43:14 -07:00
Tom Eastep
6cab1c3c8c Generate ALL_ACASTS during 'restore' processing
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-11 13:11:44 -07:00
Tom Eastep
fe7bb4abca Delete superfuous 'use' statements
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-11 12:56:37 -07:00
Tom Eastep
63b477a4de Clean up ALL_ACASTS generation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-10 15:59:33 -07:00
Tom Eastep
2166251b97 Correct physwild/wildcard usage
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-10 15:59:16 -07:00
Tom Eastep
9e6aec7687 Correct usage of $physwild, replacing with $wildcard
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-10 13:20:20 -07:00
Tom Eastep
b154803f22 Rename 'noanycast' to 'omitanycast'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-10 09:59:45 -07:00
Tom Eastep
09449d4c67 Add target file(s) 5.2.8-Beta2
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-09 12:44:17 -07:00
Tom Eastep
774be17a32 Expand the description of 'noanycast' in shorewall-interfaces(5)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-09 12:33:01 -07:00
Tom Eastep
6120eba8f9 Correct generation of code for 'noanycast'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-09 11:51:38 -07:00
Tom Eastep
6e8b25f126 Add target file(s) 5.2.8-Beta1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-07 15:07:57 -07:00
Tom Eastep
1dca860425 Add target file(s) 5.2.8-Beta1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-07 15:07:41 -07:00
Tom Eastep
bb9d574bf8 Add target file(s) 5.2.8-Beta1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-07 15:07:32 -07:00
Tom Eastep
4253f23d6b Add 'noanycast' interface option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-09-07 13:47:56 -07:00
Tom Eastep
1e90a52b31 Deprecate 'show filters/classifiers'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-29 12:38:53 -07:00
Tom Eastep
b11bea1d4d Suppress redundant filter/classifier info in 'dump' output
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-29 12:21:17 -07:00
Tom Eastep
130b3e16e5 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2020-08-17 16:34:37 -07:00
Tom Eastep
11aa92c5fc Merge branch '5.2.7' 2020-08-17 16:33:58 -07:00
Tom Eastep
68c0897352 Update GEOIPDIR setting info
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-17 16:30:50 -07:00
Tom Eastep
344bbeacb7 Update ipset article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-14 10:30:43 -07:00
Tom Eastep
3073185b39 Update ipset article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-14 10:29:39 -07:00
Tom Eastep
ef9c153dd5 Avoid double-reporting policing filters
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-10 17:52:37 -07:00
Tom Eastep
fa010dc020 Include policing filters in the show commands
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-03 13:06:06 -07:00
Tom Eastep
770637902f Merge branch '5.2.7' 2020-08-03 08:47:55 -07:00
Tom Eastep
2f56edc1ed Document TC/IPSec issue
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-02 12:23:54 -07:00
Tom Eastep
bc4c6637c3 Correct IPv6 ACK handling in Simple TC
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-01 17:44:55 -07:00
Tom Eastep
0b80856eb6 Correct IPv6 ACK handling in Simple TC
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-01 17:10:00 -07:00
Tom Eastep
92689b12bd 'show tc' now shows classifiers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-08-01 17:07:56 -07:00
Tom Eastep
070efee47a Add ?FORMAT 2 to Shorewall6 tcpri file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-31 12:23:17 -07:00
Tom Eastep
d03146491b Merge branch 'master' of ssh://gitlab.com/shorewall/code 2020-07-26 09:53:16 -07:00
Tom Eastep
995a939a37 Add target file(s) 5.2.7-RC1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-25 18:57:19 -07:00
Tom Eastep
ca19feae69 Correct tunnels file in Shared Config Article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-19 09:43:09 -07:00
Tom Eastep
bc7082fb2a Merge branch '5.2.6'
# Conflicts:
#	docs/docs-targetname
#	docs/images/docs-images-targetname

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-18 17:05:51 -07:00
Tom Eastep
109ae7e038 Link the simple TC article to FAQs 97 and 97a
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-18 17:01:33 -07:00
Tom Eastep
b3ebcc8025 Add target file(s) 5.2.7-Beta1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-13 09:57:30 -07:00
Tom Eastep
954c0185fa Add target file(s) 5.2.7-Beta1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-13 09:57:22 -07:00
Tom Eastep
8d025e3821 Add target file(s) 5.2.7-Beta1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-13 09:57:14 -07:00
Tom Eastep
49ba75252e Add target file(s) 5.2.6.1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-12 19:46:23 -07:00
Tom Eastep
c835fead34 Add target file(s) 5.2.6.1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-12 19:46:13 -07:00
Tom Eastep
ac221348c0 Add an SPORT column to the tcpri file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-09 14:15:03 -07:00
Tom Eastep
381a0ad8aa Add an IFB and SNAT/MASQUERADE section to the TC doc
- Removed the obsolete Kernel Config section

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-08 15:58:51 -07:00
Tom Eastep
4b3f9ae1e7 Clean up the connmark implementation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-07 18:23:39 -07:00
Tom Eastep
89201bd294 Add TC connmark support
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-07 16:44:20 -07:00
Tom Eastep
b617c8d224 Rodrigo Araujo's tc connmark patch
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-07 14:28:21 -07:00
Tom Eastep
d1d8371eb8 Rules tweak
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-07 12:27:48 -07:00
Tom Eastep
5d58b5da72 Avoid '::' in $CONFIG_PATH
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-06 16:00:15 -07:00
Tom Eastep
4469ddb861 Don't apply the deprecated directory more than once
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-06 15:38:28 -07:00
Tom Eastep
cd5409d633 Take care of '$LOG_LEVEL' during update
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-06 15:38:01 -07:00
Tom Eastep
2f58d4e368 Don't create a zone forwarding chain for local zones
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-06 09:06:03 -07:00
Tom Eastep
31844d22cd Update Shared Config article for July 2020 configuration
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-06 08:56:31 -07:00
Tom Eastep
628f5f0903 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2020-07-05 15:31:03 -07:00
Tom Eastep
ce73c783dc Avoid Perl diagnostic when updating shorewall[6].conf
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-05 15:29:34 -07:00
Tom Eastep
e7318459f1 Avoid double colons in the CONFIG_PATH
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-05 15:27:47 -07:00
Tom Eastep
467d41f0cc Merge branch '5.2.6'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-05 13:23:48 -07:00
Tom Eastep
ff64539de3 Update shared config document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-05 13:19:15 -07:00
Tom Eastep
418f96082e Add target file(s) 5.2.6-base
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-04 10:48:56 -07:00
Tom Eastep
b761a6eaa0 Call optimize_policy_chains() after doing other ruleset optimization
- This insures that ACCEPT policy chains are optimized when EXPAND_POLICIES=No

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-04 10:40:43 -07:00
Tom Eastep
f8b7815375 Call optimize_policy_chains() after doing other ruleset optimization
- This insures that ACCEPT policy chains are optimized when EXPAND_POLICIES=No

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-07-04 09:49:28 -07:00
Tom Eastep
d643f57bc1 Add the -D option to shorewall usage output
- Also delete an incorrect -D description in shorewall(8)

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-30 14:56:41 -07:00
Tom Eastep
d1c7b3d9da Add target file(s) 5.2.6-RC1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-29 13:48:53 -07:00
Tom Eastep
d399fd0815 Add target file(s) 5.2.6-RC1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-29 13:48:15 -07:00
Tom Eastep
3dc14e3575 Work around for Centos 7 iptables bug
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-29 11:27:14 -07:00
Tom Eastep
7ba6ac71e3 Delete blank line
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-28 20:41:21 -07:00
Tom Eastep
10aef23ab1 Correct handling of ";;+" in the snat file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-28 11:03:04 -07:00
Tom Eastep
e3f139bbdb Add SPORT column to the snat file (FORMAT 2)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-27 14:50:23 -07:00
Tom Eastep
e4f24f41fd Add target file(s) 5.2.6-Beta1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-27 10:25:51 -07:00
Tom Eastep
d0e4c53bd0 Add target file(s) 5.2.6-Beta1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-27 10:24:45 -07:00
Tom Eastep
43ac903085 Correct action dport implementation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-26 16:55:39 -07:00
Tom Eastep
28b92dae32 Update version for PORT->DPORT snat column naming
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-26 15:34:16 -07:00
Tom Eastep
bac493c2c5 Merge branch '5.2.5' 2020-06-26 15:31:51 -07:00
Tom Eastep
3ed1cdec94 Rename the snat PORT column to DPORT
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-26 14:44:00 -07:00
Tom Eastep
3f5bdfd705 Process the firewall.conf file when running shorewall[6]-lite
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-25 13:32:36 -07:00
Tom Eastep
c9512dfaf8 Make 'show actions' more robust
- Show all lines, including continuation and compiler directives
- Show both actions and actions.std entries
- The actions file need not reside in /etc/shorewall[6] but may be in
  any directory on the CONFIG_PATH

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-25 11:28:08 -07:00
Tom Eastep
5cc626fa1d Add target file(s) 5.2.5.1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-21 11:42:30 -07:00
Tom Eastep
a39ecf5b2b Add target file(s) 5.2.5.1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-21 11:41:53 -07:00
Matt Darfeuille
631bec2762 List supported releases
Signed-off-by: Matt Darfeuille <matt@shorewall.org>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-21 11:33:54 -07:00
Matt Darfeuille
aa126270b7 Avoid exporting targetfiles
Signed-off-by: Matt Darfeuille <matt@shorewall.org>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-21 11:33:38 -07:00
Matt Darfeuille
af2b7e6fc1 List supported releases
Signed-off-by: Matt Darfeuille <matt@shorewall.org>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-21 11:30:38 -07:00
Matt Darfeuille
01bfdabd5a Avoid exporting targetfiles
Signed-off-by: Matt Darfeuille <matt@shorewall.org>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-21 11:30:38 -07:00
Tom Eastep
c234a1a0ec Merge branch '5.2.5' 2020-06-20 10:02:53 -07:00
Tom Eastep
4c50f3b9bf Correct typo in shorewall-providers(5).
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-16 15:50:14 -07:00
Tom Eastep
3390897a45 Remove duplicates from the output of 'show actions'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-15 13:13:34 -07:00
Tom Eastep
7ca18c410b Remove duplicates from the output of 'show actions'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-15 13:12:43 -07:00
Tom Eastep
e2aeed898d Add the 'dport' option to the actions file(s)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-15 13:12:06 -07:00
Tom Eastep
2eb1c88555 Omit superfluous test
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-14 15:00:49 -07:00
Tom Eastep
117e9ba5bd Change kern.err to daemon.err in logger params
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-13 14:29:48 -07:00
Tom Eastep
3ce04a8ef3 Add "zone name too long" error
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-12 12:57:31 -07:00
Tom Eastep
737aca6a3d Add target file(s) 5.2.5-RC1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-10 10:36:03 -07:00
Tom Eastep
d89d35a9f0 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2020-06-08 09:48:31 -07:00
Tom Eastep
220e89755e Omit STATE-orientated rules in wildcard policy chains
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-07 20:57:55 -07:00
Tom Eastep
1d875b2909 Minor edit to the blacklisting doc
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-07 18:12:01 -07:00
Tom Eastep
011638ad7d Document use of address variables in the snat file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-07 18:11:26 -07:00
Tom Eastep
3f5c47695e Expand fail2ban documenation in the blacklisting article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-07 12:37:45 -07:00
Tom Eastep
fb14b0aafc Update targetname files for 5.2.5-Beta2
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-06 12:54:01 -07:00
Tom Eastep
54ab7cdeb5 Update blacklisting documentation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-06 12:23:32 -07:00
Tom Eastep
aa47554604 Add 'noupdate' DYNAMIC_BLACKLIST option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-06 10:14:32 -07:00
Tom Eastep
07160c5ed1 Add 'blacklist!' command.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-06 10:13:46 -07:00
Tom Eastep
527533ecb6 Add 'log' option to DYNAMIC_BLACKLIST
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-03 14:28:08 -07:00
Tom Eastep
4ac64a545c Change log facility to 'daemon'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-03 13:49:10 -07:00
Tom Eastep
6612ea6b8c Store the exported configuration paramaters in a named array
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-03 11:50:27 -07:00
Tom Eastep
2646ec79a5 Read the params file when processing an 'allow' command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-03 11:39:42 -07:00
Tom Eastep
023437a0e0 Add target files 5.2.5-Beta1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-01 10:07:23 -07:00
Tom Eastep
ffb6ac178e Shorten the disposition in ADD/DEL log messages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-06-01 09:36:00 -07:00
Tom Eastep
726d7cde65 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2020-05-31 17:39:38 -07:00
Tom Eastep
c061d87919 Fix links in shorewall(8)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-05-31 17:39:13 -07:00
Tom Eastep
5af7dce96b Merge branch 'master' of ssh://gitlab.com/shorewall/code 2020-05-31 14:03:23 -07:00
Tom Eastep
eb5bc3d8a4 Create DBL ipset with 'timeout 0'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-05-31 12:37:42 -07:00
Tom Eastep
b34474df11 Remove the -f option from the documentation of the 'stop' command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-05-30 20:10:07 -07:00
Tom Eastep
16a3384a70 Add an example of using 'blacklist ... timeout nnn'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-05-30 19:57:37 -07:00
Tom Eastep
67b421dc00 Correct a comment in the optimize level 8 code
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-05-21 11:37:04 -07:00
Matt Darfeuille
c518887a19 Reflect changes in tools repository
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-05-21 10:40:14 -07:00
Tom Eastep
5493a7e4a6 Merge branch '5.2.4' 2020-05-17 13:20:46 -07:00
Tom Eastep
1093f1ac32 Add target files 5.2.4.5
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-05-14 09:43:10 -07:00
Tom Eastep
7882c87afe Allow AUTOMAKE to work with symbolic links
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-05-14 09:22:44 -07:00
Tom Eastep
7343b19abc Clarify the 'optional' interface option.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-05-13 12:30:12 -07:00
Tom Eastep
f27ab4704c Merge branch '5.2.4' 2020-04-30 11:18:18 -07:00
Tom Eastep
e5e8e6fbc0 Correct logic for deleting ipsets
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-29 13:07:04 -07:00
Tom Eastep
c11b647b1b Fix defect which prevented dynamic blacklist ipsets from being created
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-29 12:34:41 -07:00
Tom Eastep
5706c5a860 Avoid hang during 'shorewall[6] start'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-29 12:33:50 -07:00
Tom Eastep
fd1d4a3f35 Update Shared Config Doc
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-25 14:48:45 -07:00
Tom Eastep
2bf9048057 Another Debian if_pre-down fix.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-24 16:47:42 -07:00
Tom Eastep
d618fd5812 Remove extraneous whitespace
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-23 20:31:07 -07:00
Tom Eastep
177cdb1b98 Move a block of code to keep function declarations adjacent
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-23 18:37:47 -07:00
Tom Eastep
dddde56454 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code
# Conflicts:
#	Shorewall-init/install.sh
#	Shorewall/Perl/Shorewall/Providers.pm

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-23 18:35:11 -07:00
Tom Eastep
9b196e87e9 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code
# Conflicts:
#	Shorewall-init/shorewall-init

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-23 18:27:54 -07:00
Tom Eastep
c30a4fd080 Merge branch '5.2.4' of ssh://server.shorewall.net/home/teastep/shorewall/code into 5.2.4
# Conflicts:
#	Shorewall/Perl/Shorewall/Chains.pm

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-22 16:27:03 -07:00
Tom Eastep
0a9d2d9a33 Don't install script in if_down.d on Debian
- Eliminates need for Debian-specific code in generated script

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-22 13:47:09 -07:00
Tom Eastep
39de88563f Cleanup of Optimize 16 change
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-21 13:02:56 -07:00
Tom Eastep
e14798b4a2 Make OPTIMIZE=16 an order of magnitude faster
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-21 13:02:34 -07:00
Tom Eastep
3042ae815e Make OPTIMIZE=16 an order of magnitude faster
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-20 15:00:33 -07:00
Tom Eastep
86ebb22dd3 Cosmetic changes to shorewall-init
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-20 10:29:36 -07:00
Tom Eastep
18360471ab Have Shorewall-init restore ipsets before stopping the firewalls
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-20 09:23:34 -07:00
Tom Eastep
086f7a0e6d Only destroy ipsets that will be restored
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-20 09:11:03 -07:00
Tom Eastep
057a2dec70 Correct typo with bad consequences
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-19 18:44:19 -07:00
Tom Eastep
16af9ee2de Revert "Don't install ifupdown script in if-down.d on Debian"
This reverts commit 7d4d409799.
2020-04-19 15:19:13 -07:00
Tom Eastep
cabadd4846 Honor 'wait=<seconds> when enabling an interface.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-19 14:31:12 -07:00
Tom Eastep
3c06be28be Delete unnecessary check if IPv6 interface_is_usable()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-19 12:28:16 -07:00
Tom Eastep
7d4d409799 Don't install ifupdown script in if-down.d on Debian
- Proper location for the script is if-post-down

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-19 12:18:44 -07:00
Tom Eastep
32ca53706c Don't run the 'up' command twice when an dual-stack interface comes up
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-18 12:44:19 -07:00
Tom Eastep
0adb9c8f87 Don't run the 'up' command twice when an dual-stack interface comes up
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-18 12:43:27 -07:00
Tom Eastep
381d55760b Don't install ifupdown script in /etc/network/if-down.d on Debian
- Network Manager sets PHASE=post-down when calling our updown script
  so we must process down commands in that phase.

- Modify the generated script to eliminate PHASE checks.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-18 11:42:32 -07:00
Tom Eastep
88a799b860 Allow IFUPDOWN=1 to work on Debian
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-18 11:27:15 -07:00
Tom Eastep
5101a6be4a Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2020-04-18 09:36:20 -07:00
Tom Eastep
15ca726c49 Add target files 5.2.4.1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-17 17:56:06 -07:00
Tom Eastep
27510d9ed6 Add a comment to clarify where info comes from
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-16 15:20:24 -07:00
Tom Eastep
f832846a8d Remove extraneous white space
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-16 14:05:07 -07:00
Tuomo Soini
64bf5882db ifupdown: only handle up and down state changes
Signed-off-by: Tuomo Soini <tis@foobar.fi>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-16 14:02:15 -07:00
Tuomo Soini
6841fc9eb2 Ignore 'start' and 'stop' if firewall product is active
Signed-off-by: Tuomo Soini <tis@foobar.fi>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-16 13:32:19 -07:00
Tom Eastep
caa0290cb2 Revert "Ignore 'start' and 'stop' if firewall(s) is started"
This reverts commit b6f5b6ba98.
2020-04-16 13:32:03 -07:00
Tom Eastep
4e1262ec7e Revert "Upcase a variable to follow pattern in this file"
This reverts commit 1be78f8f15.
2020-04-16 13:31:48 -07:00
Tom Eastep
53b05aa5fb Revert "Fix omitted instance of product -> PRODUCT"
This reverts commit 072053995c.
2020-04-16 13:31:39 -07:00
Tom Eastep
072053995c Fix omitted instance of product -> PRODUCT
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-15 14:27:28 -07:00
Tom Eastep
1be78f8f15 Upcase a variable to follow pattern in this file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-15 14:18:28 -07:00
Tom Eastep
b6f5b6ba98 Ignore 'start' and 'stop' if firewall(s) is started
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-15 14:15:17 -07:00
Tom Eastep
3c36d638a5 Use the correct error code when Shoerwall-init is not configured
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-15 09:17:51 -07:00
Tom Eastep
9d3da44dad Ignore 'start' and 'stop' if firewall(s) is started
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-15 09:13:31 -07:00
Tom Eastep
a5d4cbd76c Add cautions to the ipsets article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-14 15:23:33 -07:00
Tom Eastep
4e83d0788e Rename valuesort() to sortchainsiftest() and remove keysort()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-11 13:42:41 -07:00
Tom Eastep
a49a9f9f9d Sort specific hash keys and values if -t
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-07 11:12:16 -07:00
Tom Eastep
6dc99e77ae Revert "Sort specific hash keys and values if -e"
This reverts commit 5e648a9379.
2020-04-07 11:09:27 -07:00
Tom Eastep
92b25d88b0 Revert "Add conditional sorts to find[_zone]_hosts_by_option()"
This reverts commit 42a505c99d.
2020-04-07 11:08:46 -07:00
Tom Eastep
42a505c99d Add conditional sorts to find[_zone]_hosts_by_option()
- Another case of different behavior by different Perl versions

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-06 13:48:45 -07:00
Tom Eastep
5e648a9379 Sort specific hash keys and values if -e
- Makes testing output consistent across Perl versions

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-06 10:57:35 -07:00
Tom Eastep
ed2fa863c3 Correct Ids in new FAQs.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-03 12:46:28 -07:00
Tom Eastep
386dff4c33 Add FAQs regarding AUTOMAKE=Yes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-03 12:42:37 -07:00
Tom Eastep
e49f31fb42 Don't compute sha1 hash when testing
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-04-02 10:11:21 -07:00
Tom Eastep
3f0e4959a1 Revert "When exporting or testing, set all variables defined in the params file"
This reverts commit f9003fab43.
2020-04-01 12:55:41 -07:00
Tom Eastep
112c4dc38a Revert "Temporarily disable fix for exported variables"
This reverts commit 137cc48779.
2020-04-01 12:55:14 -07:00
Tom Eastep
137cc48779 Temporarily disable fix for exported variables
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-03-31 16:43:30 -07:00
Tom Eastep
f9003fab43 When exporting or testing, set all variables defined in the params file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-03-31 15:55:09 -07:00
Tom Eastep
78da975989 Fix a couple of issues with product name
- Use $Product rather that addressfamily-dependent logic
- Revert unneeded change from 5.2.3.7

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-03-28 14:24:32 -07:00
Tuomo Soini
be924ff765 Fix http links to point to current project website
Also removes deprecated Shorewall6/configfiles/masq

Signed-off-by: Tuomo Soini <tis@foobar.fi>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-03-27 14:24:37 -07:00
Tom Eastep
6f484da821 Add target files 5.2.4-base
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-03-24 10:05:34 -07:00
Tom Eastep
82d2863b29 Update ipsets document
- Clarify use of ipsets in stoppedrules.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2020-03-21 14:37:59 -07:00
386 changed files with 3022 additions and 1723 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
*targetname export-ignore

View File

@@ -18,7 +18,7 @@ Shoreline Firewall (Shorewall) Version 5
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Please see http://www.shorewall.org/Install.htm for installation Please see https://shorewall.org/Install.htm for installation
instructions. instructions.

View File

@@ -1 +1 @@
5.2.4-Beta1 5.2.8-RC1

View File

@@ -4,7 +4,7 @@
# #
# (c) 2012,2014,2017 - Tom Eastep (teastep@shorewall.net) # (c) 2012,2014,2017 - Tom Eastep (teastep@shorewall.net)
# #
# Shorewall documentation is available at http://www.shorewall.org # Shorewall documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -4,7 +4,7 @@
# #
# (c) 2012, 2014 - Tom Eastep (teastep@shorewall.net) # (c) 2012, 2014 - Tom Eastep (teastep@shorewall.net)
# #
# Shorewall documentation is available at http://www.shorewall.org # Shorewall documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -4,7 +4,7 @@
# #
# (c) 2000-2018 - Tom Eastep (teastep@shorewall.net) # (c) 2000-2018 - Tom Eastep (teastep@shorewall.net)
# #
# Shorewall documentation is available at http://shorewall.org # Shorewall documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -324,6 +324,15 @@ install_file wait4ifup ${DESTDIR}${LIBEXECDIR}/shorewall/wait4ifup 0755
echo echo
echo "wait4ifup installed in ${DESTDIR}${LIBEXECDIR}/shorewall/wait4ifup" echo "wait4ifup installed in ${DESTDIR}${LIBEXECDIR}/shorewall/wait4ifup"
#
# Install stop_service
#
if [ -n "${STOPSERVICEFILE}" ]; then
install_file ${STOPSERVICEFILE} ${DESTDIR}${LIBEXECDIR}/shorewall/stop_service 0755
echo
echo "${STOPSERVICEFILE} installed in ${DESTDIR}${LIBEXECDIR}/shorewall/stop_service"
fi
# #
# Install the libraries # Install the libraries

View File

@@ -3,7 +3,7 @@
# #
# (c) 1999-2017 - Tom Eastep (teastep@shorewall.net) # (c) 1999-2017 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -3,7 +3,7 @@
# #
# (c) 1999-2018 - Tom Eastep (teastep@shorewall.net) # (c) 1999-2018 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -25,7 +25,7 @@
# loaded after this one and replaces some of the functions declared here. # loaded after this one and replaces some of the functions declared here.
# #
SHOREWALL_CAPVERSION=50200 SHOREWALL_CAPVERSION=50207
if [ -z "$g_basedir" ]; then if [ -z "$g_basedir" ]; then
# #
@@ -247,10 +247,39 @@ search_log() # $1 = IP address to search for
# #
# Show traffic control information # Show traffic control information
# #
show_tc1() { show_one_classifier() {
local class
qt tc -s filter ls root dev $1 && tc -s filter ls root dev $device | grep -v '^$'
tc filter show dev $1
tc class show dev $1 | 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
}
show_classifier1() {
local device
local qdisc
device=${1%@*}
qdisc=$(tc qdisc list dev $device)
if [ -n "$qdisc" ]; then
echo Device $device:
show_one_classifier $device
fi
}
show_tc1() {
show_one_tc() { show_one_tc() {
local device local device
local qdisc
local ingress
device=${1%@*} device=${1%@*}
qdisc=$(tc qdisc list dev $device) qdisc=$(tc qdisc list dev $device)
@@ -260,6 +289,7 @@ show_tc1() {
echo echo
tc -s -d class show dev $device tc -s -d class show dev $device
echo echo
show_one_classifier $device "$qdisc"
fi fi
} }
@@ -270,7 +300,6 @@ show_tc1() {
show_one_tc ${interface%:} show_one_tc ${interface%:}
done done
fi fi
} }
show_tc() { show_tc() {
@@ -291,28 +320,8 @@ show_tc() {
# #
show_classifiers() { show_classifiers() {
show_one_classifier() {
local device
device=${1%@*}
qdisc=$(tc qdisc list dev $device)
if [ -n "$qdisc" ]; then
echo Device $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
}
ip -o link list | while read inx interface details; do ip -o link list | while read inx interface details; do
show_one_classifier ${interface%:} show_classifier1 ${interface%:}
done done
} }
@@ -937,11 +946,28 @@ show_events() {
fi fi
} }
sort_actions() {
local sep #separates sort keys from the action[.std] record
sep="##"
awk -v sep="$sep" \
'BEGIN { action = ""; ifrec = ""; nr = 0; };\
/^#/ { next; };\
/^\?(if|IF|If)/ { ifrec = $0; nr = NR; next; };\
/^( |\t|\?)/ { if ( action != "" ) print action, NR, sep $0; next; };\
{ action = $1; };\
nr != 0 { print action , nr, sep ifrec; nr = 0; };\
{ print action , NR, sep $0; }' | sort -k 1,2 | sed "s/^.*${sep}//"
}
show_actions() { show_actions() {
if [ -f ${g_confdir}/actions ]; then local actions
cat ${g_sharedir}/actions.std ${g_confdir}/actions | grep -Ev '^[#?[:space:]]|^$' actions=$(find_file actions)
if [ -f ${actions} ]; then
cat ${actions} ${g_sharedir}/actions.std | sort_actions
else else
grep -Ev '^[#?[:space:]]|^$' ${g_sharedir}/actions.std sort_actions < ${g_sharedir}/actions.std
fi fi
} }
@@ -1000,6 +1026,8 @@ show_mangle() {
show_classifiers_command() { show_classifiers_command() {
echo "$g_product $SHOREWALL_VERSION Classifiers at $g_hostname - $(date)" echo "$g_product $SHOREWALL_VERSION Classifiers at $g_hostname - $(date)"
echo echo
echo "Warning: This command is deprecated in favor of the 'show tc' command"
echo
show_classifiers show_classifiers
} }
@@ -1108,10 +1136,6 @@ show_blacklists() {
show_bl; show_bl;
} }
show_actions_sorted() {
show_actions | sort
}
show_macros() { show_macros() {
for directory in $(split $CONFIG_PATH); do for directory in $(split $CONFIG_PATH); do
temp= temp=
@@ -1543,7 +1567,7 @@ show_command() {
;; ;;
actions) actions)
[ $# -gt 1 ] && too_many_arguments $2 [ $# -gt 1 ] && too_many_arguments $2
eval show_actions_sorted $g_pager eval show_actions $g_pager
return return
;; ;;
macro) macro)
@@ -1891,8 +1915,6 @@ do_dump_command() {
if [ -n "$TC_ENABLED" ]; then if [ -n "$TC_ENABLED" ]; then
heading "Traffic Control" heading "Traffic Control"
show_tc1 show_tc1
heading "TC Filters"
show_classifiers
fi fi
} }
@@ -2651,6 +2673,7 @@ allow_command() {
if [ -n "$g_blacklistipset" ]; then if [ -n "$g_blacklistipset" ]; then
if qt $IPSET -D $g_blacklistipset $1; then if qt $IPSET -D $g_blacklistipset $1; then
allowed=Yes allowed=Yes
[ -n "$g_dbllog" ] && mylogger daemon.info "$g_product: $1 Allowed"
fi fi
fi fi
@@ -2667,6 +2690,7 @@ allow_command() {
*) *)
if [ -n "$g_blacklistipset" ]; then if [ -n "$g_blacklistipset" ]; then
if qt $IPSET -D $g_blacklistipset $1; then if qt $IPSET -D $g_blacklistipset $1; then
[ -n "$g_dbllog" ] && mylogger daemon.info "$g_product: $1 Allowed"
allowed=Yes allowed=Yes
fi fi
fi fi
@@ -2863,6 +2887,7 @@ determine_capabilities() {
NETMAP_TARGET= NETMAP_TARGET=
NFLOG_SIZE= NFLOG_SIZE=
RESTORE_WAIT_OPTION= RESTORE_WAIT_OPTION=
CONNMARK_ACTION=
AMANDA_HELPER= AMANDA_HELPER=
FTP_HELPER= FTP_HELPER=
@@ -3230,6 +3255,10 @@ determine_capabilities() {
BASIC_FILTER=Yes BASIC_FILTER=Yes
$TC filter add basic help 2>&1 | egrep -q match && BASIC_EMATCH=Yes $TC filter add basic help 2>&1 | egrep -q match && BASIC_EMATCH=Yes
fi fi
if $TC action add connmark help 2>&1 | grep -q ^Usage; then
CONNMARK_ACTION=Yes
fi
fi fi
[ -n "$IP" ] && $IP rule add help 2>&1 | grep -q /MASK && FWMARK_RT_MASK=Yes [ -n "$IP" ] && $IP rule add help 2>&1 | grep -q /MASK && FWMARK_RT_MASK=Yes
@@ -3373,6 +3402,7 @@ report_capabilities_unsorted() {
report_capability "NETMAP Target (NETMAP_TARGET)" $NETMAP_TARGET report_capability "NETMAP Target (NETMAP_TARGET)" $NETMAP_TARGET
report_capability "--nflog-size support (NFLOG_SIZE)" $NFLOG_SIZE report_capability "--nflog-size support (NFLOG_SIZE)" $NFLOG_SIZE
report_capability "INPUT chain in nat table (NAT_INPUT_CHAIN)" $NAT_INPUT_CHAIN report_capability "INPUT chain in nat table (NAT_INPUT_CHAIN)" $NAT_INPUT_CHAIN
report_capability "TC connmark support (CONNMARK_ACTION)" $CONNMARK_ACTION
echo " Kernel Version (KERNELVERSION): $KERNELVERSION" echo " Kernel Version (KERNELVERSION): $KERNELVERSION"
echo " Capabilities Version (CAPVERSION): $CAPVERSION" echo " Capabilities Version (CAPVERSION): $CAPVERSION"
@@ -3479,6 +3509,7 @@ report_capabilities_unsorted1() {
report_capability1 NFLOG_SIZE report_capability1 NFLOG_SIZE
report_capability1 RESTORE_WAIT_OPTION report_capability1 RESTORE_WAIT_OPTION
report_capability1 NAT_INPUT_CHAIN report_capability1 NAT_INPUT_CHAIN
report_capability1 CONNMARK_ACTION
report_capability1 AMANDA_HELPER report_capability1 AMANDA_HELPER
report_capability1 FTP_HELPER report_capability1 FTP_HELPER
@@ -3574,7 +3605,7 @@ status_command() {
[ $# -eq 0 ] || missing_argument [ $# -eq 0 ] || missing_argument
[ $VERBOSITY -ge 1 ] && echo "${g_product}-$SHOREWALL_VERSION Status at $g_hostname - $(date)" && echo [ $VERBOSITY -ge 1 ] && echo "${g_product} $SHOREWALL_VERSION Status at $g_hostname - $(date)" && echo
show_status show_status
[ -n "$interfaces" ] && show_interfaces [ -n "$interfaces" ] && show_interfaces
exit $status exit $status
@@ -3622,6 +3653,7 @@ reject_command() {
blacklist_command() { blacklist_command() {
local family local family
local timeout
[ $# -gt 0 ] || fatal_error "Missing address" [ $# -gt 0 ] || fatal_error "Missing address"
@@ -3639,10 +3671,17 @@ blacklist_command() {
;; ;;
esac esac
if $IPSET -A $g_blacklistipset $@ -exist; then if [ $COMMAND = 'blacklist!' ]; then
timeout='timeout 0'
else
echo "$@" | fgrep -q ' timeout ' || timeout="timeout $g_dbltimeout"
fi
if $IPSET -A $g_blacklistipset $@ $timeout -exist; then
local message local message
progress_message2 "$1 Blacklisted" progress_message2 "$1 Blacklisted"
[ -n "$g_dbllog" ] && mylogger daemon.info "$g_product: $1 Blacklisted"
if [ -n "$g_disconnect" ]; then if [ -n "$g_disconnect" ]; then
message="$(conntrack -D -s $1 2>&1)" message="$(conntrack -D -s $1 2>&1)"
@@ -3897,7 +3936,7 @@ setup_dbl() {
case $DYNAMIC_BLACKLIST in case $DYNAMIC_BLACKLIST in
ipset*,src-dst*) ipset*,src-dst*)
# #
# This utility doesn't need to know about 'src-dst' # Capture 'src-dst'
# #
DYNAMIC_BLACKLIST=$(echo $DYNAMIC_BLACKLIST | sed 's/,src-dst//') DYNAMIC_BLACKLIST=$(echo $DYNAMIC_BLACKLIST | sed 's/,src-dst//')
@@ -3905,11 +3944,49 @@ setup_dbl() {
;; ;;
esac esac
case $DYNAMIC_BLACKLIST in
ipset*,log*)
#
# Capture 'log'
#
DYNAMIC_BLACKLIST=$(echo $DYNAMIC_BLACKLIST | sed 's/,log//')
g_dbllog=Yes
;;
esac
case $DYNAMIC_BLACKLIST in
ipset*,noupdate*)
#
# This utility doesn't use this option
#
DYNAMIC_BLACKLIST=$(echo $DYNAMIC_BLACKLIST | sed 's/,noupdate//')
;;
esac
case $DYNAMIC_BLACKLIST in case $DYNAMIC_BLACKLIST in
ipset*,timeout*) ipset*,timeout*)
# #
# This utility doesn't need to know about 'timeout=nnn' # Capture timeout
# #
local ifs
local f
ifs=$IFS
IFS=','
for f in $DYNAMIC_BLACKLIST; do
case $f in
timeout=*)
g_dbltimeout=${f#timeout=}
g_dbltimeout=${g_dbltimeout%%:*}
break
;;
esac
done
IFS=$ifs
DYNAMIC_BLACKLIST=$(echo $DYNAMIC_BLACKLIST | sed -r 's/,timeout=[[:digit:]]+//') DYNAMIC_BLACKLIST=$(echo $DYNAMIC_BLACKLIST | sed -r 's/,timeout=[[:digit:]]+//')
;; ;;
esac esac
@@ -3942,9 +4019,15 @@ setup_dbl() {
# the Standard CLI by loading lib.cli-std # the Standard CLI by loading lib.cli-std
################################################################################ ################################################################################
# #
# Set the configuration variables from shorewall[6]-lite.conf. # Set the configuration variables from shorewall[6]-lite.conf. This function
# is replaced by the one in lib.cli-std (Shorewall product) when Shorewall or
# Shorewall6 is being run.
# #
get_config() { # $1 = Yes: read the params file
# $2 = Yes: check for STARTUP_ENABLED
# $3 = Yes: Check for LOGFILE
#
lite_get_config() {
local config local config
local lib local lib
@@ -3964,7 +4047,7 @@ get_config() {
ensure_config_path ensure_config_path
[ -f $g_firewall.conf ] && . ${VARDIR}/firewall.conf [ -f ${VARDIR}/firewall.conf ] && . ${VARDIR}/firewall.conf
[ -n "$PATH" ] || PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin [ -n "$PATH" ] || PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
@@ -4093,7 +4176,7 @@ get_config() {
[ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable" [ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable"
g_pager="| $g_pager" g_pager="2>&1 | $g_pager"
fi fi
fi fi
@@ -4106,10 +4189,22 @@ get_config() {
[ -f $lib ] && . $lib [ -f $lib ] && . $lib
} }
#
# get_config() -- calls the appropriate xxx_get_config()
#
get_config() {
if [ -z "$g_lite" ]; then
std_get_config $@
else
lite_get_config $@
fi
}
# #
# Start Command Executor # Start Command Executor
# #
start_command() { lite_start_command() {
local finished local finished
finished=0 finished=0
@@ -4127,7 +4222,7 @@ start_command() {
rc=$? rc=$?
else else
error_message "$g_firewall is missing or is not executable" error_message "$g_firewall is missing or is not executable"
mylogger kern.err "ERROR:$g_product start failed" mylogger daemon.err "ERROR:$g_product start failed"
rc=6 rc=6
fi fi
@@ -4196,10 +4291,21 @@ start_command() {
do_it do_it
} }
#
# start_command() -- calls the appropriate xxx_start_command()
#
start_command() {
if [ -z "$g_lite" ]; then
std_start_command $@
else
lite_start_command $@
fi
}
# #
# Reload/Restart Command Executor # Reload/Restart Command Executor
# #
restart_command() { lite_restart_command() {
local finished local finished
finished=0 finished=0
local rc local rc
@@ -4260,7 +4366,7 @@ restart_command() {
rc=$? rc=$?
else else
error_message "$g_firewall is missing or is not executable" error_message "$g_firewall is missing or is not executable"
mylogger kern.err "ERROR:$g_product $COMMAND failed" mylogger daemon.err "ERROR:$g_product $COMMAND failed"
rc=6 rc=6
fi fi
@@ -4268,6 +4374,17 @@ restart_command() {
return $rc return $rc
} }
#
# restart_command() -- calls the appropriate xxx_restart_command()
#
restart_command() {
if [ -z "$g_lite" ]; then
std_restart_command $@
else
lite_restart_command $@
fi
}
run_command() { run_command() {
if [ -x $g_firewall ] ; then if [ -x $g_firewall ] ; then
run_it $g_firewall $@ run_it $g_firewall $@
@@ -4298,9 +4415,9 @@ usage() # $1 = exit status
echo " add <interface>[:<host-list>] ... <zone>" echo " add <interface>[:<host-list>] ... <zone>"
echo " allow <address> ..." echo " allow <address> ..."
echo " blacklist <address> [ <option> ... ]" echo " blacklist <address> [ <option> ... ]"
ecko " [ check | ck ] [ -e ] [ -r ] [ -p ] [ -r ] [ -T ] [ -i ] [ <directory> ]" ecko " [ check | ck ] [ -e ] [ -r ] [ -p ] [ -r ] [ -T ] [ -i ] [ -D ] [ <directory> ]"
echo " clear" echo " clear"
ecko " [ compile | co ] [ -e ] [ -p ] [ -t ] [ -c ] [ -d ] [ -T ] [ -i ] [ <directory name> ] [ <path name> ]" ecko " [ compile | co ] [ -e ] [ -p ] [ -t ] [ -c ] [ -d ] [ -T ] [ -i ] [ -D ] [ <directory name> ] [ <path name> ]"
echo " close <source> <dest> [ <protocol> [ <port> ] ]" echo " close <source> <dest> [ <protocol> [ <port> ] ]"
echo " delete <interface>[:<host-list>] ... <zone>" echo " delete <interface>[:<host-list>] ... <zone>"
echo " disable <interface>" echo " disable <interface>"
@@ -4340,7 +4457,7 @@ usage() # $1 = exit status
if [ -n "$g_lite" ]; then if [ -n "$g_lite" ]; then
echo " reload [ -n ] [ -p ] [ -f ] [ -C ] [ <directory> ]" echo " reload [ -n ] [ -p ] [ -f ] [ -C ] [ <directory> ]"
else else
echo " reload [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ -C ] [ <directory> ]" echo " reload [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ -C ] [ -D ] [ <directory> ]"
fi fi
if [ -z "$g_lite" ]; then if [ -z "$g_lite" ]; then
@@ -4356,7 +4473,7 @@ usage() # $1 = exit status
if [ -n "$g_lite" ]; then if [ -n "$g_lite" ]; then
echo " restart [ -n ] [ -p ] [ -f ] [ -C ] [ <directory> ]" echo " restart [ -n ] [ -p ] [ -f ] [ -C ] [ <directory> ]"
else else
echo " restart [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ -C ] [ <directory> ]" echo " restart [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ -C ] [ -D ] [ <directory> ]"
fi fi
echo " restore [ -n ] [ -p ] [ -C ] [ <file name> ]" echo " restore [ -n ] [ -p ] [ -C ] [ <file name> ]"
@@ -4371,12 +4488,11 @@ usage() # $1 = exit status
echo " [ show | list | ls ] arptables" echo " [ show | list | ls ] arptables"
echo " [ show | list | ls ] [ -f ] capabilities" echo " [ show | list | ls ] [ -f ] capabilities"
echo " [ show | list | ls ] [ -x ] {bl|blacklists}" echo " [ show | list | ls ] [ -x ] {bl|blacklists}"
echo " [ show | list | ls ] classifiers" echo " [ show | list | ls ] {classifiers|filters)"
echo " [ show | list | ls ] config" echo " [ show | list | ls ] config"
echo " [ show | list | ls ] connections" echo " [ show | list | ls ] connections"
echo " [ show | list | ls ] event [ <event> ...]" echo " [ show | list | ls ] event [ <event> ...]"
echo " [ show | list | ls ] events" echo " [ show | list | ls ] events"
echo " [ show | list | ls ] filters"
echo " [ show | list | ls ] ip" echo " [ show | list | ls ] ip"
if [ $g_family -eq 4 ]; then if [ $g_family -eq 4 ]; then
@@ -4458,6 +4574,8 @@ shorewall_cli() {
g_disconnect= g_disconnect=
g_havemutex= g_havemutex=
g_trace= g_trace=
g_dbltimeout=
g_dbllog=
VERBOSE= VERBOSE=
VERBOSITY=1 VERBOSITY=1
@@ -4635,7 +4753,7 @@ shorewall_cli() {
exit 1 exit 1
fi fi
banner="${g_product}-${SHOREWALL_VERSION} Status at $g_hostname -" banner="${g_product} ${SHOREWALL_VERSION} Status at $g_hostname -"
COMMAND=$1 COMMAND=$1
@@ -4679,7 +4797,7 @@ shorewall_cli() {
fatal_error "$g_product is not running" fatal_error "$g_product is not running"
fi fi
;; ;;
blacklist) blacklist|blacklist!)
only_root only_root
get_config Yes get_config Yes
shift shift
@@ -4725,7 +4843,7 @@ shorewall_cli() {
logwatch) logwatch)
only_root only_root
get_config Yes Yes Yes get_config Yes Yes Yes
banner="${g_product}-$SHOREWALL_VERSION Logwatch at $g_hostname -" banner="${g_product} $SHOREWALL_VERSION Logwatch at $g_hostname -"
logwatch_command $@ logwatch_command $@
;; ;;
drop) drop)
@@ -4757,7 +4875,7 @@ shorewall_cli() {
;; ;;
allow) allow)
only_root only_root
get_config get_config Yes
allow_command $@ allow_command $@
;; ;;
add) add)

View File

@@ -3,7 +3,7 @@
# #
# (c) 2010-2018 - Tom Eastep (teastep@shorewall.net) # (c) 2010-2018 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -55,13 +55,13 @@ startup_error() # $* = Error Message
case $COMMAND in case $COMMAND in
start) start)
mylogger kern.err "ERROR:$g_product start failed:Firewall state not changed" mylogger daemon.err "ERROR:$g_product start failed:Firewall state not changed"
;; ;;
restart) restart)
mylogger kern.err "ERROR:$g_product restart failed:Firewall state not changed" mylogger daemon.err "ERROR:$g_product restart failed:Firewall state not changed"
;; ;;
restore) restore)
mylogger kern.err "ERROR:$g_product restore failed:Firewall state not changed" mylogger daemon.err "ERROR:$g_product restore failed:Firewall state not changed"
;; ;;
esac esac

View File

@@ -3,7 +3,7 @@
# #
# (c) 1999-2017 - Tom Eastep (teastep@shorewall.net) # (c) 1999-2017 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -337,8 +337,15 @@ ensure_config_path() {
. $F . $F
fi fi
if [ -n "$g_shorewalldir" ]; then if [ -n "$g_shorewalldir" ] && [ "${CONFIG_PATH%%:*}" = "$g_shorewalldir" ];then
[ "${CONFIG_PATH%%:*}" = "$g_shorewalldir" ] || CONFIG_PATH=$g_shorewalldir:$CONFIG_PATH case $CONFIG_PATH in
:*)
CONFIG_PATH=${g_shorewalldir}${CONFIG_PATH}
;;
*)
CONFIG_PATH=$g_shorewalldir:$CONFIG_PATH
;;
esac
fi fi
} }

View File

@@ -4,7 +4,7 @@
# (c) 2017 - Tom Eastep (teastep@shorewall.net) # (c) 2017 - Tom Eastep (teastep@shorewall.net)
# (c) 2017 - Matt Darfeuille (matdarf@gmail.com) # (c) 2017 - Matt Darfeuille (matdarf@gmail.com)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -4,7 +4,7 @@
# (c) 2017 - Tom Eastep (teastep@shorewall.net) # (c) 2017 - Tom Eastep (teastep@shorewall.net)
# (c) 2017 - Matt Darfeuille (matdarf@gmail.com) # (c) 2017 - Matt Darfeuille (matdarf@gmail.com)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -48,7 +48,7 @@
<arg>options</arg> <arg>options</arg>
<arg choice="plain"><option>blacklist</option></arg> <arg choice="plain"><option>blacklist[!]</option></arg>
<arg <arg
choice="plain"><replaceable>address</replaceable><arg><replaceable>option</replaceable> choice="plain"><replaceable>address</replaceable><arg><replaceable>option</replaceable>
@@ -981,7 +981,22 @@
<td><command>shorewall -6</command> or <command>shorewall <td><command>shorewall -6</command> or <command>shorewall
-6l</command></td> -6l</command></td>
</tr> </tr>
<tr>
<td><command>shorewall</command></td>
<td><command>shorewall -l</command></td>
</tr>
</table> </table>
<para>Note that when Shorewall isn't installed, the 'shorewall'
command behaves like shorewall-lite. The same is not true with
respect to Shorewall6, "shorewall6" and 'shorewall6-lite". You can
make 'shorewall6' behave like 'shorewallt-lite' by adding the
following command to root's .profile file (or to .bashrc, if root's
shell is bash):</para>
<programlisting> alias shorewall6=shorewall6-lite</programlisting>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -1151,7 +1166,7 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">blacklist</emphasis> <term><emphasis role="bold">blacklist[!]</emphasis>
<replaceable>address</replaceable> [ <replaceable>option</replaceable> <replaceable>address</replaceable> [ <replaceable>option</replaceable>
... ]</term> ... ]</term>
@@ -1165,7 +1180,17 @@
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5). The url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5). The
<replaceable>address</replaceable> along with any <replaceable>address</replaceable> along with any
<replaceable>option</replaceable>s are passed to the <command>ipset <replaceable>option</replaceable>s are passed to the <command>ipset
add</command> command.</para> add</command> command. Probably the most useful
<replaceable>option</replaceable> is the <option>timeout</option>
option. For example, to permanently blacklist 192.0.2.22, the
command would be:</para>
<programlisting> shorewall blacklist 192.0.2.22 timeout 0</programlisting>
<para>Beginning with Shorewall 5.2.5, the above command can be
shortened to:</para>
<programlisting> shorewall blacklist! 192.0.2.22</programlisting>
<para>If the <option>disconnect</option> option is specified in the <para>If the <option>disconnect</option> option is specified in the
DYNAMIC_BLACKLISTING setting, then the effective VERBOSITY DYNAMIC_BLACKLISTING setting, then the effective VERBOSITY
@@ -2108,10 +2133,6 @@
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5) url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5)
(<ulink (<ulink
url="/manpages/shorewall.conf.html">shorewall6.conf</ulink>(5).</para> url="/manpages/shorewall.conf.html">shorewall6.conf</ulink>(5).</para>
<para>The <emphasis role="bold">-D </emphasis>option was added in
Shoewall 5.2.4 and causes the compiler to write a large amount of
debugging information to standard output.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -2452,8 +2473,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">bl|blacklists</emphasis> <term><emphasis role="bold">[-<option>x</option>]
[-<option>x</option>]</term> bl|blacklists</emphasis></term>
<listitem> <listitem>
<para>Added in Shorewall 4.6.2. Displays the dynamic chain <para>Added in Shorewall 4.6.2. Displays the dynamic chain
@@ -2521,7 +2542,9 @@
<listitem> <listitem>
<para>Displays information about the packet classifiers <para>Displays information about the packet classifiers
defined on the system as a result of traffic shaping defined on the system as a result of traffic shaping
configuration.</para> configuration. Beginning with Shorewall 5.2.8, this command is
deprecated, as its output is included in the information
displayed by the 'show tc' command.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -2891,25 +2914,18 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">stop</emphasis> <term><emphasis role="bold">stop</emphasis></term>
[-<option>f</option>]</term>
<listitem> <listitem>
<para>Stops the firewall. All existing connections, except those <para>Stops the firewall. All existing connections, except those
listed in <ulink listed in <ulink
url="/manpages/shorewall-routestopped.html">shorewall-routestopped</ulink>(5) url="/manpages/shorewall-stoppedrules.html">shorewall-stoppedrules</ulink>(5)
or permitted by the ADMINISABSENTMINDED option in <ulink or permitted by the ADMINISABSENTMINDED option in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5), are url="/manpages/shorewall.conf.html">shorewall.conf</ulink>, are taken
taken down. The only new traffic permitted through the firewall is down. The only new traffic permitted through the firewall is from
from systems listed in <ulink systems listed in <ulink
url="/manpages/shorewall-routestopped.html">shorewall-routestopped</ulink>(5) url="/manpages/shorewall-stoppedrules.html">shorewall-stoppedrules</ulink>(5)
or by ADMINISABSENTMINDED.</para> or by ADMINISABSENTMINDED.</para>
<para>If <option>-f</option> is given, the command will be processed
by the compiled script that executed the last successful <emphasis
role="bold">start</emphasis>, <emphasis
role="bold">restart</emphasis> or <emphasis
role="bold">reload</emphasis> command if that script exists.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -3170,7 +3186,7 @@
<simplelist> <simplelist>
<member><ulink <member><ulink
url="/starting_and_stopping_shorewall.htm">http://www.shorewall.org/starting_and_stopping_shorewall.htm</ulink> url="/starting_and_stopping_shorewall.htm">https://shorewall.org/starting_and_stopping_shorewall.htm</ulink>
- Describes operational aspects of Shorewall.</member> - Describes operational aspects of Shorewall.</member>
<member><ulink url="shorewall-files.html">shorewall-files(5)</ulink> - <member><ulink url="shorewall-files.html">shorewall-files(5)</ulink> -

View File

@@ -5,7 +5,7 @@
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2014,2015-2017 # (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2014,2015-2017
# Tom Eastep (teastep@shorewall.net) # Tom Eastep (teastep@shorewall.net)
# #
# Shorewall documentation is available at http://www.shorewall.org # Shorewall documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -22,3 +22,4 @@ SPARSE=Yes #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR
VARLIB=/var/lib #Directory where product variable data is stored. VARLIB=/var/lib #Directory where product variable data is stored.
VARDIR=${VARLIB}/$PRODUCT #Directory where product variable data is stored. VARDIR=${VARLIB}/$PRODUCT #Directory where product variable data is stored.
DEFAULT_PAGER=/usr/bin/less #Pager to use if none specified in shorewall[6].conf DEFAULT_PAGER=/usr/bin/less #Pager to use if none specified in shorewall[6].conf
STOPSERVICEFILE=stop_service.debian #Name of script to stop systemd service that honours `SAFESTOP`.

View File

@@ -0,0 +1,19 @@
#!/bin/sh
PRODUCT=$1
. /etc/default/${PRODUCT}
if [ "$SAFESTOP" = 1 ]; then
COMMAND=stop
else
COMMAND=clear
fi
if [ "${PRODUCT}" = shorewall6 ]; then
EXEC="/sbin/shorewall -6"
else
EXEC="/sbin/${PRODUCT}"
fi
exec ${EXEC} ${OPTIONS} ${COMMAND}

View File

@@ -4,7 +4,7 @@
# #
# (c) 2000-2016 - Tom Eastep (teastep@shorewall.net) # (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
# #
# Shorewall documentation is available at http://www.shorewall.org # Shorewall documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -134,6 +134,7 @@ fi
remove_directory ${SHAREDIR}/shorewall remove_directory ${SHAREDIR}/shorewall
remove_file ~/.shorewallrc remove_file ~/.shorewallrc
remove_file ${SBINDIR}/shorewall
# #
# Report Success # Report Success

View File

@@ -6,7 +6,7 @@
# #
# This file is installed in /usr/share/shorewall/wait4ifup # This file is installed in /usr/share/shorewall/wait4ifup
# #
# Shorewall documentation is available at http://www.shorewall.org # Shorewall documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -6,7 +6,7 @@
# #
# (c) 2010,2013 - Tom Eastep (teastep@shorewall.net) # (c) 2010,2013 - Tom Eastep (teastep@shorewall.net)
# #
# Shorewall documentation is available at http://shorewall.org # Shorewall documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License
@@ -110,7 +110,7 @@ case $0 in
;; ;;
*) *)
# #
# Debian ifupdown system # Debian ifupdown system - MODE and INTERFACE inherited from the environment
# #
INTERFACE="$IFACE" INTERFACE="$IFACE"
@@ -127,6 +127,17 @@ esac
[ -n "$LOGFILE" ] || LOGFILE=/dev/null [ -n "$LOGFILE" ] || LOGFILE=/dev/null
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if [ -n "$ADDRFAM" -a ${COMMAND} = up ]; then
case $PRODUCT in
*6*)
[ ${ADDRFAM} = inet6 ] || continue
;;
*)
[ ${ADDRFAM} = inet ] || continue
;;
esac
fi
setstatedir setstatedir
if [ -x $VARLIB/$PRODUCT/firewall ]; then if [ -x $VARLIB/$PRODUCT/firewall ]; then

View File

@@ -6,7 +6,7 @@
# #
# (c) 2010,2013 - Tom Eastep (teastep@shorewall.net) # (c) 2010,2013 - Tom Eastep (teastep@shorewall.net)
# #
# Shorewall documentation is available at http://shorewall.org # Shorewall documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License
@@ -90,7 +90,14 @@ case $0 in
COMMAND=down COMMAND=down
;; ;;
*dispatcher.d*) *dispatcher.d*)
COMMAND="$2" case "$2" in
up|down)
COMMAND="$2"
;;
*)
exit 0
;;
esac
;; ;;
*) *)
exit 0 exit 0

View File

@@ -6,7 +6,7 @@
# #
# (c) 2010,2013 - Tom Eastep (teastep@shorewall.net) # (c) 2010,2013 - Tom Eastep (teastep@shorewall.net)
# #
# Shorewall documentation is available at http://shorewall.org # Shorewall documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License
@@ -120,7 +120,14 @@ case $0 in
case $0 in case $0 in
*dispatcher.d*) *dispatcher.d*)
INTERFACE="$1" INTERFACE="$1"
COMMAND="$2" case "$2" in
up|down)
COMMAND="$2"
;;
*)
exit 0
;;
esac
;; ;;
*if-up.d*) *if-up.d*)
COMMAND=up COMMAND=up

View File

@@ -8,7 +8,7 @@
# #
# On most distributions, this file should be called /etc/init.d/shorewall. # On most distributions, this file should be called /etc/init.d/shorewall.
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -7,7 +7,7 @@
# #
# On most distributions, this file should be called /etc/init.d/shorewall. # On most distributions, this file should be called /etc/init.d/shorewall.
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -5,7 +5,7 @@
# (c) 2000-2016 - Tom Eastep (teastep@shorewall.net) # (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
# (c) 2010 - Roberto C. Sanchez (roberto@connexer.com) # (c) 2010 - Roberto C. Sanchez (roberto@connexer.com)
# #
# Shorewall documentation is available at http://shorewall.org # Shorewall documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -169,7 +169,7 @@ if [ -z "$BUILD" ]; then
;; ;;
*) *)
if [ -f /etc/os-release ]; then if [ -f /etc/os-release ]; then
eval $(cat /etc/os-release | grep ^ID=) ID=$(grep '^ID=' /etc/os-release | sed 's/ID=//; s/"//g;')
case $ID in case $ID in
fedora|rhel|centos|foobar) fedora|rhel|centos|foobar)
@@ -357,12 +357,11 @@ fi
if [ $HOST = debian ]; then if [ $HOST = debian ]; then
if [ -n "${DESTDIR}" ]; then if [ -n "${DESTDIR}" ]; then
make_parent_directory ${DESTDIR}${ETC}/network/if-up.d 0755 make_parent_directory ${DESTDIR}${ETC}/network/if-up.d 0755
make_parent_directory ${DESTDIR}${ETC}/network/if-down.d 0755
make_parent_directory ${DESTDIR}${ETC}/network/if-post-down.d 0755 make_parent_directory ${DESTDIR}${ETC}/network/if-post-down.d 0755
elif [ $configure -eq 0 ]; then elif [ $configure -eq 0 ]; then
make_parent_directory ${DESTDIR}${CONFDIR}/network/if-up.d 0755 make_parent_directory ${CONFDIR}/network/if-up.d 0755
make_parent_directory ${DESTDIR}${CONFDIR}/network/if-down.d 0755 make_parent_directory ${CONFDIR}/network/if-post-down.d 0755
make_parent_directory ${DESTDIR}${CONFDIR}/network/if-post-down.d 0755 rm -f ${CONFDIR}/network/if-down.d/shorewall
fi fi
if [ ! -f ${DESTDIR}${CONFDIR}/default/$PRODUCT ]; then if [ ! -f ${DESTDIR}${CONFDIR}/default/$PRODUCT ]; then
@@ -388,7 +387,7 @@ else
elif [ $HOST = openwrt ]; then elif [ $HOST = openwrt ]; then
# Not implemented on OpenWRT # Not implemented on OpenWRT
/bin/true /bin/true
else elif [ "$HOST" != debian ]; then
make_parent_directory ${DESTDIR}/${ETC}/NetworkManager/dispatcher.d 0755 make_parent_directory ${DESTDIR}/${ETC}/NetworkManager/dispatcher.d 0755
fi fi
fi fi
@@ -417,19 +416,22 @@ if [ $HOST != openwrt ]; then
fi fi
if [ -d ${DESTDIR}/etc/NetworkManager ]; then if [ -d ${DESTDIR}/etc/NetworkManager ]; then
[ $configure -eq 1 ] || make_parent_directory ${DESTDIR}${CONFDIR}/NetworkManager/dispatcher.d 0755 if [ "$HOST" = debian ]; then
install_file ifupdown ${DESTDIR}${ETC}/NetworkManager/dispatcher.d/01-shorewall 0544 rm -f ${DESTDIR}${ETC}/NetworkManager/dispatcher.d/01-shorewall
else
[ $configure -eq 1 ] || make_parent_directory ${DESTDIR}${CONFDIR}/NetworkManager/dispatcher.d 0755
install_file ifupdown ${DESTDIR}${ETC}/NetworkManager/dispatcher.d/01-shorewall 0544
fi
fi fi
case $HOST in case $HOST in
debian) debian)
if [ $configure -eq 1 ]; then if [ $configure -eq 1 ]; then
install_file ifupdown ${DESTDIR}/etc/network/if-up.d/shorewall 0544 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 install_file ifupdown ${DESTDIR}/etc/network/if-post-down.d/shorewall 0544
rm -f ${DESTDIR}/etc/network/if-down.d/shorewall
else else
install_file ifupdown ${DESTDIR}${CONFDIR}/network/if-up.d/shorewall 0544 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 install_file ifupdown ${DESTDIR}${CONFDIR}/network/if-post-down.d/shorewall 0544
fi fi
;; ;;

View File

@@ -6,7 +6,7 @@
# On most distributions, this file should be called # On most distributions, this file should be called
# /etc/init.d/shorewall. # /etc/init.d/shorewall.
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -25,6 +25,7 @@
# #
############################################################################### ###############################################################################
# set the STATEDIR variable # set the STATEDIR variable
setstatedir() { setstatedir() {
local statedir local statedir
if [ -f ${CONFDIR}/${PRODUCT}/vardir ]; then if [ -f ${CONFDIR}/${PRODUCT}/vardir ]; then
@@ -42,6 +43,67 @@ setstatedir() {
fi fi
} }
# Initialize the firewalls
shorewall_init_start () {
local PRODUCT
local STATEDIR
printf "Initializing \"Shorewall-based firewalls\": "
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
ipset -R < "$SAVE_IPSETS"
fi
for PRODUCT in $PRODUCTS; do
if setstatedir; 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
done
return 0
}
# Clear the firewalls
shorewall_init_stop () {
local PRODUCT
local STATEDIR
printf "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do
if setstatedir; then
#
# Run in sub-shell to avoid name collisions
#
(
if ! ${STATEDIR}/firewall status > /dev/null 2>&1; then
${STATEDIR}/firewall ${OPTIONS} clear
fi
)
fi
done
if [ -n "$SAVE_IPSETS" ]; then
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" || rm -f "${SAVE_IPSETS}.tmp"
else
rm -f "${SAVE_IPSETS}.tmp"
fi
fi
return 0
}
# #
# This is modified by the installer when ${SHAREDIR} <> /usr/share # This is modified by the installer when ${SHAREDIR} <> /usr/share
# #
@@ -59,62 +121,12 @@ else
exit 1 exit 1
fi fi
# Initialize the firewall
shorewall_start () {
local PRODUCT
local STATEDIR
printf "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do
if setstatedir; 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
done
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
ipset -R < "$SAVE_IPSETS"
fi
return 0
}
# Clear the firewall
shorewall_stop () {
local PRODUCT
local STATEDIR
printf "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do
if setstatedir; then
${STATEDIR}/firewall ${OPTIONS} clear
fi
done
if [ -n "$SAVE_IPSETS" ]; then
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" || rm -f "${SAVE_IPSETS}.tmp"
else
rm -f "${SAVE_IPSETS}.tmp"
fi
fi
return 0
}
case "$1" in case "$1" in
start) start)
shorewall_start shorewall_init_start
;; ;;
stop) stop)
shorewall_stop shorewall_init_stop
;; ;;
*) *)
echo "Usage: $0 {start|stop}" echo "Usage: $0 {start|stop}"

View File

@@ -12,7 +12,7 @@ Wants=network-pre.target
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
EnvironmentFile=-/etc/sysconfig/shorewall-init EnvironmentFile=-/etc/sysconfig/shorewall-init
StandardOutput=syslog StandardOutput=journal
ExecStart=/sbin/shorewall-init start ExecStart=/sbin/shorewall-init start
ExecStop=/sbin/shorewall-init stop ExecStop=/sbin/shorewall-init stop

View File

@@ -6,6 +6,7 @@
# #
[Unit] [Unit]
Description=Shorewall firewall (bootup security) Description=Shorewall firewall (bootup security)
Documentation=man:shorewall-init(8)
Before=network.target Before=network.target
[Service] [Service]

View File

@@ -1 +1 @@
5.2.4-Beta1 5.2.4.1

View File

@@ -13,8 +13,8 @@
. /lib/lsb/init-functions . /lib/lsb/init-functions
SRWL='/sbin/shorewall -l' SRWL=/sbin/shorewall
SRWL_OPTS="-tvv" SRWL_OPTS="-ltvv"
test -n ${INITLOG:=/var/log/shorewall-lite-init.log} test -n ${INITLOG:=/var/log/shorewall-lite-init.log}
[ "$INITLOG" = "/dev/null" ] && SHOREWALL_INIT_SCRIPT=1 || SHOREWALL_INIT_SCRIPT=0 [ "$INITLOG" = "/dev/null" ] && SHOREWALL_INIT_SCRIPT=1 || SHOREWALL_INIT_SCRIPT=0

View File

@@ -7,7 +7,7 @@
# #
# On most distributions, this file should be called /etc/init.d/shorewall. # On most distributions, this file should be called /etc/init.d/shorewall.
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -7,7 +7,7 @@ RCDLINKS="2,S41 3,S41 6,K41"
# #
# On most distributions, this file should be called /etc/init.d/shorewall. # On most distributions, this file should be called /etc/init.d/shorewall.
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -8,7 +8,7 @@
# #
# On most distributions, this file should be called /etc/init.d/shorewall. # On most distributions, this file should be called /etc/init.d/shorewall.
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -4,7 +4,7 @@
# #
# (c) 2000-2016 - Tom Eastep (teastep@shorewall.net) # (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
# #
# Shorewall documentation is available at http://shorewall.org # Shorewall documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -3,7 +3,7 @@
# #
# (c) 2011,2014 - Tom Eastep (teastep@shorewall.net) # (c) 2011,2014 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -183,7 +183,7 @@
<title>See ALSO</title> <title>See ALSO</title>
<para><ulink <para><ulink
url="http://www.shorewall.org/Documentation_Index.html">http://www.shorewall.org/Documentation_Index.html</ulink></para> url="https://shorewall.org/Documentation_Index.html">https://shorewall.org/Documentation_Index.html</ulink></para>
<para>shorewall-lite(8), shorewall-accounting(5), shorewall-actions(5), <para>shorewall-lite(8), shorewall-accounting(5), shorewall-actions(5),
shorewall-blacklist(5), shorewall-hosts(5), shorewall-interfaces(5), shorewall-blacklist(5), shorewall-hosts(5), shorewall-interfaces(5),

View File

@@ -8,7 +8,7 @@
# "man shorewall-lite.conf" # "man shorewall-lite.conf"
# #
# Manpage also online at # Manpage also online at
# http://www.shorewall.org/manpages/shorewall-lite.conf.html # https://shorewall.org/manpages/shorewall-lite.conf.html
############################################################################### ###############################################################################
# N 0 T E # N 0 T E
############################################################################### ###############################################################################

View File

@@ -13,7 +13,7 @@ Conflicts=iptables.service firewalld.service
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
EnvironmentFile=-/etc/sysconfig/shorewall-lite EnvironmentFile=-/etc/sysconfig/shorewall-lite
StandardOutput=syslog StandardOutput=journal
ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS
ExecStop=/sbin/shorewall-lite $OPTIONS stop ExecStop=/sbin/shorewall-lite $OPTIONS stop

View File

@@ -6,6 +6,7 @@
# #
[Unit] [Unit]
Description=Shorewall IPv4 firewall (lite) Description=Shorewall IPv4 firewall (lite)
Documentation=man:shorewall-lite(8)
Wants=network-online.target Wants=network-online.target
After=network-online.target After=network-online.target
Conflicts=iptables.service firewalld.service Conflicts=iptables.service firewalld.service
@@ -16,7 +17,7 @@ RemainAfterExit=yes
EnvironmentFile=-/etc/default/shorewall-lite EnvironmentFile=-/etc/default/shorewall-lite
StandardOutput=syslog StandardOutput=syslog
ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS
ExecStop=/sbin/shorewall-lite $OPTIONS clear ExecStop=/usr/share/shorewall/stop_service shorewall-lite
ExecReload=/sbin/shorewall-lite $OPTIONS reload $RELOADOPTIONS ExecReload=/sbin/shorewall-lite $OPTIONS reload $RELOADOPTIONS
[Install] [Install]

View File

@@ -7,7 +7,7 @@
# #
# (c) 2012-2017 Tom Eastep (teastep@shorewall.net) # (c) 2012-2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -7,7 +7,7 @@
# #
# (c) 2012-2017 Tom Eastep (teastep@shorewall.net) # (c) 2012-2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -20,22 +20,23 @@ DEFAULTS ACCEPT
# The following should have a ttl of 255 and must be allowed to transit a bridge # The following should have a ttl of 255 and must be allowed to transit a bridge
@1 - - ipv6-icmp router-solicitation @1 - - ipv6-icmp router-solicitation
@1 - - ipv6-icmp router-advertisement
@1 - - ipv6-icmp neighbour-solicitation @1 - - ipv6-icmp neighbour-solicitation
@1 - - ipv6-icmp neighbour-advertisement @1 - - ipv6-icmp neighbour-advertisement
@1 - - ipv6-icmp 137 # Redirect
@1 - - ipv6-icmp 141 # Inverse neighbour discovery solicitation @1 - - ipv6-icmp 141 # Inverse neighbour discovery solicitation
@1 - - ipv6-icmp 142 # Inverse neighbour discovery advertisement @1 - - ipv6-icmp 142 # Inverse neighbour discovery advertisement
# The following should have a link local source address and must be allowed to transit a bridge # The following must have a link local source address and must be allowed to transit a bridge
@1 fe80::/10 - ipv6-icmp 130 # Listener query @1 fe80::/10 - ipv6-icmp 130 # Listener query
@1 fe80::/10 - ipv6-icmp 131 # Listener report @1 fe80::/10 - ipv6-icmp 131 # Listener report
@1 fe80::/10 - ipv6-icmp 132 # Listener done @1 fe80::/10 - ipv6-icmp 132 # Listener done
@1 fe80::/10 - ipv6-icmp router-advertisement
@1 :: - ipv6-icmp 143 # Listener report v2
@1 fe80::/10 - ipv6-icmp 143 # Listener report v2 @1 fe80::/10 - ipv6-icmp 143 # Listener report v2
# The following should be received with a ttl of 255 and must be allowed to transit a bridge # The following should be received with a ttl of 255 and must be allowed to transit a bridge
@1 - - ipv6-icmp 148 # Certificate path solicitation @1 :: - ipv6-icmp 148 # Certificate path solicitation
@1 - - ipv6-icmp 149 # Certificate path advertisement @1 fe80::/10 - ipv6-icmp 148 # Certificate path solicitation
@1 fe80::/10 - ipv6-icmp 149 # Certificate path advertisement
# The following should have a link local source address and a ttl of 1 and must be allowed to transit a bridge # The following should have a link local source address and a ttl of 1 and must be allowed to transit a bridge
@1 fe80::/10 - ipv6-icmp 151 # Multicast router advertisement @1 fe80::/10 - ipv6-icmp 151 # Multicast router advertisement

View File

@@ -5,7 +5,7 @@
# #
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net) # (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -7,7 +7,7 @@
# #
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net) # (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -7,7 +7,7 @@
# #
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net) # (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -7,7 +7,7 @@
# #
# (c) 2017 Tom Eastep (teastep@shorewall.net) # (c) 2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -27,7 +27,7 @@
# the IP address that are older than <duration> seconds. # the IP address that are older than <duration> seconds.
# Disposition - Disposition for any event generated. # Disposition - Disposition for any event generated.
# #
# For additional information, see http://www.shorewall.org/Events.html # For additional information, see https://shorewall.org/Events.html
# #
############################################################################### ###############################################################################
# DO NOT REMOVE THE FOLLOWING LINE # DO NOT REMOVE THE FOLLOWING LINE

View File

@@ -6,7 +6,7 @@
# #
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net) # (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -5,7 +5,7 @@
# #
# (c) 2017 Tom Eastep (teastep@shorewall.net) # (c) 2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -5,7 +5,7 @@
# #
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net) # (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -7,7 +7,7 @@
# #
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net) # (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -7,7 +7,7 @@
# #
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net) # (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -7,7 +7,7 @@
# #
# (c) 2012-2017 Tom Eastep (teastep@shorewall.net) # (c) 2012-2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -7,7 +7,7 @@
# #
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net) # (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -13,7 +13,7 @@
# address (dst) # address (dst)
# Disposition - Disposition for any rule generated. # Disposition - Disposition for any rule generated.
# #
# For additional information, see http://www.shorewall.org/Events.html # For additional information, see https://shorewall.org/Events.html
# #
############################################################################### ###############################################################################
# DO NOT REMOVE THE FOLLOWING LINE # DO NOT REMOVE THE FOLLOWING LINE

View File

@@ -13,7 +13,7 @@
# address (dst) # address (dst)
# Disposition - Disposition for any event generated. # Disposition - Disposition for any event generated.
# #
# For additional information, see http://www.shorewall.org/Events.html # For additional information, see https://shorewall.org/Events.html
# #
DEFAULTS -,ACCEPT,src DEFAULTS -,ACCEPT,src

View File

@@ -7,7 +7,7 @@
# #
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net) # (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -5,7 +5,7 @@
# #
# (c) 2017 Tom Eastep (teastep@shorewall.net) # (c) 2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -5,7 +5,7 @@
# #
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net) # (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -5,7 +5,7 @@
# #
# (c) 2017 Tom Eastep (teastep@shorewall.net) # (c) 2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -5,7 +5,7 @@
# #
# (c) 2017 Tom Eastep (teastep@shorewall.net) # (c) 2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -5,7 +5,7 @@
# #
# (c) 2017 Tom Eastep (teastep@shorewall.net) # (c) 2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -5,7 +5,7 @@
# #
# (c) 2017 Tom Eastep (teastep@shorewall.net) # (c) 2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -7,7 +7,7 @@
# #
# (c) 2011-2017 Tom Eastep (teastep@shorewall.net) # (c) 2011-2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -5,7 +5,7 @@
# #
# (c) 2017 Tom Eastep (teastep@shorewall.net) # (c) 2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -5,7 +5,7 @@
# #
# (c) 2017 Tom Eastep (teastep@shorewall.net) # (c) 2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -5,7 +5,7 @@
# #
# (c) 2017 Tom Eastep (teastep@shorewall.net) # (c) 2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -13,7 +13,7 @@
# 2. Copy this file to /etc/shorewall/action.<action name> # 2. Copy this file to /etc/shorewall/action.<action name>
# 3. Add the desired rules to that file. # 3. Add the desired rules to that file.
# #
# Please see http://shorewall.org/Actions.html for additional # Please see https://shorewall.org/Actions.html for additional
# information. # information.
# #
# Columns are the same as in /etc/shorewall/mangle. # Columns are the same as in /etc/shorewall/mangle.

View File

@@ -5,7 +5,7 @@
# #
# (c) 2017 Tom Eastep (teastep@shorewall.net) # (c) 2017 Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -13,7 +13,7 @@
# 2. Copy this file to /etc/shorewall/action.<action name> # 2. Copy this file to /etc/shorewall/action.<action name>
# 3. Add the desired rules to that file. # 3. Add the desired rules to that file.
# #
# Please see http://shorewall.org/Actions.html for additional # Please see https://shorewall.org/Actions.html for additional
# information. # information.
# #
# Columns are the same as in /etc/shorewall/rules. # Columns are the same as in /etc/shorewall/rules.

View File

@@ -21,7 +21,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
# For information about this script, see http://www.shorewall.org/MultiISP.html#swping. # For information about this script, see https://shorewall.org/MultiISP.html#swping.
# #
########################################################################################### ###########################################################################################
# #

View File

@@ -7,7 +7,7 @@
# #
# On most distributions, this file should be called /etc/init.d/shorewall. # On most distributions, this file should be called /etc/init.d/shorewall.
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of Version 2 of the GNU General Public License

View File

@@ -18,7 +18,7 @@ Shoreline Firewall (Shorewall) Version 5
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
Please see http://www.shorewall.org/Install.htm for installation Please see https://shorewall.org/Install.htm for installation
instructions. instructions.

View File

@@ -0,0 +1,12 @@
#
# Shorewall -- /usr/share/shorewall/macro.NFS
#
# This macro handles NFS v4.1+ traffic with default ports.
# You should only allow NFS traffic between hosts you fully trust.
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
PARAM - - tcp 111 # portmapper, rpcbind
PARAM - - tcp 2049 # nfs
PARAM - - tcp 20048 # mountd

View File

@@ -0,0 +1,8 @@
#
# Shorewall --/usr/share/shorewall/macro.TorMetrics
#
# Macro for handling Tor Onion Network traffic
#
##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH HELPER
PARAM - - tcp 9035

View File

@@ -5,7 +5,7 @@
# #
# (c) 2013 - Tom Eastep (teastep@shorewall.net) # (c) 2013 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -5,7 +5,7 @@
# #
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -5,7 +5,7 @@
# #
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -37,6 +37,7 @@ use Shorewall::Config qw(:DEFAULT :internal);
use Shorewall::Zones; use Shorewall::Zones;
use Shorewall::IPAddrs; use Shorewall::IPAddrs;
use strict; use strict;
use sort 'stable';
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT = ( qw( our @EXPORT = ( qw(
@@ -319,6 +320,7 @@ our $VERSION = 'MODULEVERSION';
# %chain_table { <table> => { <chain1> => { name => <chain name> # %chain_table { <table> => { <chain1> => { name => <chain name>
# table => <table name> # table => <table name>
# is_policy => undef|1 -- if 1, this is a policy chain # is_policy => undef|1 -- if 1, this is a policy chain
# wild => undef|1 -- If 1, source or dest is 'all'. Only applies to policy chains
# provisional => undef|1 -- See below. # provisional => undef|1 -- See below.
# referenced => undef|1 -- If 1, will be written to the iptables-restore-input. # referenced => undef|1 -- If 1, will be written to the iptables-restore-input.
# builtin => undef|1 -- If 1, one of Netfilter's built-in chains. # builtin => undef|1 -- If 1, one of Netfilter's built-in chains.
@@ -725,6 +727,7 @@ our %opttype = ( rule => CONTROL,
'icmpv6-type' => UNIQUE, 'icmpv6-type' => UNIQUE,
comment => CONTROL, comment => CONTROL,
digest => CONTROL,
policy => MATCH, policy => MATCH,
state => EXCLUSIVE, state => EXCLUSIVE,
@@ -891,7 +894,7 @@ sub validate_port( $$ ) {
fatal_error "The separator for a port range is ':', not '-' ($port)" if $port =~ /^\d+-\d+$/; fatal_error "The separator for a port range is ':', not '-' ($port)" if $port =~ /^\d+-\d+$/;
fatal_error "Invalid/Unknown $proto port/service ($_[1])" unless defined $value; fatal_error "Invalid/Unknown $proto port/service ($_[1])";
} }
# #
@@ -3520,6 +3523,33 @@ sub irule_to_string( $ ) {
$string; $string;
} }
#
# This one omits the comment
#
sub irule_to_string1( $ ) {
my ( $ruleref ) = @_;
return $ruleref->{cmd} if exists $ruleref->{cmd};
my $string = '';
for ( grep ! ( get_opttype( $_, 0 ) & ( CONTROL | TARGET ) ), @{$ruleref->{matches}}) {
my $value = $ruleref->{$_};
if ( reftype $value ) {
$string .= "$_=" . join( ',', @$value ) . ' ';
} else {
$string .= "$_=$value ";
}
}
if ( $ruleref->{target} ) {
$string .= join( ' ', " -$ruleref->{jump}", $ruleref->{target} );
$string .= join( '', ' ', $ruleref->{targetopts} ) if $ruleref->{targetopts};
}
$string;
}
sub calculate_digest( $ ) { sub calculate_digest( $ ) {
my $chainref = shift; my $chainref = shift;
my $rules = ''; my $rules = '';
@@ -3706,6 +3736,16 @@ sub optimize_level0() {
} }
} }
#
# Conditionally sort a list of chain table entry references by name, if -t was specified
#
sub sortchainsiftest(\%) {
my $hashref = shift;
return sort { $a->{name} cmp $b->{name} } values %$hashref if $test;
return values %$hashref;
}
sub optimize_level4( $$ ) { sub optimize_level4( $$ ) {
my ( $table, $tableref ) = @_; my ( $table, $tableref ) = @_;
my $progress = 1; my $progress = 1;
@@ -3927,7 +3967,7 @@ sub optimize_level4( $$ ) {
my @chains = grep ( $_->{referenced} && my @chains = grep ( $_->{referenced} &&
! $_->{optflags} && ! $_->{optflags} &&
@{$_->{rules}} < 4 && @{$_->{rules}} < 4 &&
keys %{$_->{references}} == 1 , values %$tableref ); keys %{$_->{references}} == 1 , sortchainsiftest %$tableref );
if ( my $chains = @chains ) { if ( my $chains = @chains ) {
$passes++; $passes++;
@@ -3936,7 +3976,7 @@ sub optimize_level4( $$ ) {
for my $chainref ( @chains ) { for my $chainref ( @chains ) {
my $name = $chainref->{name}; my $name = $chainref->{name};
for my $sourceref ( map $tableref->{$_}, keys %{$chainref->{references}} ) { for my $sourceref ( map $tableref->{$_}, sortkeysiftest %{$chainref->{references}} ) {
my $name1 = $sourceref->{name}; my $name1 = $sourceref->{name};
if ( $chainref->{references}{$name1} == 1 ) { if ( $chainref->{references}{$name1} == 1 ) {
@@ -4040,7 +4080,7 @@ sub optimize_level8( $$$ ) {
if ( $config{RENAME_COMBINED} && $chainref->{name} !~ /^[~%]/ ) { if ( $config{RENAME_COMBINED} && $chainref->{name} !~ /^[~%]/ ) {
# #
# For simple use of the BLACKLIST section, we can end up with many identical # For simple use of the blrules file, we can end up with many identical
# chains. To distinguish them from other renamed chains, we keep track of # chains. To distinguish them from other renamed chains, we keep track of
# these chains via the 'blacklistsection' member. # these chains via the 'blacklistsection' member.
# #
@@ -4066,7 +4106,7 @@ sub optimize_level8( $$$ ) {
# #
# First create aliases for each renamed chain and change the {name} member. # First create aliases for each renamed chain and change the {name} member.
# #
for my $oldname ( @rename ) { for my $oldname ( sortiftest @rename ) {
my $newname = $renamed{ $oldname } = $rename{ $oldname } . $chainseq++; my $newname = $renamed{ $oldname } = $rename{ $oldname } . $chainseq++;
trace( $tableref->{$oldname}, 'RN', 0, " Renamed $newname" ) if $debug; trace( $tableref->{$oldname}, 'RN', 0, " Renamed $newname" ) if $debug;
@@ -4179,10 +4219,10 @@ sub get_multi_sports( $ ) {
} }
# #
# Return an array of keys for the passed rule. 'dport', 'comment', and 'origin' are omitted; # Return an array of keys for the passed rule. 'dport', 'comment', 'origin' and 'digest' are omitted;
# #
sub get_keys( $ ) { sub get_keys( $ ) {
my %skip = ( dport => 1, comment => 1, origin => 1 ); my %skip = ( dport => 1, comment => 1, origin => 1, digest => 1 );
sort grep ! $skip{$_}, keys %{$_[0]}; sort grep ! $skip{$_}, keys %{$_[0]};
} }
@@ -4363,64 +4403,54 @@ sub delete_duplicates {
my @rules; my @rules;
my $chainref = shift; my $chainref = shift;
my $lastrule = @_; my $lastrule = @_;
my $baseref = pop;
my $ruleref; my $ruleref;
my %skip = ( comment => 1, origin => 1 ); my %skip = ( comment => 1, origin => 1 );
for ( @_ ) {
$_->{digest} = sha1_hex irule_to_string1( $_ );
}
my $baseref = pop;
while ( @_ ) { while ( @_ ) {
my $docheck; my $docheck;
my $duplicate = 0; my $duplicate = 0;
if ( $baseref->{mode} == CAT_MODE && $baseref->{target} ) { if ( $baseref->{mode} == CAT_MODE && $baseref->{target} ) {
my $ports1; my $ports1;
my @keys1 = sort( grep ! $skip{$_}, keys( %$baseref ) ); my $bad_key;
my $rulenum = @_; my $rulenum = @_;
my $adjacent = 1; my $adjacent = 1;
my $digest = $baseref->{digest};
{
RULE:
while ( --$rulenum >= 0 ) { for ( grep ! $skip{$_}, keys( %$baseref ) ) {
$ruleref = $_[$rulenum]; $bad_key = 1, last if $bad_match{$_};
}
last unless $ruleref->{mode} == CAT_MODE; while ( --$rulenum >= 0 ) {
$ruleref = $_[$rulenum];
my @keys2 = sort(grep ! $skip{$_}, keys( %$ruleref ) ); last unless $ruleref->{mode} == CAT_MODE;
next unless @keys1 == @keys2 ; next unless $digest eq $ruleref->{digest};
my $keynum = 0; unless ( $adjacent > 0 ) {
if ( $adjacent > 0 ) {
#
# There are no non-duplicate rules between this rule and the base rule
#
for my $key ( @keys1 ) {
next RULE unless $key eq $keys2[$keynum++];
next RULE unless compare_values( $baseref->{$key}, $ruleref->{$key} );
}
} else {
#
# There are non-duplicate rules between this rule and the base rule
#
for my $key ( @keys1 ) {
next RULE unless $key eq $keys2[$keynum++];
next RULE unless compare_values( $baseref->{$key}, $ruleref->{$key} );
last RULE if $bad_match{$key};
}
}
# #
# This rule is a duplicate # There are non-duplicate rules between this rule and the base rule
# #
$duplicate = 1; last if $bad_key;
#
# Increment $adjacent so that the continue block won't set it to zero
#
$adjacent++;
} continue {
$adjacent--;
} }
#
# This rule is a duplicate
#
$duplicate = 1;
#
# Increment $adjacent so that the continue block won't set it to zero
#
$adjacent++;
} continue {
$adjacent--;
} }
} }
@@ -4457,10 +4487,10 @@ sub get_conntrack( $ ) {
} }
# #
# Return an array of keys for the passed rule. 'conntrack', 'comment' & 'origin' are omitted; # Return an array of keys for the passed rule. 'conntrack', 'comment', 'origin' and 'digest' are omitted;
# #
sub get_keys1( $ ) { sub get_keys1( $ ) {
my %skip = ( comment => 1, origin => 1 , 'conntrack --ctstate' => 1 ); my %skip = ( comment => 1, origin => 1 , digest => 1, 'conntrack --ctstate' => 1 );
sort grep ! $skip{$_}, keys %{$_[0]}; sort grep ! $skip{$_}, keys %{$_[0]};
} }
@@ -4579,7 +4609,7 @@ sub combine_states {
sub optimize_level16( $$$ ) { sub optimize_level16( $$$ ) {
my ( $table, $tableref , $passes ) = @_; my ( $table, $tableref , $passes ) = @_;
my @chains = ( grep $_->{referenced}, values %{$tableref} ); my @chains = ( grep $_->{referenced}, sortchainsiftest %{$tableref} );
my @chains1 = @chains; my @chains1 = @chains;
my $chains = @chains; my $chains = @chains;
@@ -4696,7 +4726,7 @@ sub setup_zone_mss() {
my $hosts = find_zone_hosts_by_option( $zone, 'mss' ); my $hosts = find_zone_hosts_by_option( $zone, 'mss' );
for my $hostref ( @$hosts ) { for my $hostref ( $test ? sort { $a->[0] cmp $b->[0] } @$hosts : @$hosts ) {
my $mss = $hostref->[4]; my $mss = $hostref->[4];
my @mssmatch = have_capability( 'TCPMSS_MATCH' ) ? ( tcpmss => "--mss $mss:" ) : (); my @mssmatch = have_capability( 'TCPMSS_MATCH' ) ? ( tcpmss => "--mss $mss:" ) : ();
my @sourcedev = imatch_source_dev $hostref->[0]; my @sourcedev = imatch_source_dev $hostref->[0];
@@ -7448,20 +7478,20 @@ sub have_address_variables() {
# #
# Generate setting of run-time global shell variables # Generate setting of run-time global shell variables
# #
sub set_global_variables( $$ ) { sub set_global_variables( $$$ ) {
my ( $setall, $conditional ) = @_; my ( $setall, $conditional, $call_generate_all_acasts ) = @_;
if ( $conditional ) { if ( $conditional ) {
my ( $interface, @interfaces ); my ( $interface, @interfaces );
@interfaces = keys %interfaceaddr; @interfaces = sortkeysiftest %interfaceaddr;
for $interface ( @interfaces ) { for $interface ( @interfaces ) {
emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $interfaceaddr{$interface}) ); emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $interfaceaddr{$interface}) );
} }
@interfaces = keys %interfacegateways; @interfaces = sortkeysiftest %interfacegateways;
for $interface ( @interfaces ) { for $interface ( @interfaces ) {
emit( qq(if [ -z "\$interface" -o "\$interface" = "$interface" ]; then) ); emit( qq(if [ -z "\$interface" -o "\$interface" = "$interface" ]; then) );
@@ -7471,29 +7501,30 @@ sub set_global_variables( $$ ) {
emit( qq(fi\n) ); emit( qq(fi\n) );
} }
@interfaces = keys %interfacemacs; @interfaces = sortkeysiftest %interfacemacs;
for $interface ( @interfaces ) { for $interface ( @interfaces ) {
emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $interfacemacs{$interface}) ); emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $interfacemacs{$interface}) );
} }
} else { } else {
emit $_ for values %interfaceaddr; emit $interfaceaddr{$_} for sortkeysiftest %interfaceaddr;
emit "$_\n" for values %interfacegateways; emit "$interfacegateways{$_}\n" for sortkeysiftest %interfacegateways;
emit $_ for values %interfacemacs; emit $interfacemacs{$_} for sortkeysiftest %interfacemacs;
} }
if ( $setall ) { if ( $setall ) {
emit $_ for values %interfaceaddrs; if ( $conditional ) {
emit $_ for values %interfacenets; emit $interfaceaddr{$_} for sortkeysiftest %interfaceaddr;
emit $interfacenets{$_} for sortkeysiftest %interfacenets;
}
unless ( have_capability( 'ADDRTYPE' ) ) { unless ( have_capability( 'ADDRTYPE' ) ) {
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
emit 'ALL_BCASTS="$(get_all_bcasts) 255.255.255.255"'; emit 'ALL_BCASTS="$(get_all_bcasts) 255.255.255.255"';
emit $_ for values %interfacebcasts; emit $interfacebcasts{$_} for sortkeysiftest %interfacebcasts;
} else { } else {
emit 'ALL_ACASTS="$(get_all_acasts)"'; emit $call_generate_all_acasts;
emit $_ for values %interfaceacasts; emit $interfaceacasts{$_} for sortkeysiftest %interfaceacasts;
} }
} }
} }
@@ -8457,7 +8488,7 @@ sub add_interface_options( $ ) {
# Insert jumps to the interface chains into the rules chains # Insert jumps to the interface chains into the rules chains
# #
for my $zone1 ( off_firewall_zones ) { for my $zone1 ( off_firewall_zones ) {
my @input_interfaces = keys %{zone_interfaces( $zone1 )}; my @input_interfaces = sortkeysiftest %{zone_interfaces( $zone1 )};
my @forward_interfaces = @input_interfaces; my @forward_interfaces = @input_interfaces;
if ( @input_interfaces > 1 ) { if ( @input_interfaces > 1 ) {
@@ -8543,7 +8574,7 @@ sub add_interface_options( $ ) {
for my $zone1 ( firewall_zone, vserver_zones ) { for my $zone1 ( firewall_zone, vserver_zones ) {
for my $zone2 ( off_firewall_zones ) { for my $zone2 ( off_firewall_zones ) {
my $chainref = $filter_table->{rules_chain( $zone1, $zone2 )}; my $chainref = $filter_table->{rules_chain( $zone1, $zone2 )};
my @interfaces = keys %{zone_interfaces( $zone2 )}; my @interfaces = sortkeysiftest %{zone_interfaces( $zone2 )};
my $chain1ref; my $chain1ref;
for my $interface ( @interfaces ) { for my $interface ( @interfaces ) {
@@ -8861,7 +8892,7 @@ sub ensure_ipsets( @ ) {
my $set; my $set;
my $counters = have_capability( 'IPSET_MATCH_COUNTERS' ) ? ' counters' : ''; my $counters = have_capability( 'IPSET_MATCH_COUNTERS' ) ? ' counters' : '';
if ( $globals{DBL_TIMEOUT} ne '' && $_[0] eq $globals{DBL_IPSET} ) { if ( $_[0] eq $globals{DBL_IPSET} ) {
shift; shift;
emit( qq( if ! qt \$IPSET list $globals{DBL_IPSET}; then)); emit( qq( if ! qt \$IPSET list $globals{DBL_IPSET}; then));
@@ -8872,12 +8903,12 @@ sub ensure_ipsets( @ ) {
emit( q( #), emit( q( #),
q( # Set the timeout for the dynamic blacklisting ipset), q( # Set the timeout for the dynamic blacklisting ipset),
q( #), q( #),
qq( \$IPSET -exist create $globals{DBL_IPSET} hash:net family inet timeout $globals{DBL_TIMEOUT}${counters}) ); qq( \$IPSET -exist create $globals{DBL_IPSET} hash:net family inet timeout 0${counters}) );
} else { } else {
emit( q( #), emit( q( #),
q( # Set the timeout for the dynamic blacklisting ipset), q( # Set the timeout for the dynamic blacklisting ipset),
q( #), q( #),
qq( \$IPSET -exist create $globals{DBL_IPSET} hash:net family inet6 timeout $globals{DBL_TIMEOUT}${counters}) ); qq( \$IPSET -exist create $globals{DBL_IPSET} hash:net family inet6 timeout 0${counters}) );
} }
pop_indent; pop_indent;
@@ -8984,7 +9015,7 @@ sub create_save_ipsets() {
# #
$ipsets{$_} = 1 for ( @ipsets, @{$globals{SAVED_IPSETS}} ); $ipsets{$_} = 1 for ( @ipsets, @{$globals{SAVED_IPSETS}} );
my @sets = keys %ipsets; my @sets = sortkeysiftest %ipsets;
emit( '' , emit( '' ,
' rm -f $file' , ' rm -f $file' ,
@@ -9054,10 +9085,14 @@ sub create_load_ipsets() {
# Requires V5 or later # Requires V5 or later
# #
emit( '' , emit( '' ,
" for set in \$(\$IPSET save | grep '$select' | cut -d' ' -f2); do" , ' if [ -f ${VARDIR}/ipsets.save ]; then' ,
' $IPSET flush $set' , ' while read verb set rest; do' ,
' $IPSET destroy $set' , ' if [ $verb = create ]; then' ,
" done" , ' $IPSET flush $set' ,
' $IPSET destroy $set' ,
' fi' ,
' done < ${VARDIR}/ipsets.save' ,
' fi',
); );
} else { } else {
# #
@@ -9100,7 +9135,7 @@ sub create_load_ipsets() {
emit( ' #', emit( ' #',
' # Update the dynamic blacklisting ipset timeout value', ' # Update the dynamic blacklisting ipset timeout value',
' #', ' #',
qq( awk '/create $set/ { sub( /timeout [0-9]+/, "timeout $globals{DBL_TIMEOUT}" ) }; {print};' \${VARDIR}/ipsets.save > \${VARDIR}/ipsets.temp), qq( awk '/create $set/ { sub( /timeout [0-9]+/, "timeout 0" ) }; {print};' \${VARDIR}/ipsets.save > \${VARDIR}/ipsets.temp),
' zap_ipsets', ' zap_ipsets',
' $IPSET restore < ${VARDIR}/ipsets.temp', ' $IPSET restore < ${VARDIR}/ipsets.temp',
' fi' ); ' fi' );
@@ -9153,7 +9188,7 @@ sub create_load_ipsets() {
# #
sub create_nfobjects() { sub create_nfobjects() {
my @objects = ( keys %nfobjects ); my @objects = ( sortkeysiftest %nfobjects );
if ( @objects ) { if ( @objects ) {
if ( $config{NFACCT} ) { if ( $config{NFACCT} ) {
@@ -9168,7 +9203,7 @@ sub create_nfobjects() {
} }
} }
for ( keys %nfobjects ) { for ( @objects ) {
emit( qq(if ! qt \$NFACCT get $_; then), emit( qq(if ! qt \$NFACCT get $_; then),
qq( \$NFACCT add $_), qq( \$NFACCT add $_),
qq(fi\n) ); qq(fi\n) );
@@ -9541,7 +9576,7 @@ sub create_stop_load( $ ) {
} }
sub initialize_switches() { sub initialize_switches() {
if ( keys %switches ) { if ( sortkeysiftest %switches ) {
emit( 'if [ $COMMAND = start ]; then' ); emit( 'if [ $COMMAND = start ]; then' );
push_indent; push_indent;
for my $switch ( keys %switches ) { for my $switch ( keys %switches ) {

View File

@@ -6,7 +6,7 @@
# #
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -49,8 +49,6 @@ our $VERSION = 'MODULEVERSION';
our $export; # True when compiling for export our $export; # True when compiling for export
our $test; # True when running regression tests
our $family; # IP address family (4 or 6) our $family; # IP address family (4 or 6)
our $have_arptables; # True if we have arptables rules our $have_arptables; # True if we have arptables rules
@@ -58,8 +56,8 @@ our $have_arptables; # True if we have arptables rules
# #
# Initilize the package-globals in the other modules # Initilize the package-globals in the other modules
# #
sub initialize_package_globals( $$$ ) { sub initialize_package_globals( $$$$ ) {
Shorewall::Config::initialize($family, $export, $_[1], $_[2]); Shorewall::Config::initialize($family, $export, $_[1], $_[2], $_[3]);
Shorewall::Chains::initialize ($family, 1, $export ); Shorewall::Chains::initialize ($family, 1, $export );
Shorewall::Zones::initialize ($family, $_[0]); Shorewall::Zones::initialize ($family, $_[0]);
Shorewall::Nat::initialize($family); Shorewall::Nat::initialize($family);
@@ -278,12 +276,18 @@ sub generate_script_2() {
emit "}\n"; # End of initialize() emit "}\n"; # End of initialize()
#
# Conditionally emit the 'generate_all_acasts() function
#
my $call_generate_all_acasts = $family == F_IPV6 && ! have_capability( 'ADDRTYPE' ) ? generate_all_acasts : '';
emit( '' , emit( '' ,
'#' , '#' ,
'# Set global variables holding detected IP information' , '# Set global variables holding detected IP information' ,
'#' , '#' ,
'detect_configuration()', 'detect_configuration()',
'{' ); '{'
);
my $global_variables = have_global_variables; my $global_variables = have_global_variables;
my $optional_interfaces = find_interfaces_by_option( 'optional' ); my $optional_interfaces = find_interfaces_by_option( 'optional' );
@@ -314,7 +318,7 @@ sub generate_script_2() {
if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) { if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) {
verify_required_interfaces(0); verify_required_interfaces(0);
set_global_variables(0, 0); set_global_variables( $family == F_IPV6, 0, $call_generate_all_acasts );
handle_optional_interfaces; handle_optional_interfaces;
} }
@@ -328,7 +332,7 @@ sub generate_script_2() {
} }
verify_required_interfaces(1); verify_required_interfaces(1);
set_global_variables(1,1); set_global_variables(1, 1, $call_generate_all_acasts );
handle_optional_interfaces; handle_optional_interfaces;
if ( $global_variables & NOT_RESTORE ) { if ( $global_variables & NOT_RESTORE ) {
@@ -545,13 +549,13 @@ date > ${VARDIR}/restarted
case $COMMAND in case $COMMAND in
start) start)
mylogger kern.info "$g_product started" mylogger daemon.info "$g_product started"
;; ;;
reload) reload)
mylogger kern.info "$g_product reloaded" mylogger daemon.info "$g_product reloaded"
;; ;;
restore) restore)
mylogger kern.info "$g_product restored" mylogger daemon.info "$g_product restored"
;; ;;
esac esac
EOF EOF
@@ -588,7 +592,7 @@ sub compiler {
( '', '', -1, '', 0, '', -1, 0, 0, 0, 0, , '' , '/usr/share/shorewall/shorewallrc', '' ); ( '', '', -1, '', 0, '', -1, 0, 0, 0, 0, , '' , '/usr/share/shorewall/shorewallrc', '' );
$export = 0; $export = 0;
$test = 0; my $test = 0;
$have_arptables = 0; $have_arptables = 0;
sub validate_boolean( $ ) { sub validate_boolean( $ ) {
@@ -641,18 +645,19 @@ sub compiler {
# #
# Now that we know the address family (IPv4/IPv6), we can initialize the other modules' globals # Now that we know the address family (IPv4/IPv6), we can initialize the other modules' globals
# #
initialize_package_globals( $update, $shorewallrc, $shorewallrc1 ); initialize_package_globals( $update, $test, $shorewallrc, $shorewallrc1 );
#
# Rather than continuing to extend the argument list of Config::initialize(),
# we use a set of small functions to export settings to the Config module.
#
set_config_path( $config_path ) if $config_path; set_config_path( $config_path ) if $config_path;
set_shorewall_dir( $directory ) if $directory ne ''; set_shorewall_dir( $directory ) if $directory ne '';
$verbosity = 1 if $debug && $verbosity < 1; $verbosity = 1 if $debug && $verbosity < 1;
set_verbosity( $verbosity ); set_verbosity( $verbosity );
set_log($log, $log_verbosity) if $log; set_log($log, $log_verbosity) if $log;
set_timestamp( $timestamp ); set_timestamp( $timestamp );
set_debug( $debug , $confess ); set_debug( $debug , $confess );
set_command( 'compile', 'Compiling', 'Compiled' );
# #
# S H O R E W A L L R C , # S H O R E W A L L R C ,
# S H O R E W A L L . C O N F A N D C A P A B I L I T I E S # S H O R E W A L L . C O N F A N D C A P A B I L I T I E S
@@ -670,12 +675,7 @@ sub compiler {
# #
# Create a temp file to hold the script # Create a temp file to hold the script
# #
if ( $scriptfilename ) { create_temp_script( $scriptfilename , $export ) 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 # Z O N E D E F I N I T I O N
# (Produces no output to the compiled script) # (Produces no output to the compiled script)
@@ -864,13 +864,13 @@ sub compiler {
if ( ( my $optimize = $config{OPTIMIZE} ) & OPTIMIZE_MASK ) { if ( ( my $optimize = $config{OPTIMIZE} ) & OPTIMIZE_MASK ) {
progress_message2 'Optimizing Ruleset...'; progress_message2 'Optimizing Ruleset...';
# #
# Optimize the ruleet
#
optimize_ruleset if $optimize & OPTIMIZE_RULESET_MASK;
#
# Optimize Policy Chains # Optimize Policy Chains
# #
optimize_policy_chains if ( $optimize & OPTIMIZE_POLICY_MASK2n4 ) == OPTIMIZE_POLICY_MASK; # Level 2 but not 4 optimize_policy_chains if $optimize & OPTIMIZE_POLICY_MASK;
#
# More Optimization
#
optimize_ruleset if $config{OPTIMIZE} & OPTIMIZE_RULESET_MASK;
} }
enable_script; enable_script;
@@ -913,7 +913,7 @@ sub compiler {
# #
# Close, rename and secure the script # Close, rename and secure the script
# #
finalize_script ( $export ); finalize_script ( $export, $test );
# #
# And generate the auxilary config file # And generate the auxilary config file
# #
@@ -934,16 +934,16 @@ sub compiler {
optimize_level0; optimize_level0;
if ( ( my $optimize = $config{OPTIMIZE} ) & 0x1e ) { if ( ( my $optimize = $config{OPTIMIZE} ) & OPTIMIZE_MASK ) {
progress_message2 'Optimizing Ruleset...'; progress_message2 'Optimizing Ruleset...';
# #
# Optimize Policy Chains
#
optimize_policy_chains if ( $optimize & OPTIMIZE_POLICY_MASK2n4 ) == OPTIMIZE_POLICY_MASK; # Level 2 but not 4
#
# Ruleset Optimization # Ruleset Optimization
# #
optimize_ruleset if $optimize & OPTIMIZE_RULESET_MASK; optimize_ruleset if $optimize & OPTIMIZE_RULESET_MASK;
#
# Optimize Policy Chains
#
optimize_policy_chains if $optimize & OPTIMIZE_POLICY_MASK;
} }
enable_script if $debug; enable_script if $debug;
@@ -978,11 +978,7 @@ sub compiler {
# #
report_used_capabilities; report_used_capabilities;
if ( $family == F_IPV4 ) { progress_message3 "$Product configuration verified";
progress_message3 "Shorewall configuration verified";
} else {
progress_message3 "Shorewall6 configuration verified";
}
} }
close_log if $log; close_log if $log;

View File

@@ -5,7 +5,7 @@
# #
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -166,7 +166,11 @@ our @EXPORT = qw(
report_used_capabilities report_used_capabilities
kernel_version kernel_version
compiletime compiletime
sortkeysiftest
sortvaluesiftest
sortiftest
F_IPV4 F_IPV4
F_IPV6 F_IPV6
@@ -264,6 +268,7 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
$debug $debug
$file_format $file_format
$comment $comment
$test
%config %config
%origin %origin
@@ -306,7 +311,6 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
OPTIMIZE_MASK OPTIMIZE_MASK
OPTIMIZE_POLICY_MASK OPTIMIZE_POLICY_MASK
OPTIMIZE_POLICY_MASK2n4
OPTIMIZE_RULESET_MASK OPTIMIZE_RULESET_MASK
OPTIMIZE_ALL OPTIMIZE_ALL
) , ] , ) , ] ,
@@ -498,6 +502,7 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
RESTORE_WAIT_OPTION RESTORE_WAIT_OPTION
=> 'iptables-restore --wait option', => 'iptables-restore --wait option',
NAT_INPUT_CHAIN => 'INPUT chain in NAT table', NAT_INPUT_CHAIN => 'INPUT chain in NAT table',
CONNMARK_ACTION => 'TC connmark support',
# #
# Helpers # Helpers
# #
@@ -550,7 +555,6 @@ use constant {
# #
use constant { use constant {
OPTIMIZE_POLICY_MASK => 0x02 , # Call optimize_policy_chains() OPTIMIZE_POLICY_MASK => 0x02 , # Call optimize_policy_chains()
OPTIMIZE_POLICY_MASK2n4 => 0x06 ,
OPTIMIZE_RULESET_MASK => 0x1C , # Call optimize_ruleset() OPTIMIZE_RULESET_MASK => 0x1C , # Call optimize_ruleset()
OPTIMIZE_MASK => 0x1E , # Do optimizations beyond level 1 OPTIMIZE_MASK => 0x1E , # Do optimizations beyond level 1
OPTIMIZE_ALL => 0x1F , # Maximum value for documented categories. OPTIMIZE_ALL => 0x1F , # Maximum value for documented categories.
@@ -652,6 +656,30 @@ our %params;
# #
our %compiler_params; our %compiler_params;
# #
# Entries conditionally exported to the compiled script via the aux config file
#
our @exported_params = ( qw(
VERBOSITY
LOGFILE
LOGFORMAT
APRTABLES
IPTABLES
IP6TABLES
IP
TC
IPSET
PATH
SHOREWALL_SHELL
SHELL
SUBSYSLOCK
LOCKFILE
RESTOREFILE
RESTART
DYNAMIC_BLACKLIST
PAGER
)
);
#
# Action parameters # Action parameters
# #
our %actparams; our %actparams;
@@ -793,6 +821,8 @@ our %filecache;
our $compiletime; our $compiletime;
our $test;
sub process_shorewallrc($$); sub process_shorewallrc($$);
sub add_variables( \% ); sub add_variables( \% );
# #
@@ -804,9 +834,12 @@ sub add_variables( \% );
# #
# 2. The compiler can run multiple times in the same process so it has to be # 2. The compiler can run multiple times in the same process so it has to be
# able to re-initialize its dependent modules' state. # able to re-initialize its dependent modules' state.
# ####################################################################################################
sub initialize($;$$$) { # Do not change the required part of this prototype unless you want to take on a lot of additional
( $family, $export, my ( $shorewallrc, $shorewallrc1 ) ) = @_; # work (This function is called from build).
####################################################################################################
sub initialize($;$$$$) {
( $family, $export, $test, my ( $shorewallrc, $shorewallrc1 ) ) = @_;
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
( $product, $Product, $toolname, $toolNAME ) = qw( shorewall Shorewall iptables IPTABLES ); ( $product, $Product, $toolname, $toolNAME ) = qw( shorewall Shorewall iptables IPTABLES );
@@ -851,8 +884,8 @@ sub initialize($;$$$) {
TC_SCRIPT => '', TC_SCRIPT => '',
EXPORT => 0, EXPORT => 0,
KLUDGEFREE => '', KLUDGEFREE => '',
VERSION => '5.2.0-Beta1', VERSION => '5.2.8-RC1',
CAPVERSION => 50200 , CAPVERSION => 50207 ,
BLACKLIST_LOG_TAG => '', BLACKLIST_LOG_TAG => '',
RELATED_LOG_TAG => '', RELATED_LOG_TAG => '',
MACLIST_LOG_TAG => '', MACLIST_LOG_TAG => '',
@@ -1146,6 +1179,7 @@ sub initialize($;$$$) {
NFLOG_SIZE => undef, NFLOG_SIZE => undef,
RESTORE_WAIT_OPTION => undef, RESTORE_WAIT_OPTION => undef,
NAT_INPUT_CHAIN => undef, NAT_INPUT_CHAIN => undef,
CONNMARK_ACTION => undef ,
AMANDA_HELPER => undef, AMANDA_HELPER => undef,
FTP_HELPER => undef, FTP_HELPER => undef,
@@ -1473,7 +1507,7 @@ sub qt1( $ ) {
} }
# #
# Delete the test chains # Delete the test chains and IP sets
# #
sub cleanup_iptables() { sub cleanup_iptables() {
qt1( "$iptables $iptablesw -F $sillyname" ); qt1( "$iptables $iptablesw -F $sillyname" );
@@ -1496,6 +1530,12 @@ sub cleanup_iptables() {
qt1( "$iptables $iptablesw -t raw -X $sillyname" ); qt1( "$iptables $iptablesw -t raw -X $sillyname" );
} }
my $ipset = $config{IPSET} || 'ipset';
$ipset = which( $ipset ) unless $ipset =~ '/';
if ( $ipset && -x $ipset ) {
qt( "$ipset -X $sillyname" );
}
$sillyname = $sillyname1 = ''; $sillyname = $sillyname1 = '';
} }
@@ -1540,7 +1580,7 @@ sub cleanup() {
unlink ( $perlscriptname ), $perlscriptname = undef if $perlscriptname; unlink ( $perlscriptname ), $perlscriptname = undef if $perlscriptname;
unlink ( @tempfiles ), @tempfiles = () if @tempfiles; unlink ( @tempfiles ), @tempfiles = () if @tempfiles;
# #
# Delete temporary chains # Delete temporary chains and IP sets
# #
cleanup_iptables if $sillyname; cleanup_iptables if $sillyname;
} }
@@ -1828,6 +1868,30 @@ sub set_command( $$$ ) {
($command, $doing, $done) = @_; ($command, $doing, $done) = @_;
} }
#
# Return the keys or values of the passed hash. If $test, the keys/values will be sorted by their own values
#
sub sortkeysiftest(\%) {
my ( $hashref ) = @_;
return sort keys %$hashref if $test;
return keys %$hashref;
}
sub sortvaluesiftest(\%) {
my ( $hashref ) = @_;
return sort values %$hashref if $test;
return keys %$hashref;
}
#
# Sort a list by the list elements if $test
#
sub sortiftest(@) {
return $test ? sort @_ : @_;
}
# #
# Print the current TOD to STDOUT. # Print the current TOD to STDOUT.
# #
@@ -2015,28 +2079,30 @@ sub generate_sha1() {
# #
# Finalize the script file # Finalize the script file
# #
sub finalize_script( $ ) { sub finalize_script( $$ ) {
my $export = $_[0]; my ( $export, $test ) = @_;
close $script; close $script;
$script = 0; $script = 0;
if ( $file ne '-' ) { if ( $file ne '-' ) {
my $sha1sum = generate_sha1; unless ( $test ) {
my $sha1sum1 = join( '-', 'sha-lh', substr( $sha1sum, 0, 20 ) ); my $sha1sum = generate_sha1;
my $sha1sum2 = join( '-', 'sha-rh', substr( $sha1sum, -20 ) ); my $sha1sum1 = join( '-', 'sha-lh', substr( $sha1sum, 0, 20 ) );
my $sha1sum2 = join( '-', 'sha-rh', substr( $sha1sum, -20 ) );
@ARGV = ( $tempfile ); @ARGV = ( $tempfile );
$^I = ''; $^I = '';
while ( <> ) { while ( <> ) {
s/g_sha1sum1=/g_sha1sum1=$sha1sum1/; s/g_sha1sum1=/g_sha1sum1=$sha1sum1/;
s/g_sha1sum2=/g_sha1sum2=$sha1sum2/; s/g_sha1sum2=/g_sha1sum2=$sha1sum2/;
print; print;
}
} }
rename $tempfile, $file or fatal_error "Cannot Rename $tempfile to $file: $!"; rename $tempfile, $file or fatal_error "Cannot Rename $tempfile to $file: $!";
chmod 0700, $file or fatal_error "Cannot secure $file for execute access"; chmod 0700, $file or fatal_error "Cannot secure $file for execute access";
progress_message3 "Shorewall configuration compiled to $file" unless $export; progress_message3 "$Product configuration compiled to $file" unless $export;
} }
} }
@@ -2058,7 +2124,7 @@ sub finalize_aux_config() {
close $script; close $script;
$script = 0; $script = 0;
rename $tempfile, "$file.conf" or fatal_error "Cannot Rename $tempfile to $file.conf: $!"; rename $tempfile, "$file.conf" or fatal_error "Cannot Rename $tempfile to $file.conf: $!";
progress_message3 "Shorewall configuration compiled to $file"; progress_message3 "$Product configuration compiled to $file";
} }
# #
@@ -4355,7 +4421,9 @@ sub validate_level( $;$ ) {
sub default_log_level( $$ ) { sub default_log_level( $$ ) {
my ( $level, $default ) = @_; my ( $level, $default ) = @_;
my $value = $config{$level}; my $value = $config{$level} || '';
$value = $config{LOG_LEVEL} if $value eq '$LOG_LEVEL'; #This can happen during update
unless ( supplied $value ) { unless ( supplied $value ) {
$config{$level} = validate_level $default, $level; $config{$level} = validate_level $default, $level;
@@ -4992,6 +5060,10 @@ sub Basic_Filter() {
$tc && system( "$tc filter add basic help 2>&1 | grep -q ^Usage" ) == 0; $tc && system( "$tc filter add basic help 2>&1 | grep -q ^Usage" ) == 0;
} }
sub Connmark_Action() {
$tc && system( "$tc action add connmark help 2>&1 | grep -q ^Usage" ) == 0;
}
sub Basic_Ematch() { sub Basic_Ematch() {
$tc && have_capability( 'BASIC_FILTER' ) && system( "$tc filter add basic help 2>&1 | egrep -q match" ) == 0; $tc && have_capability( 'BASIC_FILTER' ) && system( "$tc filter add basic help 2>&1 | egrep -q match" ) == 0;
} }
@@ -5121,6 +5193,7 @@ our %detect_capability =
COMMENTS => \&Comments, COMMENTS => \&Comments,
CONNLIMIT_MATCH => \&Connlimit_Match, CONNLIMIT_MATCH => \&Connlimit_Match,
CONNMARK => \&Connmark, CONNMARK => \&Connmark,
CONNMARK_ACTION => \&Connmark_Action,
CONNMARK_MATCH => \&Connmark_Match, CONNMARK_MATCH => \&Connmark_Match,
CONNTRACK_MATCH => \&Conntrack_Match, CONNTRACK_MATCH => \&Conntrack_Match,
CPU_FANOUT => \&Cpu_Fanout, CPU_FANOUT => \&Cpu_Fanout,
@@ -5314,17 +5387,12 @@ sub ensure_config_path() {
my $chop = ( $path =~ s/^:// ); my $chop = ( $path =~ s/^:// );
$path =~ s/:+/:/g;
@config_path = split /:/, $path; @config_path = split /:/, $path;
shift @config_path if $chop && ( $export || $> != 0 ); shift @config_path if $chop && ( $export || $> != 0 );
#
# To accomodate Cygwin-based compilation, we have separate directories for files whose names
# clash on a case-insensitive filesystem.
#
push @config_path, $globals{SHAREDIR} . "/deprecated";
push @config_path, $shorewallrc{SHAREDIR}. '/shorewall/deprecated' unless $globals{PRODUCT} eq 'shorewall';
for ( @config_path ) { for ( @config_path ) {
$_ .= '/' unless m|/$|; $_ .= '/' unless m|/$|;
s|//|/|g; s|//|/|g;
@@ -5468,6 +5536,8 @@ sub update_config_file( $ ) {
for ( qw/DROP_DEFAULT REJECT_DEFAULT BLACKLIST_DEFAULT/ ) { for ( qw/DROP_DEFAULT REJECT_DEFAULT BLACKLIST_DEFAULT/ ) {
my $policy = $config{ $_ }; my $policy = $config{ $_ };
$policy = '' unless defined $policy;
if ( $policy =~ /\bA_(?:Drop|Reject)\b/ ) { if ( $policy =~ /\bA_(?:Drop|Reject)\b/ ) {
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
$policy =~ s/A_(?:Drop|Reject)/Broadcast(A_DROP),Multicast(A_DROP)/; $policy =~ s/A_(?:Drop|Reject)/Broadcast(A_DROP),Multicast(A_DROP)/;
@@ -5619,6 +5689,11 @@ sub process_shorewall_conf( $$ ) {
$globals{CONFIGDIR} = $configfile = $file; $globals{CONFIGDIR} = $configfile = $file;
$globals{CONFIGDIR} =~ s/$product.conf//; $globals{CONFIGDIR} =~ s/$product.conf//;
if ( $export ) {
use Sys::Hostname;
$globals{CONFIGDIR} = join( ':', hostname, $globals{CONFIGDIR} );
}
if ( -r _ ) { if ( -r _ ) {
open_file $file; open_file $file;
@@ -5747,9 +5822,10 @@ sub get_capabilities($)
fatal_error "Can't find $toolname executable" unless $iptables = which $toolname; fatal_error "Can't find $toolname executable" unless $iptables = which $toolname;
} }
# #
# Determine if iptables supports the -w option # Determine if iptables supports the -w option unless we already have
# existing capabilities
# #
$iptablesw = qt1( "$iptables -w -L -n") ? '-w' : ''; $iptablesw = qt1( "$iptables -w -n -L INPUT") ? '-w' : '' unless $_[0];
my $iptables_restore=$iptables . '-restore'; my $iptables_restore=$iptables . '-restore';
@@ -6257,6 +6333,14 @@ sub get_configuration( $$$ ) {
process_shorewall_conf( $update, $annotate ); process_shorewall_conf( $update, $annotate );
ensure_config_path; ensure_config_path;
#
# To accomodate Cygwin-based compilation, we have separate directories for files whose names
# clash on a case-insensitive filesystem.
#
push @config_path, $globals{SHAREDIR} . "/deprecated/" unless $config_path[-1] eq $globals{SHAREDIR} . "/deprecated/";
push @config_path, $shorewallrc{SHAREDIR}. '/shorewall/deprecated/' unless $globals{PRODUCT} eq 'shorewall';
$config{CONFIG_PATH} = join( ':', @config_path );
@INC = @originalinc; @INC = @originalinc;
@@ -6635,7 +6719,7 @@ sub get_configuration( $$$ ) {
if ( supplied( $val = $config{DYNAMIC_BLACKLIST} ) ) { if ( supplied( $val = $config{DYNAMIC_BLACKLIST} ) ) {
if ( $val =~ /^ipset/ ) { if ( $val =~ /^ipset/ ) {
my %simple_options = ( 'src-dst' => 1, 'disconnect' => 1 ); my %simple_options = ( 'src-dst' => 1, 'disconnect' => 1, 'log' => 1, 'noupdate' => 1, );
my ( $key, $set, $level, $tag, $rest ) = split( ':', $val , 5 ); my ( $key, $set, $level, $tag, $rest ) = split( ':', $val , 5 );
@@ -6774,6 +6858,12 @@ sub get_configuration( $$$ ) {
require_capability 'AUDIT_TARGET', "SMURF_DISPOSITION=$val", 's' if $val =~ /^A_/; require_capability 'AUDIT_TARGET', "SMURF_DISPOSITION=$val", 's' if $val =~ /^A_/;
if ( supplied( $val = $config{LOG_LEVEL} ) ) {
validate_level( $val );
} else {
$config{LOG_LEVEL} = 'info';
}
default_log_level 'BLACKLIST_LOG_LEVEL', ''; default_log_level 'BLACKLIST_LOG_LEVEL', '';
default_log_level 'MACLIST_LOG_LEVEL', ''; default_log_level 'MACLIST_LOG_LEVEL', '';
default_log_level 'TCP_FLAGS_LOG_LEVEL', ''; default_log_level 'TCP_FLAGS_LOG_LEVEL', '';
@@ -6782,12 +6872,6 @@ sub get_configuration( $$$ ) {
default_log_level 'INVALID_LOG_LEVEL', ''; default_log_level 'INVALID_LOG_LEVEL', '';
default_log_level 'UNTRACKED_LOG_LEVEL', ''; default_log_level 'UNTRACKED_LOG_LEVEL', '';
if ( supplied( $val = $config{LOG_LEVEL} ) ) {
validate_level( $val );
} else {
$config{LOG_LEVEL} = 'info';
}
if ( supplied( $val = $config{LOG_BACKEND} ) ) { if ( supplied( $val = $config{LOG_BACKEND} ) ) {
if ( $family == F_IPV4 && $val eq 'ULOG' ) { if ( $family == F_IPV4 && $val eq 'ULOG' ) {
$val = 'ipt_ULOG'; $val = 'ipt_ULOG';
@@ -7160,8 +7244,8 @@ sub generate_aux_config() {
emit "#\n# Shorewall auxiliary configuration file created by Shorewall version $globals{VERSION} - $date\n#"; emit "#\n# Shorewall auxiliary configuration file created by Shorewall version $globals{VERSION} - $date\n#";
for my $option ( qw(VERBOSITY LOGFILE LOGFORMAT ARPTABLES IPTABLES IP6TABLES IP TC IPSET PATH SHOREWALL_SHELL SUBSYSLOCK LOCKFILE RESTOREFILE WORKAROUNDS RESTART DYNAMIC_BLACKLIST PAGER) ) { for my $param ( @exported_params ) {
conditionally_add_option $option; conditionally_add_option $param;
} }
conditionally_add_option1 'TC_ENABLED'; conditionally_add_option1 'TC_ENABLED';

View File

@@ -5,7 +5,7 @@
# #
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -149,14 +149,13 @@ sub validate_4address( $$ ) {
unless ( valid_4address $addr ) { unless ( valid_4address $addr ) {
fatal_error "Invalid IP Address ($addr)" unless $allow_name; fatal_error "Invalid IP Address ($addr)" unless $allow_name;
fatal_error "Unknown Host ($addr)" unless @addrs = gethostbyname( $addr ); my ( $err, @addr_structs ) = Socket::getaddrinfo( $addr, 0, {
family => Socket::AF_INET,
protocol => Socket::IPPROTO_TCP,
} );
fatal_error "Unknown Host ($addr)" if $err != 0;
if ( defined wantarray ) { @addrs = translate_addr_structs( @addr_structs );
shift @addrs for (1..4);
for ( @addrs ) {
$_ = ( inet_ntoa( $_ ) );
}
}
} }
defined wantarray ? wantarray ? @addrs : $addrs[0] : undef; defined wantarray ? wantarray ? @addrs : $addrs[0] : undef;
@@ -164,14 +163,14 @@ sub validate_4address( $$ ) {
sub resolve_4dnsname( $ ) { sub resolve_4dnsname( $ ) {
my $net = $_[0]; my $net = $_[0];
my @addrs;
fatal_error "Unknown Host ($net)" unless @addrs = gethostbyname( $net ); my ( $err, @addr_structs ) = Socket::getaddrinfo( $net, 0, {
family => Socket::AF_INET,
protocol => Socket::IPPROTO_TCP,
} );
fatal_error "Unknown Host ($net)" if $err != 0;
shift @addrs for (1..4); my @addrs = translate_addr_structs( @addr_structs );
for ( @addrs ) {
$_ = ( inet_ntoa( $_ ) );
}
@addrs; @addrs;
} }
@@ -508,15 +507,13 @@ sub validate_6address( $$ ) {
unless ( valid_6address $addr ) { unless ( valid_6address $addr ) {
fatal_error "Invalid IPv6 Address ($addr)" unless $allow_name; fatal_error "Invalid IPv6 Address ($addr)" unless $allow_name;
require Socket6; my ( $err, @addr_structs ) = Socket::getaddrinfo( $addr, 0, {
fatal_error "Unknown Host ($addr)" unless (@addrs = Socket6::gethostbyname2( $addr, Socket6::AF_INET6())); family => Socket::AF_INET6,
protocol => Socket::IPPROTO_TCP,
} );
fatal_error "Unknown Host ($addr)" if $err != 0;
if ( defined wantarray ) { @addrs = translate_addr_structs( @addr_structs );
shift @addrs for (1..4);
for ( @addrs ) {
$_ = Socket6::inet_ntop( Socket6::AF_INET6(), $_ );
}
}
} }
defined wantarray ? wantarray ? @addrs : $addrs[0] : undef; defined wantarray ? wantarray ? @addrs : $addrs[0] : undef;
@@ -524,15 +521,14 @@ sub validate_6address( $$ ) {
sub resolve_6dnsname( $ ) { sub resolve_6dnsname( $ ) {
my $net = $_[0]; my $net = $_[0];
my @addrs;
require Socket6; my ( $err, @addr_structs ) = Socket::getaddrinfo( $net, 0, {
fatal_error "Unknown Host ($net)" unless (@addrs = Socket6::gethostbyname2( $net, Socket6::AF_INET6())); family => Socket::AF_INET6,
protocol => Socket::IPPROTO_TCP,
} );
fatal_error "Unknown Host ($net)" if $err != 0;
shift @addrs for (1..4); my @addrs = translate_addr_structs( @addr_structs );
for ( @addrs ) {
$_ = Socket6::inet_ntop( Socket6::AF_INET6(), $_ );
}
@addrs; @addrs;
} }
@@ -661,6 +657,19 @@ sub validate_6host( $$ ) {
} }
} }
sub translate_addr_structs {
my @addr_structs = @_;
my @addrs;
foreach my $addr_struct ( @addr_structs ) {
my ( $err, $ip_addr ) = Socket::getnameinfo( $addr_struct->{addr},
Socket::NI_NUMERICHOST, Socket::NIx_NOSERV );
push @addrs, $ip_addr if $err == 0;
}
return @addrs;
}
my %ipv6_icmp_types = ( any => 'any', my %ipv6_icmp_types = ( any => 'any',
'destination-unreachable' => 1, 'destination-unreachable' => 1,
'no-route' => '1/0', 'no-route' => '1/0',

View File

@@ -5,7 +5,7 @@
# #
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -34,6 +34,7 @@ use Shorewall::Zones;
use Shorewall::Chains qw(:DEFAULT :internal); use Shorewall::Chains qw(:DEFAULT :internal);
use Shorewall::Rules; use Shorewall::Rules;
use Shorewall::Proc; use Shorewall::Proc;
use sort 'stable';
use strict; use strict;
@@ -130,7 +131,7 @@ sub setup_ecn()
} }
if ( @hosts ) { if ( @hosts ) {
my @interfaces = ( keys %interfaces ); my @interfaces = ( sortkeysiftest %interfaces );
progress_message "$doing ECN control on @interfaces..."; progress_message "$doing ECN control on @interfaces...";
@@ -335,7 +336,7 @@ sub convert_blacklist() {
# #
# For information about entries in this file, type "man shorewall-blrules" # For information about entries in this file, type "man shorewall-blrules"
# #
# Please see http://shorewall.org/blacklisting_support.htm for additional # Please see https://shorewall.org/blacklisting_support.htm for additional
# information. # information.
# #
################################################################################################################################################################################################### ###################################################################################################################################################################################################
@@ -434,9 +435,9 @@ sub convert_routestopped() {
# For information about entries in this file, type "man shorewall-stoppedrules" # For information about entries in this file, type "man shorewall-stoppedrules"
# #
# The manpage is also online at # The manpage is also online at
# http://www.shorewall.org/manpages/shorewall-stoppedrules.html # https://shorewall.org/manpages/shorewall-stoppedrules.html
# #
# See http://shorewall.org/starting_and_stopping_shorewall.htm for additional # See https://shorewall.org/starting_and_stopping_shorewall.htm for additional
# information. # information.
# #
############################################################################### ###############################################################################
@@ -734,6 +735,7 @@ sub add_common_rules ( $ ) {
my $dbl_tag; my $dbl_tag;
my $dbl_src_target; my $dbl_src_target;
my $dbl_dst_target; my $dbl_dst_target;
my $dbl_options;
if ( $config{REJECT_ACTION} ) { if ( $config{REJECT_ACTION} ) {
process_reject_action; process_reject_action;
@@ -795,9 +797,10 @@ sub add_common_rules ( $ ) {
if ( $dbl_ipset ) { if ( $dbl_ipset ) {
if ( $val = $globals{DBL_TIMEOUT} ) { if ( $val = $globals{DBL_TIMEOUT} ) {
$dbl_src_target = $globals{DBL_OPTIONS} =~ /src-dst/ ? 'dbl_src' : 'dbl_log'; $dbl_options = $globals{DBL_OPTIONS};
$dbl_src_target = $dbl_options =~ /src-dst/ ? 'dbl_src' : 'dbl_log';
my $chainref = set_optflags( new_standard_chain( $dbl_src_target ) , DONT_OPTIMIZE | DONT_DELETE ); my $chainref = new_standard_chain( $dbl_src_target );
log_rule_limit( $dbl_level, log_rule_limit( $dbl_level,
$chainref, $chainref,
@@ -808,11 +811,11 @@ sub add_common_rules ( $ ) {
'add', 'add',
'', '',
$origin{DYNAMIC_BLACKLIST} ) if $dbl_level; $origin{DYNAMIC_BLACKLIST} ) if $dbl_level;
add_ijump_extended( $chainref, j => "SET --add-set $dbl_ipset src --exist --timeout $val", $origin{DYNAMIC_BLACKLIST} ); add_ijump_extended( $chainref, j => "SET --add-set $dbl_ipset src --exist --timeout $val", $origin{DYNAMIC_BLACKLIST} ) unless $dbl_options =~ /noupdate/;
add_ijump_extended( $chainref, j => 'DROP', $origin{DYNAMIC_BLACKLIST} ); add_ijump_extended( $chainref, j => 'DROP', $origin{DYNAMIC_BLACKLIST} );
if ( $dbl_src_target eq 'dbl_src' ) { if ( $dbl_src_target eq 'dbl_src' ) {
$chainref = set_optflags( new_standard_chain( $dbl_dst_target = 'dbl_dst' ) , DONT_OPTIMIZE | DONT_DELETE ); $chainref = new_standard_chain( $dbl_dst_target = 'dbl_dst' );
log_rule_limit( $dbl_level, log_rule_limit( $dbl_level,
$chainref, $chainref,
@@ -829,7 +832,7 @@ sub add_common_rules ( $ ) {
$dbl_dst_target = $dbl_src_target; $dbl_dst_target = $dbl_src_target;
} }
} elsif ( $dbl_level ) { } elsif ( $dbl_level ) {
my $chainref = set_optflags( new_standard_chain( $dbl_src_target = $dbl_dst_target = 'dbl_log' ) , DONT_OPTIMIZE | DONT_DELETE ); my $chainref = new_standard_chain( $dbl_src_target = $dbl_dst_target = 'dbl_log' );
log_rule_limit( $dbl_level, log_rule_limit( $dbl_level,
$chainref, $chainref,
@@ -1322,7 +1325,7 @@ sub setup_mac_lists( $ ) {
$maclist_interfaces{ $hostref->[0] } = 1; $maclist_interfaces{ $hostref->[0] } = 1;
} }
my @maclist_interfaces = ( keys %maclist_interfaces ); my @maclist_interfaces = ( sortkeysiftest %maclist_interfaces );
if ( $phase == 1 ) { if ( $phase == 1 ) {
@@ -1408,7 +1411,7 @@ sub setup_mac_lists( $ ) {
# #
# Generate jumps from the input and forward chains # Generate jumps from the input and forward chains
# #
for my $hostref ( @$maclist_hosts ) { for my $hostref ( $test ? sort { $a->[0] cmp $b->[0] } @$maclist_hosts : @$maclist_hosts ) {
my $interface = $hostref->[0]; my $interface = $hostref->[0];
my $ipsec = $hostref->[1]; my $ipsec = $hostref->[1];
my @policy = $ipsec && have_ipsec ? ( policy => "--pol $ipsec --dir in" ) : (); my @policy = $ipsec && have_ipsec ? ( policy => "--pol $ipsec --dir in" ) : ();
@@ -1801,7 +1804,7 @@ sub handle_complex_zone( $$ ) {
my $type = $zoneref->{type}; my $type = $zoneref->{type};
my $source_ref = ( $zoneref->{hosts}{ipsec} ) || {}; my $source_ref = ( $zoneref->{hosts}{ipsec} ) || {};
for my $interface ( keys %$source_ref ) { for my $interface ( sortkeysiftest %$source_ref ) {
my $sourcechainref = $filter_table->{forward_chain $interface}; my $sourcechainref = $filter_table->{forward_chain $interface};
my @interfacematch; my @interfacematch;
my $interfaceref = find_interface $interface; my $interfaceref = find_interface $interface;
@@ -1941,7 +1944,7 @@ sub add_output_jumps( $$$$$$$$ ) {
my $use_output = 0; my $use_output = 0;
my @dest = imatch_dest_net $net; my @dest = imatch_dest_net $net;
my @ipsec_out_match = match_ipsec_out $zone , $hostref; my @ipsec_out_match = match_ipsec_out $zone , $hostref;
my @zone_interfaces = keys %{zone_interfaces( $zone )}; my @zone_interfaces = sortkeysiftest %{zone_interfaces( $zone )};
if ( @vservers || use_interface_chain( $interface, 'use_output_chain' ) || ( @{$interfacechainref->{rules}} && ! $chain1ref ) || @zone_interfaces > 1 ) { if ( @vservers || use_interface_chain( $interface, 'use_output_chain' ) || ( @{$interfacechainref->{rules}} && ! $chain1ref ) || @zone_interfaces > 1 ) {
# #
@@ -2285,10 +2288,13 @@ sub generate_matrix() {
# #
for my $zone ( @zones ) { for my $zone ( @zones ) {
my $zoneref = find_zone( $zone ); my $zoneref = find_zone( $zone );
if ( @zones > 2 || $zoneref->{complex} ) {
handle_complex_zone( $zone, $zoneref ); unless ( $zoneref->{type} == LOCAL ) {
} else { if ( @zones > 2 || $zoneref->{complex} ) {
new_standard_chain zone_forward_chain( $zone ) if @zones > 1; handle_complex_zone( $zone, $zoneref );
} else {
new_standard_chain zone_forward_chain( $zone ) if @zones > 1;
}
} }
} }
# #
@@ -2313,9 +2319,9 @@ sub generate_matrix() {
# #
# Take care of PREROUTING, INPUT and OUTPUT jumps # Take care of PREROUTING, INPUT and OUTPUT jumps
# #
for my $type ( keys %$source_hosts_ref ) { for my $type ( sortkeysiftest %$source_hosts_ref ) {
my $typeref = $source_hosts_ref->{$type}; my $typeref = $source_hosts_ref->{$type};
for my $interface ( keys %$typeref ) { for my $interface ( sortkeysiftest %$typeref ) {
if ( get_physical( $interface ) eq '+' ) { if ( get_physical( $interface ) eq '+' ) {
# #
# Insert the interface-specific jumps before this one which is not interface-specific # Insert the interface-specific jumps before this one which is not interface-specific
@@ -2400,9 +2406,9 @@ sub generate_matrix() {
my $chainref = $filter_table->{$chain}; #Will be null if $chain is a Netfilter Built-in target like ACCEPT my $chainref = $filter_table->{$chain}; #Will be null if $chain is a Netfilter Built-in target like ACCEPT
for my $type ( keys %{$zone1ref->{hosts}} ) { for my $type ( sortkeysiftest %{$zone1ref->{hosts}} ) {
my $typeref = $zone1ref->{hosts}{$type}; my $typeref = $zone1ref->{hosts}{$type};
for my $interface ( keys %$typeref ) { for my $interface ( sortkeysiftest %$typeref ) {
for my $hostref ( @{$typeref->{$interface}} ) { for my $hostref ( @{$typeref->{$interface}} ) {
next if $hostref->{options}{sourceonly}; next if $hostref->{options}{sourceonly};
if ( $zone ne $zone1 || $num_ifaces > 1 || $hostref->{options}{routeback} ) { if ( $zone ne $zone1 || $num_ifaces > 1 || $hostref->{options}{routeback} ) {
@@ -2579,13 +2585,13 @@ EOF
emit <<'EOF'; emit <<'EOF';
case $COMMAND in case $COMMAND in
start) start)
mylogger kern.err "ERROR:$g_product start failed" mylogger daemon.err "ERROR:$g_product start failed"
;; ;;
reload) reload)
mylogger kern.err "ERROR:$g_product reload failed" mylogger daemon.err "ERROR:$g_product reload failed"
;; ;;
enable) enable)
mylogger kern.err "ERROR:$g_product 'enable $g_interface' failed" mylogger daemon.err "ERROR:$g_product 'enable $g_interface' failed"
;; ;;
esac esac
@@ -2808,7 +2814,7 @@ EOF
emit ' emit '
set_state "Stopped" set_state "Stopped"
mylogger kern.info "$g_product Stopped" mylogger daemon.info "$g_product Stopped"
case $COMMAND in case $COMMAND in
stop|clear) stop|clear)

View File

@@ -5,7 +5,7 @@
# #
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -561,7 +561,7 @@ sub open_snat_for_output( $ ) {
# #
# For information about entries in this file, type "man shorewall-snat" # For information about entries in this file, type "man shorewall-snat"
# #
# See http://shorewall.org/manpages/shorewall-snat.html for additional information # See https://shorewall.org/manpages/shorewall-snat.html for additional information
EOF EOF
} else { } else {
print $snat <<'EOF'; print $snat <<'EOF';
@@ -570,7 +570,7 @@ EOF
# #
# For information about entries in this file, type "man shorewall6-snat" # For information about entries in this file, type "man shorewall6-snat"
# #
# See http://shorewall.org/manpages6/shorewall6-snat.html for additional information # See https://shorewall.org/manpages/shorewall-snat.html for additional information
EOF EOF
} }

View File

@@ -5,7 +5,7 @@
# #
# (c) 2007-2016 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2016 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -5,7 +5,7 @@
# #
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -1892,8 +1892,8 @@ sub map_provider_to_interface() {
my $haveoptional; my $haveoptional;
for my $providerref ( values %providers ) { for my $provider ( @providers ) {
if ( $providerref->{optional} ) { if ( ( my $providerref=$providers{$provider} )->{optional} ) {
unless ( $haveoptional++ ) { unless ( $haveoptional++ ) {
emit( 'if [ -n "$interface" ]; then', emit( 'if [ -n "$interface" ]; then',
' case $interface in' ); ' case $interface in' );
@@ -2054,8 +2054,7 @@ sub compile_updown() {
); );
} }
my @nonshared = ( grep $providers{$_}->{optional}, my @nonshared = ( grep $providers{$_}->{optional}, sortvaluesiftest %provider_interfaces );
values %provider_interfaces );
if ( @nonshared ) { if ( @nonshared ) {
my $interfaces = join( '|', map $providers{$_}->{physical}, @nonshared ); my $interfaces = join( '|', map $providers{$_}->{physical}, @nonshared );
@@ -2065,12 +2064,12 @@ sub compile_updown() {
push_indent; push_indent;
emit( q(if [ "$state" = started ]; then) , emit( q(if [ "$state" = started ]; then) ,
q( if [ "$COMMAND" = up ]; then) , q( if [ "$COMMAND" = up ]; then) ,
q( progress_message3 "Attempting enable on interface $1") , q( progress_message3 "Attempting enable on interface $1") ,
q( COMMAND=enable) , q( COMMAND=enable) ,
q( detect_configuration $1), q( detect_configuration $1),
q( enable_provider $1), q( enable_provider $1),
q( elif [ "$PHASE" != post-down ]; then # pre-down or not Debian) , q( else),
q( progress_message3 "Attempting disable on interface $1") , q( progress_message3 "Attempting disable on interface $1") ,
q( COMMAND=disable) , q( COMMAND=disable) ,
q( detect_configuration $1), q( detect_configuration $1),
@@ -2111,7 +2110,7 @@ sub compile_updown() {
emit( ' progress_message3 "$g_product attempting $COMMAND"', emit( ' progress_message3 "$g_product attempting $COMMAND"',
' detect_configuration', ' detect_configuration',
' define_firewall', ' define_firewall',
' elif [ "$PHASE" != pre-down ]; then # Not Debian pre-down phase' ' else' ,
); );
push_indent; push_indent;
@@ -2246,9 +2245,11 @@ sub handle_optional_interfaces() {
# names but they might derive from wildcard interface entries. Optional interfaces which do not have # names but they might derive from wildcard interface entries. Optional interfaces which do not have
# wildcard physical names are also included in the providers table. # wildcard physical names are also included in the providers table.
# #
for my $providerref ( grep $_->{optional} , values %providers ) { for my $provider ( @providers ) {
push @interfaces, $providerref->{interface}; if ( ( my $providerref = $providers{$provider} )->{optional} ) {
$wildcards ||= $providerref->{wildcard}; push @interfaces, $providerref->{interface};
$wildcards ||= $providerref->{wildcard};
}
} }
# #
@@ -2296,17 +2297,7 @@ sub handle_optional_interfaces() {
emit( "$physical)" ), push_indent if $wildcards; emit( "$physical)" ), push_indent if $wildcards;
if ( $provider eq $physical ) { emit qq(if [ -z "\$interface" -o "\$interface" = "$physical" ]; then);
#
# 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; push_indent;

View File

@@ -5,7 +5,7 @@
# #
# (c) 2007-2017 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2017 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -155,7 +155,7 @@ sub setup_proxy_arp() {
emit ''; emit '';
for my $interface ( keys %reset ) { for my $interface ( sortkeysiftest %reset ) {
unless ( $set{interface} ) { unless ( $set{interface} ) {
my $physical = get_physical $interface; my $physical = get_physical $interface;
emit ( "if [ -f /proc/sys/net/ipv$family/conf/$physical/$proc_file ]; then" , emit ( "if [ -f /proc/sys/net/ipv$family/conf/$physical/$proc_file ]; then" ,
@@ -164,7 +164,7 @@ sub setup_proxy_arp() {
} }
} }
for my $interface ( keys %set ) { for my $interface ( sortkeysiftest %set ) {
my $physical = get_physical $interface; my $physical = get_physical $interface;
emit ( "if [ -f /proc/sys/net/ipv$family/conf/$physical/$proc_file ]; then" , emit ( "if [ -f /proc/sys/net/ipv$family/conf/$physical/$proc_file ]; then" ,
" echo 1 > /proc/sys/net/ipv$family/conf/$physical/$proc_file" ); " echo 1 > /proc/sys/net/ipv$family/conf/$physical/$proc_file" );

View File

@@ -5,7 +5,7 @@
# #
# (c) 2009-2019 - Tom Eastep (teastep@shorewall.net) # (c) 2009-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -5,7 +5,7 @@
# #
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -443,6 +443,7 @@ sub convert_to_policy_chain($$$$$$)
my ($chainref, $source, $dest, $policy, $provisional, $audit ) = @_; my ($chainref, $source, $dest, $policy, $provisional, $audit ) = @_;
$chainref->{is_policy} = 1; $chainref->{is_policy} = 1;
$chainref->{wild} = $source eq 'all' || $dest eq 'all';
$chainref->{policy} = $policy; $chainref->{policy} = $policy;
$chainref->{provisional} = $provisional; $chainref->{provisional} = $provisional;
$chainref->{audit} = $audit; $chainref->{audit} = $audit;
@@ -660,7 +661,7 @@ sub handle_nfqueue( $ ) {
if ( supplied $queue2 ) { if ( supplied $queue2 ) {
require_capability 'CPU_FANOUT', '"c"', 's' if $fanout; require_capability 'CPU_FANOUT', '"c"', 's' if $fanout;
return "NFQUEUE --queue-balance ${queuenum1}:${queuenum2}${fanout}${bypass}"; return "NFQUEUE --queue-balance ${queuenum1}:${queuenum2}${bypass}${fanout}";
} else { } else {
return "NFQUEUE --queue-num ${queuenum1}${bypass}"; return "NFQUEUE --queue-num ${queuenum1}${bypass}";
} }
@@ -1000,6 +1001,24 @@ sub determine_action_protocol( $$ ) {
$proto; $proto;
} }
sub determine_action_dport( $$$ ) {
my ( $action, $proto, $dport ) = @_;
if ( my $actiondport = $actions{$action}{dport} ) {
if ( $dport eq '-' ) {
$dport = $actiondport;
} else {
fatal_error( "The $action action is only usable with destination port $actiondport" ) if $dport =~ /[,]/;
if ( ( my $portnum = validate_port( $proto, $dport ) ) ne '-' ) {
fatal_error( "The $action action is only usable with destination port $actiondport" ) unless $actiondport = $portnum;
$dport = $portnum;
}
}
}
$dport;
}
sub add_policy_rules( $$$$$ ) { sub add_policy_rules( $$$$$ ) {
my ( $chainref , $target, $loglevel, $pactions, $dropmulticast ) = @_; my ( $chainref , $target, $loglevel, $pactions, $dropmulticast ) = @_;
@@ -1014,7 +1033,11 @@ sub add_policy_rules( $$$$$ ) {
# Policy action is a regular action -- jump to the action chain # Policy action is a regular action -- jump to the action chain
# #
if ( ( my $proto = determine_action_protocol( $action, '-' ) ) ne '-' ) { if ( ( my $proto = determine_action_protocol( $action, '-' ) ) ne '-' ) {
add_ijump( $chainref, j => use_policy_action( $paction, $chainref->{name} ), p => $proto ); if ( my $dport = determine_action_dport( $action, $proto, '' ) ) {
add_ijump( $chainref, j => use_policy_action( $paction, $chainref->{name} ), p => $proto, dport => $dport );
} else {
add_ijump( $chainref, j => use_policy_action( $paction, $chainref->{name} ), p => $proto );
}
} else { } else {
add_ijump $chainref, j => use_policy_action( $paction, $chainref->{name} ); add_ijump $chainref, j => use_policy_action( $paction, $chainref->{name} );
} }
@@ -1147,7 +1170,7 @@ sub complete_policy_chains() {
} }
} }
if ( $name =~ /^all[-2]|[-2]all$/ ) { if ( $chainref->{wild} ) {
add_policy_rules $chainref , $policy, $loglevel , $defaults, $config{MULTICAST}; add_policy_rules $chainref , $policy, $loglevel , $defaults, $config{MULTICAST};
} }
} }
@@ -1252,6 +1275,7 @@ sub finish_chain_section ($$$) {
$state ) = @_; $state ) = @_;
my $chain = $chainref->{name}; my $chain = $chainref->{name};
my $save_comment = push_comment; my $save_comment = push_comment;
my $wild = $chainref->{wild} && ! $config{EXPAND_RULES};
my %state; my %state;
$state{$_} = 1 for split ',', $state; $state{$_} = 1 for split ',', $state;
@@ -1262,74 +1286,76 @@ sub finish_chain_section ($$$) {
$chain1ref->{sections}{$_} = 1 for keys %state; $chain1ref->{sections}{$_} = 1 for keys %state;
for ( qw( ESTABLISHED RELATED INVALID UNTRACKED ) ) { unless ( $wild ) {
if ( $state{$_} ) { for ( qw( ESTABLISHED RELATED INVALID UNTRACKED ) ) {
my ( $char, $level, $tag, $target , $origin, $level_origin ) = @{$statetable{$_}}; if ( $state{$_} ) {
my $twochains = substr( $chainref->{name}, 0, 1 ) eq $char; my ( $char, $level, $tag, $target , $origin, $level_origin ) = @{$statetable{$_}};
my $twochains = substr( $chainref->{name}, 0, 1 ) eq $char;
if ( $twochains || $level || $target ne 'ACCEPT' ) { if ( $twochains || $level || $target ne 'ACCEPT' ) {
if ( $level ) { if ( $level ) {
my $chain2ref; my $chain2ref;
if ( $twochains ) {
$chain2ref = $chainref;
} else {
$chain2ref = new_chain( 'filter', "${char}$chainref->{name}" , "${char}$chainref->{logname}" );
}
log_rule_limit( $level,
$chain2ref,
$chain2ref->{logname},
uc $target,
$globals{LOGLIMIT},
$tag ,
'add' ,
'',
$level_origin );
$target = ensure_audit_chain( $target ) if ( $targets{$target} || 0 ) & AUDIT;
add_ijump_extended( $chain2ref, g => $target , $origin ) if $target;
$target = $chain2ref->{name} unless $twochains;
}
if ( $twochains ) { if ( $twochains ) {
$chain2ref = $chainref; add_ijump_extended $chainref, g => $target , $origin if $target;
} else { delete $state{$_};
$chain2ref = new_chain( 'filter', "${char}$chainref->{name}" , "${char}$chainref->{logname}" ); last;
} }
log_rule_limit( $level, if ( $target ) {
$chain2ref, $target = ensure_audit_chain( $target ) if ( $targets{$target} || 0 ) & AUDIT;
$chain2ref->{logname}, #
uc $target, # Always handle ESTABLISHED first
$globals{LOGLIMIT}, #
$tag , if ( $state{ESTABLISHED} && $_ ne 'ESTABLISHED' ) {
'add' , add_ijump( $chain1ref, j => 'ACCEPT', state_imatch 'ESTABLISHED' );
'', delete $state{ESTABLISHED};
$level_origin ); }
$target = ensure_audit_chain( $target ) if ( $targets{$target} || 0 ) & AUDIT; add_ijump_extended( $chainref, j => $target, $origin, state_imatch $_ );
}
add_ijump_extended( $chain2ref, g => $target , $origin ) if $target;
$target = $chain2ref->{name} unless $twochains;
}
if ( $twochains ) {
add_ijump_extended $chainref, g => $target , $origin if $target;
delete $state{$_}; delete $state{$_};
last;
} }
if ( $target ) {
$target = ensure_audit_chain( $target ) if ( $targets{$target} || 0 ) & AUDIT;
#
# Always handle ESTABLISHED first
#
if ( $state{ESTABLISHED} && $_ ne 'ESTABLISHED' ) {
add_ijump( $chain1ref, j => 'ACCEPT', state_imatch 'ESTABLISHED' );
delete $state{ESTABLISHED};
}
add_ijump_extended( $chainref, j => $target, $origin, state_imatch $_ );
}
delete $state{$_};
}
}
}
if ( keys %state ) {
my @state;
unless ( $config{FASTACCEPT} ) {
for ( qw/ESTABLISHED RELATED/ ) {
push @state, $_ if $state{$_};
} }
} }
push( @state, 'UNTRACKED' ),if $state{UNTRACKED} && $globals{UNTRACKED_TARGET} eq 'ACCEPT'; if ( keys %state ) {
my @state;
add_ijump( $chain1ref, j => 'ACCEPT', state_imatch join(',', @state ) ) if @state; unless ( $config{FASTACCEPT} ) {
for ( qw/ESTABLISHED RELATED/ ) {
push @state, $_ if $state{$_};
}
}
push( @state, 'UNTRACKED' ),if $state{UNTRACKED} && $globals{UNTRACKED_TARGET} eq 'ACCEPT';
add_ijump( $chain1ref, j => 'ACCEPT', state_imatch join(',', @state ) ) if @state;
}
} }
if ($sections{NEW} ) { if ($sections{NEW} ) {
@@ -1497,13 +1523,13 @@ sub external_name( $ ) {
# #
# Define an Action # Define an Action
# #
sub new_action( $$$$$$ ) { sub new_action( $$$$$$$ ) {
my ( $action , $type, $options , $actionfile , $state, $proto ) = @_; my ( $action , $type, $options , $actionfile , $state, $proto, $dport ) = @_;
fatal_error "Reserved action name ($action)" if reserved_name( $action ); fatal_error "Reserved action name ($action)" if reserved_name( $action );
$actions{$action} = { file => $actionfile, actchain => '' , type => $type, options => $options , state => $state, proto => $proto }; $actions{$action} = { file => $actionfile, actchain => '' , type => $type, options => $options , state => $state, proto => $proto, dport => $dport };
$targets{$action} = $type; $targets{$action} = $type;
} }
@@ -1774,7 +1800,7 @@ sub isolate_basic_target( $ ) {
sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ); sub process_rule ( $$$$$$$$$$$$$$$$$$$$ );
sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ); sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ );
sub process_snat1( $$$$$$$$$$$$ ); sub process_snat1( $$$$$$$$$$$$$ );
sub perl_action_helper( $$;$$ ); sub perl_action_helper( $$;$$ );
# #
@@ -1968,23 +1994,49 @@ sub process_action(\$\$$) {
set_inline_matches( $matches ); set_inline_matches( $matches );
} }
} else { } else {
my ( $action, $source, $dest, $protos, $port, $ipsec, $mark, $user, $condition, $origdest, $probability) = my ( $action, $source, $dest, $protos, $port, $sport, $ipsec, $mark, $user, $condition, $origdest, $probability);
split_line2( 'snat file',
{ action =>0, if ( $file_format == 1 ) {
source => 1, ( $action, $source, $dest, $protos, $port, $ipsec, $mark, $user, $condition, $origdest, $probability) =
dest => 2, split_line2( 'snat file',
proto => 3, { action =>0,
port => 4, source => 1,
ipsec => 5, dest => 2,
mark => 6, proto => 3,
user => 7, port => 4,
switch => 8, dport => 4,
origdest => 9, ipsec => 5,
probability => 10, mark => 6,
}, user => 7,
{}, switch => 8,
11, origdest => 9,
1 ); probability => 10,
},
{},
11,
1 );
$sport = '-';
} else {
( $action, $source, $dest, $protos, $port, $sport, $ipsec, $mark, $user, $condition, $origdest, $probability) =
split_line2( 'snat file',
{ action =>0,
source => 1,
dest => 2,
proto => 3,
port => 4,
dport => 4,
sport => 5,
ipsec => 6,
mark => 7,
user => 8,
switch => 9,
origdest => 10,
probability => 11,
},
{},
12,
1 );
}
fatal_error 'ACTION must be specified' if $action eq '-'; fatal_error 'ACTION must be specified' if $action eq '-';
@@ -2000,6 +2052,7 @@ sub process_action(\$\$$) {
$dest, $dest,
$proto, $proto,
$port, $port,
$sport,
$ipsec, $ipsec,
$mark, $mark,
$user, $user,
@@ -2098,6 +2151,7 @@ sub process_actions() {
my $state = ''; my $state = '';
my $proto = 0; my $proto = 0;
my $dport = 0;
if ( $action =~ /:/ ) { if ( $action =~ /:/ ) {
warning_message 'Policy Actions are now specified in /etc/shorewall/shorewall.conf'; warning_message 'Policy Actions are now specified in /etc/shorewall/shorewall.conf';
@@ -2117,6 +2171,10 @@ sub process_actions() {
} elsif ( /^proto=(.+)$/ ) { } elsif ( /^proto=(.+)$/ ) {
fatal_error "Unknown Protocol ($1)" unless defined( $proto = resolve_proto( $1 ) ); fatal_error "Unknown Protocol ($1)" unless defined( $proto = resolve_proto( $1 ) );
fatal_error "A protocol may not be specified on the REJECT_ACTION ($action)" if $action eq $config{REJECT_ACTION}; fatal_error "A protocol may not be specified on the REJECT_ACTION ($action)" if $action eq $config{REJECT_ACTION};
} elsif ( /^dport=(.+)$/ ) {
fatal_error "The 'dport' option requires the 'proto' option" unless $proto;
$dport = validate_port($proto, $1);
fatal_error "A destination port may not be specified on the REJECT_ACTION ($action)" if $action eq $config{REJECT_ACTION};
} else { } else {
fatal_error "Invalid option ($_)" unless $options{$_}; fatal_error "Invalid option ($_)" unless $options{$_};
$opts |= $options{$_}; $opts |= $options{$_};
@@ -2138,10 +2196,12 @@ sub process_actions() {
} }
$proto = $actions{$action}{proto} unless $proto; $proto = $actions{$action}{proto} unless $proto;
$dport = $actions{$action}{dport} unless $dport;
delete $actions{$action}; delete $actions{$action};
delete $targets{$action}; delete $targets{$action};
} elsif ( ( $actiontype & INLINE ) && ( $type == ACTION ) && $opts & NOINLINE_OPT ) { } elsif ( ( $actiontype & INLINE ) && ( $type == ACTION ) && $opts & NOINLINE_OPT ) {
$proto = $actions{$action}{proto} unless $proto; $proto = $actions{$action}{proto} unless $proto;
$dport = $actions{$action}{dport} unless $dport;
delete $actions{$action}; delete $actions{$action};
delete $targets{$action}; delete $targets{$action};
} else { } else {
@@ -2185,7 +2245,7 @@ sub process_actions() {
fatal_error "Missing Action File ($actionfile)" unless -f $actionfile; fatal_error "Missing Action File ($actionfile)" unless -f $actionfile;
new_action ( $action, $type, $opts, $actionfile , $state , $proto ); new_action ( $action, $type, $opts, $actionfile , $state , $proto , $dport );
} }
} }
} }
@@ -2888,6 +2948,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
fatal_error "Invalid flags ($flags)" unless defined $flags && $flags =~ /^(dst|src)(,(dst|src)){0,5}$/; fatal_error "Invalid flags ($flags)" unless defined $flags && $flags =~ /^(dst|src)(,(dst|src)){0,5}$/;
$action = join( ' ', 'SET --' . $xlate{$basictarget} , $setname , $flags ); $action = join( ' ', 'SET --' . $xlate{$basictarget} , $setname , $flags );
$log_action = "$basictarget($setname)";
if ( supplied $timeout ) { if ( supplied $timeout ) {
fatal_error "A timeout may only be supplied in an ADD rule" unless $basictarget eq 'ADD'; fatal_error "A timeout may only be supplied in an ADD rule" unless $basictarget eq 'ADD';
@@ -3063,9 +3124,11 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
if ( $actiontype & ACTION ) { if ( $actiontype & ACTION ) {
# #
# Verify action 'proto', if any # Verify action 'proto', and 'dport' if any
# #
$proto = determine_action_protocol( $basictarget, $proto ); if ( ( $proto = determine_action_protocol( $basictarget, $proto ) ) ne '-' ) {
$ports = determine_action_dport( $basictarget, $proto, $ports );
}
# #
# Save NAT-oriented column contents # Save NAT-oriented column contents
# #
@@ -3923,9 +3986,8 @@ sub process_rules() {
# #
for my $zone ( @zones ) { for my $zone ( @zones ) {
my $zoneref = find_zone( $zone ); my $zoneref = find_zone( $zone );
my $simple = @zones <= 2 && ! $zoneref->{complex};
unless ( @zones <= 2 && ! $zoneref->{complex} ) { unless ( $zoneref->{type} == LOCAL || ( @zones <= 2 && ! $zoneref->{complex} ) ) {
# #
# Complex zone or we have more than one non-firewall zone -- create a zone forwarding chain # Complex zone or we have more than one non-firewall zone -- create a zone forwarding chain
# #
@@ -4817,9 +4879,11 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$$ ) {
function => sub() { function => sub() {
fatal_error( qq(Action $cmd may not be used in the mangle file) ) unless $actiontype & MANGLE_TABLE; fatal_error( qq(Action $cmd may not be used in the mangle file) ) unless $actiontype & MANGLE_TABLE;
# #
# Verify action 'proto', if any # Verify action 'proto' and 'dport' if any
# #
$proto = determine_action_protocol( $cmd, $proto ); if ( ( $proto = determine_action_protocol( $cmd, $proto ) ) ne '-' ) {
$ports = determine_action_dport( $cmd, $proto, $ports );
}
# #
# Create the action:level:tag:param tuple. # Create the action:level:tag:param tuple.
# #
@@ -5363,8 +5427,8 @@ sub process_mangle_rule( $ ) {
} }
} }
sub process_snat_inline( $$$$$$$$$$$$$$ ) { sub process_snat_inline( $$$$$$$$$$$$$$$ ) {
my ($inline, $chainref, $params, $loglevel, $source, $dest, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_; my ($inline, $chainref, $params, $loglevel, $source, $dest, $protos, $ports, $sports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_;
my ( $level, my ( $level,
$tag ) = split( ':', $loglevel, 2 ); $tag ) = split( ':', $loglevel, 2 );
@@ -5383,28 +5447,54 @@ sub process_snat_inline( $$$$$$$$$$$$$$ ) {
progress_message "..Expanding inline action $inlinefile..."; progress_message "..Expanding inline action $inlinefile...";
push_open $inlinefile, 2, 1, undef , 2; push_open $inlinefile, 2, 1, undef , 1;
my $save_comment = push_comment; my $save_comment = push_comment;
while ( read_a_line( NORMAL_READ ) ) { while ( read_a_line( NORMAL_READ ) ) {
my ( $maction, $msource, $mdest, $mprotos, $mports, $mipsec, $mmark, $muser, $mcondition, $morigdest, $mprobability) = my ( $maction, $msource, $mdest, $mprotos, $mports, $msports, $mipsec, $mmark, $muser, $mcondition, $morigdest, $mprobability);
split_line2( 'snat file',
{ action =>0, if ( $file_format == 1 ) {
source => 1, ( $maction, $msource, $mdest, $mprotos, $mports, $mipsec, $mmark, $muser, $mcondition, $morigdest, $mprobability) =
dest => 2, split_line2( 'snat file',
proto => 3, { action =>0,
port => 4, source => 1,
ipsec => 5, dest => 2,
mark => 6, proto => 3,
user => 7, port => 4,
switch => 8, dport => 4,
origdest => 9, ipsec => 5,
probability => 10, mark => 6,
}, user => 7,
{}, switch => 8,
11, origdest => 9,
1 ); probability => 10,
},
{},
11,
1 );
$msports = '-';
} else {
( $maction, $msource, $mdest, $mprotos, $mports, $msports, $mipsec, $mmark, $muser, $mcondition, $morigdest, $mprobability) =
split_line2( 'snat file',
{ action =>0,
source => 1,
dest => 2,
proto => 3,
port => 4,
dport => 4,
sport => 5,
ipsec => 6,
mark => 7,
user => 8,
switch => 9,
origdest => 10,
probability => 11,
},
{},
12,
1 );
}
fatal_error 'ACTION must be specified' if $maction eq '-'; fatal_error 'ACTION must be specified' if $maction eq '-';
@@ -5432,6 +5522,7 @@ sub process_snat_inline( $$$$$$$$$$$$$$ ) {
$mdest, $mdest,
$proto, $proto,
merge_macro_column( $mports, $ports ), merge_macro_column( $mports, $ports ),
merge_macro_column( $msports, $sports ),
merge_macro_column( $mipsec, $ipsec ), merge_macro_column( $mipsec, $ipsec ),
merge_macro_column( $mmark, $mark ), merge_macro_column( $mmark, $mark ),
merge_macro_column( $muser, $user ), merge_macro_column( $muser, $user ),
@@ -5458,8 +5549,8 @@ sub process_snat_inline( $$$$$$$$$$$$$$ ) {
# #
# Process a record in the snat file # Process a record in the snat file
# #
sub process_snat1( $$$$$$$$$$$$ ) { sub process_snat1( $$$$$$$$$$$$$ ) {
my ( $chainref, $origaction, $source, $dest, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_; my ( $chainref, $origaction, $source, $dest, $proto, $ports, $sports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_;
my $inchain; my $inchain;
my $inaction; my $inaction;
@@ -5479,6 +5570,13 @@ sub process_snat1( $$$$$$$$$$$$ ) {
my ( $action, $loglevel ) = split_action( $origaction ); my ( $action, $loglevel ) = split_action( $origaction );
my $logaction; my $logaction;
my $param; my $param;
#
# Handle early matches
#
if ( $inlinematches =~ s/^s*\+// ) {
$prerule = $inlinematches;
$inlinematches = '';
}
if ( $action =~ /^MASQUERADE(\+)?(?:\((.+)\))?$/ ) { if ( $action =~ /^MASQUERADE(\+)?(?:\((.+)\))?$/ ) {
$target = 'MASQUERADE'; $target = 'MASQUERADE';
@@ -5571,7 +5669,7 @@ sub process_snat1( $$$$$$$$$$$$ ) {
# #
# Handle Protocol, Ports and Condition # Handle Protocol, Ports and Condition
# #
$baserule .= do_proto( $proto, $ports, '' ); $baserule .= do_proto( $proto, $ports, $sports );
# #
# Handle Mark # Handle Mark
# #
@@ -5818,6 +5916,7 @@ sub process_snat1( $$$$$$$$$$$$ ) {
supplied( $destnets ) && $destnets ne '-' ? $inaction || $interface ? join( ':', $interface, $destnets ) : $destnets : $inaction ? '-' : $interface, supplied( $destnets ) && $destnets ne '-' ? $inaction || $interface ? join( ':', $interface, $destnets ) : $destnets : $inaction ? '-' : $interface,
$proto, $proto,
$ports, $ports,
$sports,
$ipsec, $ipsec,
$mark, $mark,
$user, $user,
@@ -5828,9 +5927,11 @@ sub process_snat1( $$$$$$$$$$$$ ) {
if ( $actiontype & ACTION ) { if ( $actiontype & ACTION ) {
fatal_error( qq(Action $target may not be used in the snat file) ) unless $actiontype & NAT_TABLE; fatal_error( qq(Action $target may not be used in the snat file) ) unless $actiontype & NAT_TABLE;
# #
# Verify action 'proto', if any # Verify action 'proto' and 'dport', if any
# #
$proto = determine_action_protocol( $target, $proto ); if ( ( $proto = determine_action_protocol( $target, $proto ) ) ne '-' ) {
$ports = determine_action_dport( $target, $proto, $ports );
}
# #
# Create the action:level:tag:param tuple. Since we don't allow logging out of nat POSTROUTING, we store # Create the action:level:tag:param tuple. Since we don't allow logging out of nat POSTROUTING, we store
# the interface name in the log tag # the interface name in the log tag
@@ -5928,18 +6029,30 @@ sub process_snat1( $$$$$$$$$$$$ ) {
sub process_snat( ) sub process_snat( )
{ {
my ($action, $source, $dest, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = my ($action, $source, $dest, $protos, $ports, $sports, $ipsec, $mark, $user, $condition, $origdest, $probability );
split_line2( 'snat file',
{ action => 0, source => 1, dest => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 }, if ( $file_format == 1 ) {
{}, #Nopad ($action, $source, $dest, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) =
undef, #Columns split_line2( 'snat file',
1 ); #Allow inline matches { action => 0, source => 1, dest => 2, proto => 3, port => 4, dport => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 },
{}, #Nopad
11, #Columns
1 ); #Allow inline matches
$sports = '-';
} else {
($action, $source, $dest, $protos, $ports, $sports, $ipsec, $mark, $user, $condition, $origdest, $probability ) =
split_line2( 'snat file',
{ action => 0, source => 1, dest => 2, proto => 3, port => 4, dport => 4, sport => 5, ipsec => 6, mark => 7, user => 8, switch => 9, origdest => 10, probability => 11 },
{}, #Nopad
12, #Columns
1 ); #Allow inline matches
}
fatal_error 'ACTION must be specified' if $action eq '-'; fatal_error 'ACTION must be specified' if $action eq '-';
fatal_error 'DEST must be specified' if $dest eq '-'; fatal_error 'DEST must be specified' if $dest eq '-';
for my $proto ( split_list $protos, 'Protocol' ) { for my $proto ( split_list $protos, 'Protocol' ) {
process_snat1( undef, $action, $source, $dest, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ); process_snat1( undef, $action, $source, $dest, $proto, $ports, $sports, $ipsec, $mark, $user, $condition, $origdest, $probability );
} }
} }
@@ -5954,7 +6067,7 @@ sub setup_snat()
# #
# Masq file was empty or didn't exist # Masq file was empty or didn't exist
# #
if ( $fn = open_file( 'snat', 1, 1 ) ) { if ( $fn = open_file( 'snat', 2, 1, undef, 1 ) ) {
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , "a non-empty snat file" , 's'; } ); first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , "a non-empty snat file" , 's'; } );
process_snat while read_a_line( NORMAL_READ ); process_snat while read_a_line( NORMAL_READ );
} }

View File

@@ -10,7 +10,7 @@
# Modified by Tom Eastep for integration into the Shorewall distribution # Modified by Tom Eastep for integration into the Shorewall distribution
# published under GPL Version 2# # published under GPL Version 2#
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -72,6 +72,9 @@ our %flow_keys = ( 'src' => 1,
# out_bandwidth => <value> , # out_bandwidth => <value> ,
# number => <number>, # number => <number>,
# classify => 0|1 # classify => 0|1
# flow => Comma-separated flow tupple
# classify => 0|1
# pfifo => 0|1
# tablenumber => <next u32 table to be allocated for this device> # tablenumber => <next u32 table to be allocated for this device>
# default => <default class mark value> # default => <default class mark value>
# redirected => [ <dev1>, <dev2>, ... ] # redirected => [ <dev1>, <dev2>, ... ]
@@ -80,6 +83,13 @@ our %flow_keys = ( 'src' => 1,
# qdisc => htb|hfsc # qdisc => htb|hfsc
# guarantee => <total RATE of classes seen so far> # guarantee => <total RATE of classes seen so far>
# name => <interface> # name => <interface>
# filters => [ filter, ... ]
# linklayer => <type> (optional)
# overhead => <number>
# mtu => <number>
# tsize => <number>
# filterpri => <number> (initially 0)
# connmark => 0|1
# } # }
# #
our @tcdevices; our @tcdevices;
@@ -139,12 +149,14 @@ sub initialize( $ ) {
sub rate_to_kbit( $ ) { sub rate_to_kbit( $ ) {
my $rate = $_[0]; my $rate = $_[0];
return 0 if $rate eq '-'; return 0 if $rate eq '-';
return $1 if $rate =~ /^((\d+)(\.\d+)?)kbit$/i; return $1 if $rate =~ /^((\d+)(\.\d+)?)kbit$/i;
return $1 * 1000 if $rate =~ /^((\d+)(\.\d+)?)mbit$/i; return $1 * 1000 if $rate =~ /^((\d+)(\.\d+)?)mbit$/i;
return $1 * 8000 if $rate =~ /^((\d+)(\.\d+)?)mbps$/i; return $1 * 1000000 if $rate =~ /^((\d+)(\.\d+)?)gbit$/i;
return $1 * 8 if $rate =~ /^((\d+)(\.\d+)?)kbps$/i; return $1 * 8000000 if $rate =~ /^((\d+)(\.\d+)?)gbps$/i;
return ($1/125) if $rate =~ /^((\d+)(\.\d+)?)(bps)?$/; return $1 * 8000 if $rate =~ /^((\d+)(\.\d+)?)mbps$/i;
return $1 * 8 if $rate =~ /^((\d+)(\.\d+)?)kbps$/i;
return ($1/125) if $rate =~ /^((\d+)(\.\d+)?)(bps)?$/;
fatal_error "Invalid Rate ($rate)"; fatal_error "Invalid Rate ($rate)";
} }
@@ -202,7 +214,7 @@ sub process_in_bandwidth( $ ) {
} else { } else {
if ( $in_band =~ /:/ ) { if ( $in_band =~ /:/ ) {
( $in_band, $burst ) = split /:/, $in_rate, 2; ( $in_band, $burst ) = split /:/, $in_rate, 2;
fatal_error "Invalid burst ($burst)" unless $burst =~ /^\d+(k|kb|m|mb|mbit|kbit|b)?$/; fatal_error "Invalid burst ($burst)" unless $burst =~ /^\d+(k|kb|m|mb|g|gb|gbit|mbit|kbit|b)?$/;
$in_burst = $burst; $in_burst = $burst;
} }
@@ -314,7 +326,7 @@ sub process_simple_device() {
my $command = "run_tc qdisc add dev $physical root handle $number: tbf rate ${out_bandwidth}kbit"; my $command = "run_tc qdisc add dev $physical root handle $number: tbf rate ${out_bandwidth}kbit";
if ( supplied $burst ) { if ( supplied $burst ) {
fatal_error "Invalid burst ($burst)" unless $burst =~ /^\d+(?:\.\d+)?(k|kb|m|mb|mbit|kbit|b)?$/; fatal_error "Invalid burst ($burst)" unless $burst =~ /^\d+(?:\.\d+)?(k|kb|m|mb|g|gb|gbit|mbit|kbit|b)?$/;
$command .= " burst $burst"; $command .= " burst $burst";
} else { } else {
$command .= ' burst 10kb'; $command .= ' burst 10kb';
@@ -330,12 +342,12 @@ sub process_simple_device() {
$command .= ' mpu 64'; #Assume Ethernet $command .= ' mpu 64'; #Assume Ethernet
if ( supplied $peak ) { if ( supplied $peak ) {
fatal_error "Invalid peak ($peak)" unless $peak =~ /^\d+(?:\.\d+)?(k|kb|m|mb|mbit|kbit|b)?$/; fatal_error "Invalid peak ($peak)" unless $peak =~ /^\d+(?:\.\d+)?(k|kb|m|mb|g|gb|gbit|mbit|kbit|b)?$/;
$command .= " peakrate $peak"; $command .= " peakrate $peak";
} }
if ( supplied $minburst ) { if ( supplied $minburst ) {
fatal_error "Invalid minburst ($minburst)" unless $minburst =~ /^\d+(?:\.\d+)?(k|kb|m|mb|mbit|kbit|b)?$/; fatal_error "Invalid minburst ($minburst)" unless $minburst =~ /^\d+(?:\.\d+)?(k|kb|m|mb|g|gb|gbit|mbit|kbit|b)?$/;
$command .= " minburst $minburst"; $command .= " minburst $minburst";
} }
@@ -365,9 +377,7 @@ sub process_simple_device() {
emit( "run_tc filter add dev $physical parent $number:0 protocol all prio 1 u32" . emit( "run_tc filter add dev $physical parent $number:0 protocol all prio 1 u32" .
"\\\n match ip6 protocol 6 0xff" . "\\\n match ip6 protocol 6 0xff" .
"\\\n match u8 0x05 0x0f at 0" . "\\\n match u8 0x10 0xff at 53 flowid $number:1\n" );
"\\\n match u16 0x0000 0xffc0 at 2" .
"\\\n match u8 0x10 0xff at 33 flowid $number:1\n" );
save_progress_message_short qq(" TC Device $physical defined."); save_progress_message_short qq(" TC Device $physical defined.");
@@ -422,8 +432,8 @@ sub validate_tc_device( ) {
fatal_error "Duplicate INTERFACE ($device)" if $tcdevices{$device}; fatal_error "Duplicate INTERFACE ($device)" if $tcdevices{$device};
fatal_error "Invalid INTERFACE name ($device)" if $device =~ /[:+]/; fatal_error "Invalid INTERFACE name ($device)" if $device =~ /[:+]/;
my ( $classify, $pfifo, $flow, $qdisc, $linklayer, $overhead, $mtu, $mpu, $tsize ) = my ( $classify, $pfifo, $flow, $qdisc, $linklayer, $overhead, $mtu, $mpu, $tsize, $connmark ) =
(0, 0, '', 'htb', '', 0, 0, 0, 0); (0, 0, '', 'htb', '', 0, 0, 0, 0, 0);
if ( $options ne '-' ) { if ( $options ne '-' ) {
for my $option ( split_list1 $options, 'option' ) { for my $option ( split_list1 $options, 'option' ) {
@@ -458,6 +468,9 @@ sub validate_tc_device( ) {
$tsize = numeric_value( $1 ); $tsize = numeric_value( $1 );
fatal_error "Invalid tsize ($1)" unless defined $tsize; fatal_error "Invalid tsize ($1)" unless defined $tsize;
fatal_error q('tsize' requires 'linklayer') unless $linklayer; fatal_error q('tsize' requires 'linklayer') unless $linklayer;
} elsif ( $option eq 'connmark' ) {
require_capability( 'CONNMARK_ACTION', q(The 'connmark' option), 's' );
$connmark = 1;
} else { } else {
fatal_error "Unknown device option ($option)"; fatal_error "Unknown device option ($option)";
} }
@@ -470,7 +483,7 @@ sub validate_tc_device( ) {
if ( @redirected ) { if ( @redirected ) {
fatal_error "IFB devices may not have IN-BANDWIDTH" if $inband ne '-' && $inband; fatal_error "IFB devices may not have IN-BANDWIDTH" if $inband ne '-' && $inband;
$classify = 1; $classify = 1 unless $connmark;
for my $rdevice ( @redirected ) { for my $rdevice ( @redirected ) {
fatal_error "Invalid device name ($rdevice)" if $rdevice =~ /[:+]/; fatal_error "Invalid device name ($rdevice)" if $rdevice =~ /[:+]/;
@@ -478,6 +491,8 @@ sub validate_tc_device( ) {
fatal_error "REDIRECTED device ($rdevice) has not been defined in this file" unless $rdevref; fatal_error "REDIRECTED device ($rdevice) has not been defined in this file" unless $rdevref;
fatal_error "IN-BANDWIDTH must be zero for REDIRECTED devices" if $rdevref->{in_bandwidth} != 0; fatal_error "IN-BANDWIDTH must be zero for REDIRECTED devices" if $rdevref->{in_bandwidth} != 0;
} }
} elsif ( $connmark ) {
fatal_error "Option connmark can only be used when setting up a IFB device";
} }
$inband = process_in_bandwidth( $inband ); $inband = process_in_bandwidth( $inband );
@@ -503,6 +518,7 @@ sub validate_tc_device( ) {
mpu => $mpu, mpu => $mpu,
tsize => $tsize, tsize => $tsize,
filterpri => 0, filterpri => 0,
connmark => $connmark,
} , } ,
push @tcdevices, $device; push @tcdevices, $device;
@@ -661,6 +677,7 @@ sub validate_tc_class( ) {
if ( $mark ne '-' ) { if ( $mark ne '-' ) {
fatal_error "MARK may not be specified when TC_BITS=0" unless $config{TC_BITS}; fatal_error "MARK may not be specified when TC_BITS=0" unless $config{TC_BITS};
fatal_error "MARK may not be specified for an interface with the 'classify' option" if $devref->{classify};
( $mark, my $priority ) = split/:/, $mark, 2; ( $mark, my $priority ) = split/:/, $mark, 2;
@@ -1639,8 +1656,8 @@ sub process_tcfilters() {
# #
# Process a tcpri record # Process a tcpri record
# #
sub process_tc_priority1( $$$$$$ ) { sub process_tc_priority1( $$$$$$$ ) {
my ( $band, $proto, $ports , $address, $interface, $helper ) = @_; my ( $band, $proto, $dports , $sports, $address, $interface, $helper ) = @_;
my $val = numeric_value $band; my $val = numeric_value $band;
@@ -1651,7 +1668,7 @@ sub process_tc_priority1( $$$$$$ ) {
$rule .= join('', '/', in_hex( $globals{TC_MASK} ) ) if have_capability( 'EXMARK' ); $rule .= join('', '/', in_hex( $globals{TC_MASK} ) ) if have_capability( 'EXMARK' );
if ( $interface ne '-' ) { if ( $interface ne '-' ) {
fatal_error "Invalid combination of columns" unless $address eq '-' && $proto eq '-' && $ports eq '-'; fatal_error "Invalid combination of columns" unless $address eq '-' && $proto eq '-' && $dports eq '-' && $sports eq '-';
my $forwardref = $mangle_table->{tcfor}; my $forwardref = $mangle_table->{tcfor};
@@ -1662,41 +1679,57 @@ sub process_tc_priority1( $$$$$$ ) {
my $postref = $mangle_table->{tcpost}; my $postref = $mangle_table->{tcpost};
if ( $address ne '-' ) { if ( $address ne '-' ) {
fatal_error "Invalid combination of columns" unless $proto eq '-' && $ports eq '-'; fatal_error "Invalid combination of columns" unless $proto eq '-' && $dports eq '-' && $sports eq '-';
add_rule( $postref , add_rule( $postref ,
join( '', match_source_net( $address) , $rule ) , join( '', match_source_net( $address) , $rule ) ,
1 ); 1 );
} else { } else {
add_rule( $postref , add_rule( $postref ,
join( '', do_proto( $proto, $ports, '-' , 0 ) , $rule ) , join( '', do_proto( $proto, $dports, $sports , 0 ) , $rule ) ,
1 ); 1 );
if ( $ports ne '-' ) { if ( $dports ne '-' ) {
my $protocol = resolve_proto $proto; my $protocol = resolve_proto $proto;
if ( $proto =~ /^ipp2p/ ) { if ( $proto =~ /^ipp2p/ ) {
fatal_error "ipp2p may not be used when there are tracked providers and PROVIDER_OFFSET=0" if @routemarked_interfaces && $config{PROVIDER_OFFSET} == 0; fatal_error "ipp2p may not be used when there are tracked providers and PROVIDER_OFFSET=0" if @routemarked_interfaces && $config{PROVIDER_OFFSET} == 0;
$ipp2p = 1; $ipp2p = 1;
} elsif ( $file_format == 1 ) {
add_rule( $postref ,
join( '' , do_proto( $proto, '-', $dports, 0 ) , $rule ) ,
1 )
unless $proto =~ /^ipp2p/ || $protocol == ICMP || $protocol == IPv6_ICMP;
} }
add_rule( $postref ,
join( '' , do_proto( $proto, '-', $ports, 0 ) , $rule ) ,
1 )
unless $proto =~ /^ipp2p/ || $protocol == ICMP || $protocol == IPv6_ICMP;
} }
} }
} }
} }
sub process_tc_priority() { sub process_tc_priority() {
my ( $band, $protos, $ports , $address, $interface, $helper ) = my ( $band, $protos, $dports , $sports, $address, $interface, $helper );
split_line1( 'tcpri',
{ band => 0, proto => 1, port => 2, address => 3, interface => 4, helper => 5 } ); if ( $file_format == 1 ) {
( $band, $protos, $dports , $address, $interface, $helper ) =
split_line2( 'tcpri',
{ band => 0, proto => 1, port => 2, dport => 2, address => 3, interface => 4, helper => 5 },
{},
6,
1 );
$sports = '-';
} else {
( $band, $protos, $dports , $sports, $address, $interface, $helper ) =
split_line2( 'tcpri',
{ band => 0, proto => 1, port => 2, dport => 2, sport => 3, address => 4, interface => 5, helper => 6 },
{},
7,
1 );
};
fatal_error 'BAND must be specified' if $band eq '-'; fatal_error 'BAND must be specified' if $band eq '-';
fatal_error "Invalid tcpri entry" if ( $protos eq '-' && fatal_error "Invalid tcpri entry" if ( $protos eq '-' &&
$ports eq '-' && $dports eq '-' &&
$sports eq '-' &&
$address eq '-' && $address eq '-' &&
$interface eq '-' && $interface eq '-' &&
$helper eq '-' ); $helper eq '-' );
@@ -1706,7 +1739,7 @@ sub process_tc_priority() {
fatal_error "Invalid PRIORITY ($band)" unless $val && $val <= 3; fatal_error "Invalid PRIORITY ($band)" unless $val && $val <= 3;
for my $proto ( split_list $protos, 'Protocol' ) { for my $proto ( split_list $protos, 'Protocol' ) {
process_tc_priority1( $band, $proto, $ports , $address, $interface, $helper ); process_tc_priority1( $band, $proto, $dports , $sports, $address, $interface, $helper );
} }
} }
@@ -1728,7 +1761,7 @@ sub process_tcinterfaces() {
# #
sub process_tcpri() { sub process_tcpri() {
my $fn = find_file 'tcinterfaces'; my $fn = find_file 'tcinterfaces';
my $fn1 = open_file 'tcpri', 1,1; my $fn1 = open_file 'tcpri', 2,1,0,1;
if ( $fn1 ) { if ( $fn1 ) {
first_entry first_entry
@@ -1865,7 +1898,7 @@ sub process_traffic_shaping() {
for my $rdev ( @{$devref->{redirected}} ) { for my $rdev ( @{$devref->{redirected}} ) {
my $phyrdev = physical_name( $rdev ); my $phyrdev = physical_name( $rdev );
emit ( "run_tc qdisc add dev $phyrdev handle ffff: ingress" ); emit ( "run_tc qdisc add dev $phyrdev handle ffff: ingress" );
emit( "run_tc filter add dev $phyrdev parent ffff: protocol all u32 match u32 0 0 action mirred egress redirect dev $device > /dev/null" ); emit( "run_tc filter add dev $phyrdev parent ffff: protocol all u32 match u32 0 0".($devref->{'connmark'} ? ' action connmark' : '')." action mirred egress redirect dev $device > /dev/null" );
} }
for my $class ( @tcclasses ) { for my $class ( @tcclasses ) {
@@ -2284,11 +2317,11 @@ sub open_mangle_for_output( $ ) {
# #
# For information about entries in this file, type "man shorewall-mangle" # For information about entries in this file, type "man shorewall-mangle"
# #
# See http://shorewall.org/traffic_shaping.htm for additional information. # See https://shorewall.org/traffic_shaping.htm for additional information.
# For usage in selecting among multiple ISPs, see # For usage in selecting among multiple ISPs, see
# http://shorewall.org/MultiISP.html # https://shorewall.org/MultiISP.html
# #
# See http://shorewall.org/PacketMarking.html for a detailed description of # See https://shorewall.org/PacketMarking.html for a detailed description of
# the Netfilter/Shorewall packet marking mechanism. # the Netfilter/Shorewall packet marking mechanism.
############################################################################################################################################################## ##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE USER TEST LENGTH TOS CONNBYTES HELPER PROBABILITY DSCP SWITCH #ACTION SOURCE DEST PROTO DEST SOURCE USER TEST LENGTH TOS CONNBYTES HELPER PROBABILITY DSCP SWITCH
@@ -2300,11 +2333,11 @@ EOF
# #
# For information about entries in this file, type "man shorewall6-mangle" # For information about entries in this file, type "man shorewall6-mangle"
# #
# See http://shorewall.org/traffic_shaping.htm for additional information. # See https://shorewall.org/traffic_shaping.htm for additional information.
# For usage in selecting among multiple ISPs, see # For usage in selecting among multiple ISPs, see
# http://shorewall.org/MultiISP.html # https://shorewall.org/MultiISP.html
# #
# See http://shorewall.org/PacketMarking.html for a detailed description of # See https://shorewall.org/PacketMarking.html for a detailed description of
# the Netfilter/Shorewall packet marking mechanism. # the Netfilter/Shorewall packet marking mechanism.
# #
###################################################################################################################################################################### ######################################################################################################################################################################
@@ -2371,7 +2404,6 @@ sub setup_tc( $ ) {
} }
if ( $config{MANGLE_ENABLED} ) { if ( $config{MANGLE_ENABLED} ) {
if ( $convert ) { if ( $convert ) {
my $have_tcrules; my $have_tcrules;
@@ -2455,7 +2487,7 @@ sub setup_tc( $ ) {
} }
} }
} elsif ( -f ( my $fn = find_file( 'tcrules' ) ) ) { } elsif ( -f ( my $fn = find_file( 'tcrules' ) ) ) {
warning_message "The tcrules file is no longer supported -- use '$shorewallrc{product} update' to convert $fn to an equivalent 'mangle' file"; warning_message "The tcrules file is no longer supported -- use '$product update' to convert $fn to an equivalent 'mangle' file";
} }
if ( my $fn = open_file( 'mangle', 1, 1 ) ) { if ( my $fn = open_file( 'mangle', 1, 1 ) ) {

View File

@@ -4,7 +4,7 @@
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] # This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
# (c) 2007-2016 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2016 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -5,7 +5,7 @@
# #
# (c) 2007-2019 - Tom Eastep (teastep@shorewall.net) # (c) 2007-2019 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -29,6 +29,7 @@ package Shorewall::Zones;
require Exporter; require Exporter;
use Shorewall::Config qw(:DEFAULT :internal); use Shorewall::Config qw(:DEFAULT :internal);
use Shorewall::IPAddrs; use Shorewall::IPAddrs;
use sort 'stable';
use strict; use strict;
@@ -102,6 +103,7 @@ our @EXPORT = ( qw( NOTHING
find_zone_hosts_by_option find_zone_hosts_by_option
find_zones_by_option find_zones_by_option
have_ipsec have_ipsec
generate_all_acasts
), ),
); );
@@ -175,7 +177,8 @@ our %reservedName = ( all => 1,
# number => <ordinal position in the interfaces file> # number => <ordinal position in the interfaces file>
# physical => <physical interface name> # physical => <physical interface name>
# base => <shell variable base representing this interface> # base => <shell variable base representing this interface>
# wildcard => undef|1 # Wildcard Name # wildcard => undef|1 # Wildcard Logical Name
# physwild => undef|1 # Wildcard Physical Name
# zones => { zone1 => 1, ... } # zones => { zone1 => 1, ... }
# origin => <where defined> # origin => <where defined>
# } # }
@@ -417,7 +420,8 @@ sub initialize( $$ ) {
32 => 'loopback', 32 => 'loopback',
64 => 'local' ); 64 => 'local' );
} else { } else {
%validinterfaceoptions = ( accept_ra => NUMERIC_IF_OPTION, %validinterfaceoptions = (
accept_ra => NUMERIC_IF_OPTION,
blacklist => SIMPLE_IF_OPTION + IF_OPTION_HOST, blacklist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
bridge => SIMPLE_IF_OPTION, bridge => SIMPLE_IF_OPTION,
dbl => ENUM_IF_OPTION + IF_OPTION_WILDOK, dbl => ENUM_IF_OPTION + IF_OPTION_WILDOK,
@@ -429,6 +433,7 @@ sub initialize( $$ ) {
nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER, nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER,
nodbl => SIMPLE_IF_OPTION, nodbl => SIMPLE_IF_OPTION,
nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST, nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST,
omitanycast => SIMPLE_IF_OPTION + IF_OPTION_WILDOK,
optional => SIMPLE_IF_OPTION, optional => SIMPLE_IF_OPTION,
proxyndp => BINARY_IF_OPTION, proxyndp => BINARY_IF_OPTION,
required => SIMPLE_IF_OPTION, required => SIMPLE_IF_OPTION,
@@ -559,7 +564,8 @@ sub process_zone( \$ ) {
@parents = split_list $2, 'zone'; @parents = split_list $2, 'zone';
} }
fatal_error "Invalid zone name ($zone)" unless $zone =~ /^[a-z]\w*$/i && length $zone <= $globals{MAXZONENAMELENGTH}; fatal_error "Invalid zone name ($zone)" unless $zone =~ /^[a-z]\w*$/i;
fatal_error "Zone name ($zone) too long" unless length $zone <= $globals{MAXZONENAMELENGTH};
fatal_error "Invalid zone name ($zone)" if $reservedName{$zone} || $zone =~ /^all2|2all$/; fatal_error "Invalid zone name ($zone)" if $reservedName{$zone} || $zone =~ /^all2|2all$/;
fatal_error( "Duplicate zone name ($zone)" ) if $zones{$zone}; fatal_error( "Duplicate zone name ($zone)" ) if $zones{$zone};
@@ -847,10 +853,10 @@ sub dump_zone_contents() {
$entry .= ( " mark=" . in_hex( $zoneref->{mark} ) ) if exists $zoneref->{mark}; $entry .= ( " mark=" . in_hex( $zoneref->{mark} ) ) if exists $zoneref->{mark};
if ( $hostref ) { if ( $hostref ) {
for my $type ( keys %$hostref ) { for my $type ( sortkeysiftest %$hostref ) {
my $interfaceref = $hostref->{$type}; my $interfaceref = $hostref->{$type};
for my $interface ( keys %$interfaceref ) { for my $interface ( sortkeysiftest %$interfaceref ) {
my $iref = $interfaces{$interface}; my $iref = $interfaces{$interface};
my $arrayref = $interfaceref->{$interface}; my $arrayref = $interfaceref->{$interface};
@@ -1241,7 +1247,7 @@ sub process_interface( $$ ) {
fatal_error "Invalid INTERFACE ($originalinterface)" if ! $interface || defined $extra; fatal_error "Invalid INTERFACE ($originalinterface)" if ! $interface || defined $extra;
if ( supplied $port ) { if ( supplied $port ) {
fatal_error qq("Virtual" interfaces are not supported -- see http://www.shorewall.org/Shorewall_and_Aliased_Interfaces.html) if $port =~ /^\d+$/; fatal_error qq("Virtual" interfaces are not supported -- see https://shorewall.org/Shorewall_and_Aliased_Interfaces.html) if $port =~ /^\d+$/;
require_capability( 'PHYSDEV_MATCH', 'Bridge Ports', ''); require_capability( 'PHYSDEV_MATCH', 'Bridge Ports', '');
fatal_error "Your iptables is not recent enough to support bridge ports" unless $globals{KLUDGEFREE}; fatal_error "Your iptables is not recent enough to support bridge ports" unless $globals{KLUDGEFREE};
@@ -1368,7 +1374,7 @@ sub process_interface( $$ ) {
$hostoptions{$option} = $value if $hostopt; $hostoptions{$option} = $value if $hostopt;
} elsif ( $type == ENUM_IF_OPTION ) { } elsif ( $type == ENUM_IF_OPTION ) {
if ( $option eq 'arp_ignore' ) { if ( $option eq 'arp_ignore' ) {
fatal_error q(The 'arp_ignore' option may not be used with a wild-card interface name) if $wildcard; fatal_error q(The 'arp_ignore' option may not be used with a wild-card interface name) if $physwild;
if ( defined $value ) { if ( defined $value ) {
if ( $value =~ /^[1-3,8]$/ ) { if ( $value =~ /^[1-3,8]$/ ) {
$options{arp_ignore} = $value; $options{arp_ignore} = $value;
@@ -1485,7 +1491,7 @@ sub process_interface( $$ ) {
if ( $options{bridge} ) { if ( $options{bridge} ) {
require_capability( 'PHYSDEV_MATCH', 'The "bridge" option', 's'); require_capability( 'PHYSDEV_MATCH', 'The "bridge" option', 's');
fatal_error "Bridges may not have wildcard names" if $wildcard; fatal_error "Bridges may not have wildcard names" if $physwild;
$hostoptions{routeback} = $options{routeback} = 1 unless supplied $options{routeback}; $hostoptions{routeback} = $options{routeback} = 1 unless supplied $options{routeback};
} }
@@ -1534,7 +1540,7 @@ sub process_interface( $$ ) {
zones => {}, zones => {},
origin => shortlineinfo( '' ), origin => shortlineinfo( '' ),
wildcard => $wildcard, wildcard => $wildcard,
physwild => $physwild, # Currently unused physwild => $physwild,
}; };
$interfaces{$physical} = $interfaceref if $physical ne $interface; $interfaces{$physical} = $interfaceref if $physical ne $interface;
@@ -1715,6 +1721,7 @@ sub known_interface($)
physical => $physical , physical => $physical ,
base => $interfaceref->{base} , base => $interfaceref->{base} ,
wildcard => $interfaceref->{wildcard} , wildcard => $interfaceref->{wildcard} ,
physwild => $interfaceref->{physwild} ,
zones => $interfaceref->{zones} , zones => $interfaceref->{zones} ,
}; };
return $interfaceref; return $interfaceref;
@@ -2027,7 +2034,7 @@ sub verify_required_interfaces( $ ) {
push_indent; push_indent;
emit( 'start|reload|restore)' ); emit( 'start|reload|restore|enable)' );
push_indent; push_indent;
@@ -2320,9 +2327,9 @@ sub find_hosts_by_option( $ ) {
} }
for my $zone ( grep ! ( $zones{$_}{type} & FIREWALL ) , @zones ) { for my $zone ( grep ! ( $zones{$_}{type} & FIREWALL ) , @zones ) {
for my $type (keys %{$zones{$zone}{hosts}} ) { for my $type (sortkeysiftest %{$zones{$zone}{hosts}} ) {
my $interfaceref = $zones{$zone}{hosts}->{$type}; my $interfaceref = $zones{$zone}{hosts}->{$type};
for my $interface ( keys %$interfaceref ) { for my $interface ( sortkeysiftest %$interfaceref ) {
my $arrayref = $interfaceref->{$interface}; my $arrayref = $interfaceref->{$interface};
for my $host ( @{$arrayref} ) { for my $host ( @{$arrayref} ) {
my $ipsec = $host->{ipsec}; my $ipsec = $host->{ipsec};
@@ -2350,9 +2357,9 @@ sub find_zone_hosts_by_option( $$ ) {
my @hosts; my @hosts;
unless ( $zones{$zone}{type} & FIREWALL ) { unless ( $zones{$zone}{type} & FIREWALL ) {
for my $type (keys %{$zones{$zone}{hosts}} ) { for my $type (sortkeysiftest %{$zones{$zone}{hosts}} ) {
my $interfaceref = $zones{$zone}{hosts}->{$type}; my $interfaceref = $zones{$zone}{hosts}->{$type};
for my $interface ( keys %$interfaceref ) { for my $interface ( sortkeysiftest %$interfaceref ) {
my $arrayref = $interfaceref->{$interface}; my $arrayref = $interfaceref->{$interface};
for my $host ( @{$arrayref} ) { for my $host ( @{$arrayref} ) {
if ( my $value = $host->{options}{$option} ) { if ( my $value = $host->{options}{$option} ) {
@@ -2383,4 +2390,110 @@ sub find_zones_by_option( $$ ) {
\@zns; \@zns;
} }
#
# Generate the shell code to populate the ALL_ACASTS run-time variable
#
sub generate_all_acasts() {
my ( @acasts, @noacasts, @wildacasts, @wildnoacasts );
for my $interface ( @interfaces ) {
my $interfaceref = $interfaces{$interface};
my $physical = $interfaceref->{physical};
next if ( $interfaceref->{options}{port} ||
$interfaceref->{options}{unmanaged} );
if ( $interfaceref->{physwild} ) {
$physical =~ s/\+/*/;
if ( $interfaceref->{options}{omitanycast} ) {
if ( $physical eq '*' ) {
@wildnoacasts = ( '*' );
} else {
push @wildnoacasts, $physical;
}
} else {
if ( $physical eq '*' ) {
@wildacasts = ( '*' );
} else {
push @wildacasts, $physical;
}
}
} else {
if ( $interfaceref->{options}{omitanycast} ) {
push @noacasts, $physical;
} else {
push @acasts, $physical;
}
}
}
return 'ALL_ACASTS="$(get_all_acasts)"' unless @noacasts || @wildnoacasts;
@wildacasts = '*' unless @wildacasts;
emit( "#\n# Populate the ALL_ACASTS variable\n#",
'generate_all_acasts()',
'{' );
push_indent;
emit( 'ALL_ACASTS=',
'',
'for iface in $(find_all_interfaces1); do' );
push_indent;
emit( 'case $iface in' );
push_indent;
if ( @noacasts ) {
unless ( @wildacasts ) {
push @noacasts, @wildnoacasts;
@wildnoacasts = ();
}
emit( join( '|', @noacasts) . ')',
' ;;' );
}
if ( @wildnoacasts ) {
if ( @acasts ) {
emit( join( '|', @acasts) . ')',
' if [ -n "$ALL_ACASTS" ]; then',
' ALL_ACASTS="$ALL_ACASTS $(get_interface_acasts $iface)"',
' else',
' ALL_ACASTS="$(get_interface_acasts $iface)"',
' fi',
' ;;' );
}
emit( join( '|', @wildnoacasts) . ')',
' ;;' );
} else {
@wildacasts = ( '*' );
}
if ( @wildacasts ) {
emit( join( '|', @wildacasts ) . ')',
' if [ -n "$ALL_ACASTS" ]; then',
' ALL_ACASTS="$ALL_ACASTS $(get_interface_acasts $iface)"',
' else',
' ALL_ACASTS="$(get_interface_acasts $iface)"',
' fi',
' ;;' );
}
pop_indent;
emit( 'esac');
pop_indent;
emit( 'done');
pop_indent;
emit( "}\n" );
return 'generate_all_acasts';
}
1; 1;

View File

@@ -4,7 +4,7 @@
# #
# (c) 2007,2008,2009,2010,2011,2014 - Tom Eastep (teastep@shorewall.net) # (c) 2007,2008,2009,2010,2011,2014 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
@@ -47,7 +47,7 @@
# #
use strict; use strict;
use FindBin; use FindBin;
use lib "$FindBin::Bin"; use lib "$FindBin::Bin"; # Required to allow modules to reside in ${BASEDIR}/Shorewall/
use Shorewall::Compiler; use Shorewall::Compiler;
use Getopt::Long; use Getopt::Long;

View File

@@ -4,7 +4,7 @@
# #
# (c) 2010,2011,2014 - Tom Eastep (teastep@shorewall.net) # (c) 2010,2011,2014 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.org # Complete documentation is available at https://shorewall.org
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #

View File

@@ -1089,7 +1089,7 @@ clear_firewall() {
set_state "Cleared" set_state "Cleared"
logger -p kern.info "$g_product Cleared" logger -p daemon.info "$g_product Cleared"
} }
# #
@@ -1113,7 +1113,7 @@ interface_is_usable() # $1 = interface
status=0 status=0
if [ "$1" != lo ]; then if [ "$1" != lo ]; then
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != :: ] && [ -z "$($IP -$g_family link list dev $1 2> /dev/null | fgrep 'state DOWN')" ]; then if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != :: ]; then
if [ "$COMMAND" != enable ]; then if [ "$COMMAND" != enable ]; then
[ ! -f ${VARDIR}/${1}_disabled ] && run_isusable_exit $1 [ ! -f ${VARDIR}/${1}_disabled ] && run_isusable_exit $1
status=$? status=$?
@@ -1389,7 +1389,7 @@ clear_firewall() {
set_state "Cleared" set_state "Cleared"
logger -p kern.info "$g_product Cleared" logger -p daemon.info "$g_product Cleared"
} }
?endif # IPv6-specific functions. ?endif # IPv6-specific functions.

View File

@@ -1,6 +1,6 @@
For instructions on using these sample configurations, please see For instructions on using these sample configurations, please see
http://www.shorewall.org/shorewall_quickstart_guide.htm https://shorewall.org/shorewall_quickstart_guide.htm
Shorewall Samples Shorewall Samples
Copyright (C) 2006 by the following authors: Copyright (C) 2006 by the following authors:

View File

@@ -4,7 +4,7 @@
# For information about entries in this file, type "man shorewall-interfaces" # For information about entries in this file, type "man shorewall-interfaces"
# #
# The manpage is also online at # The manpage is also online at
# http://www.shorewall.org/manpages/shorewall-interfaces.html # https://shorewall.org/manpages/shorewall-interfaces.html
# #
############################################################################### ###############################################################################
?FORMAT 2 ?FORMAT 2

View File

@@ -4,7 +4,7 @@
# For information about entries in this file, type "man shorewall-policy" # For information about entries in this file, type "man shorewall-policy"
# #
# The manpage is also online at # The manpage is also online at
# http://www.shorewall.org/manpages/shorewall-policy.html # https://shorewall.org/manpages/shorewall-policy.html
# #
############################################################################### ###############################################################################
#SOURCE DEST POLICY LOGLEVEL RATE CONNLIMIT #SOURCE DEST POLICY LOGLEVEL RATE CONNLIMIT

View File

@@ -4,7 +4,7 @@
# For information on the settings in this file, type "man shorewall-rules" # For information on the settings in this file, type "man shorewall-rules"
# #
# The manpage is also online at # The manpage is also online at
# http://www.shorewall.org/manpages/shorewall-rules.html # https://shorewall.org/manpages/shorewall-rules.html
# #
###################################################################################################################################################################################################### ######################################################################################################################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH HELPER #ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE USER/ MARK CONNLIMIT TIME HEADERS SWITCH HELPER

View File

@@ -4,7 +4,7 @@
# #
# For information about the settings in this file, type "man shorewall.conf" # For information about the settings in this file, type "man shorewall.conf"
# #
# Manpage also online at http://www.shorewall.org/manpages/shorewall.conf.html # Manpage also online at https://shorewall.org/manpages/shorewall.conf.html
############################################################################### ###############################################################################
# S T A R T U P E N A B L E D # S T A R T U P E N A B L E D
############################################################################### ###############################################################################

View File

@@ -4,7 +4,7 @@
# For information about this file, type "man shorewall-zones" # For information about this file, type "man shorewall-zones"
# #
# The manpage is also online at # The manpage is also online at
# http://www.shorewall.org/manpages/shorewall-zones.html # https://shorewall.org/manpages/shorewall-zones.html
# #
############################################################################### ###############################################################################
#ZONE TYPE OPTIONS IN OUT #ZONE TYPE OPTIONS IN OUT

View File

@@ -1,6 +1,6 @@
For instructions on using this sample configuration, please see For instructions on using this sample configuration, please see
http://www.shorewall.org/standalone.htm https://shorewall.org/standalone.htm
Shorewall Samples Shorewall Samples
Copyright (C) 2006-2015 by the following authors: Copyright (C) 2006-2015 by the following authors:

Some files were not shown because too many files have changed in this diff Show More