Compare commits

..

448 Commits

Author SHA1 Message Date
Tom Eastep
b0f6de62d0 Delete superfluous line from shorewall-init.service.debian
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-12-08 14:29:39 -08:00
Tom Eastep
17ce463b2d Don't delete files that are still valid in 4.6.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-12-08 11:48:53 -08:00
Tom Eastep
a3e467b8e3 Use setup_logread() in lib.cli-std
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-12-08 11:08:51 -08:00
Tom Eastep
b84f6aef55 Add some comments in get_params()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-12-08 11:06:37 -08:00
Tom Eastep
376999970b More tweaks to params processing and exporting
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-12-08 11:06:15 -08:00
Tom Eastep
7d98721169 Add Cygwin-specific code in get_params()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-12-08 11:05:59 -08:00
Tom Eastep
489ee29e53 More param handling fixes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-12-08 11:05:44 -08:00
Tom Eastep
05d99c8500 Don't export variables with parentheses in their names
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-12-08 11:05:28 -08:00
Tom Eastep
3336db6f86 Change to IP_FORWARDING=keep in shorewall6.conf files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-12-08 10:59:34 -08:00
Tom Eastep
b90513bd62 Start optional interfaces when there are no providers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-12-08 10:56:46 -08:00
Tom Eastep
2bf6b92c02 Install/uninstall/configure fixes from Matt Darfeuille
Also add OpenWRT support

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-12-08 10:56:37 -08:00
Tom Eastep
e0861408cd Handle MAC addresses in IPv6
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-12-07 15:24:13 -08:00
Tom Eastep
326cf8ba0a Correct permissions on certain files in $CONFDIR/$PRODUCT
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-10-26 13:09:30 -07:00
Tom Eastep
41880276a9 Deal with missing 'hostname' utility
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-10-26 13:09:10 -07:00
Tom Eastep
6835caf484 Correct error message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-10-26 13:08:43 -07:00
Tom Eastep
266863713d Delete main default routes when there are 'load=' or 'fallback=' interfaces
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-10-14 07:46:00 -07:00
Tom Eastep
85e44c70eb Add the Meta-connection to Tinc
- Both the macro and the tunnel type are updated

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-09-17 09:17:35 -07:00
Tom Eastep
03d99de8d5 Correct handling of reset
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-09-11 15:02:32 -07:00
Tom Eastep
426636458c Correct shorewall6 mangle man page
- Replace 'TTL' by 'HL'

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-09-08 12:25:59 -07:00
Tom Eastep
0aa5cb5086 Allow non-experts to use the user bits in the fw mark
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-09-07 11:35:47 -07:00
Tom Eastep
eddd58d459 Move a line of code
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-09-06 10:33:09 -07:00
Tom Eastep
1bf13e5fda Provide default for SHOREWALL_SHELL
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-09-06 10:29:36 -07:00
Tom Eastep
682a449e7b Correct more Mangle examples
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-09-02 13:08:05 -07:00
Tom Eastep
9e98d30c92 Correct handling of log levels with default actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-09-02 08:55:18 -07:00
Tom Eastep
582755edf4 Unconditionally get inline matches
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-09-02 08:03:22 -07:00
Tom Eastep
dea1f853ea Correct progress messages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-09-01 12:42:01 -07:00
Tom Eastep
e15a6f452e Cosmetic changes to first_entry() calls
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-31 10:54:30 -07:00
Tom Eastep
656eaabce9 Correct a typo
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-31 09:39:40 -07:00
Tom Eastep
f42dc6def1 Uniform mechanism for inserting conversion comments
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-30 15:35:05 -07:00
Tom Eastep
6e303aef69 Fix $convert/$tcrules mess
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-29 18:52:11 -07:00
Tom Eastep
ab260dc5b1 Place a header in a created mangle file during update -t
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-29 12:52:21 -07:00
Tom Eastep
55ab498291 Don't enforce FASTACCEPT/BLACKLISTNEWONLY on convert
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-29 12:51:52 -07:00
Tom Eastep
10cda4cee7 Update man pages for 'minute' and 'second' in LOGLIMIT specifications
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-27 15:49:59 -07:00
Tom Eastep
de74273dbb Assume EXPORTMODULES=No if it doesn't exist in old file during update
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-27 15:15:03 -07:00
Tom Eastep
af1e2f6c8b Read capabilities file before the .conf file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-27 11:26:26 -07:00
Tom Eastep
dc2406d25b update -t also converts the 'tos' file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-26 13:51:02 -07:00
Tom Eastep
e0734a45ee Allow 'seconds' and 'minutes' in LOGLIMIT specifications
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-26 12:53:36 -07:00
Tom Eastep
28df894add Improve 'update'
- convert BLACKLISTNEWONLY
- convert LOGRATE and LOGBURST
- default USE_DEFAULT_RT to No

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-26 12:50:56 -07:00
Tom Eastep
1d8873d3d5 Correct the shorewall6-hosts man page
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-26 12:28:57 -07:00
Tom Eastep
ad06ec3eef Correct IPV6 range parsing
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-26 11:52:51 -07:00
Tom Eastep
eae492cef5 Some rules manpage updates
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-22 09:24:47 -07:00
Tom Eastep
05f9f926c4 Move fatal_error() to lib.base
Signed-off-by: Tom Eastep <teastep@shorewall.net>

Conflicts:
	Shorewall-core/lib.common
2015-08-21 14:32:09 -07:00
Tom Eastep
a709395949 Allow 'none' in the log level argument to AutoBL
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-21 13:40:12 -07:00
Tom Eastep
7956c5f6e0 Update a message to refer to the 'mangle' file rather than 'tcrules'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-20 14:48:29 -07:00
Tom Eastep
4b003163d6 Use NYTProf for profiling.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-19 14:05:15 -07:00
Tom Eastep
67aef659b5 Tweak tcrules references
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-19 12:57:36 -07:00
Tom Eastep
39982c20c4 Restore the text of tcrules warning message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-19 12:34:35 -07:00
Tom Eastep
2b1f33c391 Don't unlink the tcrules file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-19 11:48:23 -07:00
Tom Eastep
1c33717cf5 Reverse the change to delete host routes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-19 11:06:28 -07:00
Tom Eastep
cd8fe38c85 Delete host routes added to the main routing table for providers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-19 10:44:37 -07:00
Tom Eastep
d525419c65 Correct wording of an error message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-19 10:44:00 -07:00
Tom Eastep
0e67357d63 Rewrite the trace/debugging section of the start/stop article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-18 16:00:37 -07:00
Tom Eastep
537f53f611 Restore [Install] section in the Debian .service files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-17 07:41:15 -07:00
Tom Eastep
3b1ad1e284 Delete 'conflicts=' from Shorewall-init .service files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-17 06:40:36 -07:00
Tom Eastep
9d3f35a22d Enable new update options in compiler.pl
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-16 11:57:36 -07:00
Tom Eastep
7c2a969de0 Correct handling of notrack file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-14 09:26:45 -07:00
Tom Eastep
8bdea65325 Update manpages for new update options
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-13 16:12:28 -07:00
Tom Eastep
fd46c0ffed Correct handling of termination after .conf file not updated
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-13 15:42:38 -07:00
Tom Eastep
60acddbb37 Add conversion version and date to the converted files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-13 14:37:13 -07:00
Tom Eastep
306dc34b31 Correct convert_blacklist()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-13 13:22:14 -07:00
Tom Eastep
f5c6a6fe82 Correct tcrules update
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-13 13:21:51 -07:00
Tom Eastep
af2b7910bd Port update changes from 5.0.0
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-12 12:33:09 -07:00
Tom Eastep
3b59e46799 Restore Debian-specific service files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-12 10:19:07 -07:00
Tom Eastep
955a2e38b7 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2015-08-10 17:49:40 -07:00
Tom Eastep
0f283ddc44 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2015-08-10 17:15:29 -07:00
Tom Eastep
4c4c5a436a Allow zero-valued options on multi-zoned interfaces
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-07 14:09:08 -07:00
Tom Eastep
d949824f94 Correct shorewall-mangle(5) examples
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-08-06 10:15:57 -07:00
Tom Eastep
a62adef0b0 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-07-31 15:21:48 -07:00
Tom Eastep
97881bb683 Create separate shorewallrc files for Debian systemd and sysvinit
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-31 14:57:59 -07:00
Tom Eastep
8bcee0ee01 Add Debian .service files
- Install both .service files and SysV init scripts on Debian.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-30 14:17:36 -07:00
Tom Eastep
954f8b5790 Install both SysV init script and .service file on Debian
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-29 09:44:20 -07:00
Tom Eastep
13650d156e Manual Updates
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-26 12:51:51 -07:00
Tom Eastep
8e31255c9b Correct Shorewall6-lite manpage
- Caution moved from the restart description to the restore restriction
where it belonged

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-24 13:41:09 -07:00
Tom Eastep
5d597cb43c Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-07-19 13:52:29 -07:00
Tom Eastep
0aa7f831c4 Update my config document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-19 13:50:26 -07:00
Tom Eastep
df817b6d2c Correct formatting in the interfaces man pages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-13 13:06:53 -07:00
Tom Eastep
d0fc7f6547 Add some comments to the Zones module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-13 12:57:00 -07:00
Tom Eastep
30a5488a8a Merge branch '4.6.11' 2015-07-12 15:12:07 -07:00
Tom Eastep
5704438a44 Second Wave of changes to make script output reproducable
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-12 15:00:41 -07:00
Tom Eastep
014ec1af1d First phase of producing consistent scripts with Perl >= 5.18.0
Beginning with Perl 5.18.0, the order of elements returned by the 'keys'
and 'each' iterators is no longer deterministic. This is the first wave
of Shorewall changes to compensate for this irrational behavior.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-12 10:54:48 -07:00
Tom Eastep
7fa39a63ed Don't apply 'postcompile' during an update
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-10 11:06:02 -07:00
Tom Eastep
3959feebe0 Remove extraneous line that causes a "not found" shell diagnostic
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-10 09:35:43 -07:00
Tom Eastep
bc8156b503 Include Compiler version in the compiler progress commands
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-08 12:53:42 -07:00
Tom Eastep
3d325431ff Change Default IPv6 .conf to specify INLINE_MATCHES=No
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-06 14:49:20 -07:00
Tom Eastep
f4741686e6 Correct NFLOG group description
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-06 13:42:10 -07:00
Tom Eastep
4995456563 Clean up compiler PATH fix
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-03 14:33:20 -07:00
Tom Eastep
c6f48a77e0 Only add dhcp rule if one rpfilter interface has the 'dhcp' option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-03 12:21:04 -07:00
Tom Eastep
e7792fc868 Exempt IPv4 DHCP broadcasts from rpfilter
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-03 10:03:03 -07:00
Tom Eastep
c47abe416a Add default PATH to current PATH in the compiler
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-07-03 09:38:06 -07:00
Tom Eastep
37248c9698 Correct capitalization of 'IPsec' in the IPsec-2.6 document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-29 15:35:23 -07:00
Tom Eastep
0414166d6d 'show connections' enhancement
- Allow tayloring of the entries displayed by specifying conntrack
  -L options.
2015-06-29 14:55:47 -07:00
Tom Eastep
6bd1141a8c Update Build article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-29 12:43:04 -07:00
Tom Eastep
7153146759 Don't ask for script version when WORKAROUNDS=No
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-28 09:18:47 -07:00
Tom Eastep
a911ec318e Add a comment
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-27 09:19:14 -07:00
Tom Eastep
5ca68477d5 Corrections to last commit
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-26 15:18:07 -07:00
Tom Eastep
9f08726794 Eliminate running the script twice is some cases
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-26 14:32:43 -07:00
Tom Eastep
846d629c47 Eliminate the usage() function in lib.cli-std
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-26 12:55:34 -07:00
Tom Eastep
273a42b068 Correct the check for ordinary user attempting to access the default config
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-26 11:35:11 -07:00
Tom Eastep
aa7aec8552 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-06-22 17:30:16 -07:00
Tom Eastep
9bf65ab9ab Don't run the postcompile script when compilation is bypassed
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-22 16:41:21 -07:00
Tom Eastep
fad92be473 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-06-22 12:23:53 -07:00
Tom Eastep
b35c214c70 Defer 'Compiling...' message until after AUTOMAKE is checked
- Avoid an export statement in compiler()

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-22 10:56:17 -07:00
Tom Eastep
b5ee52e8de Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-06-19 10:04:08 -07:00
Tom Eastep
267d6c87be Merge branch '4.6.10' 2015-06-19 10:03:16 -07:00
Tom Eastep
d9e4273e6b Clarify the Universal configuration
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-19 10:00:05 -07:00
Tom Eastep
fd69209776 :Merge branch '4.6.10' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-06-09 13:09:14 -07:00
Tuomo Soini
f175ab853b rename not_configured() to not_configured_error()
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-06-09 11:02:00 -07:00
Tuomo Soini
e10c078a06 Set exit code to 6 when startup is disabled
Handles cases missed by 4b27c72c79

Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-06-09 11:01:50 -07:00
Tuomo Soini
274f054d87 Add to lib.common a new function not_configured()
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-06-09 11:01:36 -07:00
Tuomo Soini
f3a4e25d27 Complete Shorewall-init improvements
completes 548c0558c1

Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-06-09 11:01:28 -07:00
Tuomo Soini
e1da59e037 shorewall-init: use consitent indent
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-06-09 11:01:18 -07:00
Tom Eastep
5003e826b9 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2015-06-09 10:58:58 -07:00
Tuomo Soini
f8d95d1ee9 rename not_configured() to not_configured_error()
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-06-09 20:29:45 +03:00
Tom Eastep
7f50557250 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2015-06-08 13:50:47 -07:00
Tuomo Soini
15276b1f89 Set exit code to 6 when startup is disabled
Handles cases missed by 4b27c72c79

Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-06-08 22:23:38 +03:00
Tuomo Soini
5221c92d7f Add to lib.common a new function not_configured()
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-06-08 22:18:01 +03:00
Tuomo Soini
8bc62d1474 Complete Shorewall-init improvements
completes 548c0558c1

Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-06-08 22:15:45 +03:00
Tuomo Soini
e96fcde678 shorewall-init: use consitent indent
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-06-08 22:10:21 +03:00
Tom Eastep
116e85e040 Cosmetic cleanup of the Compiler module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-08 11:27:37 -07:00
Tom Eastep
f6b77c17ac Correct a couple of blunders in the Introductory article.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-08 10:28:18 -07:00
Tom Eastep
6be802aa7c Update the Shorewall 4 article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-08 09:46:51 -07:00
Tom Eastep
92905f0d31 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2015-06-07 18:18:23 -07:00
Tuomo Soini
86ffbc7e01 Fix typo in commit 1bfae13f75 2015-06-07 22:36:44 +03:00
Tom Eastep
2956698298 Corrections to WORKAROUNDS implementation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-06 12:15:03 -07:00
Tom Eastep
7c9155a6e8 Update man pages and .conf files for WORKAROUNDS
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-06 07:56:14 -07:00
Tom Eastep
eb6be0e84d Remove old comment that now makes no sense
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-01 15:55:06 -07:00
Tom Eastep
019e49b481 Implement WORKAROUNDS option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-01 12:59:25 -07:00
Tom Eastep
1bfae13f75 Add note about the IPv6 address convention that uses square brackets
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-01 11:20:16 -07:00
Tom Eastep
70d41adee8 Delete extraneous '3' from the config basics article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-06-01 10:55:01 -07:00
Tom Eastep
9a3c43b6d3 Make NFQUEUE parsing more robust
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-30 07:01:30 -07:00
Tom Eastep
0a45c7a646 Another Tweak to the NFQUEUE parser
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-30 06:38:21 -07:00
Tom Eastep
f227250959 Fix NFQUEUE parsing and documentation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-29 18:19:35 -07:00
Tom Eastep
29a0c92918 Fix ancient bug in old parameter syntax
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-29 14:39:48 -07:00
Tom Eastep
cfc6b7405f Add sample 'findgw' scripts to the Multi-ISP doc
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-29 13:44:26 -07:00
Tuomo Soini
4edd6026f0 prog.footer: disabling already disabled inteface is not an error.
Neither is enabling already enabled interface

Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-05-29 22:15:55 +03:00
Tom Eastep
f629d574e6 Add ipv6 'findgw' file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-28 07:20:26 -07:00
Tom Eastep
18348ef6f1 Clean up distribute_load()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-27 06:58:10 -07:00
Tom Eastep
93c7e2c2f7 Change the way in which a warning message is suppressed
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-26 15:54:41 -07:00
Tom Eastep
602315938c Correct the load distribution algorithm
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-26 14:59:20 -07:00
Tom Eastep
f3d32e0023 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2015-05-26 11:31:12 -07:00
Tuomo Soini
19ab4472c9 shorewall-init.service*: fix description to be more generic
shorewall-init is not IPv4 only

Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-05-26 19:47:28 +03:00
Tom Eastep
425094de18 Mention load= warning (sum not 1.000000)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-25 10:31:08 -07:00
Tom Eastep
ca35f565e0 Return success exit status when no ipsets are saved by the script
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-25 07:36:00 -07:00
Tom Eastep
bbdbdf7c47 Clean up 'call' description in the manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-25 07:06:17 -07:00
Tom Eastep
631ebdecb8 load= enhancements
- Normalize loads to 0.nnnnnnnn
- Issue warning if the loads don't sum to 1.000000

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-23 08:05:58 -07:00
Tom Eastep
c851e03313 Don't try to use a probibility >= 1.00000000
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-23 07:06:31 -07:00
Tom Eastep
df4d6f1f92 Document load= in the providers manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-22 16:31:21 -07:00
Tom Eastep
c7ca3119ef Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-05-22 07:20:51 -07:00
Tom Eastep
ba7afcaeae Make 'call' a supported command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-21 10:38:35 -07:00
Tom Eastep
809e56cef6 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-05-21 09:04:35 -07:00
Tom Eastep
e3805b0ada Implement 'call' in the compiled script
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-21 09:00:11 -07:00
Tom Eastep
f1b6e71e56 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-05-20 10:59:06 -07:00
Tom Eastep
f77d649ac7 Make policy descriptions match what the user entered rather than what was generated by the compiler
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-20 10:58:57 -07:00
Tom Eastep
267637f139 NFQUEUE enhancements
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-20 10:55:21 -07:00
Tom Eastep
acd921cd08 Don't require a helper for ctevents and expevents
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-16 13:40:40 -07:00
Tom Eastep
9329e7c36c Don't require a helper in the CT action.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-16 09:08:32 -07:00
Tom Eastep
86ef3d3e35 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-05-15 15:39:58 -07:00
Tom Eastep
cccf6b4657 Merge branch '4.6.9' 2015-05-13 14:57:53 -07:00
Tom Eastep
7195ee708e Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-05-08 09:49:42 -07:00
Tom Eastep
50d1a719f9 Delete superfluous test
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-08 09:48:58 -07:00
Tom Eastep
4b27c72c79 Set exit code to 6 when startup is disabled
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-07 14:12:41 -07:00
Tom Eastep
548c0558c1 Shorewall-init improvements
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-07 12:31:46 -07:00
Tom Eastep
7a9270136c Clarify Shorewall-core's contribution in the Anatomy article.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-06 18:39:32 -07:00
Tom Eastep
a508bcf6d7 Refer to directory relocation from the Anatomy article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-05 14:35:42 -07:00
Tom Eastep
3bb1f74283 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code into 4.6.9 2015-05-05 11:28:13 -07:00
Tuomo Soini
87eca92b10 lib.core: use consisten indenting 2015-05-05 20:40:17 +03:00
Tom Eastep
b58aadad01 Correct Syntax error in the generated code.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-04 08:23:42 -07:00
Tom Eastep
6dcd8174ee Don't require interfaces on stop, clear, etc.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-04 08:23:10 -07:00
Tom Eastep
fe37844455 Correct CLI helper capability detection
- Previously, the HELPERS setting was ignored

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-05-02 07:54:01 -07:00
Tom Eastep
e248c0a3d7 Update Shorewall/Shorewall6 help text for 'reenable'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-28 13:29:42 -07:00
Tom Eastep
3f17a8cf24 Update the program header information in lib.core
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-28 13:13:06 -07:00
Tom Eastep
2cea78e6df Add the 'reenable' command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-28 13:02:12 -07:00
Tom Eastep
0abd51c796 Fix module versioning
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-28 11:59:01 -07:00
Tom Eastep
86e053be7a More optimization of detect_configuration()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-28 11:32:45 -07:00
Tom Eastep
864dba2e62 Clarify the need to manually create and modify ipsets
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-25 21:14:55 -07:00
Tom Eastep
75d18139f7 Optimize detect_configuration() for enable/disable
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-25 15:46:19 -07:00
Tom Eastep
bebb41674a Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2015-04-25 12:57:04 -07:00
Tom Eastep
42f75f7ba2 Correct SetEvent and ResetEvent
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-25 12:56:36 -07:00
Tuomo Soini
2c9b7fbb07 macro.JabberSecure: use of Jabber SSL is deprecated. Note user. 2015-04-23 10:03:07 +03:00
Tuomo Soini
119299421f macro.JabberPlain: deprecate the macro in favor of macro.Jabber 2015-04-23 09:39:23 +03:00
Tuomo Soini
aef019e16d macro.Jabber: use of jabber has changed from Plain+SSL to STARTTLS 2015-04-23 09:38:40 +03:00
Tom Eastep
3ae243b882 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2015-04-22 20:34:03 -07:00
Tuomo Soini
0fc58f81cc macro.QUIC: added support for QUIC
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-04-22 16:29:17 +03:00
Tom Eastep
7db99832ca Add ip6tables.service to the conflicts list for Shorewall-init
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-18 17:22:35 -07:00
Tom Eastep
0e8b427778 Remove false comment
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-18 14:31:07 -07:00
Tom Eastep
ccccd847c8 Update the helpers article to mention how to avoid loading a helper.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-17 15:22:38 -07:00
Tom Eastep
6cb3004a39 Clarify helper module loading
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-17 09:51:25 -07:00
Tom Eastep
f5aa0373cb Correct interfaces example 4
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-12 08:38:55 -07:00
Tom Eastep
057ad45fd9 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2015-04-12 07:52:34 -07:00
Tuomo Soini
ade24e6299 shorewall6.service: wants before after to be consistent
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-04-12 11:31:39 +03:00
Tuomo Soini
65394b9f8c shorewall-init.service: running shorewall-init must not require networking
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-04-12 11:26:40 +03:00
Tom Eastep
b128c30813 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code
Get Tuomo Soini's fix for serviced startup
2015-04-11 07:33:15 -07:00
Tuomo Soini
194252afd3 systemd: fix shorewall startup by adding Wants=network-online.target
Before shorewall failed to load if there were interfaces which were required
but there wasn't any other service which wanted network-online.target.
By adding Wants=network-online.target we make sure shorewall[6]* startup
won't fail if there are required interfaces

Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-04-11 10:50:54 +03:00
Tom Eastep
3cb45f234e Delete questionable logic in lib.cli
- It hasn't worked since there was a typo in it that prevented it from
  doing the correct thing.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-07 12:12:59 -07:00
Tom Eastep
16e3cb1b43 More manpage updates
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-07 10:14:42 -07:00
Tom Eastep
27c1ffc5fb Include full syntax in lists of CLI commands
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-07 09:23:58 -07:00
Tom Eastep
23137e5e8a Correct typo in lib.cli
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-07 09:23:35 -07:00
Tom Eastep
0e54a86e82 Add descriptions of 'list' and 'ls' to the CLI manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-06 09:39:41 -07:00
Tom Eastep
4fd8aa692d Add comment to setting of TCPMSS_TARGET with old caps file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-04 09:34:23 -07:00
Tom Eastep
8c3dda80a3 Simplify previous change
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-03 16:35:50 -07:00
Tom Eastep
9f96f58a0d Default TCPMSS_TARGET to 1 in old capabilities files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-03 14:46:50 -07:00
Tom Eastep
77165326f2 Merge branch '4.6.8'
Conflicts:
	Shorewall6/uninstall.sh
2015-04-03 14:02:21 -07:00
Tom Eastep
eb3a162560 Apply Matt Darfeuille's fix for fatal_error()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-02 13:26:51 -07:00
Tom Eastep
a8026999a5 Another fix for the Shorewall6 uninstaller
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-02 07:47:53 -07:00
Tom Eastep
44142ed457 Apply Matt Darfeuille's uninstall fixes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-02 07:28:21 -07:00
Tom Eastep
659e9d550c Apply Matt Darfeuille's uninstall fixes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-04-02 07:27:57 -07:00
Tom Eastep
7442c2189d Implement TCPMSS_TARGET capability
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-31 15:53:05 -07:00
Tom Eastep
551be3ed39 Rearrange script samples in the Multi-ISP document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-30 09:11:20 -07:00
Tom Eastep
468167f9e5 Apply nfw's fix for IP[6]TABLES in the conntrack file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-24 09:23:15 -07:00
Tom Eastep
6921270c77 Clarify DESTDIR
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-24 09:08:30 -07:00
Tom Eastep
50bbf9499a Don't install in global directories when configure == 0
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-24 07:51:56 -07:00
Tom Eastep
b00a7af619 Allow a comma-separated list in the rtrules file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-18 15:16:25 -07:00
Tom Eastep
0c11870e46 Implement the 'savesets' command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-17 10:03:12 -07:00
Tom Eastep
fdc36747ad Allow the 'open' and 'close' commands to handle icmp
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-16 16:25:32 -07:00
Tom Eastep
79d8d73e02 Correct types in config file basics doc 2015-03-16 15:11:14 -07:00
Tom Eastep
ecaae1f644 Improve editing of open numbers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-15 10:15:39 -07:00
Tom Eastep
52e7efc666 Move open_close_setup() inside open_close_command()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-14 09:42:43 -07:00
Tom Eastep
c5ef3fd905 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-03-14 08:55:40 -07:00
Tom Eastep
86d6d6900e Improve 'close' and 'show opens' commands
- close accepts a rule number
- list opens displays rule numbers

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-14 08:54:30 -07:00
Tom Eastep
9a5cc5e51c Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-03-07 07:57:26 -08:00
Tom Eastep
d7a1ca41f9 Another attempt to correct the formatting of the manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-07 07:56:34 -08:00
Tom Eastep
d3552346b0 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-03-06 15:38:48 -08:00
Tom Eastep
1e6c266b51 Formatting fix (I hope)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-06 15:37:56 -08:00
Tom Eastep
d6f8cda2d5 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-03-06 14:10:13 -08:00
Tom Eastep
4cc866cd81 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-03-06 14:09:11 -08:00
Tom Eastep
095e523c9f Add 'show opens' command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-06 13:10:23 -08:00
Tom Eastep
2817060edb Improvements to the 'open' and 'close' commands
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-06 08:13:44 -08:00
Tom Eastep
30e750608b Fix broken links
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-05 16:23:49 -08:00
Tom Eastep
a85fdc45ac Implement 'open' and 'close' commands
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-03-05 16:20:54 -08:00
Roberto C. Sánchez
79b6b7cf08 Fix incorrectly specified directory for VARDIR 2015-03-02 10:27:03 -05:00
Roberto C. Sánchez
5f2a8dd9cb Fix typo 2015-03-02 10:12:36 -05:00
Roberto C. Sánchez
a28cd7371c Fix typo 2015-03-02 10:10:52 -05:00
Roberto C. Sánchez
e9bb447537 Fix typo 2015-03-02 09:58:09 -05:00
Tom Eastep
cdc2d52208 Implement ADD and DEL in the mangle file.
- Also document the parameter to SAME

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-02-18 12:04:01 -08:00
Tom Eastep
18c8f1f835 Remove blank line
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-02-17 20:10:25 -08:00
Tom Eastep
aff8623a44 Allow TTL to be specified in the SAME action.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-02-17 19:11:28 -08:00
Tom Eastep
361f5af3e0 Fix broken link
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-02-13 14:28:21 -08:00
Tom Eastep
b14e7c54f9 Merge branch '4.6.6' 2015-02-07 08:29:44 -08:00
Tom Eastep
30a5f508be Change samples to specify MODULE_SUFFIX="ko ko.xz"
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-02-06 12:56:35 -08:00
Orion Poplawski
9ad0b297e2 Supporting xz compressed kernel modules
- I've attached a patch that adds xz support to the default MODULE_SUFFIX.
- I'm wondering it wouldn't be better to not have MODULE_SUFFX=ko in various
sample configs so that the default value is used instead:

./Shorewall/configfiles/shorewall.conf:MODULE_SUFFIX=ko
./Shorewall/Samples/Universal/shorewall.conf:MODULE_SUFFIX=ko
./Shorewall/Samples/three-interfaces/shorewall.conf:MODULE_SUFFIX=ko
./Shorewall/Samples/two-interfaces/shorewall.conf:MODULE_SUFFIX=ko
./Shorewall/Samples/one-interface/shorewall.conf:MODULE_SUFFIX=ko
./docs/MultiISP.xml:MODULE_SUFFIX=ko
./docs/MyNetwork.xml:MODULE_SUFFIX=ko
./Shorewall6/configfiles/shorewall6.conf:MODULE_SUFFIX=ko
./Shorewall6/Samples6/Universal/shorewall6.conf:MODULE_SUFFIX=ko
./Shorewall6/Samples6/three-interfaces/shorewall6.conf:MODULE_SUFFIX=ko
./Shorewall6/Samples6/two-interfaces/shorewall6.conf:MODULE_SUFFIX=ko
./Shorewall6/Samples6/one-interface/shorewall6.conf:MODULE_SUFFIX=ko

- Is:

MODULE_SUFFIX=

sufficient to use the default value or does it need to be commented out?

Thanks,

  Orion

--
Orion Poplawski
Technical Manager                     303-415-9701 x222
NWRA, Boulder/CoRA Office             FAX: 303-415-9702
3380 Mitchell Lane                       orion@nwra.com
Boulder, CO 80301                   http://www.nwra.com

>From f13edf8fc07c7b62825408b8665b10d6014d368d Mon Sep 17 00:00:00 2001
From: Orion Poplawski <orion@cora.nwra.com>
Date: Mon, 26 Jan 2015 09:48:48 -0700
Subject: [PATCH] Support xz compressed modules

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-02-06 12:51:00 -08:00
Tom Eastep
40104d0c86 Correct handling of +set[n]
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-26 07:53:41 -08:00
Tom Eastep
5d110616a5 Merge branch '4.6.6' 2015-01-24 18:16:47 -08:00
Tom Eastep
a2b8069ee3 Clarify Zone exclusion
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-24 18:15:10 -08:00
Tom Eastep
c7cd0060f0 Merge branch '4.6.6' 2015-01-23 09:07:28 -08:00
Tom Eastep
e3b96862ef Propagate the LOCKFILE setting to the generated script.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-23 08:18:30 -08:00
Tom Eastep
a060f683cc Correct file name in mangle 'split_line' error messages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-22 08:34:47 -08:00
Tom Eastep
01220d58ea Change the installation default value of INLINE_MATCHES to 'No'.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-22 08:34:39 -08:00
Tom Eastep
c2b6d974e7 Protect 'enable' and 'disable' with mutex
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-22 08:34:28 -08:00
Tom Eastep
7ab055e61e Correct file name in mangle 'split_line' error messages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-22 08:31:51 -08:00
Tom Eastep
758f3cf955 Change the installation default value of INLINE_MATCHES to 'No'.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-22 08:30:50 -08:00
Tom Eastep
08a184d95b Protect 'enable' and 'disable' with mutex
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-22 08:30:05 -08:00
Tom Eastep
50a0103e89 Merge branch '4.6.6' 2015-01-20 08:11:07 -08:00
Tom Eastep
6f2308e0fa Correct syntax of the SAVE and RESTORE actions.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-20 08:09:55 -08:00
Tom Eastep
a7cacdfee3 Allow SAVE and RESTORE in the INPUT chain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-20 08:09:09 -08:00
Tom Eastep
28ac76bde4 Add tinc tunnel support
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-13 13:28:37 -08:00
Tom Eastep
83431514fb Add Tinc macro
- From Răzvan Sandu
2015-01-13 07:05:15 -08:00
Tom Eastep
111c454193 Make leading SHELL case-sensitive
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-13 07:04:20 -08:00
Tuomo Soini
b06ba536e9 macro.Zabbix: This macro handles Zabbix monitoring software server traffic to agent
and trap traffic from agent to zabbix server.

Signed-off-by: Tuomo Soini <tis@foobar.fi>
2015-01-13 13:51:00 +02:00
Tuomo Soini
3f32afe371 ifupdown*: fix namespace problem with VARDIR
fixes similar bug than 23e869ad50 did
2015-01-10 19:07:55 +02:00
Tom Eastep
740e19968b Don't complain if the 'ip' executable doesn't exist.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-09 12:20:51 -08:00
Tom Eastep
97846e14de Correct handling of ipsets in one of the PORTS columns
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-09 09:28:08 -08:00
Tom Eastep
07c21b8968 Add 'primary' provider option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-06 09:06:27 -08:00
Tom Eastep
668759edad Catch parameter problems with TARPIT
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-04 11:09:39 -08:00
Tom Eastep
0f1f54b57b Tweak loopback change
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-04 11:00:02 -08:00
Tom Eastep
60d5a177a3 Use the 'Iface Match' capability for loopback traffic.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-04 09:46:39 -08:00
Tom Eastep
3ed5ced581 Correct syntax error introduced in Beta 2
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-04 08:35:33 -08:00
Tom Eastep
086f8b6073 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2015-01-03 13:23:00 -08:00
Tom Eastep
fa377df9dc Fix installer's use of the DIGEST environmental variable
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-03 13:22:06 -08:00
Tom Eastep
7dd9ccd06b Add the 'loopback' interface option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-03 09:22:40 -08:00
Tom Eastep
33e2e19193 Always set IP
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-02 09:28:50 -08:00
Tom Eastep
4a4bfe77ce Implement IFACE_MATCH capability
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-02 09:05:06 -08:00
Tom Eastep
3890b8a884 Infrastructure for detecting loopback interfaces
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-02 08:49:38 -08:00
Tom Eastep
551a16d18f Document TARPIT
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2015-01-01 09:14:00 -08:00
Tom Eastep
d1b597394f Correct typo (TARPIT_MATCH -> TARPIT_TARGET)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-30 10:22:33 -08:00
Tom Eastep
15a2fd14f9 Implement TARPIT target
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-28 15:23:30 -08:00
Tom Eastep
f96baca780 Use the readable representation of the SHA1 digest in the chain table
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-27 11:13:10 -08:00
Tom Eastep
1b5f439609 Rewrite 'process_actions'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-27 09:28:02 -08:00
Tom Eastep
1655054de2 Rename 'externalize' to 'external_name'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-27 09:19:00 -08:00
Tom Eastep
89877ed3f7 Rename 'policy_rules' to 'add_policy_rules'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-26 15:58:13 -08:00
Tom Eastep
9649107a8e Rename 'apply_policy_rules' to 'complete_policy_chains'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-26 15:53:50 -08:00
Tom Eastep
33eb47a48a Reorder parameters and change identifiers in set_policy_chain()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-26 15:47:50 -08:00
Tom Eastep
93285e2798 Cleanup of preceding fix
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-26 14:05:43 -08:00
Tom Eastep
2430796495 Document the -c option of 'show routing'
Correct choice in show commands to 'req'

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-26 12:15:28 -08:00
Tom Eastep
06ef7596cd Document the -c 'dump' option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-26 11:57:24 -08:00
Tom Eastep
227db0cfa7 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2014-12-23 15:37:38 -08:00
Tom Eastep
c0f7d0e65d Start firewall after the network-online target has been reached
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-23 15:37:22 -08:00
Tom Eastep
ba806379f4 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2014-12-23 15:36:56 -08:00
Tom Eastep
6a15cead52 Cosmetic/commentary changes to the Config Module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-23 15:25:20 -08:00
Tom Eastep
f925358872 Minor Compiler Reorganization
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-23 12:27:37 -08:00
Tom Eastep
52d2e62274 Convert two macros to Format 2
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-22 08:36:34 -08:00
Tom Eastep
56e8068f3d Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2014-12-20 15:12:44 -08:00
Tom Eastep
35fc7b34b8 Minor code tweak
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-20 15:09:21 -08:00
Tom Eastep
fdf513fba6 Correct font in mangle manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-19 14:26:20 -08:00
Tom Eastep
79430673b8 Correct handling of duplicate states in the mangle file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-16 19:08:25 -08:00
Tom Eastep
695db284c0 Improve Mark Range Implementation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-15 11:19:23 -08:00
Tom Eastep
807b9ca627 Revert "Improve handling of mark ranges"
This reverts commit 62f480897e.
2014-12-15 09:39:24 -08:00
Tom Eastep
62f480897e Improve handling of mark ranges
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-14 09:13:41 -08:00
Tom Eastep
685825a336 Correct Handling of Dynamic Zones
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-13 13:48:36 -08:00
Tom Eastep
8edb86ccdd Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2014-12-13 08:35:30 -08:00
Tom Eastep
2d7025dcc3 Correct mark range handling
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-12-13 08:31:31 -08:00
Tuomo Soini
23e869ad50 shorewall-init: correctly set STATEDIR, we can't use VARDIR from shorewallrc
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2014-11-24 09:43:32 +02:00
Tom Eastep
a833815b31 Correct IPv6 handling of LOG_BACKEND=LOG
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-15 08:56:42 -08:00
Thomas D
664e3bb0a8 Installer: $INITDIR already starts with a "/", so no need for, "$DESTDIR/$INITDIR"
Hi,

before the patch (DESTDIR = "/tmp/shorewall-4.6.5"; INITDIR =
"/etc/init.d"),

> [...]
> SysV init script init.gentoo.sh installed in /tmp/shorewall-4.6.5//etc/init.d/shorewall-lite

after the patch

> [...]
> SysV init script init.gentoo.sh installed in /tmp/shorewall-4.6.5/etc/init.d/shorewall-lite

-Thomas

From e7a192397323bb6cb66d08a6f24e7edfee044f31 Mon Sep 17 00:00:00 2001
From: Thomas D <whissi@whissi.de>
Date: Sat, 15 Nov 2014 16:38:05 +0100
Subject: [PATCH] $INITDIR already starts with a "/", so no need for
 "$DESTDIR/$INITDIR"

Before the patch (DESTDIR = "/tmp/shorewall-4.6.5"; INITDIR = "/etc/init.d"),

  > [...]
  > SysV init script init.gentoo.sh installed in /tmp/shorewall-4.6.5//etc/init.d/shorewall-lite

after the patch

  > [...]
  > SysV init script init.gentoo.sh installed in /tmp/shorewall-4.6.5/etc/init.d/shorewall-lite

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-15 07:55:14 -08:00
Evangelos Foutras
3a64ef7d3a Set SBINDIR to /usr/bin in shorewallrc.archlinux
/usr/bin is the directory used for all binaries that were previously
installed to /bin, /sbin or /usr/sbin. This unification occurred in
Arch Linux in mid-2013, so might as well change it in Shorewall too.

Signed-off-by: Evangelos Foutras <evangelos@foutrelis.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-15 07:55:08 -08:00
Evangelos Foutras
b746c9319f Rename SYSTEMDDIR to SERVICEDIR in shorewallrc.*
This was omitted from commit e3b1034 (Change SYSTEMDDIR to SERVICEDIR).

Signed-off-by: Evangelos Foutras <evangelos@foutrelis.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-15 07:55:04 -08:00
Evangelos Foutras
6f81bb5c8e Fix setting of options[SERVICEDIR] in configure
The previous syntax resulted in:

  ./configure: line 199: [SERVICEDIR]=: command not found

Signed-off-by: Evangelos Foutras <evangelos@foutrelis.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-15 07:55:00 -08:00
Tom Eastep
9241552c52 Make emacs sh-mode work better with lib.core
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-14 16:28:44 -08:00
Tom Eastep
16c1809ef2 Apply Alan Barrett's dhclient patch
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-14 13:39:23 -08:00
Tom Eastep
ec0ff7f305 Remove $OPTIONS from Shorewall-init service files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-12 14:38:48 -08:00
Tom Eastep
7100af5380 Correct .service files
- Make them match earlier versions

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-11 18:05:04 -08:00
Tom Eastep
f9932d2b08 Correct typos in the -lite manpages
- Remove redundant 'a specify'.
- Change reference to /etc/shorewall[6]/started.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-11 07:48:57 -08:00
Thomas D
2bf80ee3d9 Patches for shorewall manpage
Hi,

here is the patch set for the shorewall6-lite man page.

-Thomas

>From d3fc3bd79f6313e8c940f6df49ae6ea3e05fa590 Mon Sep 17 00:00:00 2001
From: Thomas D <whissi@whissi.de>
Date: Tue, 11 Nov 2014 01:23:44 +0100
Subject: [PATCH 2/2] Fixes for the "commands" section.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-11 07:41:18 -08:00
Tom Eastep
22ac37b51e Patches for Shorewall6 manpage from Thomas D
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-10 07:50:28 -08:00
Tom Eastep
c4171a92f6 Change spacing in shorewall[6] usage output
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-10 07:38:58 -08:00
Thomas D
a5b2886ae9 Patches for shorewall manpage
Hi,

I corrected some errors in the manpages. I started with "shorewall".

Tom, please tell me if you like this format and the patches at all.
If you like them, I can send you a similar patch set for shorewall6, too.

-Thomas

From 2aaeaa4f2da7aae92177ced0530f1deff86f44a9 Mon Sep 17 00:00:00 2001
From: Thomas D <whissi@whissi.de>
Date: Sun, 9 Nov 2014 15:45:29 +0100
Subject: [PATCH 11/14] The "-i" option from the "reload" command wasn't marked
 as an option.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-09 07:40:59 -08:00
Tom Eastep
9a6047b3c4 Correct reversed naming of SHA chains
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-06 08:18:52 -08:00
Tom Eastep
6f5de7ef3f Add now logging modules to the modules files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-05 16:19:30 -08:00
Tom Eastep
5b4e3bc07c Accomodate new module names for LOG_BACKEND
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-05 12:51:24 -08:00
Tom Eastep
dc3f163e71 Change the names of the sha1 chains for uniqueness
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-04 17:54:38 -08:00
Tom Eastep
2f545012a6 More documentation updates for -C
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-02 09:25:58 -08:00
Tom Eastep
c97226c46c Correct behavior of 'start -fC'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-02 09:25:23 -08:00
Tom Eastep
8c0c1bd1e0 Omit the 'shorewall' chain from .ip[6]tables-restore-input
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-02 08:16:47 -08:00
Tom Eastep
8b825c4c4c Avoid failure of ip[6]tables-restore.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-02 07:56:05 -08:00
Tom Eastep
4493b2ab6b Correct typo in 'rules' manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-02 06:50:40 -08:00
Tom Eastep
9598ac6fad Correct a couple of problems with -C
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-01 10:09:04 -07:00
Tom Eastep
8fb73026c8 Replace SAVE_COUNTERS with the -C command option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-11-01 09:37:57 -07:00
Tom Eastep
4546cbaff7 Use chains with names derived from a digest to identify ruleset
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-31 11:36:53 -07:00
Tom Eastep
a83c146636 Cleanup
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-30 20:27:06 -07:00
Tom Eastep
2ffc97867c Correct syntax error in the generated script
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-30 19:59:20 -07:00
Tom Eastep
f08803e293 Preserve counts on 'restart' without compilation.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-30 18:38:45 -07:00
Tom Eastep
b7ab82dba4 Implement -f option in the -lite products' start command
- Remove 'recover' command

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-30 10:42:39 -07:00
Tom Eastep
113f95c11e Provide STARTOPTIONS and RESTARTOPTIONS in all cases
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-30 10:22:39 -07:00
Tom Eastep
3454e10525 Add SAVE_COUNTERS option.
- Also implement recover command

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-30 08:57:56 -07:00
Tom Eastep
edc30fcc8d Process the params file with SHOREWALL_SHELL
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-29 12:22:00 -07:00
Tom Eastep
85e5669fc7 Rename function interface_up() to interface_enabled()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-27 18:38:22 -07:00
Tom Eastep
055fceb82f Update policy manpages for duel limits
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-22 12:27:27 -07:00
Tom Eastep
f5bdc9e7f4 Allow two limits in the RATE LIMIT columns
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-22 11:21:43 -07:00
Tom Eastep
54461a9a90 Correct indentation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-20 12:29:45 -07:00
Tom Eastep
b60d6dd6e5 Avoid duplicate module loads
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-20 10:42:53 -07:00
Tom Eastep
4bc91e89db Remove debugging code from Shorewall-init installer
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-19 08:28:41 -07:00
Tom Eastep
2784e93307 Load xt_LOG in both helpers files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-19 08:28:36 -07:00
Tom Eastep
90d1e41dcb Correct IPv4 Helpers file
- Change xt_ULOG to ipt_ULOG

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-19 08:28:29 -07:00
Tom Eastep
20c8bf02b1 Correct Shorewall6 helpers file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-19 08:28:19 -07:00
Tom Eastep
38d4b1c5a9 Revert "Correct last patch"
This reverts commit b528625329.
2014-10-19 08:28:11 -07:00
Tom Eastep
e3a332ec27 Correct last patch
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-19 08:28:00 -07:00
Tom Eastep
49218a4d28 ipt_LOG in helpers file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-15 18:07:09 -07:00
Tom Eastep
3236cd2660 Reinstate IPv6 DropSmurfs
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-13 12:34:25 -07:00
Tom Eastep
e3b10343a5 Change SYSTEMDDIR to SERVICEDIR
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-13 11:56:26 -07:00
Tom Eastep
286bc50bb3 Remove 'optional' from the Universal interfaces file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-13 08:07:14 -07:00
Tom Eastep
a5086f785f Avoid confusing output when 4.6.4 CLI executes a 'save'
- If a down-rev firewall is running, the savesets command produces
  confusing usage output

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-10 18:40:55 -07:00
Tom Eastep
19482ac197 Allow Shorewall-init installer to create SBINDIR if configure == 0
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-09 10:14:23 -07:00
Tom Eastep
42363da458 Add new .service files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-09 10:00:53 -07:00
Tom Eastep
c5074bddb2 Rename the .service files to .service.214
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-09 09:45:52 -07:00
Tom Eastep
4b9d8ad5f6 Merge branch '4.6.4'
Conflicts:
	Shorewall-init/shorewall-init.service
2014-10-08 18:26:42 -07:00
Tom Eastep
8e9d769723 Add iptables.service to Shorewall-init conflicts
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-08 18:24:53 -07:00
Tom Eastep
77015ebb4d Adjust the .service files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-08 17:33:33 -07:00
Tom Eastep
12458d111a Adjust the .service files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-08 17:28:22 -07:00
Tom Eastep
815e93e80c Rename SYSTEMD to SYSTEMDDIR
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-07 16:46:16 -07:00
Tom Eastep
7771e5d48f More ipset article tweaks
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-07 13:37:56 -07:00
Tom Eastep
0cd694370e Add nat link from Shorewall6 manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-07 12:21:44 -07:00
Tom Eastep
5fd7c573fc Clarify Shorewall-init SAVE_IPSETS setting
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-07 11:41:57 -07:00
Tom Eastep
80c024c4aa Amplify the 4.6.4 SAVE_IPSETS changes in the ipset article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-07 09:52:15 -07:00
Tom Eastep
3bae6e61cf Eliminate syntax errors in the generated script
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-07 07:53:26 -07:00
Tom Eastep
5204cbc95f Suppress 'No ipsets were saved' warning when SAVE_IPSETS=No
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-07 07:50:12 -07:00
Tom Eastep
ea1b8ac63a Correct handling of empty LOG_BACKEND
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-07 07:34:55 -07:00
Tuomo Soini
a31fd20f22 Shorewall6/nat: clearly make it ipv6 specific 2014-10-07 12:42:57 +03:00
Tom Eastep
2c7ffb525d Updagte Shorewall6-nat manpage
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-05 20:09:18 -07:00
Tom Eastep
316866482b Add ipv6 nat file and manpage
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-05 19:54:19 -07:00
Tom Eastep
6c6a1d82d9 Make Debian installation work with SANDBOX
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-05 16:52:59 -07:00
Tom Eastep
a72a1ef7a6 Update the install document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-05 13:30:28 -07:00
Tom Eastep
4398fb23d1 Create INITDIR in the Shorewall init installer
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-04 18:49:55 -07:00
Tom Eastep
e3a7a4fc98 Fix typo in the -lite installer
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-04 17:48:20 -07:00
Tom Eastep
e36b34ce15 Fix -lite installer for MANDIR
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-04 14:26:12 -07:00
Tom Eastep
178d1fbc26 Correct typo
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-04 14:19:48 -07:00
Tom Eastep
c9fd390782 Final cleanup of the uninstallers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-04 14:07:33 -07:00
Tom Eastep
3206021278 Another round of uninstall fixes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-04 13:50:39 -07:00
Tom Eastep
8571e0dca0 Another round of uninstall fixes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-04 13:29:51 -07:00
Tom Eastep
9dc2bba025 More uninstall corrections.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-04 09:39:03 -07:00
Tom Eastep
2fce05b3ab Correct a couple of errors
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-04 09:11:29 -07:00
Tom Eastep
70bb9147cd Correct Shorewall-init installer handling of SANDBOX
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-04 09:00:12 -07:00
Tom Eastep
00b0489047 Implement SANDBOX variable in the installers/uninstallers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-04 07:50:30 -07:00
Tom Eastep
f9a21bd90e Add -n option to the uninstallers.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-03 17:10:36 -07:00
Tom Eastep
5e81bdfe19 Another install script fix
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-03 17:07:03 -07:00
Tom Eastep
f2cc68b93b Correct -lite installer and uninstaller
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-03 16:41:27 -07:00
Tom Eastep
8a5e71a56f Implement the -n option in the installers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-03 07:59:41 -07:00
Tom Eastep
483ea3e437 Create INITDIR in -lite installs.
- Also don't link the init script if it isn't installed.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-02 17:42:08 -07:00
Tom Eastep
2ec3adcc44 Don't link the init script if SYSTEMD is set.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-02 16:23:26 -07:00
Tom Eastep
205dd6e250 Add FAQ 104
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-10-01 19:47:56 -07:00
Tom Eastep
770a505cd2 Delete DropSmurfs from IPv6 actions.std
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-30 16:16:53 -07:00
Tom Eastep
4071b9d337 Update SuSE shorewallrc for SBINDIR
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-30 16:16:33 -07:00
Tom Eastep
820c769499 Correct silly bug in last change
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-29 07:08:39 -07:00
Tom Eastep
e6b0666ac9 Save ipsets during normal stop (duh)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-28 18:43:11 -07:00
Tom Eastep
2a463e06aa More documentation changes regarding SAVE_IPSETS.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-28 17:10:45 -07:00
Tom Eastep
3174454300 Correct SAVE_IPSETS logic in Config.pm
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-28 14:38:01 -07:00
Tom Eastep
ce1c367d1d Re-commit the fix that saves only the appropriate family
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-28 14:09:20 -07:00
Tom Eastep
3e2c903a41 Revert "Only save ipsets of the proper family"
This reverts commit b053cab630.
2014-09-28 13:32:32 -07:00
Tom Eastep
b053cab630 Only save ipsets of the proper family
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-28 12:58:52 -07:00
Tom Eastep
6f7d063921 Remove the target file before saving ipsets in the savesets command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-28 11:53:52 -07:00
Tom Eastep
cbcb1ff7e1 Add SAVE_IPSETS to shorewall6.conf.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-28 11:37:24 -07:00
Tom Eastep
3858683e94 Allow saving a specified list of ipsets
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-28 11:19:41 -07:00
Tom Eastep
38a18ac9ac Allow indefinite alternative to 'yes' and 'no'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-27 15:06:18 -07:00
Tom Eastep
a09484356c Support 'yes', 'no, <other> values for simple config options
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-27 07:57:46 -07:00
Tom Eastep
bc8588a68e Fix rule numbers in trace output
- Don't increment $number needlessly when not tracing

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-27 07:57:09 -07:00
Tom Eastep
10df9d31c4 Correct typo in the actions manpages (4.6.5 s/b 4.6.4).
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-25 14:47:27 -07:00
Tom Eastep
4989f694cd Correct trace output
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-25 14:47:00 -07:00
Tom Eastep
b84a9e16e6 Correct typo in the config basics document
- SOURCE/DEST example had extra colon

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-25 10:59:18 -07:00
Tom Eastep
053df2a5fb Go back to original insert_irule() fix.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-25 09:21:20 -07:00
Tom Eastep
976a1f3deb Merge branch '4.6.3'
Conflicts:
	Shorewall/Perl/Shorewall/Misc.pm
2014-09-25 08:06:16 -07:00
Tom Eastep
ea40068c10 Fix ADMINISABSENTMINDED=No used with stoppedrules
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-25 08:03:35 -07:00
Tom Eastep
56649e2183 Don't compile routestopped during check if there is stoppedrules.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-24 19:24:13 -07:00
Tom Eastep
520d21c056 Another tweak to LOG_BACKEND
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-24 17:12:05 -07:00
Tom Eastep
540eff24aa Correctons to LOG_BACKEND implementation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-24 16:35:41 -07:00
Tom Eastep
580e00dabd Implement LOG_BACKEND option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-24 15:26:13 -07:00
Tom Eastep
4815f7eba3 Correct warning message in stoppedrules processing.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-24 11:05:15 -07:00
Tom Eastep
a7b57ad32c Clarify iptrace logging.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-24 09:14:38 -07:00
Tom Eastep
ba7f88c912 Re-apply 'terminating' changes to the actions manpages.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-23 09:33:57 -07:00
Tom Eastep
7481514a97 Implement the 'terminating' action option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-23 09:29:13 -07:00
Tom Eastep
20c68dddf2 Merge branch 'master' of ssh://server.shorewall.net/home/teastep/shorewall/code 2014-09-23 09:24:44 -07:00
Tom Eastep
35e60aa10c Fix actions manpage
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-23 09:24:32 -07:00
Tom Eastep
1f5439257a Revert "Implement the 'terminating' action option"
This reverts commit 6851744cb7.
2014-09-23 07:39:25 -07:00
Tom Eastep
4495ed687b Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2014-09-23 07:10:46 -07:00
Tom Eastep
d97d45f4ad Merge branch '4.6.3' 2014-09-23 07:10:17 -07:00
Tom Eastep
a69cec5228 Add link to Events article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-23 07:09:56 -07:00
Tuomo Soini
a03f00bf0f systemd services: multi-user is not same as old runlevel 3 so use basic
add conflicts to obviously conflicting services
remove old version number from init files
remove legacy syslog.target which is not needed on modern systems
fix formatting of email address onold Copyright text

Signed-off-by: Tuomo Soini <tis@foobar.fi>
2014-09-23 16:44:03 +03:00
Tuomo Soini
8f05d0f16d install.sh: support install on centos7 and foobar7
Signed-off-by: Tuomo Soini <tis@foobar.fi>
2014-09-23 13:19:09 +03:00
Tom Eastep
f9d98b74a2 Merge branch '4.6.2' into 4.6.3
Conflicts:
	Shorewall/Perl/Shorewall/Providers.pm

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-16 08:09:20 -07:00
Tom Eastep
0d23b9c542 Don't verify required interfaces during 'stop' or 'clear'.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-14 09:29:04 -07:00
Tom Eastep
a7bdfcc47b Refine the rule reduction fix
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-11 20:58:01 -07:00
Tom Eastep
988ee64621 Eliminate Redundant Rules
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-11 10:17:01 -07:00
Tom Eastep
9947f4d968 Re-enable SECTION PREROUTING in the accounting file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-10 12:53:08 -07:00
Tom Eastep
feb747260d Add /etc/shorewall/params to the multi-ISP LSM example
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-03 06:59:37 -07:00
Tom Eastep
fc58dab66d Remove redundant 'run' command from help output
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-02 12:57:04 -07:00
Tom Eastep
9e039e30e5 Issue warning message when /etc/iproute2/rt_tables is not writeable
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-02 08:11:33 -07:00
Tom Eastep
771e487b02 Merge branch '4.6.3' 2014-09-01 09:10:55 -07:00
Tom Eastep
0b66c475a7 Make <command> replacable in the run synopsis
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-01 09:10:03 -07:00
Tom Eastep
8727a6f1d8 Correct 'run' command synopsis in the shorewall[6] manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-01 08:52:09 -07:00
Tom Eastep
f9a62e1650 Correct builtin example in the actions manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-01 08:29:29 -07:00
Tom Eastep
6851744cb7 Implement the 'terminating' action option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-09-01 08:16:42 -07:00
Tom Eastep
f963adccf5 Correct silly typo in Chains.pm
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-08-31 16:57:24 -07:00
Tom Eastep
48549b35ac Correct inaccuracy in default.debian
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-08-30 08:25:58 -07:00
Tom Eastep
9001643996 Merge branch 'master' into 4.6.3 2014-08-30 07:18:55 -07:00
Tom Eastep
045d5ac048 Correct typo in error messages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-08-24 08:34:04 -07:00
Tom Eastep
e4a8cb31ba Clean up the Goto Meeting macro a bit
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-08-24 08:16:11 -07:00
Tom Eastep
9e6fffc231 Goto-Meeting Macro from Eric Teeter
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-08-23 16:05:38 -07:00
Tom Eastep
8236ce572e Apply Louis Lagendijk's patch for Shorewall-init
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-08-12 16:39:52 -07:00
Tom Eastep
bf5be7198b Make dump work correctly on RHEL5
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-08-12 16:18:42 -07:00
Tom Eastep
6f777098d7 Add 'wildcard' member to the interface table
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-08-12 06:51:17 -07:00
Tom Eastep
e545329eb9 Modify the preceding fix to work with wildcard interfaces
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2014-08-12 06:50:59 -07:00
158 changed files with 9031 additions and 3489 deletions

View File

@@ -91,6 +91,8 @@ for p in $@; do
fi fi
done done
cd $(dirname $0)
vendor=${params[HOST]} vendor=${params[HOST]}
if [ -z "$vendor" ]; then if [ -z "$vendor" ]; then
@@ -122,7 +124,6 @@ if [ -z "$vendor" ]; then
params[HOST]=apple params[HOST]=apple
rcfile=shorewallrc.apple rcfile=shorewallrc.apple
;; ;;
cygwin*|CYGWIN*) cygwin*|CYGWIN*)
params[HOST]=cygwin params[HOST]=cygwin
rcfile=shorewallrc.cygwin rcfile=shorewallrc.cygwin
@@ -130,7 +131,7 @@ if [ -z "$vendor" ]; then
*) *)
if [ -f /etc/debian_version ]; then if [ -f /etc/debian_version ]; then
params[HOST]=debian params[HOST]=debian
rcfile=shorewallrc.debian ls -l /sbin/init | fgrep -q systemd && rcfile=shorewallrc.debian.systemd || rcfile=shorewallrc.debian.sysvinit
elif [ -f /etc/redhat-release ]; then elif [ -f /etc/redhat-release ]; then
params[HOST]=redhat params[HOST]=redhat
rcfile=shorewallrc.redhat rcfile=shorewallrc.redhat
@@ -143,28 +144,38 @@ if [ -z "$vendor" ]; then
elif [ -f /etc/arch-release ] ; then elif [ -f /etc/arch-release ] ; then
params[HOST]=archlinux params[HOST]=archlinux
rcfile=shorewallrc.archlinux rcfile=shorewallrc.archlinux
elif [ -f /etc/openwrt_release ]; then
params[HOST]=openwrt
rcfile=shorewallrc.openwrt
else else
params[HOST]=linux params[HOST]=linux
rcfile=shorewallrc.default rcfile=shorewallrc.default
fi fi
;; ;;
esac esac
vendor=${params[HOST]} vendor=${params[HOST]}
elif [ $vendor = linux ]; then
rcfile=shorewallrc.default;
else else
rcfile=shorewallrc.$vendor if [ $vendor = linux ]; then
rcfile=shorewallrc.default;
elif [ $vendor = debian -a -f /etc/debian_version ]; then
ls -l /sbin/init | fgrep -q systemd && rcfile=shorewallrc.debian.systemd || rcfile=shorewallrc.debian.sysvinit
else
rcfile=shorewallrc.$vendor
fi
if [ ! -f $rcfile ]; then if [ ! -f $rcfile ]; then
echo "ERROR: $vendor is not a recognized host type" >&2 echo "ERROR: $vendor is not a recognized host type" >&2
exit 1 exit 1
elif [ $vendor = default ]; then
params[HOST]=linux
vendor=linux
fi fi
fi fi
if [ $vendor = linux ]; then if [ $vendor = linux ]; then
echo "INFO: Creating a generic Linux installation - " `date`; echo "INFO: Creating a generic Linux installation - " `date`;
else else
echo "INFO: Creating a ${vendor}-specific installation - " `date`; echo "INFO: Creating a ${params[HOST]}-specific installation - " `date`;
fi fi
echo echo
@@ -177,6 +188,7 @@ done
echo '#' > shorewallrc echo '#' > shorewallrc
echo "# Created by Shorewall Core version $VERSION configure - " `date` >> shorewallrc echo "# Created by Shorewall Core version $VERSION configure - " `date` >> shorewallrc
echo "# rc file: $rcfile" >> shorewallrc
echo '#' >> shorewallrc echo '#' >> shorewallrc
if [ $# -gt 0 ]; then if [ $# -gt 0 ]; then
@@ -195,6 +207,10 @@ elif [ -n "${options[VARDIR]}" ]; then
fi fi
fi fi
if [ -z "${options[SERVICEDIR]}" ]; then
options[SERVICEDIR]="${options[SYSTEMD]}"
fi
for on in \ for on in \
HOST \ HOST \
PREFIX \ PREFIX \
@@ -209,7 +225,7 @@ for on in \
INITFILE \ INITFILE \
AUXINITSOURCE \ AUXINITSOURCE \
AUXINITFILE \ AUXINITFILE \
SYSTEMD \ SERVICEDIR \
SERVICEFILE \ SERVICEFILE \
SYSCONFFILE \ SYSCONFFILE \
SYSCONFDIR \ SYSCONFDIR \

View File

@@ -52,6 +52,9 @@ for ( @ARGV ) {
$params{$pn} = $pv; $params{$pn} = $pv;
} }
use File::Basename;
chdir dirname($0);
my $vendor = $params{HOST}; my $vendor = $params{HOST};
my $rcfile; my $rcfile;
my $rcfilename; my $rcfilename;
@@ -68,23 +71,50 @@ unless ( defined $vendor ) {
$vendor = 'redhat'; $vendor = 'redhat';
} elsif ( $id eq 'opensuse' ) { } elsif ( $id eq 'opensuse' ) {
$vendor = 'suse'; $vendor = 'suse';
} elsif ( $id eq 'ubuntu' ) { } elsif ( $id eq 'ubuntu' || $id eq 'debian' ) {
$vendor = 'debian'; my $init = `ls -l /sbin/init`;
$vendor = $init =~ /systemd/ ? 'debian.systemd' : 'debian.sysvinit';
} else { } else {
$vendor = $id; $vendor = $id;
} }
} }
$params{HOST} = $vendor; $params{HOST} = $vendor;
$params{HOST} =~ s/\..*//;
} }
if ( defined $vendor ) { if ( defined $vendor ) {
$rcfilename = $vendor eq 'linux' ? 'shorewallrc.default' : 'shorewallrc.' . $vendor; if ( $vendor eq 'debian' && -f '/etc/debian_version' ) {
die qq("ERROR: $vendor" is not a recognized host type) unless -f $rcfilename; if ( -l '/sbin/init' ) {
if ( readlink('/sbin/init') =~ /systemd/ ) {
$rcfilename = 'shorewallrc.debian.systemd';
} else {
$rcfilename = 'shorewallrc.debian.sysvinit';
}
} else {
$rcfilename = 'shorewallrc.debian.sysvinit';
}
} else {
$rcfilename = $vendor eq 'linux' ? 'shorewallrc.default' : 'shorewallrc.' . $vendor;
}
unless ( -f $rcfilename ) {
die qq("ERROR: $vendor" is not a recognized host type);
} elsif ( $vendor eq 'default' ) {
$params{HOST} = $vendor = 'linux';
}
} else { } else {
if ( -f '/etc/debian_version' ) { if ( -f '/etc/debian_version' ) {
$vendor = 'debian'; $vendor = 'debian';
$rcfilename = 'shorewallrc.debian'; if ( -l '/sbin/init' ) {
if ( readlink '/sbin/init' =~ /systemd/ ) {
$rcfilename = 'debian.systemd';
} else {
$rcfilename = 'shorewallrc.debian.sysvinit';
}
} else {
$rcfilename = 'shorewallrc.debian.sysvinit';
}
} elsif ( -f '/etc/redhat-release' ){ } elsif ( -f '/etc/redhat-release' ){
$vendor = 'redhat'; $vendor = 'redhat';
$rcfilename = 'shorewallrc.redhat'; $rcfilename = 'shorewallrc.redhat';
@@ -117,7 +147,7 @@ my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
if ( $vendor eq 'linux' ) { if ( $vendor eq 'linux' ) {
printf "INFO: Creating a generic Linux installation - %s %2d %04d %02d:%02d:%02d\n\n", $abbr[$localtime[4]], $localtime[3], 1900 + $localtime[5] , @localtime[2,1,0];; printf "INFO: Creating a generic Linux installation - %s %2d %04d %02d:%02d:%02d\n\n", $abbr[$localtime[4]], $localtime[3], 1900 + $localtime[5] , @localtime[2,1,0];;
} else { } else {
printf "INFO: Creating a %s-specific installation - %s %2d %04d %02d:%02d:%02d\n\n", $vendor, $abbr[$localtime[4]], $localtime[3], 1900 + $localtime[5] , @localtime[2,1,0];; printf "INFO: Creating a %s-specific installation - %s %2d %04d %02d:%02d:%02d\n\n", $params{HOST}, $abbr[$localtime[4]], $localtime[3], 1900 + $localtime[5] , @localtime[2,1,0];;
} }
open $rcfile, '<', $rcfilename or die "Unable to open $rcfilename for input: $!"; open $rcfile, '<', $rcfilename or die "Unable to open $rcfilename for input: $!";
@@ -141,7 +171,8 @@ my $outfile;
open $outfile, '>', 'shorewallrc' or die "Can't open 'shorewallrc' for output: $!"; open $outfile, '>', 'shorewallrc' or die "Can't open 'shorewallrc' for output: $!";
printf $outfile "#\n# Created by Shorewall Core version %s configure.pl - %s %2d %04d %02d:%02d:%02d\n#\n", VERSION, $abbr[$localtime[4]], $localtime[3], 1900 + $localtime[5] , @localtime[2,1,0]; printf $outfile "#\n# Created by Shorewall Core version %s configure.pl - %s %2d %04d %02d:%02d:%02d\n", VERSION, $abbr[$localtime[4]], $localtime[3], 1900 + $localtime[5] , @localtime[2,1,0];
print $outfile "# rc file: $rcfilename\n#\n";
print $outfile "# Input: @ARGV\n#\n" if @ARGV; print $outfile "# Input: @ARGV\n#\n" if @ARGV;
@@ -154,6 +185,8 @@ if ( $options{VARLIB} ) {
$options{VARDIR} = '${VARLIB}/${PRODUCT}'; $options{VARDIR} = '${VARLIB}/${PRODUCT}';
} }
$options{SERVICEDIR}=$options{SYSTEMD} unless $options{SERVICEDIR};
for ( qw/ HOST for ( qw/ HOST
PREFIX PREFIX
SHAREDIR SHAREDIR
@@ -167,8 +200,8 @@ for ( qw/ HOST
INITFILE INITFILE
AUXINITSOURCE AUXINITSOURCE
AUXINITFILE AUXINITFILE
SYSTEMD SERVICEDIR
SERVICEFILE SERVICEFILE
SYSCONFFILE SYSCONFFILE
SYSCONFDIR SYSCONFDIR
SPARSE SPARSE

View File

@@ -66,15 +66,6 @@ mywhich() {
return 2 return 2
} }
run_install()
{
if ! install $*; then
echo
echo "ERROR: Failed to install $*" >&2
exit 1
fi
}
cant_autostart() cant_autostart()
{ {
echo echo
@@ -88,7 +79,20 @@ delete_file() # $1 = file to delete
install_file() # $1 = source $2 = target $3 = mode install_file() # $1 = source $2 = target $3 = mode
{ {
run_install $T $OWNERSHIP -m $3 $1 ${2} if cp -f $1 $2; then
if chmod $3 $2; then
if [ -n "$OWNER" ]; then
if chown $OWNER:$GROUP $2; then
return
fi
else
return 0
fi
fi
fi
echo "ERROR: Failed to install $2" >&2
exit 1
} }
require() require()
@@ -181,10 +185,6 @@ done
[ "${INITFILE}" != 'none/' ] && require INITSOURCE && require INITDIR [ "${INITFILE}" != 'none/' ] && require INITSOURCE && require INITDIR
T="-T"
INSTALLD='-D'
if [ -z "$BUILD" ]; then if [ -z "$BUILD" ]; then
case $(uname) in case $(uname) in
cygwin*|CYGWIN*) cygwin*|CYGWIN*)
@@ -198,7 +198,7 @@ if [ -z "$BUILD" ]; then
eval $(cat /etc/os-release | grep ^ID) eval $(cat /etc/os-release | grep ^ID)
case $ID in case $ID in
fedora|rhel) fedora|rhel|centos|foobar)
BUILD=redhat BUILD=redhat
;; ;;
debian) debian)
@@ -226,6 +226,8 @@ if [ -z "$BUILD" ]; then
BUILD=suse BUILD=suse
elif [ -f /etc/arch-release ] ; then elif [ -f /etc/arch-release ] ; then
BUILD=archlinux BUILD=archlinux
elif [ -f ${CONFDIR}/openwrt_release ] ; then
BUILD=openwrt
else else
BUILD=linux BUILD=linux
fi fi
@@ -252,17 +254,15 @@ case $BUILD in
[ -z "$OWNER" ] && OWNER=root [ -z "$OWNER" ] && OWNER=root
[ -z "$GROUP" ] && GROUP=wheel [ -z "$GROUP" ] && GROUP=wheel
INSTALLD=
T=
;; ;;
*) *)
[ -z "$OWNER" ] && OWNER=root if [ $(id -u) -eq 0 ]; then
[ -z "$GROUP" ] && GROUP=root [ -z "$OWNER" ] && OWNER=root
[ -z "$GROUP" ] && GROUP=root
fi
;; ;;
esac esac
OWNERSHIP="-o $OWNER -g $GROUP"
# #
# Determine where to install the firewall script # Determine where to install the firewall script
# #
@@ -276,7 +276,7 @@ case "$HOST" in
apple) apple)
echo "Installing Mac-specific configuration..."; echo "Installing Mac-specific configuration...";
;; ;;
debian|gentoo|redhat|slackware|archlinux|linux|suse) debian|gentoo|redhat|slackware|archlinux|linux|suse|openwrt)
;; ;;
*) *)
echo "ERROR: Unknown HOST \"$HOST\"" >&2 echo "ERROR: Unknown HOST \"$HOST\"" >&2
@@ -305,7 +305,6 @@ if [ -n "$DESTDIR" ]; then
if [ $BUILD != cygwin ]; then if [ $BUILD != cygwin ]; then
if [ `id -u` != 0 ] ; then if [ `id -u` != 0 ] ; then
echo "Not setting file owner/group permissions, not running as root." echo "Not setting file owner/group permissions, not running as root."
OWNERSHIP=""
fi fi
fi fi
fi fi
@@ -329,9 +328,13 @@ if [ -n "${SYSCONFDIR}" ]; then
chmod 755 ${DESTDIR}${SYSCONFDIR} chmod 755 ${DESTDIR}${SYSCONFDIR}
fi fi
if [ -n "${SYSTEMD}" ]; then if [ -z "${SERVICEDIR}" ]; then
mkdir -p ${DESTDIR}${SYSTEMD} SERVICEDIR="$SYSTEMD"
chmod 755 ${DESTDIR}${SYSTEMD} fi
if [ -n "${SERVICEDIR}" ]; then
mkdir -p ${DESTDIR}${SERVICEDIR}
chmod 755 ${DESTDIR}${SERVICEDIR}
fi fi
mkdir -p ${DESTDIR}${SBINDIR} mkdir -p ${DESTDIR}${SBINDIR}
@@ -403,9 +406,9 @@ fi
if [ ${SHAREDIR} != /usr/share ]; then if [ ${SHAREDIR} != /usr/share ]; then
for f in lib.*; do for f in lib.*; do
if [ $BUILD != apple ]; then if [ $BUILD != apple ]; then
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${SHAREDIR}/shorewall/$f eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/shorewall/$f
else else
eval sed -i \'\' -e \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${SHAREDIR}/shorewall/$f eval sed -i \'\' -e \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/shorewall/$f
fi fi
done done
fi fi

View File

@@ -75,6 +75,24 @@ elif [ -z "${VARDIR}" ]; then
VARDIR="${VARLIB}/${PRODUCT}" VARDIR="${VARLIB}/${PRODUCT}"
fi fi
#
# Fatal Error
#
fatal_error() # $@ = Message
{
echo " ERROR: $@" >&2
exit 2
}
#
# Not configured Error
#
not_configured_error() # $@ = Message
{
echo " ERROR: $@" >&2
exit 6
}
# #
# Conditionally produce message # Conditionally produce message
# #

File diff suppressed because it is too large Load Diff

View File

@@ -33,7 +33,7 @@ startup_error() # $* = Error Message
echo " ERROR: $@: Firewall state not changed" >&2 echo " ERROR: $@: Firewall state not changed" >&2
if [ $LOG_VERBOSITY -ge 0 ]; then if [ $LOG_VERBOSITY -ge 0 ]; then
timestamp="$(date +'%_b %d %T') " timestamp="$(date +'%b %d %T') "
echo "${timestamp} ERROR: $@" >> $STARTUP_LOG echo "${timestamp} ERROR: $@" >> $STARTUP_LOG
fi fi
@@ -50,7 +50,7 @@ startup_error() # $* = Error Message
esac esac
if [ $LOG_VERBOSITY -ge 0 ]; then if [ $LOG_VERBOSITY -ge 0 ]; then
timestamp="$(date +'%_b %d %T') " timestamp="$(date +'%b %d %T') "
case $COMMAND in case $COMMAND in
start) start)
@@ -80,14 +80,23 @@ get_script_version() { # $1 = script
local digits local digits
local verbosity local verbosity
verbosity="$VERBOSITY" if [ -z "$WORKAROUNDS" -o "$g_compiled" = "$g_file" ]; then
VERBOSITY=0 #
# Unless WORKAROUNDS=No, either this script was just compiled or AUTOMAKE
# determined that re-compilation wasn't needed
#
temp="$SHOREWALL_VERSION"
else
verbosity="$VERBOSITY"
VERBOSITY=0
temp=$( $SHOREWALL_SHELL $1 version | tail -n 1 | sed 's/-.*//' ) temp=$( $SHOREWALL_SHELL $1 version | tail -n 1 )
fi
if [ -z "$temp" ]; then if [ -z "$temp" ]; then
version=0 version=0
else else
temp=${temp%-*}
ifs=$IFS ifs=$IFS
IFS=. IFS=.
temp=$(echo $temp) temp=$(echo $temp)
@@ -157,6 +166,7 @@ run_it() {
[ -n "$g_timestamp" ] && options=${options}t [ -n "$g_timestamp" ] && options=${options}t
[ -n "$g_purge" ] && options=${options}p [ -n "$g_purge" ] && options=${options}p
[ -n "$g_recovering" ] && options=${options}r [ -n "$g_recovering" ] && options=${options}r
[ -n "$g_counters" ] && options=${options}c
options="${options}V $VERBOSITY" options="${options}V $VERBOSITY"
@@ -210,6 +220,17 @@ split() {
IFS=$ifs IFS=$ifs
} }
#
# Split a comma-separated list into a space-separated list
#
split_list() {
local ifs
ifs=$IFS
IFS=,
echo $*
IFS=$ifs
}
# #
# Search a list looking for a match -- returns zero if a match found # Search a list looking for a match -- returns zero if a match found
# 1 otherwise # 1 otherwise
@@ -373,7 +394,7 @@ reload_kernel_modules() {
moduleloader=insmod moduleloader=insmod
fi fi
[ -n "${MODULE_SUFFIX:=ko ko.gz o o.gz gz}" ] [ -n "${MODULE_SUFFIX:=ko ko.gz ko.xz o o.gz o.xz gz xz}" ]
[ -z "$MODULESDIR" ] && \ [ -z "$MODULESDIR" ] && \
uname=$(uname -r) && \ uname=$(uname -r) && \
@@ -412,7 +433,7 @@ load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
moduleloader=insmod moduleloader=insmod
fi fi
[ -n "${MODULE_SUFFIX:=o gz ko o.gz ko.gz}" ] [ -n "${MODULE_SUFFIX:=o gz xz ko o.gz o.xz ko.gz ko.xz}" ]
[ -z "$MODULESDIR" ] && \ [ -z "$MODULESDIR" ] && \
uname=$(uname -r) && \ uname=$(uname -r) && \
@@ -551,9 +572,9 @@ in_network() # $1 = IP address, $2 = CIDR network
# #
# Query NetFilter about the existence of a filter chain # Query NetFilter about the existence of a filter chain
# #
chain_exists() # $1 = chain name chain_exists() # $1 = chain name, $2 = table name (optional)
{ {
qt1 $g_tool -L $1 -n qt1 $g_tool -t ${2:-filter} -L $1 -n
} }
# #
@@ -644,6 +665,24 @@ find_first_interface_address_if_any() # $1 = interface
fi fi
} }
#
#Determines if the passed interface is a loopback interface
#
loopback_interface() { #$1 = Interface name
[ "$1" = lo ] || $IP link show $1 | fgrep -q LOOPBACK
}
#
# Find Loopback Interfaces
#
find_loopback_interfaces() {
local interfaces
[ -x "$IP" ] && interfaces=$($IP link show | fgrep LOOPBACK | sed 's/://g' | cut -d ' ' -f 2)
[ -n "$interfaces" ] && echo $interfaces || echo lo
}
# #
# Internal version of 'which' # Internal version of 'which'
# #
@@ -743,12 +782,15 @@ mutex_on()
local lockf local lockf
lockf=${LOCKFILE:=${VARDIR}/lock} lockf=${LOCKFILE:=${VARDIR}/lock}
local lockpid local lockpid
local lockd
MUTEX_TIMEOUT=${MUTEX_TIMEOUT:-60} MUTEX_TIMEOUT=${MUTEX_TIMEOUT:-60}
if [ $MUTEX_TIMEOUT -gt 0 ]; then if [ $MUTEX_TIMEOUT -gt 0 ]; then
[ -d ${VARDIR} ] || mkdir -p ${VARDIR} lockd=$(dirname $LOCKFILE)
[ -d "$lockd" ] || mkdir -p "$lockd"
if [ -f $lockf ]; then if [ -f $lockf ]; then
lockpid=`cat ${lockf} 2> /dev/null` lockpid=`cat ${lockf} 2> /dev/null`
@@ -768,6 +810,11 @@ mutex_on()
chmod u+w ${lockf} chmod u+w ${lockf}
echo $$ > ${lockf} echo $$ > ${lockf}
chmod u-w ${lockf} chmod u-w ${lockf}
elif qt mywhich lock; then
lock -${MUTEX_TIMEOUT} -r1 ${lockf}
chmod u+w ${lockf}
echo $$ > ${lockf}
chmod u-w ${lockf}
else else
while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do
sleep 1 sleep 1

View File

@@ -14,7 +14,7 @@ INITDIR= #Unused on OS X
INITFILE= #Unused on OS X INITFILE= #Unused on OS X
INITSOURCE= #Unused on OS X INITSOURCE= #Unused on OS X
ANNOTATED= #Unused on OS X ANNOTATED= #Unused on OS X
SYSTEMD= #Unused on OS X SERVICEDIR= #Unused on OS X
SERVICEFILE= #Unused on OS X SERVICEFILE= #Unused on OS X
SYSCONFDIR= #Unused on OS X SYSCONFDIR= #Unused on OS X
SPARSE=Yes #Only install $PRODUCT/$PRODUCT.conf in $CONFDIR. SPARSE=Yes #Only install $PRODUCT/$PRODUCT.conf in $CONFDIR.

View File

@@ -8,14 +8,14 @@ SHAREDIR=${PREFIX}/share #Directory for arch-neutral files.
LIBEXECDIR=${PREFIX}/share #Directory for executable scripts. LIBEXECDIR=${PREFIX}/share #Directory for executable scripts.
PERLLIBDIR=${PREFIX}/share/shorewall #Directory to install Shorewall Perl module directory PERLLIBDIR=${PREFIX}/share/shorewall #Directory to install Shorewall Perl module directory
CONFDIR=/etc #Directory where subsystem configurations are installed CONFDIR=/etc #Directory where subsystem configurations are installed
SBINDIR=/usr/sbin #Directory where system administration programs are installed SBINDIR=/usr/bin #Directory where system administration programs are installed
MANDIR=${SHAREDIR}/man #Directory where manpages are installed. MANDIR=${SHAREDIR}/man #Directory where manpages are installed.
INITDIR= #Directory where SysV init scripts are installed. INITDIR= #Directory where SysV init scripts are installed.
INITFILE= #Name of the product's installed SysV init script INITFILE= #Name of the product's installed SysV init script
INITSOURCE= #Name of the distributed file to be installed as the SysV init script INITSOURCE= #Name of the distributed file to be installed as the SysV init script
ANNOTATED= #If non-zero, annotated configuration files are installed ANNOTATED= #If non-zero, annotated configuration files are installed
SYSCONFDIR= #Directory where SysV init parameter files are installed SYSCONFDIR= #Directory where SysV init parameter files are installed
SYSTEMD=/usr/lib/systemd/system #Directory where .service files are installed (systems running systemd only) SERVICEDIR=/usr/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
SPARSE= #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR SPARSE= #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.

View File

@@ -14,7 +14,7 @@ INITDIR=/etc/init.d #Unused on Cygwin
INITFILE= #Unused on Cygwin INITFILE= #Unused on Cygwin
INITSOURCE= #Unused on Cygwin INITSOURCE= #Unused on Cygwin
ANNOTATED= #Unused on Cygwin ANNOTATED= #Unused on Cygwin
SYSTEMD= #Unused on Cygwin SERVICEDIR= #Unused on Cygwin
SERVICEFILE= #Unused on Cygwin SERVICEFILE= #Unused on Cygwin
SYSCONFDIR= #Unused on Cygwin SYSCONFDIR= #Unused on Cygwin
SPARSE=Yes #Only install $PRODUCT/$PRODUCT.conf in $CONFDIR. SPARSE=Yes #Only install $PRODUCT/$PRODUCT.conf in $CONFDIR.

View File

@@ -0,0 +1,23 @@
#
# Debian Shorewall 4.5 rc file
#
BUILD= #Default is to detect the build system
HOST=debian
PREFIX=/usr #Top-level directory for shared files, libraries, etc.
SHAREDIR=${PREFIX}/share #Directory for arch-neutral files.
LIBEXECDIR=${PREFIX}/share #Directory for executable scripts.
PERLLIBDIR=${PREFIX}/share/shorewall #Directory to install Shorewall Perl module directory
CONFDIR=/etc #Directory where subsystem configurations are installed
SBINDIR=/sbin #Directory where system administration programs are installed
MANDIR=${PREFIX}/share/man #Directory where manpages are installed.
INITDIR= #Directory where SysV init scripts are installed.
INITFILE= #Name of the product's installed SysV init script
INITSOURCE=init.debian.sh #Name of the distributed file to be installed as the SysV init script
ANNOTATED= #If non-zero, annotated configuration files are installed
SYSCONFFILE=default.debian #Name of the distributed file to be installed in $SYSCONFDIR
SERVICEFILE=$PRODUCT.service.debian #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
SYSCONFDIR=/etc/default #Directory where SysV init parameter files are installed
SERVICEDIR=/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
SPARSE=Yes #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR
VARLIB=/var/lib #Directory where product variable data is stored.
VARDIR=${VARLIB}/$PRODUCT #Directory where product variable data is stored.

View File

@@ -15,9 +15,9 @@ INITFILE=$PRODUCT #Name of the product's installed SysV in
INITSOURCE=init.debian.sh #Name of the distributed file to be installed as the SysV init script INITSOURCE=init.debian.sh #Name of the distributed file to be installed as the SysV init script
ANNOTATED= #If non-zero, annotated configuration files are installed ANNOTATED= #If non-zero, annotated configuration files are installed
SYSCONFFILE=default.debian #Name of the distributed file to be installed in $SYSCONFDIR SYSCONFFILE=default.debian #Name of the distributed file to be installed in $SYSCONFDIR
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
SYSCONFDIR=/etc/default #Directory where SysV init parameter files are installed SYSCONFDIR=/etc/default #Directory where SysV init parameter files are installed
SYSTEMD= #Directory where .service files are installed (systems running systemd only) SERVICEDIR= #Directory where .service files are installed (systems running systemd only)
SPARSE=Yes #If non-empty, only install $PRODUCT/$PRODUCT.conf in $CONFDIR 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.

View File

@@ -14,7 +14,7 @@ INITDIR=/etc/init.d #Directory where SysV init scripts are i
INITFILE=$PRODUCT #Name of the product's installed SysV init script INITFILE=$PRODUCT #Name of the product's installed SysV init script
INITSOURCE=init.sh #Name of the distributed file to be installed as the SysV init script INITSOURCE=init.sh #Name of the distributed file to be installed as the SysV init script
ANNOTATED= #If non-zero, annotated configuration files are installed ANNOTATED= #If non-zero, annotated configuration files are installed
SYSTEMD= #Directory where .service files are installed (systems running systemd only) SERVICEDIR= #Directory where .service files are installed (systems running systemd only)
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
SYSCONFFILE= #Name of the distributed file to be installed in $SYSCONFDIR SYSCONFFILE= #Name of the distributed file to be installed in $SYSCONFDIR
SYSCONFDIR= #Directory where SysV init parameter files are installed SYSCONFDIR= #Directory where SysV init parameter files are installed

View File

@@ -0,0 +1,26 @@
#
# Created by Shorewall Core version 5.0.2-RC1 configure - Fri, Nov 06, 2015 10:02:03 AM
#
# Input: host=openwrt
#
HOST=openwrt
PREFIX=/usr
SHAREDIR=${PREFIX}/share
LIBEXECDIR=${PREFIX}/share
PERLLIBDIR=${PREFIX}/share/shorewall
CONFDIR=/etc
SBINDIR=/sbin
MANDIR=${PREFIX}/man
INITDIR=/etc/init.d
INITSOURCE=init.openwrt.sh
INITFILE=$PRODUCT
AUXINITSOURCE=
AUXINITFILE=
SERVICEDIR=
SERVICEFILE=
SYSCONFFILE=default.openwrt
SYSCONFDIR=${CONFDIR}/sysconfig
SPARSE=
ANNOTATED=
VARLIB=/lib
VARDIR=${VARLIB}/$PRODUCT

View File

@@ -14,7 +14,7 @@ INITDIR=/etc/rc.d/init.d #Directory where SysV init scripts are i
INITFILE=$PRODUCT #Name of the product's installed SysV init script INITFILE=$PRODUCT #Name of the product's installed SysV init script
INITSOURCE=init.fedora.sh #Name of the distributed file to be installed as the SysV init script INITSOURCE=init.fedora.sh #Name of the distributed file to be installed as the SysV init script
ANNOTATED= #If non-zero, annotated configuration files are installed ANNOTATED= #If non-zero, annotated configuration files are installed
SYSTEMD=/lib/systemd/system #Directory where .service files are installed (systems running systemd only) SERVICEDIR=/lib/systemd/system #Directory where .service files are installed (systems running systemd only)
SYSCONFFILE=sysconfig #Name of the distributed file to be installed as $SYSCONFDIR/$PRODUCT SYSCONFFILE=sysconfig #Name of the distributed file to be installed as $SYSCONFDIR/$PRODUCT
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
SYSCONFDIR=/etc/sysconfig/ #Directory where SysV init parameter files are installed SYSCONFDIR=/etc/sysconfig/ #Directory where SysV init parameter files are installed

View File

@@ -15,7 +15,7 @@ AUXINITSOURCE=init.slackware.firewall.sh #Name of the distributed file to be i
AUXINITFILE=rc.firewall #Name of the product's installed SysV init script AUXINITFILE=rc.firewall #Name of the product's installed SysV init script
INITSOURCE=init.slackware.$PRODUCT.sh #Name of the distributed file to be installed as a second SysV init script INITSOURCE=init.slackware.$PRODUCT.sh #Name of the distributed file to be installed as a second SysV init script
INITFILE=rc.$PRODUCT #Name of the product's installed second init script INITFILE=rc.$PRODUCT #Name of the product's installed second init script
SYSTEMD= #Name of the directory where .service files are installed (systems running systemd only) SERVICEDIR= #Name of the directory where .service files are installed (systems running systemd only)
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
SYSCONFFILE= #Name of the distributed file to be installed in $SYSCONFDIR SYSCONFFILE= #Name of the distributed file to be installed in $SYSCONFDIR
SYSCONFDIR= #Name of the directory where SysV init parameter files are installed. SYSCONFDIR= #Name of the directory where SysV init parameter files are installed.

View File

@@ -8,13 +8,13 @@ CONFDIR=/etc #Directory where subsystem
SHAREDIR=${PREFIX}/share #Directory for arch-neutral files. SHAREDIR=${PREFIX}/share #Directory for arch-neutral files.
LIBEXECDIR=${PREFIX}/lib #Directory for executable scripts. LIBEXECDIR=${PREFIX}/lib #Directory for executable scripts.
PERLLIBDIR=${PREFIX}/lib/perl5/vendor_perl/5.14.2 #Directory to install Shorewall Perl module directory PERLLIBDIR=${PREFIX}/lib/perl5/vendor_perl/5.14.2 #Directory to install Shorewall Perl module directory
SBINDIR=/sbin #Directory where system administration programs are installed SBINDIR=/usr/sbin #Directory where system administration programs are installed
MANDIR=${SHAREDIR}/man/ #Directory where manpages are installed. MANDIR=${SHAREDIR}/man/ #Directory where manpages are installed.
INITDIR=/etc/init.d #Directory where SysV init scripts are installed. INITDIR=/etc/init.d #Directory where SysV init scripts are installed.
INITFILE=$PRODUCT #Name of the product's SysV init script INITFILE=$PRODUCT #Name of the product's SysV init script
INITSOURCE=init.suse.sh #Name of the distributed file to be installed as the SysV init script INITSOURCE=init.suse.sh #Name of the distributed file to be installed as the SysV init script
ANNOTATED= #If non-zero, annotated configuration files are installed ANNOTATED= #If non-zero, annotated configuration files are installed
SYSTEMD= #Directory where .service files are installed (systems running systemd only) SERVICEDIR= #Directory where .service files are installed (systems running systemd only)
SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service SERVICEFILE= #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
SYSCONFFILE=sysconfig #Name of the distributed file to be installed in $SYSCONFDIR SYSCONFFILE=sysconfig #Name of the distributed file to be installed in $SYSCONFDIR
SYSCONFDIR=/etc/sysconfig/ #Directory where SysV init parameter files are installed SYSCONFDIR=/etc/sysconfig/ #Directory where SysV init parameter files are installed

View File

@@ -35,6 +35,12 @@ usage() # $1 = exit status
exit $1 exit $1
} }
fatal_error()
{
echo " ERROR: $@" >&2
exit 1
}
qt() qt()
{ {
"$@" >/dev/null 2>&1 "$@" >/dev/null 2>&1

View File

@@ -28,7 +28,7 @@ setstatedir() {
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR ) statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
fi fi
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ ! -x $STATEDIR/firewall ]; then if [ ! -x $STATEDIR/firewall ]; then
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then

View File

@@ -31,7 +31,7 @@ setstatedir() {
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR ) statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
fi fi
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ ! -x "$STATEDIR/firewall" ]; then if [ ! -x "$STATEDIR/firewall" ]; then
if [ $PRODUCT == shorewall -o $PRODUCT == shorewall6 ]; then if [ $PRODUCT == shorewall -o $PRODUCT == shorewall6 ]; then

View File

@@ -28,7 +28,7 @@ setstatedir() {
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR ) statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
fi fi
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ ! -x $STATEDIR/firewall ]; then if [ ! -x $STATEDIR/firewall ]; then
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then

View File

@@ -71,10 +71,12 @@ setstatedir() {
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR ) statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
fi fi
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c || echo_notdone ${SBINDIR}/$PRODUCT ${OPTIONS} compile -c
else
return 0
fi fi
} }
@@ -103,21 +105,17 @@ shorewall_start () {
echo -n "Initializing \"Shorewall-based firewalls\": " echo -n "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
setstatedir if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then
if [ -x ${STATEDIR}/firewall ]; then #
# # Run in a sub-shell to avoid name collisions
# Run in a sub-shell to avoid name collisions #
# (
( if ! ${STATEDIR}/firewall status > /dev/null 2>&1; then
if ! ${STATEDIR}/firewall status > /dev/null 2>&1; then ${STATEDIR}/firewall ${OPTIONS} stop
${STATEDIR}/firewall ${OPTIONS} stop || echo_notdone fi
else )
echo_notdone fi
fi
)
else
echo_notdone
fi fi
done done
@@ -144,10 +142,10 @@ shorewall_stop () {
echo -n "Clearing \"Shorewall-based firewalls\": " echo -n "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
setstatedir if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then
if [ -x ${STATEDIR}/firewall ]; then ${STATEDIR}/firewall ${OPTIONS} clear
${STATEDIR}/firewall ${OPTIONS} clear || echo_notdone fi
fi fi
done done

View File

@@ -42,7 +42,7 @@ setstatedir() {
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR ) statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
fi fi
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT == shorewall -o $PRODUCT == shorewall6 ]; then if [ $PRODUCT == shorewall -o $PRODUCT == shorewall6 ]; then
${SBINDIR}/$PRODUCT $OPTIONS compile -c ${SBINDIR}/$PRODUCT $OPTIONS compile -c

View File

@@ -67,12 +67,12 @@ setstatedir() {
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR ) statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
fi fi
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ ! -x $STATEDIR/firewall ]; then if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then ${SBINDIR}/$PRODUCT ${OPTIONS} compile $STATEDIR/firewall
${SBINDIR}/$PRODUCT ${OPTIONS} compile $STATEDIR/firewall else
fi return 0
fi fi
} }
@@ -83,11 +83,11 @@ shorewall_start () {
echo -n "Initializing \"Shorewall-based firewalls\": " echo -n "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
setstatedir if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then
if [ -x ${STATEDIR}/firewall ]; then if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then ${STATEDIR}/firewall ${OPTIONS} stop
${STATEDIR}/firewall ${OPTIONS} stop || exit 1 fi
fi fi
fi fi
done done
@@ -106,10 +106,10 @@ shorewall_stop () {
echo -n "Clearing \"Shorewall-based firewalls\": " echo -n "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
setstatedir if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then
if [ -x ${STATEDIR}/firewall ]; then ${STATEDIR}/firewall ${OPTIONS} clear
${STATEDIR}/firewall ${OPTIONS} clear || exit 1 fi
fi fi
done done

View File

@@ -77,10 +77,12 @@ setstatedir() {
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR ) statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
fi fi
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c || exit ${SBINDIR}/$PRODUCT ${OPTIONS} compile -c
else
return 0
fi fi
} }
@@ -91,14 +93,12 @@ shorewall_start () {
echo -n "Initializing \"Shorewall-based firewalls\": " echo -n "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
setstatedir if setstatedir; then
if [ -x $STATEDIR/firewall ]; then
if [ -x $STATEDIR/firewall ]; then if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then
if ! ${SBIN}/$PRODUCT status > /dev/null 2>&1; then $STATEDIR/$PRODUCT/firewall ${OPTIONS} stop
$STATEDIR/$PRODUCT/firewall ${OPTIONS} stop || exit fi
fi fi
else
exit 6
fi fi
done done
@@ -114,12 +114,10 @@ shorewall_stop () {
echo -n "Clearing \"Shorewall-based firewalls\": " echo -n "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
setstatedir if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then
if [ -x ${STATEDIR}/firewall ]; then ${STATEDIR}/firewall ${OPTIONS} clear
${STATEDIR}/firewall ${OPTIONS} clear || exit fi
else
exit 6
fi fi
done done

View File

@@ -35,6 +35,7 @@ usage() # $1 = exit status
echo "usage: $ME [ <configuration-file> ]" echo "usage: $ME [ <configuration-file> ]"
echo " $ME -v" echo " $ME -v"
echo " $ME -h" echo " $ME -h"
echo " $ME -n"
exit $1 exit $1
} }
@@ -105,9 +106,12 @@ PRODUCT=shorewall-init
T='-T' T='-T'
finished=0 finished=0
configure=1
while [ $finished -eq 0 ] ; do while [ $finished -eq 0 ] ; do
case "$1" in option="$1"
case "$option" in
-*) -*)
option=${option#-} option=${option#-}
@@ -120,6 +124,10 @@ while [ $finished -eq 0 ] ; do
echo "Shorewall-init Firewall Installer Version $VERSION" echo "Shorewall-init Firewall Installer Version $VERSION"
exit 0 exit 0
;; ;;
n*)
configure=0
option=${option#n}
;;
*) *)
usage 1 usage 1
;; ;;
@@ -176,8 +184,12 @@ for var in SHAREDIR LIBEXECDIR CONFDIR SBINDIR VARLIB VARDIR; do
require $var require $var
done done
[ -n "$SANDBOX" ] && configure=0
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
[ $configure -eq 1 ] && ETC=/etc || ETC="${CONFDIR}"
if [ -z "$BUILD" ]; then if [ -z "$BUILD" ]; then
case $(uname) in case $(uname) in
cygwin*) cygwin*)
@@ -191,7 +203,7 @@ if [ -z "$BUILD" ]; then
eval $(cat /etc/os-release | grep ^ID=) eval $(cat /etc/os-release | grep ^ID=)
case $ID in case $ID in
fedora|rhel) fedora|rhel|centos|foobar)
BUILD=redhat BUILD=redhat
;; ;;
debian|ubuntu) debian|ubuntu)
@@ -306,6 +318,7 @@ fi
# Install the Firewall Script # Install the Firewall Script
# #
if [ -n "$INITFILE" ]; then if [ -n "$INITFILE" ]; then
mkdir -p ${DESTDIR}${INITDIR}
install_file $INITSOURCE ${DESTDIR}${INITDIR}/$INITFILE 0544 install_file $INITSOURCE ${DESTDIR}${INITDIR}/$INITFILE 0544
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${INITDIR}/$INITFILE [ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${INITDIR}/$INITFILE
@@ -319,13 +332,17 @@ fi
# #
# Install the .service file # Install the .service file
# #
if [ -n "$SYSTEMD" ]; then if [ -z "${SERVICEDIR}" ]; then
mkdir -p ${DESTDIR}${SYSTEMD} SERVICEDIR="$SYSTEMD"
fi
if [ -n "$SERVICEDIR" ]; then
mkdir -p ${DESTDIR}${SERVICEDIR}
[ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service [ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service
run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SYSTEMD}/$PRODUCT.service run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SYSTEMD}/$PRODUCT.service [ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SYSTEMD}/$PRODUCT.service" echo "Service file $SERVICEFILE installed as ${DESTDIR}${SERVICEDIR}/$PRODUCT.service"
if [ -n "$DESTDIR" ]; then if [ -n "$DESTDIR" -o $configure -eq 0 ]; then
mkdir -p ${DESTDIR}${SBINDIR} mkdir -p ${DESTDIR}${SBINDIR}
chmod 755 ${DESTDIR}${SBINDIR} chmod 755 ${DESTDIR}${SBINDIR}
fi fi
@@ -364,16 +381,23 @@ fi
if [ $HOST = debian ]; then if [ $HOST = debian ]; then
if [ -n "${DESTDIR}" ]; then if [ -n "${DESTDIR}" ]; then
mkdir -p ${DESTDIR}/etc/network/if-up.d/ mkdir -p ${DESTDIR}${ETC}/network/if-up.d/
mkdir -p ${DESTDIR}/etc/network/if-down.d/ mkdir -p ${DESTDIR}${ETC}/network/if-down.d/
mkdir -p ${DESTDIR}${ETC}/network/if-post-down.d/
elif [ $configure -eq 0 ]; then
mkdir -p ${DESTDIR}${CONFDIR}/network/if-up.d/
mkdir -p ${DESTDIR}${CONFDIR}/network/if-down.d/
mkdir -p ${DESTDIR}${CONFDIR}/network/if-post-down.d/
fi fi
if [ ! -f ${DESTDIR}/etc/default/shorewall-init ]; then if [ ! -f ${DESTDIR}${CONFDIR}/default/shorewall-init ]; then
if [ -n "${DESTDIR}" ]; then if [ -n "${DESTDIR}" ]; then
mkdir ${DESTDIR}/etc/default mkdir ${DESTDIR}${ETC}/default
fi fi
install_file sysconfig ${DESTDIR}/etc/default/shorewall-init 0644 [ $configure -eq 1 ] || mkdir -p ${DESTDIR}${CONFDIR}/default
install_file sysconfig ${DESTDIR}${ETC}/default/shorewall-init 0644
echo "sysconfig file installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}"
fi fi
IFUPDOWN=ifupdown.debian.sh IFUPDOWN=ifupdown.debian.sh
@@ -383,13 +407,13 @@ else
if [ -z "$RPM" ]; then if [ -z "$RPM" ]; then
if [ $HOST = suse ]; then if [ $HOST = suse ]; then
mkdir -p ${DESTDIR}/etc/sysconfig/network/if-up.d mkdir -p ${DESTDIR}${ETC}/sysconfig/network/if-up.d
mkdir -p ${DESTDIR}${SYSCONFDIR}/network/if-down.d mkdir -p ${DESTDIR}${ETC}/sysconfig/network/if-down.d
elif [ $HOST = gentoo ]; then elif [ $HOST = gentoo ]; then
# Gentoo does not support if-{up,down}.d # Gentoo does not support if-{up,down}.d
/bin/true /bin/true
else else
mkdir -p ${DESTDIR}/etc/NetworkManager/dispatcher.d mkdir -p ${DESTDIR}/${ETC}/NetworkManager/dispatcher.d
fi fi
fi fi
fi fi
@@ -415,17 +439,29 @@ mkdir -p ${DESTDIR}${LIBEXECDIR}/shorewall-init
install_file ifupdown ${DESTDIR}${LIBEXECDIR}/shorewall-init/ifupdown 0544 install_file ifupdown ${DESTDIR}${LIBEXECDIR}/shorewall-init/ifupdown 0544
if [ -d ${DESTDIR}/etc/NetworkManager ]; then if [ -d ${DESTDIR}/etc/NetworkManager ]; then
install_file ifupdown ${DESTDIR}/etc/NetworkManager/dispatcher.d/01-shorewall 0544 [ $configure -eq 1 ] || mkdir -p ${DESTDIR}${CONFDIR}/NetworkManager/dispatcher.d/
install_file ifupdown ${DESTDIR}${ETC}/NetworkManager/dispatcher.d/01-shorewall 0544
fi fi
case $HOST in case $HOST in
debian) debian)
install_file ifupdown ${DESTDIR}/etc/network/if-up.d/shorewall 0544 if [ $configure -eq 1 ]; then
install_file ifupdown ${DESTDIR}/etc/network/if-down.d/shorewall 0544 install_file ifupdown ${DESTDIR}/etc/network/if-up.d/shorewall 0544
install_file ifupdown ${DESTDIR}/etc/network/if-post-down.d/shorewall 0544 install_file ifupdown ${DESTDIR}/etc/network/if-down.d/shorewall 0544
install_file ifupdown ${DESTDIR}/etc/network/if-post-down.d/shorewall 0544
else
install_file ifupdown ${DESTDIR}${CONFDIR}/network/if-up.d/shorewall 0544
install_file ifupdown ${DESTDIR}${CONFDIR}/network/if-down.d/shorewall 0544
install_file ifupdown ${DESTDIR}${CONFDIR}/network/if-post-down.d/shorewall 0544
fi
;; ;;
suse) suse)
if [ -z "$RPM" ]; then if [ -z "$RPM" ]; then
if [ $configure -eq 0 ]; then
mkdir -p ${DESTDIR}${SYSCONFDIR}/network/if-up.d/
mkdir -p ${DESTDIR}${SYSCONFDIR}/network/if-down.d/
fi
install_file ifupdown ${DESTDIR}${SYSCONFDIR}/network/if-up.d/shorewall 0544 install_file ifupdown ${DESTDIR}${SYSCONFDIR}/network/if-up.d/shorewall 0544
install_file ifupdown ${DESTDIR}${SYSCONFDIR}/network/if-down.d/shorewall 0544 install_file ifupdown ${DESTDIR}${SYSCONFDIR}/network/if-down.d/shorewall 0544
fi fi
@@ -453,9 +489,13 @@ case $HOST in
esac esac
if [ -z "$DESTDIR" ]; then if [ -z "$DESTDIR" ]; then
if [ -n "$first_install" ]; then if [ $configure -eq 1 -a -n "$first_install" ]; then
if [ $HOST = debian ]; then if [ $HOST = debian ]; then
if mywhich insserv; then if [ -n "$SERVICEDIR" ]; then
if systemctl enable ${PRODUCT}.service; then
echo "Shorewall Init will start automatically at boot"
fi
elif mywhich insserv; then
if insserv ${INITDIR}/shorewall-init; then if insserv ${INITDIR}/shorewall-init; then
echo "Shorewall Init will start automatically at boot" echo "Shorewall Init will start automatically at boot"
else else
@@ -476,7 +516,7 @@ if [ -z "$DESTDIR" ]; then
# not by the installer # not by the installer
/bin/true /bin/true
else else
if [ -n "$SYSTEMD" ]; then if [ -n "$SERVICEDIR" ]; then
if systemctl enable shorewall-init.service; then if systemctl enable shorewall-init.service; then
echo "Shorewall Init will start automatically at boot" echo "Shorewall Init will start automatically at boot"
fi fi
@@ -505,7 +545,7 @@ if [ -z "$DESTDIR" ]; then
fi fi
fi fi
else else
if [ -n "$first_install" ]; then if [ $configure -eq 1 -a -n "$first_install" ]; then
if [ $HOST = debian ]; then if [ $HOST = debian ]; then
if [ -n "${DESTDIR}" ]; then if [ -n "${DESTDIR}" ]; then
mkdir -p ${DESTDIR}/etc/rcS.d mkdir -p ${DESTDIR}/etc/rcS.d
@@ -519,7 +559,7 @@ fi
[ -z "${DESTDIR}" ] && [ ! -f ~/.shorewallrc ] && cp ${SHAREDIR}/shorewall/shorewallrc . [ -z "${DESTDIR}" ] && [ ! -f ~/.shorewallrc ] && cp ${SHAREDIR}/shorewall/shorewallrc .
if [ -f ${DESTDIR}/etc/ppp ]; then if [ -d ${DESTDIR}/etc/ppp ]; then
case $HOST in case $HOST in
debian|suse) debian|suse)
for directory in ip-up.d ip-down.d ipv6-up.d ipv6-down.d; do for directory in ip-up.d ip-down.d ipv6-up.d ipv6-down.d; do

View File

@@ -1,18 +1,19 @@
#! /bin/bash #!/bin/bash
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.5 # The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.6
# #
# (c) 2012-2014 - Tom Eastep (teastep@shorewall.net) # (c) 2012-2014 - Tom Eastep (teastep@shorewall.net)
# #
# 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.net # Complete documentation is available at http://shorewall.net
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the # it under the terms of the GNU General Public License as published by
# Free Software Foundation, either version 2 of the license or, at your # the Free Software Foundation, either version 2 of the license or,
# option, any later version. # at your option, any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -22,7 +23,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>. # along with this program; if not, see <http://www.gnu.org/licenses/>.
# #
######################################################################################### ###############################################################################
# set the STATEDIR variable # set the STATEDIR variable
setstatedir() { setstatedir() {
local statedir local statedir
@@ -30,10 +31,12 @@ setstatedir() {
statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR ) statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
fi fi
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARDIR}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c || exit 1 ${SBINDIR}/$PRODUCT ${OPTIONS} compile -c
else
return 0
fi fi
} }
@@ -46,7 +49,7 @@ setstatedir() {
if [ -f "$SYSCONFDIR/shorewall-init" ]; then if [ -f "$SYSCONFDIR/shorewall-init" ]; then
. $SYSCONFDIR/shorewall-init . $SYSCONFDIR/shorewall-init
if [ -z "$PRODUCTS" ]; then if [ -z "$PRODUCTS" ]; then
echo "ERROR: No products configured" >&2 echo "ERROR: No products configured" >&2
exit 1 exit 1
fi fi
else else
@@ -56,70 +59,66 @@ fi
# Initialize the firewall # Initialize the firewall
shorewall_start () { shorewall_start () {
local PRODUCT local PRODUCT
local STATEDIR local STATEDIR
echo -n "Initializing \"Shorewall-based firewalls\": " echo -n "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
setstatedir if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then
#
# Run in a sub-shell to avoid name collisions
#
(
if ! ${STATEDIR}/firewall status > /dev/null 2>&1; then
${STATEDIR}/firewall ${OPTIONS} stop
fi
)
fi
fi
done
if [ -x ${STATEDIR}/$PRODUCT/firewall ]; then if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
# ipset -R < "$SAVE_IPSETS"
# Run in a sub-shell to avoid name collisions fi
#
(
if ! ${STATEDIR}/$PRODUCT/firewall status > /dev/null 2>&1; then
${STATEDIR}/$PRODUCT/firewall ${OPTIONS} stop || exit 1
else
exit 1
fi
)
else
exit 1
fi
done
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then return 0
ipset -R < "$SAVE_IPSETS"
fi
return 0
} }
# Clear the firewall # Clear the firewall
shorewall_stop () { shorewall_stop () {
local PRODUCT local PRODUCT
local STATEDIR local STATEDIR
echo -n "Clearing \"Shorewall-based firewalls\": " echo -n "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
setstatedir if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then
${STATEDIR}/firewall ${OPTIONS} clear
fi
fi
done
if [ -x ${STATEDIR}/$PRODUCT/firewall ]; then if [ -n "$SAVE_IPSETS" ]; then
${STATEDIR}/$PRODUCT/firewall ${OPTIONS} clear || exit 1 mkdir -p $(dirname "$SAVE_IPSETS")
fi if ipset -S > "${SAVE_IPSETS}.tmp"; then
done grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS"
fi
fi
if [ -n "$SAVE_IPSETS" ]; then return 0
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"
fi
fi
return 0
} }
case "$1" in case "$1" in
start) start)
shorewall_start shorewall_start
;; ;;
stop) stop)
shorewall_stop shorewall_stop
;; ;;
*) *)
echo "Usage: $0 {start|stop}" echo "Usage: $0 {start|stop}"
exit 1 exit 1
esac esac
exit 0 exit 0

View File

@@ -1,11 +1,10 @@
# #
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.4 # The Shoreline Firewall (Shorewall) Packet Filtering Firewall
# #
# Copyright 2011 Jonathan Underwood (jonathan.underwood@gmail.com) # Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
# #
[Unit] [Unit]
Description=Shorewall IPv4 firewall Description=Shorewall firewall (bootup security)
After=syslog.target
Before=network.target Before=network.target
[Service] [Service]
@@ -13,8 +12,8 @@ Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
EnvironmentFile=-/etc/sysconfig/shorewall-init EnvironmentFile=-/etc/sysconfig/shorewall-init
StandardOutput=syslog StandardOutput=syslog
ExecStart=/sbin/shorewall-init $OPTIONS start ExecStart=/sbin/shorewall-init start
ExecStop=/sbin/shorewall-init $OPTIONS stop ExecStop=/sbin/shorewall-init stop
[Install] [Install]
WantedBy=multi-user.target WantedBy=basic.target

View File

@@ -0,0 +1,20 @@
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
#
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
#
[Unit]
Description=Shorewall firewall (bootup security)
Before=network-pre.target
Wants=network-pre.target
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=-/etc/sysconfig/shorewall-init
StandardOutput=syslog
ExecStart=/sbin/shorewall-init start
ExecStop=/sbin/shorewall-init stop
[Install]
WantedBy=basic.target

View File

@@ -0,0 +1,21 @@
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
#
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
# Copyright 2015 Tom Eastep <teastep@shorewall.net>
#
[Unit]
Description=Shorewall firewall (bootup security)
Before=network-pre.target
Wants=network-pre.target
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=-/etc/default/shorewall-init
StandardOutput=syslog
ExecStart=/sbin/shorewall-init start
ExecStop=/sbin/shorewall-init stop
[Install]
WantedBy=basic.target

View File

@@ -0,0 +1,20 @@
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
#
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
# Copyright 2015 Tom Eastep <teastep@shorewall.net>
#
[Unit]
Description=Shorewall firewall (bootup security)
Before=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=-/etc/default/shorewall-init
StandardOutput=syslog
ExecStart=/sbin/shorewall-init start
ExecStop=/sbin/shorewall-init stop
[Install]
WantedBy=basic.target

View File

@@ -1,4 +1,4 @@
\#!/bin/sh #!/bin/sh
# #
# Script to back uninstall Shoreline Firewall # Script to back uninstall Shoreline Firewall
# #
@@ -35,6 +35,12 @@ usage() # $1 = exit status
exit $1 exit $1
} }
fatal_error()
{
echo " ERROR: $@" >&2
exit 1
}
qt() qt()
{ {
"$@" >/dev/null 2>&1 "$@" >/dev/null 2>&1
@@ -69,6 +75,42 @@ remove_file() # $1 = file to restore
fi fi
} }
finished=0
configure=1
while [ $finished -eq 0 ]; do
option=$1
case "$option" in
-*)
option=${option#-}
while [ -n "$option" ]; do
case $option in
h)
usage 0
;;
v)
echo "$Product Firewall Installer Version $VERSION"
exit 0
;;
n*)
configure=0
option=${option#n}
;;
*)
usage 1
;;
esac
done
shift
;;
*)
finished=1
;;
esac
done
# #
# Read the RC file # Read the RC file
# #
@@ -114,22 +156,33 @@ fi
echo "Uninstalling Shorewall Init $VERSION" echo "Uninstalling Shorewall Init $VERSION"
[ -n "$SANDBOX" ] && configure=0
INITSCRIPT=${CONFDIR}/init.d/shorewall-init INITSCRIPT=${CONFDIR}/init.d/shorewall-init
if [ -f "$INITSCRIPT" ]; then if [ -f "$INITSCRIPT" ]; then
if mywhich updaterc.d ; then if [ $configure -eq 1 ]; then
updaterc.d shorewall-init remove if mywhich updaterc.d ; then
elif mywhich insserv ; then updaterc.d shorewall-init remove
insserv -r $INITSCRIPT elif mywhich insserv ; then
elif mywhich chkconfig ; then insserv -r $INITSCRIPT
chkconfig --del $(basename $INITSCRIPT) elif mywhich chkconfig ; then
elif mywhich systemctl ; then chkconfig --del $(basename $INITSCRIPT)
systemctl disable shorewall-init fi
fi fi
remove_file $INITSCRIPT remove_file $INITSCRIPT
fi fi
if [ -z "${SERVICEDIR}" ]; then
SERVICEDIR="$SYSTEMD"
fi
if [ -n "$SERVICEDIR" ]; then
[ $configure -eq 1 ] && systemctl disable shorewall-init.service
rm -f $SERVICEDIR/shorewall-init.service
fi
[ "$(readlink -m -q ${SBINDIR}/ifup-local)" = ${SHAREDIR}/shorewall-init ] && remove_file ${SBINDIR}/ifup-local [ "$(readlink -m -q ${SBINDIR}/ifup-local)" = ${SHAREDIR}/shorewall-init ] && remove_file ${SBINDIR}/ifup-local
[ "$(readlink -m -q ${SBINDIR}/ifdown-local)" = ${SHAREDIR}/shorewall-init ] && remove_file ${SBINDIR}/ifdown-local [ "$(readlink -m -q ${SBINDIR}/ifdown-local)" = ${SHAREDIR}/shorewall-init ] && remove_file ${SBINDIR}/ifdown-local
@@ -153,14 +206,17 @@ if [ -d ${CONFDIR}/ppp ]; then
done done
for file in if-up.local if-down.local; do for file in if-up.local if-down.local; do
if grep -qF Shorewall-based ${CONFDIR}/ppp/$FILE; then if [ -f ${CONFDIR}/ppp/$file ]; then
remove_file ${CONFDIR}/ppp/$FILE if grep -qF Shorewall-based ${CONFDIR}/ppp/$FILE; then
remove_file ${CONFDIR}/ppp/$FILE
fi
fi fi
done done
fi fi
rm -f ${SBINDIR}/shorewall-init
rm -rf ${SHAREDIR}/shorewall-init rm -rf ${SHAREDIR}/shorewall-init
rm -rf ${LIBEXEC}/shorewall-init rm -rf ${LIBEXECDIR}/shorewall-init
echo "Shorewall Init Uninstalled" echo "Shorewall Init Uninstalled"

View File

@@ -39,7 +39,7 @@ fi
start() { start() {
echo -n $"Starting Shorewall: " echo -n $"Starting Shorewall: "
$shorewall $OPTIONS start 2>&1 | $logger $shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
retval=${PIPESTATUS[0]} retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then if [[ $retval == 0 ]]; then
touch $lockfile touch $lockfile
@@ -69,7 +69,7 @@ restart() {
# Note that we don't simply stop and start since shorewall has a built in # Note that we don't simply stop and start since shorewall has a built in
# restart which stops the firewall if running and then starts it. # restart which stops the firewall if running and then starts it.
echo -n $"Restarting Shorewall: " echo -n $"Restarting Shorewall: "
$shorewall $OPTIONS restart 2>&1 | $logger $shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
retval=${PIPESTATUS[0]} retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then if [[ $retval == 0 ]]; then
touch $lockfile touch $lockfile

View File

@@ -30,6 +30,7 @@ usage() # $1 = exit status
echo "usage: $ME [ <configuration-file> ]" echo "usage: $ME [ <configuration-file> ]"
echo " $ME -v" echo " $ME -v"
echo " $ME -h" echo " $ME -h"
echo " $ME -n"
exit $1 exit $1
} }
@@ -66,15 +67,6 @@ mywhich() {
return 2 return 2
} }
run_install()
{
if ! install $*; then
echo
echo "ERROR: Failed to install $*" >&2
exit 1
fi
}
cant_autostart() cant_autostart()
{ {
echo echo
@@ -88,7 +80,28 @@ delete_file() # $1 = file to delete
install_file() # $1 = source $2 = target $3 = mode install_file() # $1 = source $2 = target $3 = mode
{ {
run_install $T $OWNERSHIP -m $3 $1 ${2} if cp -f $1 $2; then
if chmod $3 $2; then
if [ -n "$OWNER" ]; then
if chown $OWNER:$GROUP $2; then
return
fi
else
return 0
fi
fi
fi
echo "ERROR: Failed to install $2" >&2
exit 1
}
make_directory() # $1 = directory , $2 = mode
{
mkdir -p $1
chmod 755 $1
[ -n "$OWNERSHIP" ] && chown $OWNERSHIP $1
} }
require() require()
@@ -113,9 +126,13 @@ fi
# Parse the run line # Parse the run line
# #
finished=0 finished=0
configure=1
while [ $finished -eq 0 ] ; do while [ $finished -eq 0 ] ; do
case "$1" in
option=$1
case "$option" in
-*) -*)
option=${option#-} option=${option#-}
@@ -128,6 +145,10 @@ while [ $finished -eq 0 ] ; do
echo "$Product Firewall Installer Version $VERSION" echo "$Product Firewall Installer Version $VERSION"
exit 0 exit 0
;; ;;
n*)
configure=0
option=${option#n}
;;
*) *)
usage 1 usage 1
;; ;;
@@ -178,7 +199,7 @@ elif [ -z "${VARDIR}" ]; then
VARDIR=${VARLIB}/${PRODUCT} VARDIR=${VARLIB}/${PRODUCT}
fi fi
for var in SHAREDIR LIBEXECDIRDIRDIR CONFDIR SBINDIR VARLIB VARDIR; do for var in SHAREDIR LIBEXECDIR CONFDIR SBINDIR VARLIB VARDIR; do
require $var require $var
done done
@@ -186,12 +207,12 @@ done
PATH=${SBINDIR}:/bin:/usr${SBINDIR}:/usr/bin:/usr/local/bin:/usr/local${SBINDIR} PATH=${SBINDIR}:/bin:/usr${SBINDIR}:/usr/bin:/usr/local/bin:/usr/local${SBINDIR}
[ -n "$SANDBOX" ] && configure=0
# #
# Determine where to install the firewall script # Determine where to install the firewall script
# #
cygwin= cygwin=
INSTALLD='-D'
T='-T'
if [ -z "$BUILD" ]; then if [ -z "$BUILD" ]; then
case $(uname) in case $(uname) in
@@ -206,7 +227,7 @@ if [ -z "$BUILD" ]; then
eval $(cat /etc/os-release | grep ^ID) eval $(cat /etc/os-release | grep ^ID)
case $ID in case $ID in
fedora|rhel) fedora|rhel|centos|foobar)
BUILD=redhat BUILD=redhat
;; ;;
debian) debian)
@@ -234,6 +255,8 @@ if [ -z "$BUILD" ]; then
BUILD=slackware BUILD=slackware
elif [ -f ${CONFDIR}/arch-release ] ; then elif [ -f ${CONFDIR}/arch-release ] ; then
BUILD=archlinux BUILD=archlinux
elif [ -f ${CONFDIR}/openwrt_release ]; then
BUILD=openwrt
else else
BUILD=linux BUILD=linux
fi fi
@@ -249,16 +272,16 @@ case $BUILD in
apple) apple)
[ -z "$OWNER" ] && OWNER=root [ -z "$OWNER" ] && OWNER=root
[ -z "$GROUP" ] && GROUP=wheel [ -z "$GROUP" ] && GROUP=wheel
INSTALLD=
T=
;; ;;
*) *)
[ -z "$OWNER" ] && OWNER=root if [ $(id -u) -eq 0 ]; then
[ -z "$GROUP" ] && GROUP=root [ -z "$OWNER" ] && OWNER=root
[ -z "$GROUP" ] && GROUP=root
fi
;; ;;
esac esac
OWNERSHIP="-o $OWNER -g $GROUP" [ -n "$OWNER" ] && OWNERSHIP="$OWNER:$GROUP"
[ -n "$HOST" ] || HOST=$BUILD [ -n "$HOST" ] || HOST=$BUILD
@@ -289,6 +312,9 @@ case "$HOST" in
suse) suse)
echo "Installing Suse-specific configuration..." echo "Installing Suse-specific configuration..."
;; ;;
openwrt)
echo "Installing OpenWRT-specific configuration..."
;;
linux) linux)
;; ;;
*) *)
@@ -305,8 +331,9 @@ if [ -n "$DESTDIR" ]; then
OWNERSHIP="" OWNERSHIP=""
fi fi
install -d $OWNERSHIP -m 755 ${DESTDIR}/${SBINDIR} make_directory ${DESTDIR}${SBINDIR} 755
install -d $OWNERSHIP -m 755 ${DESTDIR}${INITDIR} make_directory ${DESTDIR}${INITDIR} 755
else else
if [ ! -f ${SHAREDIR}/shorewall/coreversion ]; then if [ ! -f ${SHAREDIR}/shorewall/coreversion ]; then
echo "$PRODUCT $VERSION requires Shorewall Core which does not appear to be installed" >&2 echo "$PRODUCT $VERSION requires Shorewall Core which does not appear to be installed" >&2
@@ -346,6 +373,7 @@ fi
delete_file ${DESTDIR}/usr/share/$PRODUCT/xmodules delete_file ${DESTDIR}/usr/share/$PRODUCT/xmodules
install_file $PRODUCT ${DESTDIR}${SBINDIR}/$PRODUCT 0544 install_file $PRODUCT ${DESTDIR}${SBINDIR}/$PRODUCT 0544
[ -n "${INITFILE}" ] && make_directory ${DESTDIR}${INITDIR} 755
echo "$Product control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT" echo "$Product control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT"
@@ -358,7 +386,7 @@ mkdir -p ${DESTDIR}${LIBEXECDIR}/$PRODUCT
mkdir -p ${DESTDIR}${VARDIR} mkdir -p ${DESTDIR}${VARDIR}
chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT
chmod 755 ${DESTDIR}/usr/share/$PRODUCT chmod 755 ${DESTDIR}${SHAREDIR}/$PRODUCT
if [ -n "$DESTDIR" ]; then if [ -n "$DESTDIR" ]; then
mkdir -p ${DESTDIR}${CONFDIR}/logrotate.d mkdir -p ${DESTDIR}${CONFDIR}/logrotate.d
@@ -369,7 +397,7 @@ fi
if [ -n "$INITFILE" ]; then if [ -n "$INITFILE" ]; then
if [ -f "${INITSOURCE}" ]; then if [ -f "${INITSOURCE}" ]; then
initfile="${DESTDIR}/${INITDIR}/${INITFILE}" initfile="${DESTDIR}${INITDIR}/${INITFILE}"
install_file ${INITSOURCE} "$initfile" 0544 install_file ${INITSOURCE} "$initfile" 0544
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' "$initfile" [ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' "$initfile"
@@ -380,12 +408,16 @@ fi
# #
# Install the .service file # Install the .service file
# #
if [ -n "$SYSTEMD" ]; then if [ -z "${SERVICEDIR}" ]; then
mkdir -p ${DESTDIR}${SYSTEMD} SERVICEDIR="$SYSTEMD"
fi
if [ -n "$SERVICEDIR" ]; then
mkdir -p ${DESTDIR}${SERVICEDIR}
[ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service [ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service
run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SYSTEMD}/$PRODUCT.service install_file $SERVICEFILE ${DESTDIR}${SERVICEDIR}/$PRODUCT.service 644
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SYSTEMD}/$PRODUCT.service [ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SYSTEMD}/$PRODUCT.service" echo "Service file $SERVICEFILE installed as ${DESTDIR}${SERVICEDIR}/$PRODUCT.service"
fi fi
# #
# Install the config file # Install the config file
@@ -405,9 +437,9 @@ fi
# #
# Install the Makefile # Install the Makefile
# #
run_install $OWNERSHIP -m 0600 Makefile ${DESTDIR}${CONFDIR}/$PRODUCT install_file Makefile ${DESTDIR}${CONFDIR}/$PRODUCT/Makefile 0600
[ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${CONFDIR}/$PRODUCT/Makefile [ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${CONFDIR}/$PRODUCT/Makefile
[ $SBINDIR = /sbin ] || eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}/${CONFDIR}/$PRODUCT/Makefile [ $SBINDIR = /sbin ] || eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${CONFDIR}/$PRODUCT/Makefile
echo "Makefile installed as ${DESTDIR}${CONFDIR}/$PRODUCT/Makefile" echo "Makefile installed as ${DESTDIR}${CONFDIR}/$PRODUCT/Makefile"
# #
@@ -422,7 +454,7 @@ echo "Default config path file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/confi
for f in lib.* ; do for f in lib.* ; do
if [ -f $f ]; then if [ -f $f ]; then
install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 0644 install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 0644
echo "Library ${f#*.} file installed as ${DESTDIR}/${SHAREDIR}/$PRODUCT/$f" echo "Library ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f"
fi fi
done done
@@ -435,7 +467,7 @@ echo "Common functions linked through ${DESTDIR}${SHAREDIR}/$PRODUCT/functions"
# #
install_file shorecap ${DESTDIR}${LIBEXECDIR}/$PRODUCT/shorecap 0755 install_file shorecap ${DESTDIR}${LIBEXECDIR}/$PRODUCT/shorecap 0755
[ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${LIBEXECDIR}/$PRODUCT/shorecap [ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${LIBEXECDIR}/$PRODUCT/shorecap
echo echo
echo "Capability file builder installed in ${DESTDIR}${LIBEXECDIR}/$PRODUCT/shorecap" echo "Capability file builder installed in ${DESTDIR}${LIBEXECDIR}/$PRODUCT/shorecap"
@@ -445,17 +477,17 @@ echo "Capability file builder installed in ${DESTDIR}${LIBEXECDIR}/$PRODUCT/shor
# #
if [ -f modules ]; then if [ -f modules ]; then
run_install $OWNERSHIP -m 0600 modules ${DESTDIR}${SHAREDIR}/$PRODUCT install_file modules ${DESTDIR}${SHAREDIR}/$PRODUCT/modules 0600
echo "Modules file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/modules" echo "Modules file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/modules"
fi fi
if [ -f helpers ]; then if [ -f helpers ]; then
run_install $OWNERSHIP -m 0600 helpers ${DESTDIR}${SHAREDIR}/$PRODUCT install_file helpers ${DESTDIR}${SHAREDIR}/$PRODUCT/helpers 600
echo "Helper modules file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/helpers" echo "Helper modules file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/helpers"
fi fi
for f in modules.*; do for f in modules.*; do
run_install $OWNERSHIP -m 0644 $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 644
echo "Module file $f installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f" echo "Module file $f installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f"
done done
@@ -466,18 +498,18 @@ done
if [ -d manpages ]; then if [ -d manpages ]; then
cd manpages cd manpages
[ -n "$INSTALLD" ] || mkdir -p ${DESTDIR}${SHAREDIR}/man/man5/ ${DESTDIR}${SHAREDIR}/man/man8/ mkdir -p ${DESTDIR}${MANDIR}/man5/ ${DESTDIR}${MANDIR}/man8/
for f in *.5; do for f in *.5; do
gzip -c $f > $f.gz gzip -c $f > $f.gz
run_install $T $INSTALLD $OWNERSHIP -m 0644 $f.gz ${DESTDIR}${SHAREDIR}/man/man5/$f.gz install_file $f.gz ${DESTDIR}${MANDIR}/man5/$f.gz 644
echo "Man page $f.gz installed to ${DESTDIR}${SHAREDIR}/man/man5/$f.gz" echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man5/$f.gz"
done done
for f in *.8; do for f in *.8; do
gzip -c $f > $f.gz gzip -c $f > $f.gz
run_install $T $INSTALLD $OWNERSHIP -m 0644 $f.gz ${DESTDIR}${SHAREDIR}/man/man8/$f.gz install_file $f.gz ${DESTDIR}${MANDIR}/man8/$f.gz 644
echo "Man page $f.gz installed to ${DESTDIR}${SHAREDIR}/man/man8/$f.gz" echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man8/$f.gz"
done done
cd .. cd ..
@@ -486,7 +518,7 @@ if [ -d manpages ]; then
fi fi
if [ -d ${DESTDIR}${CONFDIR}/logrotate.d ]; then if [ -d ${DESTDIR}${CONFDIR}/logrotate.d ]; then
run_install $OWNERSHIP -m 0644 logrotate ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT install_file logrotate ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT 644
echo "Logrotate file installed as ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT" echo "Logrotate file installed as ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT"
fi fi
@@ -499,7 +531,7 @@ chmod 644 ${DESTDIR}${SHAREDIR}/$PRODUCT/version
# Remove and create the symbolic link to the init script # Remove and create the symbolic link to the init script
# #
if [ -z "$DESTDIR" ]; then if [ -z "${DESTDIR}" -a -n "${INITFILE}" ]; then
rm -f ${SHAREDIR}/$PRODUCT/init rm -f ${SHAREDIR}/$PRODUCT/init
ln -s ${INITDIR}/${INITFILE} ${SHAREDIR}/$PRODUCT/init ln -s ${INITDIR}/${INITFILE} ${SHAREDIR}/$PRODUCT/init
fi fi
@@ -517,17 +549,17 @@ if [ -n "$SYSCONFFILE" -a -f "$SYSCONFFILE" -a ! -f ${DESTDIR}${SYSCONFDIR}/${PR
chmod 755 ${DESTDIR}${SYSCONFDIR} chmod 755 ${DESTDIR}${SYSCONFDIR}
fi fi
run_install $OWNERSHIP -m 0644 ${SYSCONFFILE} ${DESTDIR}${SYSCONFDIR}/${PRODUCT} install_file ${SYSCONFFILE} ${DESTDIR}${SYSCONFDIR}/${PRODUCT} 0640
echo "$SYSCONFFILE installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}" echo "$SYSCONFFILE installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}"
fi fi
if [ ${SHAREDIR} != /usr/share ]; then if [ ${SHAREDIR} != /usr/share ]; then
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${SHAREDIR}/${PRODUCT}/lib.base eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/${PRODUCT}/lib.base
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${SBINDIR}/$PRODUCT eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SBINDIR}/$PRODUCT
fi fi
if [ -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then if [ $configure -eq 1 -a -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
if [ -n "$SYSTEMD" ]; then if [ -n "$SERVICEDIR" ]; then
if systemctl enable ${PRODUCT}.service; then if systemctl enable ${PRODUCT}.service; then
echo "$Product will start automatically at boot" echo "$Product will start automatically at boot"
fi fi
@@ -571,6 +603,13 @@ if [ -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
else else
cant_autostart cant_autostart
fi fi
elif [ $HOST = openwrt -a -f ${CONFDIR}/rc.common ]; then
/etc/init.d/$PRODUCT enable
if /etc/init.d/$PRODUCT enabled; then
echo "$PRODUCT will start automatically at boot"
else
cant_autostart
fi
elif [ "$INITFILE" != rc.${PRODUCT} ]; then #Slackware starts this automatically elif [ "$INITFILE" != rc.${PRODUCT} ]; then #Slackware starts this automatically
cant_autostart cant_autostart
fi fi

View File

@@ -47,6 +47,19 @@
<arg choice="plain"><replaceable>address</replaceable></arg> <arg choice="plain"><replaceable>address</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis>
<command>shorewall-lite</command>
<arg
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
<arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>allow</option></arg>
<arg choice="plain"><replaceable>address</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
<command>shorewall-lite</command> <command>shorewall-lite</command>
@@ -59,6 +72,21 @@
choice="plain"><option>clear</option><arg><option>-f</option></arg></arg> choice="plain"><option>clear</option><arg><option>-f</option></arg></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis>
<command>shorewall-lite</command>
<arg
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
<arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>close</option><arg choice="req">
<replaceable>open-number</replaceable> |
<replaceable>source</replaceable><replaceable>dest</replaceable><arg><replaceable>protocol</replaceable><arg>
<replaceable>port</replaceable> </arg></arg></arg><replaceable>
</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
<command>shorewall-lite</command> <command>shorewall-lite</command>
@@ -116,6 +144,8 @@
<arg><option>-l</option></arg> <arg><option>-l</option></arg>
<arg><option>-m</option></arg> <arg><option>-m</option></arg>
<arg><option>-c</option></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
@@ -263,6 +293,29 @@
expression</replaceable></arg> expression</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis>
<command>shorewall-lite</command>
<arg choice="plain"><option>open</option><replaceable>
source</replaceable><replaceable> dest</replaceable><arg>
<replaceable>protocol</replaceable><arg> <replaceable>port</replaceable>
</arg> </arg></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>shorewall-lite</command>
<arg
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
<arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>reenable</option></arg>
<arg choice="plain">{ <replaceable>interface</replaceable> |
<replaceable>provider</replaceable> }</arg>
</cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
<command>shorewall-lite</command> <command>shorewall-lite</command>
@@ -299,9 +352,7 @@
<arg><option>-n</option></arg> <arg><option>-n</option></arg>
<arg><option>-p</option></arg> <arg><option>-p</option><arg><option>-C</option></arg></arg>
<arg><replaceable>directory</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
@@ -314,6 +365,8 @@
<arg choice="plain"><option>restore</option></arg> <arg choice="plain"><option>restore</option></arg>
<arg><option>-C</option></arg>
<arg><replaceable>filename</replaceable></arg> <arg><replaceable>filename</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
@@ -340,11 +393,23 @@
<arg>-<replaceable>options</replaceable></arg> <arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>save</option></arg> <arg
choice="plain"><option>save</option><arg><option>-C</option></arg></arg>
<arg choice="opt"><replaceable>filename</replaceable></arg> <arg choice="opt"><replaceable>filename</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis>
<command>shorewall-lite</command>
<arg
choice="opt"><option>trace</option>|<option>debug</option><arg><option>nolock</option></arg></arg>
<arg>-<replaceable>options</replaceable></arg>
<arg choice="plain"><option>savesets</option></arg>
</cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
<command>shorewall-lite</command> <command>shorewall-lite</command>
@@ -352,7 +417,7 @@
<arg>-<replaceable>options</replaceable></arg> <arg>-<replaceable>options</replaceable></arg>
<arg choice="opt"><option>show | list | ls </option></arg> <arg choice="req"><option>show | list | ls </option></arg>
<arg><option>-b</option></arg> <arg><option>-b</option></arg>
@@ -374,7 +439,7 @@
<arg>-<replaceable>options</replaceable></arg> <arg>-<replaceable>options</replaceable></arg>
<arg choice="opt"><option>show | list | ls </option></arg> <arg choice="req"><option>show | list | ls </option></arg>
<arg><option>-x</option></arg> <arg><option>-x</option></arg>
@@ -388,7 +453,7 @@
<arg>-<replaceable>options</replaceable></arg> <arg>-<replaceable>options</replaceable></arg>
<arg choice="opt"><option>show | list | ls </option></arg> <arg choice="req"><option>show | list | ls </option></arg>
<arg><option>-f</option></arg> <arg><option>-f</option></arg>
@@ -402,7 +467,7 @@
<arg>-<replaceable>options</replaceable></arg> <arg>-<replaceable>options</replaceable></arg>
<arg choice="opt"><option>show | list | ls </option></arg> <arg choice="req"><option>show | list | ls </option></arg>
<arg <arg
choice="req"><option>classifiers|connections|config|events|filters|ip|ipa|zones|policies|marks</option></arg> choice="req"><option>classifiers|connections|config|events|filters|ip|ipa|zones|policies|marks</option></arg>
@@ -415,7 +480,7 @@
<arg>-<replaceable>options</replaceable></arg> <arg>-<replaceable>options</replaceable></arg>
<arg choice="opt"><option>show | list | ls </option></arg> <arg choice="req"><option>show | list | ls </option></arg>
<arg choice="plain"><option>event</option><arg <arg choice="plain"><option>event</option><arg
choice="plain"><replaceable>event</replaceable></arg></arg> choice="plain"><replaceable>event</replaceable></arg></arg>
@@ -428,11 +493,11 @@
<arg>-<replaceable>options</replaceable></arg> <arg>-<replaceable>options</replaceable></arg>
<arg choice="opt"><option>show | list | ls </option></arg> <arg choice="req"><option>show | list | ls </option></arg>
<arg><option>-x</option></arg> <arg><option>-c</option></arg>
<arg choice="req"><option>mangle|nat|routing|raw|rawpost</option></arg> <arg choice="plain"><option>routing</option></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
@@ -442,7 +507,21 @@
<arg>-<replaceable>options</replaceable></arg> <arg>-<replaceable>options</replaceable></arg>
<arg choice="opt"><option>show | list | ls </option></arg> <arg choice="req"><option>show | list | ls </option></arg>
<arg><option>-x</option></arg>
<arg choice="req"><option>mangle|nat|raw|rawpost</option></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>shorewall-lite</command>
<arg choice="opt"><option>trace</option>|<option>debug</option></arg>
<arg>-<replaceable>options</replaceable></arg>
<arg choice="req"><option>show | list | ls </option></arg>
<arg choice="plain"><option>tc</option></arg> <arg choice="plain"><option>tc</option></arg>
</cmdsynopsis> </cmdsynopsis>
@@ -454,7 +533,7 @@
<arg>-<replaceable>options</replaceable></arg> <arg>-<replaceable>options</replaceable></arg>
<arg choice="opt"><option>show | list | ls </option></arg> <arg choice="req"><option>show | list | ls </option></arg>
<arg><option>-m</option></arg> <arg><option>-m</option></arg>
@@ -474,6 +553,10 @@
<arg><option>-n</option></arg> <arg><option>-n</option></arg>
<arg><option>-p</option></arg> <arg><option>-p</option></arg>
<arg><option>-f</option></arg>
<arg><option>-C</option></arg>
</cmdsynopsis> </cmdsynopsis>
<cmdsynopsis> <cmdsynopsis>
@@ -526,8 +609,9 @@
<para>The nolock <option>option</option> prevents the command from <para>The nolock <option>option</option> prevents the command from
attempting to acquire the Shorewall-lite lockfile. It is useful if you attempting to acquire the Shorewall-lite lockfile. It is useful if you
need to include <command>shorewall</command> commands in need to include <command>shorewall</command> commands in the
<filename>/etc/shorewall/started</filename>.</para> <filename>started</filename> <ulink
url="../shorewall_extension_scripts.html">extension script</ulink>.</para>
<para>The <emphasis>options</emphasis> control the amount of output that <para>The <emphasis>options</emphasis> control the amount of output that
the command produces. They consist of a sequence of the letters <emphasis the command produces. They consist of a sequence of the letters <emphasis
@@ -538,8 +622,8 @@
role="bold">v</emphasis> adds one to the effective verbosity and each role="bold">v</emphasis> adds one to the effective verbosity and each
<emphasis role="bold">q</emphasis> subtracts one from the effective <emphasis role="bold">q</emphasis> subtracts one from the effective
VERBOSITY. Alternately, <emphasis role="bold">v</emphasis> may be followed VERBOSITY. Alternately, <emphasis role="bold">v</emphasis> may be followed
immediately with one of -1,0,1,2 to specify a specify VERBOSITY. There may immediately with one of -1,0,1,2 to specify VERBOSITY. There may be no
be no white-space between <emphasis role="bold">v</emphasis> and the white-space between <emphasis role="bold">v</emphasis> and the
VERBOSITY.</para> VERBOSITY.</para>
<para>The <emphasis>options</emphasis> may also include the letter <para>The <emphasis>options</emphasis> may also include the letter
@@ -554,7 +638,10 @@
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term><emphasis role="bold">add</emphasis></term> <term><emphasis role="bold">add </emphasis>{
<replaceable>interface</replaceable>[:<replaceable>host-list</replaceable>]...
<replaceable>zone</replaceable> | <replaceable>zone</replaceable>
<replaceable>host-list</replaceable> }</term>
<listitem> <listitem>
<para>Adds a list of hosts or subnets to a dynamic zone usually used <para>Adds a list of hosts or subnets to a dynamic zone usually used
@@ -579,7 +666,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">allow</emphasis></term> <term><emphasis role="bold">allow
</emphasis><replaceable>address</replaceable></term>
<listitem> <listitem>
<para>Re-enables receipt of packets from hosts previously <para>Re-enables receipt of packets from hosts previously
@@ -591,7 +679,25 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">clear</emphasis></term> <term><emphasis role="bold">call <replaceable>function</replaceable> [
<replaceable>parameter</replaceable> ... ]</emphasis></term>
<listitem>
<para>Added in Shorewall 4.6.10. Allows you to call a function in
one of the Shorewall libraries or in your compiled script. function
must name the shell function to be called. The listed parameters are
passed to the function.</para>
<para>The function is first searched for in
<filename>lib.base</filename>, <filename>lib.common</filename> and
<filename>lib.cli</filename>. If it is not found, the call command
is passed to the generated script to be executed.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">clear
</emphasis>[-<option>f</option>]</term>
<listitem> <listitem>
<para>Clear will remove all rules and chains installed by <para>Clear will remove all rules and chains installed by
@@ -608,7 +714,31 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">delete</emphasis></term> <term><emphasis role="bold">close</emphasis> {
<replaceable>open-number</replaceable> |
<replaceable>source</replaceable> <replaceable>dest</replaceable> [
<replaceable>protocol</replaceable> [ <replaceable>port</replaceable>
] ] }</term>
<listitem>
<para>Added in Shorewall 4.5.8. This command closes a temporary open
created by the <command>open</command> command. In the first form,
an <replaceable>open-number</replaceable> specifies the open to be
closed. Open numbers are displayed in the <emphasis
role="bold">num</emphasis> column of the output of the
<command>shorewall-lite show opens </command>command.</para>
<para>When the second form of the command is used, the parameters
must match those given in the earlier <command>open</command>
command.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">delete </emphasis>{
<replaceable>interface</replaceable>[:<replaceable>host-list</replaceable>]...
<replaceable>zone</replaceable> | <replaceable>zone</replaceable>
<replaceable>host-list</replaceable> }</term>
<listitem> <listitem>
<para>The delete command reverses the effect of an earlier <emphasis <para>The delete command reverses the effect of an earlier <emphasis
@@ -623,7 +753,9 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">disable</emphasis></term> <term><emphasis role="bold">disable </emphasis>{
<replaceable>interface</replaceable> |
<replaceable>provider</replaceable> }</term>
<listitem> <listitem>
<para>Added in Shorewall 4.4.26. Disables the optional provider <para>Added in Shorewall 4.4.26. Disables the optional provider
@@ -635,7 +767,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">drop</emphasis></term> <term><emphasis role="bold">drop
</emphasis><replaceable>address</replaceable></term>
<listitem> <listitem>
<para>Causes traffic from the listed <emphasis>address</emphasis>es <para>Causes traffic from the listed <emphasis>address</emphasis>es
@@ -644,7 +777,9 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">dump</emphasis></term> <term><emphasis role="bold">dump </emphasis>[-<option>x</option>]
[-<option>l</option>] [-<option>m</option>]
[-<option>c</option>]</term>
<listitem> <listitem>
<para>Produces a verbose report about the firewall configuration for <para>Produces a verbose report about the firewall configuration for
@@ -658,11 +793,16 @@
<para>The <emphasis role="bold">-l</emphasis> option causes the rule <para>The <emphasis role="bold">-l</emphasis> option causes the rule
number for each Netfilter rule to be displayed.</para> number for each Netfilter rule to be displayed.</para>
<para>The <option>-c</option> option causes the route cache to be
dumped in addition to the other routing information.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">enable</emphasis></term> <term><emphasis role="bold">enable </emphasis>{
<replaceable>interface</replaceable> |
<replaceable>provider</replaceable> }</term>
<listitem> <listitem>
<para>Added in Shorewall 4.4.26. Enables the optional provider <para>Added in Shorewall 4.4.26. Enables the optional provider
@@ -674,7 +814,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">forget</emphasis></term> <term><emphasis role="bold">forget </emphasis>[
<replaceable>filename</replaceable> ]</term>
<listitem> <listitem>
<para>Deletes /var/lib/shorewall-lite/<emphasis>filename</emphasis> <para>Deletes /var/lib/shorewall-lite/<emphasis>filename</emphasis>
@@ -695,7 +836,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">hits</emphasis></term> <term><emphasis role="bold">hits </emphasis>
[-<option>t</option>]</term>
<listitem> <listitem>
<para>Generates several reports from Shorewall-lite log messages in <para>Generates several reports from Shorewall-lite log messages in
@@ -705,7 +847,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">ipcalc</emphasis></term> <term><emphasis role="bold">ipcalc </emphasis>{ address mask |
address/vlsm }</term>
<listitem> <listitem>
<para>Ipcalc displays the network address, broadcast address, <para>Ipcalc displays the network address, broadcast address,
@@ -715,7 +858,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">iprange</emphasis></term> <term><emphasis role="bold">iprange
</emphasis><replaceable>address1</replaceable>-<replaceable>address2</replaceable></term>
<listitem> <listitem>
<para>Iprange decomposes the specified range of IP addresses into <para>Iprange decomposes the specified range of IP addresses into
@@ -724,7 +868,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">iptrace</emphasis></term> <term><emphasis role="bold">iptrace </emphasis><replaceable>iptables
match expression</replaceable></term>
<listitem> <listitem>
<para>This is a low-level debugging command that causes iptables <para>This is a low-level debugging command that causes iptables
@@ -743,7 +888,17 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">logdrop</emphasis></term> <term><emphasis role="bold">list</emphasis></term>
<listitem>
<para><command>list</command> is a synonym for
<command>show</command> -- please see below.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">logdrop
</emphasis><replaceable>address</replaceable></term>
<listitem> <listitem>
<para>Causes traffic from the listed <emphasis>address</emphasis>es <para>Causes traffic from the listed <emphasis>address</emphasis>es
@@ -754,7 +909,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">logwatch</emphasis></term> <term><emphasis role="bold">logwatch </emphasis>[-<option>m</option>]
[<replaceable>refresh-interval</replaceable>]</term>
<listitem> <listitem>
<para>Monitors the log file specified by the LOGFILE option in <para>Monitors the log file specified by the LOGFILE option in
@@ -773,7 +929,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">logreject</emphasis></term> <term><emphasis role="bold">logreject
</emphasis><replaceable>address</replaceable></term>
<listitem> <listitem>
<para>Causes traffic from the listed <emphasis>address</emphasis>es <para>Causes traffic from the listed <emphasis>address</emphasis>es
@@ -784,7 +941,17 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">noiptrace</emphasis></term> <term><emphasis role="bold">ls</emphasis></term>
<listitem>
<para><command>ls</command> is a synonym for <command>show</command>
-- please see below.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">noiptrace </emphasis><replaceable>iptables
match expression</replaceable></term>
<listitem> <listitem>
<para>This is a low-level debugging command that cancels a trace <para>This is a low-level debugging command that cancels a trace
@@ -797,16 +964,83 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">reset</emphasis></term> <term><emphasis role="bold">open</emphasis>
<replaceable>source</replaceable> <replaceable>dest</replaceable> [
<replaceable>protocol</replaceable> [ <replaceable>port</replaceable>
] ]</term>
<listitem> <listitem>
<para>All the packet and byte counters in the firewall are <para>Added in Shorewall 4.6.8. This command requires that the
reset.</para> firewall be in the started state and that DYNAMIC_BLACKLIST=Yes in
<ulink url="/manpages/shorewall.conf.html">shorewall.conf
(5)</ulink>. The effect of the command is to temporarily open the
firewall for connections matching the parameters.</para>
<para>The <replaceable>source</replaceable> and
<replaceable>dest</replaceable> parameters may each be specified as
<emphasis role="bold">all</emphasis> if you don't wish to restrict
the connection source or destination respectively. Otherwise, each
must contain a host or network address or a valid DNS name.</para>
<para>The <replaceable>protocol</replaceable> may be specified
either as a number or as a name listed in /etc/protocols. The
<replaceable>port</replaceable> may be specified numerically or as a
name listed in /etc/services.</para>
<para>To reverse the effect of a successful <command>open</command>
command, use the <command>close</command> command with the same
parameters or simply restart the firewall.</para>
<para>Example: To open the firewall for SSH connections to address
192.168.1.1, the command would be:</para>
<programlisting> shorewall-lite open all 192.168.1.1 tcp 22</programlisting>
<para>To reverse that command, use:</para>
<screen> shorewall-lite close all 192.168.1.1 tcp 22</screen>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">restart</emphasis></term> <term><emphasis role="bold">reenable</emphasis>{
<replaceable>interface</replaceable> |
<replaceable>provider</replaceable> }</term>
<listitem>
<para>Added in Shorewall 4.6.9. This is equivalent to a
<command>disable</command> command followed by an
<command>enable</command> command on the specified
<replaceable>interface</replaceable> or
<replaceable>provider</replaceable>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">reject</emphasis><replaceable>
address</replaceable></term>
<listitem>
<para>Causes traffic from the listed <emphasis>address</emphasis>es
to be silently rejected.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">reset [<replaceable>chain</replaceable>,
...]</emphasis><acronym/></term>
<listitem>
<para>Resets the packet and byte counters in the specified
<replaceable>chain</replaceable>(s). If no
<replaceable>chain</replaceable> is specified, all the packet and
byte counters in the firewall are reset.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">restart </emphasis>[-n] [-p]
[-<option>C</option>]</term>
<listitem> <listitem>
<para>Restart is similar to <emphasis role="bold">shorewall-lite <para>Restart is similar to <emphasis role="bold">shorewall-lite
@@ -819,11 +1053,19 @@
<para>The <option>-p</option> option causes the connection tracking <para>The <option>-p</option> option causes the connection tracking
table to be flushed; the <command>conntrack</command> utility must table to be flushed; the <command>conntrack</command> utility must
be installed to use this option.</para> be installed to use this option.</para>
<para>The <option>-C</option> option was added in Shorewall 4.6.5.
If the specified (or implicit) firewall script is the one that
generated the current running configuration, then the running
netfilter configuration will be reloaded as is so as to preserve the
iptables packet and byte counters.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">restore</emphasis></term> <term><emphasis role="bold">restore </emphasis>[-<option>n</option>]
[-<option>p</option>] [-<option>C</option>] [
<replaceable>filename</replaceable> ]</term>
<listitem> <listitem>
<para>Restore Shorewall-lite to a state saved using the <emphasis <para>Restore Shorewall-lite to a state saved using the <emphasis
@@ -834,11 +1076,34 @@
<emphasis>filename</emphasis> is given then Shorewall-lite will be <emphasis>filename</emphasis> is given then Shorewall-lite will be
restored from the file specified by the RESTOREFILE option in <ulink restored from the file specified by the RESTOREFILE option in <ulink
url="shorewall.conf.html">shorewall.conf</ulink>(5).</para> url="shorewall.conf.html">shorewall.conf</ulink>(5).</para>
<caution>
<para>If your iptables ruleset depends on variables that are
detected at run-time, either in your params file or by
Shorewall-generated code, <command>restore</command> will use the
values that were current when the ruleset was saved, which may be
different from the current values.</para>
</caution>
<para>The <option>-n</option> option causes Shorewall to avoid
updating the routing table(s).</para>
<para>The <option>-p</option> option, added in Shorewall 4.6.5,
causes the connection tracking table to be flushed; the
<command>conntrack</command> utility must be installed to use this
option.</para>
<para>The <option>-C</option> option was added in Shorewall 4.6.5.
If the <option>-C</option> option was specified during <emphasis
role="bold">shorewall save</emphasis>, then the counters saved by
that operation will be restored.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">run</emphasis></term> <term><emphasis role="bold">run
</emphasis><replaceable>command</replaceable> [
<replaceable>parameter</replaceable> ... ]</term>
<listitem> <listitem>
<para>Added in Shorewall 4.6.3. Executes <para>Added in Shorewall 4.6.3. Executes
@@ -855,7 +1120,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">save</emphasis></term> <term><emphasis role="bold">save </emphasis>[-<option>C</option>] [
<replaceable>filename</replaceable> ]</term>
<listitem> <listitem>
<para>The dynamic blacklist is stored in <para>The dynamic blacklist is stored in
@@ -865,6 +1131,24 @@
<emphasis>filename</emphasis> is not given then the state is saved <emphasis>filename</emphasis> is not given then the state is saved
in the file specified by the RESTOREFILE option in <ulink in the file specified by the RESTOREFILE option in <ulink
url="shorewall.conf.html">shorewall.conf</ulink>(5).</para> url="shorewall.conf.html">shorewall.conf</ulink>(5).</para>
<para>The <option>-C</option> option, added in Shorewall 4.6.5,
causes the iptables packet and byte counters to be saved along with
the chains and rules.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">savesets</emphasis></term>
<listitem>
<para>Added in shorewall 4.6.8. Performs the same action as the
<command>stop</command> command with respect to saving ipsets (see
the SAVE_IPSETS option in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf</ulink> (5)).
This command may be used to proactively save your ipset contents in
the event that a system failure occurs prior to issuing a
<command>stop</command> command.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -877,7 +1161,8 @@
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term><emphasis role="bold">bl|blacklists</emphasis></term> <term><emphasis role="bold">bl|blacklists
</emphasis>[-<option>x</option>]</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
@@ -890,7 +1175,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">capabilities</emphasis></term> <term>[-<option>f</option>] <emphasis
role="bold">capabilities</emphasis></term>
<listitem> <listitem>
<para>Displays your kernel/iptables capabilities. The <para>Displays your kernel/iptables capabilities. The
@@ -901,8 +1187,10 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>[ [ <option>chain</option> ] <emphasis>chain</emphasis>... <term>[-<option>b</option>] [-<option>x</option>]
]</term> [-<option>l</option>] [-<option>t</option>
{<option>filter</option>|<option>mangle</option>|<option>nat</option>|<option>raw</option>|<option>rawpost</option>}]
[ <emphasis>chain</emphasis>... ]</term>
<listitem> <listitem>
<para>The rules in each <emphasis>chain</emphasis> are <para>The rules in each <emphasis>chain</emphasis> are
@@ -955,11 +1243,19 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">connections</emphasis></term> <term><emphasis role="bold">connections
[<replaceable>filter_parameter</replaceable>
...]</emphasis></term>
<listitem> <listitem>
<para>Displays the IP connections currently being tracked by <para>Displays the IP connections currently being tracked by
the firewall.</para> the firewall.</para>
<para>If the <command>conntrack</command> utility is
installed, beginning with Shorewall 4.6.11 the set of
connections displayed can be limited by including conntrack
filter parameters (-p , -s, --dport, etc). See conntrack(8)
for details.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -1001,7 +1297,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">log</emphasis></term> <term>[-<option>m</option>] <emphasis
role="bold">log</emphasis></term>
<listitem> <listitem>
<para>Displays the last 20 Shorewall-lite messages from the <para>Displays the last 20 Shorewall-lite messages from the
@@ -1013,6 +1310,20 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>[-<option>x</option>] <emphasis
role="bold">mangle</emphasis></term>
<listitem>
<para>Displays the Netfilter mangle table using the command
<emphasis role="bold">iptables -t mangle -L -n -v</emphasis>.
The <emphasis role="bold">-x</emphasis> option is passed
directly through to iptables and causes actual packet and byte
counts to be displayed. Without this option, those counts are
abbreviated.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">marks</emphasis></term> <term><emphasis role="bold">marks</emphasis></term>
@@ -1036,6 +1347,16 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis role="bold">opens</emphasis></term>
<listitem>
<para>Added in Shorewall 4.5.8. Displays the iptables rules in
the 'dynamic' chain created through use of the <command>open
</command>command..</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">policies</emphasis></term> <term><emphasis role="bold">policies</emphasis></term>
@@ -1052,7 +1373,9 @@
<term><emphasis role="bold">routing</emphasis></term> <term><emphasis role="bold">routing</emphasis></term>
<listitem> <listitem>
<para>Displays the system's IPv4 routing configuration.</para> <para>Displays the system's IPv4 routing configuration. The -c
option causes the route cache to be displayed in addition to
the other routing information.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -1091,7 +1414,9 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">start</emphasis></term> <term><emphasis role="bold">start</emphasis> [-<option>p</option>]
[-<option>n</option>] [<option>-f</option>]
[-<option>C</option>]</term>
<listitem> <listitem>
<para>Start Shorewall Lite. Existing connections through <para>Start Shorewall Lite. Existing connections through
@@ -1102,6 +1427,22 @@
<para>The <option>-p</option> option causes the connection tracking <para>The <option>-p</option> option causes the connection tracking
table to be flushed; the <command>conntrack</command> utility must table to be flushed; the <command>conntrack</command> utility must
be installed to use this option.</para> be installed to use this option.</para>
<para>The <option>-n</option> option prevents the firewall script
from modifying the current routing configuration.</para>
<para>The <option>-f</option> option was added in Shorewall 4.6.5.
If the RESTOREFILE named in <ulink
url="shorewall.conf.html">shorewall.conf</ulink>(5) exists, is
executable and is not older than the current filewall script, then
that saved configuration is restored.</para>
<para>The <option>-C</option> option was added in Shorewall 4.6.5
and is only meaningful when the <option>-f</option> option is also
specified. If the previously-saved configuration is restored, and if
the <option>-C</option> option was also specified in the <emphasis
role="bold">save</emphasis> command, then the packet and byte
counters will be restored.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@@ -38,7 +38,7 @@
# #
# IPTABLES - iptables # IPTABLES - iptables
# MODULESDIR - /lib/modules/$(uname -r)/kernel/net/ipv4/netfilter # MODULESDIR - /lib/modules/$(uname -r)/kernel/net/ipv4/netfilter
# MODULE_SUFFIX - "o gz ko o.gz ko.gz" # MODULE_SUFFIX - "o gz xz ko o.gz o.xz ko.gz ko.xz"
# #
# Shorewall need not be installed on the target system to run shorecap. If the '-e' flag is # Shorewall need not be installed on the target system to run shorecap. If the '-e' flag is
# used during firewall compilation, then the generated firewall program will likewise not # used during firewall compilation, then the generated firewall program will likewise not

View File

@@ -1,20 +1,21 @@
# #
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.4 # The Shoreline Firewall (Shorewall) Packet Filtering Firewall
# #
# Copyright 2011 Jonathan Underwood (jonathan.underwood@gmail.com) # Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
# #
[Unit] [Unit]
Description=Shorewall IPv4 firewall (lite) Description=Shorewall IPv4 firewall (lite)
After=syslog.target Wants=network-online.target
After=network.target After=network-online.target
Conflicts=iptables.service firewalld.service
[Service] [Service]
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
EnvironmentFile=-/etc/sysconfig/shorewall-lite EnvironmentFile=-/etc/sysconfig/shorewall-lite
StandardOutput=syslog StandardOutput=syslog
ExecStart=/sbin/shorewall-lite $OPTIONS start ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS
ExecStop=/sbin/shorewall-lite $OPTIONS stop ExecStop=/sbin/shorewall-lite $OPTIONS stop
[Install] [Install]
WantedBy=multi-user.target WantedBy=basic.target

View File

@@ -0,0 +1,21 @@
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
#
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
#
[Unit]
Description=Shorewall IPv4 firewall (lite)
Wants=network-online.target
After=network-online.target
Conflicts=iptables.service firewalld.service
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=-/etc/sysconfig/shorewall-lite
StandardOutput=syslog
ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS
ExecStop=/sbin/shorewall-lite $OPTIONS stop
[Install]
WantedBy=basic.target

View File

@@ -0,0 +1,22 @@
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
#
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
# Copyright 2015 Tom Eastep <teastep@shorewall.net>
#
[Unit]
Description=Shorewall IPv4 firewall (lite)
Wants=network-online.target
After=network-online.target
Conflicts=iptables.service firewalld.service
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=-/etc/default/shorewall-lite
StandardOutput=syslog
ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS
ExecStop=/sbin/shorewall-lite $OPTIONS stop
[Install]
WantedBy=basic.target

View File

@@ -27,14 +27,25 @@
# shown below. Simply run this script to remove Shorewall Firewall # shown below. Simply run this script to remove Shorewall Firewall
VERSION=xxx #The Build script inserts the actual version VERSION=xxx #The Build script inserts the actual version
PRODUCT=shorewall-lite
usage() # $1 = exit status usage() # $1 = exit status
{ {
ME=$(basename $0) ME=$(basename $0)
echo "usage: $ME [ <shorewallrc file> ]" echo "usage: $ME [ <option> ] [ <shorewallrc file> ]"
echo "where <option> is one of"
echo " -h"
echo " -v"
echo " -n"
exit $1 exit $1
} }
fatal_error()
{
echo " ERROR: $@" >&2
exit 1
}
qt() qt()
{ {
"$@" >/dev/null 2>&1 "$@" >/dev/null 2>&1
@@ -69,6 +80,42 @@ remove_file() # $1 = file to restore
fi fi
} }
finished=0
configure=1
while [ $finished -eq 0 ]; do
option=$1
case "$option" in
-*)
option=${option#-}
while [ -n "$option" ]; do
case $option in
h)
usage 0
;;
v)
echo "$Product Firewall Installer Version $VERSION"
exit 0
;;
n*)
configure=0
option=${option#n}
;;
*)
usage 1
;;
esac
done
shift
;;
*)
finished=1
;;
esac
done
# #
# Read the RC file # Read the RC file
# #
@@ -112,39 +159,60 @@ fi
echo "Uninstalling Shorewall Lite $VERSION" echo "Uninstalling Shorewall Lite $VERSION"
if qt iptables -L shorewall -n && [ ! -f ${SBINDIR}/shorewall ]; then [ -n "$SANDBOX" ] && configure=0
shorewall-lite clear
if [ $configure -eq 1 ]; then
if qt iptables -L shorewall -n && [ ! -f ${SBINDIR}/shorewall ]; then
shorewall-lite clear
fi
fi fi
if [ -L ${SHAREDIR}/shorewall-lite/init ]; then if [ -L ${SHAREDIR}/shorewall-lite/init ]; then
FIREWALL=$(readlink -m -q ${SHAREDIR}/shorewall-lite/init) if [ $HOST = openwrt ]; then
if [ $configure -eq 1 ] && /etc/init.d/shorewall-lite enabled; then
/etc/init.d/shorewall-lite disable
fi
FIREWALL=$(readlink ${SHAREDIR}/shorewall-lite/init)
else
FIREWALL=$(readlink -m -q ${SHAREDIR}/shorewall-lite/init)
fi
elif [ -n "$INITFILE" ]; then elif [ -n "$INITFILE" ]; then
FIREWALL=${INITDIR}/${INITFILE} FIREWALL=${INITDIR}/${INITFILE}
fi fi
if [ -f "$FIREWALL" ]; then if [ -f "$FIREWALL" ]; then
if mywhich updaterc.d ; then if [ $configure -eq 1 ]; then
updaterc.d shorewall-lite remove if mywhich updaterc.d ; then
elif mywhich insserv ; then updaterc.d shorewall-lite remove
insserv -r $FIREWALL elif mywhich insserv ; then
elif [ mywhich chkconfig ; then insserv -r $FIREWALL
chkconfig --del $(basename $FIREWALL) elif mywhich chkconfig ; then
elif mywhich systemctl ; then chkconfig --del $(basename $FIREWALL)
systemctl disable shorewall-lite fi
fi fi
remove_file $FIREWALL remove_file $FIREWALL
fi fi
[ -z "$SERVICEDIR" ] && SERVICEDIR="$SYSTEMD"
if [ -n "$SERVICEDIR" ]; then
[ $configure -eq 1 ] && systemctl disable ${PRODUCT}
rm -f $SERVICEDIR/shorewall-lite.service
fi
rm -f ${SBINDIR}/shorewall-lite rm -f ${SBINDIR}/shorewall-lite
rm -rf ${SBINDIR}/shorewall-lite rm -rf ${CONFDIR}/shorewall-lite
rm -rf ${VARDIR}/shorewall-lite rm -rf ${VARDIR}/shorewall-lite
rm -rf ${SHAREDIR}/shorewall-lite rm -rf ${SHAREDIR}/shorewall-lite
rm -rf ${LIBEXEC}/shorewall-lite rm -rf ${LIBEXECDIR}/shorewall-lite
rm -f ${CONFDIR}/logrotate.d/shorewall-lite rm -f ${CONFDIR}/logrotate.d/shorewall-lite
[ -n "$SYSTEMD" ] && rm -f ${SYSTEMD}/shorewall-lite.service rm -f ${SYSCONFDIR}/shorewall-lite
rm -f ${MANDIR}/man5/shorewall-lite*
rm -f ${MANDIR}/man8/shorewall-lite*
echo "Shorewall Lite Uninstalled" echo "Shorewall Lite Uninstalled"

View File

@@ -7,10 +7,12 @@
# #
# You can comment out the ports you do not want open # You can comment out the ports you do not want open
# #
# #
############################################################################### ###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/ ?FORMAT 2
# PORT(S) PORT(S) LIMIT GROUP ###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
# PORT(S) PORT(S) DEST LIMIT GROUP
PARAM - - tcp 389 #LDAP services PARAM - - tcp 389 #LDAP services
PARAM - - udp 389 PARAM - - udp 389
PARAM - - tcp 636 #LDAP SSL PARAM - - tcp 636 #LDAP SSL

View File

@@ -0,0 +1,14 @@
#
# Shorewall version 4 - Citrix/Goto Meeting macro
#
# /usr/share/shorewall/macro.Goto-Meeting
# by Eric Teeter
# This macro handles Citrix/Goto Meeting
# Assumes that ports 80 and 443 are already open
# If needed, use the macros that open Http and Https to reduce redundancy
####################################################################################
?FORMAT 2
####################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
# PORT(S) PORT(S) DEST LIMIT GROUP
PARAM - - tcp 8200 # Goto Meeting only needed (TCP outbound)

View File

@@ -0,0 +1,13 @@
#
# Shorewall version 4 - Jabber Macro
#
# /usr/share/shorewall/macro.Jabber
#
# This macro accepts Jabber traffic.
#
###############################################################################
?FORMAT 2
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
# PORT(S) PORT(S) DEST LIMIT GROUP
PARAM - - tcp 5222

View File

@@ -1,13 +1,14 @@
# #
# Shorewall version 3.4 - JabberPlain Macro # Shorewall version 4 - JabberPlain Macro
# #
# /usr/share/shorewall/macro.JabberPlain # /usr/share/shorewall/macro.JabberPlain
# #
# This macro accepts Jabber traffic (plaintext). # This macro accepts Jabber traffic (plaintext). This macro is
# deprecated - use of macro.Jabber instead is recommended.
# #
############################################################################### ###############################################################################
?FORMAT 2 ?FORMAT 2
############################################################################### ###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/ #ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
# PORT(S) PORT(S) DEST LIMIT GROUP # PORT(S) PORT(S) DEST LIMIT GROUP
PARAM - - tcp 5222 Jabber

View File

@@ -1,9 +1,11 @@
# #
# Shorewall version 3.4 - JabberSecure (ssl) Macro # Shorewall version 4 - JabberSecure (SSL) Macro
# #
# /usr/share/shorewall/macro.JabberSecure # /usr/share/shorewall/macro.JabberSecure
# #
# This macro accepts Jabber traffic (ssl). # This macro accepts Jabber traffic (SSL). Use of Jabber with SSL
# is deprecated, please configure Jabber with STARTTLS and use
# Jabber macro instead.
# #
############################################################################### ###############################################################################
?FORMAT 2 ?FORMAT 2

View File

@@ -0,0 +1,13 @@
#
# Shorewall version 4 - QUIC Macro
#
# /usr/share/shorewall/macro.QUIC
#
# This macro handles QUIC (Quick UDP Internet Connections).
#
###############################################################################
?FORMAT 2
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
# PORT(S) PORT(S) DEST LIMIT GROUP
PARAM - - udp 80,443

View File

@@ -0,0 +1,12 @@
#
# Shorewall version 4 - tinc Macro
#
# /usr/share/shorewall/macro.Tinc Macro
#
# This macro handles tinc traffic.
#
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE RATE USER/
# PORT(S) PORT(S) LIMIT GROUP
PARAM - - udp 655
PARAM - - tcp 655

View File

@@ -0,0 +1,15 @@
#
# Shorewall version 4 - Zabbix Macro
#
# /usr/share/shorewall/macro.Zabbix
#
# This macro handles Zabbix monitoring software server traffic to agent
# and trap traffic from agent to zabbix server.
#
###############################################################################
?FORMAT 2
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE ORIGIN RATE USER/
# PORT(S) PORT(S) DEST LIMIT GROUP
PARAM - - tcp 10050 # zabbix_agent
PARAM DEST SOURCE tcp 10051 # zabbix_trap

View File

@@ -34,6 +34,7 @@ use strict;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT = ( qw( process_arprules create_arptables_load preview_arptables_load ) ); our @EXPORT = ( qw( process_arprules create_arptables_load preview_arptables_load ) );
our $VERSION = 'MODULEVERSION';
our %arp_table; our %arp_table;
our $arp_input; our $arp_input;

View File

@@ -155,8 +155,6 @@ sub process_accounting_rule1( $$$$$$$$$$$ ) {
my ($action, $chain, $source, $dest, $proto, $ports, $sports, $user, $mark, $ipsec, $headers ) = @_; my ($action, $chain, $source, $dest, $proto, $ports, $sports, $user, $mark, $ipsec, $headers ) = @_;
$acctable = $config{ACCOUNTING_TABLE};
$jumpchainref = 0; $jumpchainref = 0;
$asection = LEGACY if $asection < 0; $asection = LEGACY if $asection < 0;
@@ -453,6 +451,8 @@ sub setup_accounting() {
set_section_function( &process_section ); set_section_function( &process_section );
$acctable = $config{ACCOUNTING_TABLE};
first_entry "$doing $fn..."; first_entry "$doing $fn...";
my $nonEmpty = 0; my $nonEmpty = 0;
@@ -521,9 +521,9 @@ sub setup_accounting() {
while ( $chainswithjumps && $progress ) { while ( $chainswithjumps && $progress ) {
$progress = 0; $progress = 0;
for my $chain1 ( keys %accountingjumps ) { for my $chain1 ( sort keys %accountingjumps ) {
if ( keys %{$accountingjumps{$chain1}} ) { if ( keys %{$accountingjumps{$chain1}} ) {
for my $chain2 ( keys %{$accountingjumps{$chain1}} ) { for my $chain2 ( sort keys %{$accountingjumps{$chain1}} ) {
delete $accountingjumps{$chain1}{$chain2}, $progress = 1 unless $accountingjumps{$chain2}; delete $accountingjumps{$chain1}{$chain2}, $progress = 1 unless $accountingjumps{$chain2};
} }
} else { } else {

View File

@@ -30,7 +30,7 @@ package Shorewall::Chains;
require Exporter; require Exporter;
use Scalar::Util 'reftype'; use Scalar::Util 'reftype';
use Digest::SHA qw(sha1); use Digest::SHA qw(sha1_hex);
use File::Basename; use File::Basename;
use Shorewall::Config qw(:DEFAULT :internal); use Shorewall::Config qw(:DEFAULT :internal);
use Shorewall::Zones; use Shorewall::Zones;
@@ -73,6 +73,7 @@ our @EXPORT = ( qw(
allow_optimize allow_optimize
allow_delete allow_delete
allow_move allow_move
make_terminating
set_optflags set_optflags
reset_optflags reset_optflags
has_return has_return
@@ -104,12 +105,12 @@ our @EXPORT = ( qw(
AUDIT AUDIT
HELPER HELPER
INLINE INLINE
TERMINATING
STATEMATCH STATEMATCH
USERBUILTIN USERBUILTIN
INLINERULE INLINERULE
OPTIONS OPTIONS
IPTABLES IPTABLES
TARPIT
FILTER_TABLE FILTER_TABLE
NAT_TABLE NAT_TABLE
MANGLE_TABLE MANGLE_TABLE
@@ -259,9 +260,11 @@ our %EXPORT_TAGS = (
get_interface_gateway get_interface_gateway
get_interface_mac get_interface_mac
have_global_variables have_global_variables
have_address_variables
set_global_variables set_global_variables
save_dynamic_chains save_dynamic_chains
load_ipsets load_ipsets
create_save_ipsets
validate_nfobject validate_nfobject
create_nfobjects create_nfobjects
create_netfilter_load create_netfilter_load
@@ -277,7 +280,7 @@ our %EXPORT_TAGS = (
Exporter::export_ok_tags('internal'); Exporter::export_ok_tags('internal');
our $VERSION = '4.5_18'; our $VERSION = 'MODULEVERSION';
# #
# Chain Table # Chain Table
@@ -315,7 +318,7 @@ our $VERSION = '4.5_18';
# restriction => Restrictions on further rules in this chain. # restriction => Restrictions on further rules in this chain.
# audit => Audit the result. # audit => Audit the result.
# filtered => Number of filter rules at the front of an interface forward chain # filtered => Number of filter rules at the front of an interface forward chain
# digest => string representation of the chain's rules for use in optimization # digest => SHA1 digest of the string representation of the chain's rules for use in optimization
# level 8. # level 8.
# complete => The last rule in the chain is a -g or a simple -j to a terminating target # complete => The last rule in the chain is a -g or a simple -j to a terminating target
# Suppresses adding additional rules to the chain end of the chain # Suppresses adding additional rules to the chain end of the chain
@@ -425,6 +428,7 @@ use constant { STANDARD => 0x1, #defined by Netfilter
INLINERULE => 0x40000, #INLINE INLINERULE => 0x40000, #INLINE
OPTIONS => 0x80000, #Target Accepts Options OPTIONS => 0x80000, #Target Accepts Options
IPTABLES => 0x100000, #IPTABLES or IP6TABLES IPTABLES => 0x100000, #IPTABLES or IP6TABLES
TARPIT => 0x200000, #TARPIT
FILTER_TABLE => 0x1000000, FILTER_TABLE => 0x1000000,
MANGLE_TABLE => 0x2000000, MANGLE_TABLE => 0x2000000,
@@ -646,6 +650,7 @@ our %opttype = ( rule => CONTROL,
simple => CONTROL, simple => CONTROL,
matches => CONTROL, matches => CONTROL,
complex => CONTROL, complex => CONTROL,
t => CONTROL,
i => UNIQUE, i => UNIQUE,
s => UNIQUE, s => UNIQUE,
@@ -760,7 +765,6 @@ sub initialize( $$$ ) {
RETURN => 1, RETURN => 1,
QUEUE => 1, QUEUE => 1,
CLASSIFY => 1, CLASSIFY => 1,
CT => 1,
DNAT => 1, DNAT => 1,
MASQUERADE => 1, MASQUERADE => 1,
NETMAP => 1, NETMAP => 1,
@@ -793,6 +797,13 @@ sub decr_cmd_level( $ ) {
assert( --$_[0]->{cmdlevel} >= 0, $_[0] ); assert( --$_[0]->{cmdlevel} >= 0, $_[0] );
} }
#
# Mark an action as terminating
#
sub make_terminating( $ ) {
$terminating{$_[0]} = 1;
}
# #
# Transform the passed iptables rule into an internal-form hash reference. # Transform the passed iptables rule into an internal-form hash reference.
# Most of the compiler has been converted to use the new form natively. # Most of the compiler has been converted to use the new form natively.
@@ -881,6 +892,8 @@ sub set_rule_option( $$$ ) {
} }
} elsif ( $opttype == EXCLUSIVE ) { } elsif ( $opttype == EXCLUSIVE ) {
$ruleref->{$option} .= ",$value"; $ruleref->{$option} .= ",$value";
} elsif ( $opttype == CONTROL ) {
$ruleref->{$option} = $value;
} elsif ( $opttype == UNIQUE ) { } elsif ( $opttype == UNIQUE ) {
# #
# Shorewall::Rules::perl_action_tcp_helper() can produce rules that have two -p specifications. # Shorewall::Rules::perl_action_tcp_helper() can produce rules that have two -p specifications.
@@ -915,7 +928,7 @@ sub transform_rule( $;\$ ) {
my $option; my $option;
my $invert = ''; my $invert = '';
if ( $input =~ s/^(!\s+)?-([psdjgiom])\s+// ) { if ( $input =~ s/^(!\s+)?-([psdjgiomt])\s+// ) {
# #
# Normal case of single-character # Normal case of single-character
$invert = '!' if $1; $invert = '!' if $1;
@@ -945,7 +958,7 @@ sub transform_rule( $;\$ ) {
PARAM: PARAM:
{ {
while ( $input ne '' && $input !~ /^(?:!|-[psdjgiom])\s/ ) { while ( $input ne '' && $input !~ /^(?:!|-[psdjgiomt])\s/ ) {
last PARAM if $input =~ /^--([^\s]+)/ && $aliases{$1 || '' }; last PARAM if $input =~ /^--([^\s]+)/ && $aliases{$1 || '' };
$input =~ s/^([^\s]+)\s*//; $input =~ s/^([^\s]+)\s*//;
my $token = $1; my $token = $1;
@@ -1149,7 +1162,7 @@ sub merge_rules( $$$ ) {
} }
} }
for my $option ( grep ! $opttype{$_} || $_ eq 'nfacct' || $_ eq 'recent', keys %$fromref ) { for my $option ( grep ! $opttype{$_} || $_ eq 'nfacct' || $_ eq 'recent', sort { $b cmp $a } keys %$fromref ) {
set_rule_option( $toref, $option, $fromref->{$option} ); set_rule_option( $toref, $option, $fromref->{$option} );
} }
@@ -1165,7 +1178,7 @@ sub merge_rules( $$$ ) {
set_rule_option( $toref, 'policy', $fromref->{policy} ) if exists $fromref->{policy}; set_rule_option( $toref, 'policy', $fromref->{policy} ) if exists $fromref->{policy};
for my $option ( grep( get_opttype( $_, 0 ) == EXPENSIVE, keys %$fromref ) ) { for my $option ( grep( get_opttype( $_, 0 ) == EXPENSIVE, sort keys %$fromref ) ) {
set_rule_option( $toref, $option, $fromref->{$option} ); set_rule_option( $toref, $option, $fromref->{$option} );
} }
@@ -1654,7 +1667,8 @@ sub insert_rule($$$) {
sub insert_irule( $$$$;@ ) { sub insert_irule( $$$$;@ ) {
my ( $chainref, $jump, $target, $number, @matches ) = @_; my ( $chainref, $jump, $target, $number, @matches ) = @_;
my $ruleref = {}; my $rulesref = $chainref->{rules};
my $ruleref = {};
$ruleref->{mode} = ( $ruleref->{cmdlevel} = $chainref->{cmdlevel} ) ? CMD_MODE : CAT_MODE; $ruleref->{mode} = ( $ruleref->{cmdlevel} = $chainref->{cmdlevel} ) ? CMD_MODE : CAT_MODE;
@@ -1673,7 +1687,15 @@ sub insert_irule( $$$$;@ ) {
$ruleref->{comment} = shortlineinfo( $chainref->{origin} ) || $ruleref->{comment} || $comment; $ruleref->{comment} = shortlineinfo( $chainref->{origin} ) || $ruleref->{comment} || $comment;
splice( @{$chainref->{rules}}, $number, 0, $ruleref ); if ( $number >= @$rulesref ) {
#
# Avoid failure in spice if we insert beyond the end of the chain
#
$number = @$rulesref;
push @$rulesref, $ruleref;
} else {
splice( @$rulesref, $number, 0, $ruleref );
}
trace( $chainref, 'I', ++$number, format_rule( $chainref, $ruleref ) ) if $debug; trace( $chainref, 'I', ++$number, format_rule( $chainref, $ruleref ) ) if $debug;
@@ -1967,6 +1989,10 @@ sub zone_forward_chain($) {
# #
sub use_forward_chain($$) { sub use_forward_chain($$) {
my ( $interface, $chainref ) = @_; my ( $interface, $chainref ) = @_;
my @loopback_zones = loopback_zones;
return 0 if $interface eq loopback_interface && ! @loopback_zones;
my $interfaceref = find_interface($interface); my $interfaceref = find_interface($interface);
my $nets = $interfaceref->{nets}; my $nets = $interfaceref->{nets};
@@ -2841,6 +2867,7 @@ sub initialize_chain_table($) {
'HELPER' => STANDARD + HELPER + NATONLY, #Actually RAWONLY 'HELPER' => STANDARD + HELPER + NATONLY, #Actually RAWONLY
'INLINE' => INLINERULE, 'INLINE' => INLINERULE,
'IPTABLES' => IPTABLES, 'IPTABLES' => IPTABLES,
'TARPIT' => STANDARD + TARPIT + OPTIONS,
); );
for my $chain ( qw(OUTPUT PREROUTING) ) { for my $chain ( qw(OUTPUT PREROUTING) ) {
@@ -2906,6 +2933,7 @@ sub initialize_chain_table($) {
'HELPER' => STANDARD + HELPER + NATONLY, #Actually RAWONLY 'HELPER' => STANDARD + HELPER + NATONLY, #Actually RAWONLY
'INLINE' => INLINERULE, 'INLINE' => INLINERULE,
'IP6TABLES' => IPTABLES, 'IP6TABLES' => IPTABLES,
'TARPIT' => STANDARD + TARPIT + OPTIONS,
); );
for my $chain ( qw(OUTPUT PREROUTING) ) { for my $chain ( qw(OUTPUT PREROUTING) ) {
@@ -3037,7 +3065,7 @@ sub calculate_digest( $ ) {
} }
} }
$chainref->{digest} = sha1 $digest; $chainref->{digest} = sha1_hex $digest;
} }
# #
@@ -3228,7 +3256,7 @@ sub optimize_level4( $$ ) {
$progress = 0; $progress = 0;
$passes++; $passes++;
my @chains = grep $_->{referenced}, values %$tableref; my @chains = grep $_->{referenced}, sort { $a->{name} cmp $b->{name} } values %$tableref;
my $chains = @chains; my $chains = @chains;
progress_message "\n Table $table pass $passes, $chains referenced chains, level 4a..."; progress_message "\n Table $table pass $passes, $chains referenced chains, level 4a...";
@@ -3549,7 +3577,7 @@ sub optimize_level8( $$$ ) {
} }
if ( $progress ) { if ( $progress ) {
my @rename = keys %rename; my @rename = sort keys %rename;
# #
# First create aliases for each renamed chain and change the {name} member. # First create aliases for each renamed chain and change the {name} member.
# #
@@ -4420,6 +4448,7 @@ sub do_proto( $$$;$ )
if ( $ports =~ /^\+/ ) { if ( $ports =~ /^\+/ ) {
$output .= $invert; $output .= $invert;
$output .= '-m set ';
$output .= get_set_flags( $ports, 'dst' ); $output .= get_set_flags( $ports, 'dst' );
} else { } else {
$sports = '', require_capability( 'MULTIPORT', "'=' in the SOURCE PORT(S) column", 's' ) if ( $srcndst = $sports eq '=' ); $sports = '', require_capability( 'MULTIPORT', "'=' in the SOURCE PORT(S) column", 's' ) if ( $srcndst = $sports eq '=' );
@@ -4459,7 +4488,8 @@ sub do_proto( $$$;$ )
if ( $ports =~ /^\+/ ) { if ( $ports =~ /^\+/ ) {
$output .= $invert; $output .= $invert;
$output .= get_set_flags( $ports, 'dst' ); $output .= '-m set ';
$output .= get_set_flags( $ports, 'src' );
} elsif ( $multiport ) { } elsif ( $multiport ) {
if ( port_count( $sports ) > 15 ) { if ( port_count( $sports ) > 15 ) {
if ( $restricted ) { if ( $restricted ) {
@@ -4624,30 +4654,35 @@ sub do_iproto( $$$ )
if ( $ports ne '' ) { if ( $ports ne '' ) {
$invert = $ports =~ s/^!// ? '! ' : ''; $invert = $ports =~ s/^!// ? '! ' : '';
$sports = '', require_capability( 'MULTIPORT', "'=' in the SOURCE PORT(S) column", 's' ) if ( $srcndst = $sports eq '=' );
if ( $multiport || $ports =~ tr/,/,/ > 0 || $sports =~ tr/,/,/ > 0 ) { if ( $ports =~ /^\+/ ) {
fatal_error "Port lists require Multiport support in your kernel/iptables" unless have_capability( 'MULTIPORT' , 1 ); push @output , set => ${invert} . get_set_flags( $ports, 'dst' );
} else {
$sports = '', require_capability( 'MULTIPORT', "'=' in the SOURCE PORT(S) column", 's' ) if ( $srcndst = $sports eq '=' );
if ( port_count ( $ports ) > 15 ) { if ( $multiport || $ports =~ tr/,/,/ > 0 || $sports =~ tr/,/,/ > 0 ) {
if ( $restricted ) { fatal_error "Port lists require Multiport support in your kernel/iptables" unless have_capability( 'MULTIPORT' , 1 );
fatal_error "A port list in this file may only have up to 15 ports";
} elsif ( $invert ) { if ( port_count ( $ports ) > 15 ) {
fatal_error "An inverted port list may only have up to 15 ports"; if ( $restricted ) {
fatal_error "A port list in this file may only have up to 15 ports";
} elsif ( $invert ) {
fatal_error "An inverted port list may only have up to 15 ports";
}
} }
}
$ports = validate_port_list $pname , $ports; $ports = validate_port_list $pname , $ports;
push @output, multiport => ( $srcndst ? "${invert}--ports ${ports} " : "${invert}--dports ${ports} " ); push @output, multiport => ( $srcndst ? "${invert}--ports ${ports} " : "${invert}--dports ${ports} " );
$multiport = 1; $multiport = 1;
} else { } else {
fatal_error "Missing DEST PORT" unless supplied $ports; fatal_error "Missing DEST PORT" unless supplied $ports;
$ports = validate_portpair $pname , $ports; $ports = validate_portpair $pname , $ports;
if ( $srcndst ) { if ( $srcndst ) {
push @output, multiport => "${invert}--ports ${ports}"; push @output, multiport => "${invert}--ports ${ports}";
} else { } else {
push @output, dport => "${invert}${ports}"; push @output, dport => "${invert}${ports}";
}
} }
} }
} else { } else {
@@ -4657,8 +4692,10 @@ sub do_iproto( $$$ )
if ( $sports ne '' ) { if ( $sports ne '' ) {
fatal_error "'=' in the SOURCE PORT(S) column requires one or more ports in the DEST PORT(S) column" if $sports eq '='; fatal_error "'=' in the SOURCE PORT(S) column requires one or more ports in the DEST PORT(S) column" if $sports eq '=';
$invert = $sports =~ s/^!// ? '! ' : ''; $invert = $sports =~ s/^!// ? '! ' : '';
if ( $multiport ) {
if ( $ports =~ /^\+/ ) {
push @output, set => ${invert} . get_set_flags( $ports, 'src' );
} elsif ( $multiport ) {
if ( port_count( $sports ) > 15 ) { if ( port_count( $sports ) > 15 ) {
if ( $restricted ) { if ( $restricted ) {
fatal_error "A port list in this file may only have up to 15 ports"; fatal_error "A port list in this file may only have up to 15 ports";
@@ -4818,7 +4855,7 @@ sub validate_mark( $ ) {
sub verify_small_mark( $ ) { sub verify_small_mark( $ ) {
my $val = validate_mark ( (my $mark) = $_[0] ); my $val = validate_mark ( (my $mark) = $_[0] );
fatal_error "Mark value ($mark) too large" if numeric_value( $mark ) > $globals{TC_MAX}; fatal_error "Mark value ($mark) too large" if numeric_value( $mark ) > $globals{SMALL_MASK};
$val; $val;
} }
@@ -4859,62 +4896,79 @@ my %norate = ( DROP => 1, REJECT => 1 );
# Create a "-m limit" match for the passed LIMIT/BURST # Create a "-m limit" match for the passed LIMIT/BURST
# #
sub do_ratelimit( $$ ) { sub do_ratelimit( $$ ) {
my ( $rate, $action ) = @_; my ( $rates, $action ) = @_;
return '' unless $rate and $rate ne '-'; return '' unless $rates and $rates ne '-';
fatal_error "Rate Limiting not available with $action" if $norate{$action}; fatal_error "Rate Limiting not available with $action" if $norate{$action};
#
# "-m hashlimit" match for the passed LIMIT/BURST
#
if ( $rate =~ /^[sd]:{1,2}/ ) {
require_capability 'HASHLIMIT_MATCH', 'Per-ip rate limiting' , 's';
my $limit = "-m hashlimit "; my @rates = split_list $rates, 'rate';
my $match = have_capability( 'OLD_HL_MATCH' ) ? 'hashlimit' : 'hashlimit-upto';
my $units;
if ( $rate =~ /^[sd]:((\w*):)?((\d+)(\/(sec|min|hour|day))?):(\d+)$/ ) { if ( @rates == 2 ) {
fatal_error "Invalid Rate ($3)" unless $4; $rates[0] = 's:' . $rates[0];
fatal_error "Invalid Burst ($7)" unless $7; $rates[1] = 'd:' . $rates[1];
$limit .= "--$match $3 --hashlimit-burst $7 --hashlimit-name "; } elsif ( @rates > 2 ) {
$limit .= $2 ? $2 : 'shorewall' . $hashlimitset++; fatal error "Only two rates may be specified";
$limit .= ' --hashlimit-mode '; }
$units = $6;
} elsif ( $rate =~ /^[sd]:((\w*):)?((\d+)(\/(sec|min|hour|day))?)$/ ) {
fatal_error "Invalid Rate ($3)" unless $4;
$limit .= "--$match $3 --hashlimit-name ";
$limit .= $2 ? $2 : 'shorewall' . $hashlimitset++;
$limit .= ' --hashlimit-mode ';
$units = $6;
} else {
fatal_error "Invalid rate ($rate)";
}
$limit .= $rate =~ /^s:/ ? 'srcip ' : 'dstip '; my $limit = '';
if ( $units && $units ne 'sec' ) { for my $rate ( @rates ) {
my $expire = 60000; # 1 minute in milliseconds #
# "-m hashlimit" match for the passed LIMIT/BURST
#
if ( $rate =~ /^([sd]):{1,2}/ ) {
require_capability 'HASHLIMIT_MATCH', 'Per-ip rate limiting' , 's';
if ( $units ne 'min' ) { my $match = have_capability( 'OLD_HL_MATCH' ) ? 'hashlimit' : 'hashlimit-upto';
$expire *= 60; #At least an hour my $units;
$expire *= 24 if $units eq 'day';
$limit .= "-m hashlimit ";
if ( $rate =~ /^[sd]:((\w*):)?((\d+)(\/(sec|min|hour|day))?):(\d+)$/ ) {
fatal_error "Invalid Rate ($3)" unless $4;
fatal_error "Invalid Burst ($7)" unless $7;
$limit .= "--$match $3 --hashlimit-burst $7 --hashlimit-name ";
$limit .= $2 ? $2 : 'shorewall' . $hashlimitset++;
$limit .= ' --hashlimit-mode ';
$units = $6;
} elsif ( $rate =~ /^[sd]:((\w*):)?((\d+)(\/(sec|min|hour|day))?)$/ ) {
fatal_error "Invalid Rate ($3)" unless $4;
$limit .= "--$match $3 --hashlimit-name ";
$limit .= $2 ? $2 : 'shorewall' . $hashlimitset++;
$limit .= ' --hashlimit-mode ';
$units = $6;
} else {
fatal_error "Invalid rate ($rate)";
} }
$limit .= "--hashlimit-htable-expire $expire "; $limit .= $rate =~ /^s:/ ? 'srcip ' : 'dstip ';
}
$limit; if ( $units && $units ne 'sec' ) {
} elsif ( $rate =~ /^((\d+)(\/(sec|min|hour|day))?):(\d+)$/ ) { my $expire = 60000; # 1 minute in milliseconds
fatal_error "Invalid Rate ($1)" unless $2;
fatal_error "Invalid Burst ($5)" unless $5; if ( $units ne 'min' ) {
"-m limit --limit $1 --limit-burst $5 "; $expire *= 60; #At least an hour
} elsif ( $rate =~ /^(\d+)(\/(sec|min|hour|day))?$/ ) { $expire *= 24 if $units eq 'day';
fatal_error "Invalid Rate (${1}${2})" unless $1; }
"-m limit --limit $rate ";
} else { $limit .= "--hashlimit-htable-expire $expire ";
fatal_error "Invalid rate ($rate)"; }
} else {
if ( $rate =~ /^((\d+)(\/(sec|min|hour|day))?):(\d+)$/ ) {
fatal_error "Invalid Rate ($1)" unless $2;
fatal_error "Invalid Burst ($5)" unless $5;
$limit = "-m limit --limit $1 --limit-burst $5 ";
} elsif ( $rate =~ /^(\d+)(\/(sec|min|hour|day))?$/ ) {
fatal_error "Invalid Rate (${1}${2})" unless $1;
$limit = "-m limit --limit $rate ";
} else {
fatal_error "Invalid rate ($rate)";
}
}
} }
$limit;
} }
# #
@@ -5459,7 +5513,7 @@ sub get_set_flags( $$ ) {
my $rest = ''; my $rest = '';
if ( $setname =~ /^(.*)\[([1-6])(?:,(.*))\]$/ ) { if ( $setname =~ /^(.*)\[([1-6])(?:,(.+))?\]$/ ) {
$setname = $1; $setname = $1;
my $count = $2; my $count = $2;
$rest = $3; $rest = $3;
@@ -5484,7 +5538,7 @@ sub get_set_flags( $$ ) {
} }
} }
if ( $rest ) { if ( supplied $rest ) {
my @extensions = split_list($rest, 'ipset option'); my @extensions = split_list($rest, 'ipset option');
for ( @extensions ) { for ( @extensions ) {
@@ -5550,6 +5604,8 @@ sub have_ipset_rules() {
sub get_interface_address( $ ); sub get_interface_address( $ );
sub get_interface_gateway ( $;$ );
sub record_runtime_address( $$;$ ) { sub record_runtime_address( $$;$ ) {
my ( $addrtype, $interface, $protect ) = @_; my ( $addrtype, $interface, $protect ) = @_;
@@ -6487,7 +6543,6 @@ sub set_chain_variables() {
emit( 'IPTABLES_RESTORE=${IPTABLES}-restore', emit( 'IPTABLES_RESTORE=${IPTABLES}-restore',
'[ -x "$IPTABLES_RESTORE" ] || startup_error "$IPTABLES_RESTORE does not exist or is not executable"' ); '[ -x "$IPTABLES_RESTORE" ] || startup_error "$IPTABLES_RESTORE does not exist or is not executable"' );
emit( 'g_tool=$IPTABLES' ); emit( 'g_tool=$IPTABLES' );
} else { } else {
if ( $config{IP6TABLES} ) { if ( $config{IP6TABLES} ) {
@@ -6502,7 +6557,6 @@ sub set_chain_variables() {
emit( 'IP6TABLES_RESTORE=${IP6TABLES}-restore', emit( 'IP6TABLES_RESTORE=${IP6TABLES}-restore',
'[ -x "$IP6TABLES_RESTORE" ] || startup_error "$IP6TABLES_RESTORE does not exist or is not executable"' ); '[ -x "$IP6TABLES_RESTORE" ] || startup_error "$IP6TABLES_RESTORE does not exist or is not executable"' );
emit( 'g_tool=$IP6TABLES' ); emit( 'g_tool=$IP6TABLES' );
} }
@@ -6641,11 +6695,10 @@ sub get_interface_gateway ( $;$ ) {
$global_variables |= ALL_COMMANDS; $global_variables |= ALL_COMMANDS;
if ( interface_is_optional $logical ) { if ( interface_is_optional $logical ) {
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$($routine $interface)\n); $interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$($routine $interface));
} else { } else {
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$($routine $interface) $interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$($routine $interface)
[ -n "\$$variable" ] || startup_error "Unable to detect the gateway through interface $interface" [ -n "\$$variable" ] || startup_error "Unable to detect the gateway through interface $interface");
);
} }
$protect ? "\${$variable:-" . NILIP . '}' : "\$$variable"; $protect ? "\${$variable:-" . NILIP . '}' : "\$$variable";
@@ -6751,36 +6804,67 @@ sub have_global_variables() {
have_capability( 'ADDRTYPE' ) ? $global_variables : $global_variables | NOT_RESTORE; have_capability( 'ADDRTYPE' ) ? $global_variables : $global_variables | NOT_RESTORE;
} }
sub have_address_variables() {
( keys %interfaceaddr || keys %interfacemacs || keys %interfacegateways );
}
# #
# Generate setting of run-time global shell variables # Generate setting of run-time global shell variables
# #
sub set_global_variables( $ ) { sub set_global_variables( $$ ) {
my $setall = shift; my ( $setall, $conditional ) = @_;
emit $_ for values %interfaceaddr; if ( $conditional ) {
emit $_ for values %interfacegateways; my ( $interface, @interfaces );
emit $_ for values %interfacemacs;
@interfaces = sort keys %interfaceaddr;
for $interface ( @interfaces ) {
emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $interfaceaddr{$interface}) );
}
@interfaces = sort keys %interfacegateways;
for $interface ( @interfaces ) {
emit( qq(if [ -z "\$interface" -o "\$interface" = "$interface" ]; then) );
push_indent;
emit( $interfacegateways{$interface} );
pop_indent;
emit( qq(fi\n) );
}
@interfaces = sort keys %interfacemacs;
for $interface ( @interfaces ) {
emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $interfacemacs{$interface}) );
}
} else {
emit $_ for sort values %interfaceaddr;
emit "$_\n" for sort values %interfacegateways;
emit $_ for sort values %interfacemacs;
}
if ( $setall ) { if ( $setall ) {
emit $_ for values %interfaceaddrs; emit $_ for sort values %interfaceaddrs;
emit $_ for values %interfacenets; emit $_ for sort values %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 $_ for sort values %interfacebcasts;
} else { } else {
emit 'ALL_ACASTS="$(get_all_acasts)"'; emit 'ALL_ACASTS="$(get_all_acasts)"';
emit $_ for values %interfaceacasts; emit $_ for sort values %interfaceacasts;
} }
} }
} }
} }
sub verify_address_variables() { sub verify_address_variables() {
while ( my ( $variable, $type ) = ( each %address_variables ) ) { for my $variable ( sort keys %address_variables ) {
my $type = $address_variables{$variable};
my $address = "\$$variable"; my $address = "\$$variable";
if ( $type eq '&' ) { if ( $type eq '&' ) {
@@ -6945,7 +7029,7 @@ sub isolate_source_interface( $ ) {
$inets = $2; $inets = $2;
} elsif ( $source =~ /^(.+?):\[(.+)\]\s*$/ || } elsif ( $source =~ /^(.+?):\[(.+)\]\s*$/ ||
$source =~ /^(.+?):(!?\+.+)$/ || $source =~ /^(.+?):(!?\+.+)$/ ||
$source =~ /^(.+?):(!?[&%].+)$/ || $source =~ /^(.+?):(!?[&%~].+)$/ ||
$source =~ /^(.+?):(\[.+\]\/(?:\d+))\s*$/ $source =~ /^(.+?):(\[.+\]\/(?:\d+))\s*$/
) { ) {
$iiface = $1; $iiface = $1;
@@ -7570,7 +7654,7 @@ sub expand_rule( $$$$$$$$$$$;$ )
$exceptionrule, $exceptionrule,
$actparms{disposition} || $disposition, $actparms{disposition} || $disposition,
$target ), $target ),
$terminating{$basictarget} || ( $targetref || $targetref->{complete} ), $terminating{$basictarget} || ( $targetref && $targetref->{complete} ),
$matches ); $matches );
} }
@@ -7620,7 +7704,7 @@ sub add_interface_options( $ ) {
# #
# Generate a digest for each chain # Generate a digest for each chain
# #
for my $chainref ( values %input_chains, values %forward_chains ) { for my $chainref ( sort { $a->{name} cmp $b->{name} } values %input_chains, values %forward_chains ) {
my $digest = ''; my $digest = '';
assert( $chainref ); assert( $chainref );
@@ -7633,13 +7717,13 @@ sub add_interface_options( $ ) {
} }
} }
$chainref->{digest} = sha1 $digest; $chainref->{digest} = sha1_hex $digest;
} }
# #
# 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 = sort keys %{zone_interfaces( $zone1 )};
my @forward_interfaces = @input_interfaces; my @forward_interfaces = @input_interfaces;
if ( @input_interfaces > 1 ) { if ( @input_interfaces > 1 ) {
@@ -7721,7 +7805,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 = sort keys %{zone_interfaces( $zone2 )};
my $chain1ref; my $chain1ref;
for my $interface ( @interfaces ) { for my $interface ( @interfaces ) {
@@ -7875,14 +7959,18 @@ sub emitr1( $$ ) {
sub save_dynamic_chains() { sub save_dynamic_chains() {
my $tool; my $tool = $family == F_IPV4 ? '${IPTABLES}' : '${IP6TABLES}';
my $utility = $family == F_IPV4 ? 'iptables-restore' : 'ip6tables-restore';
emit ( 'if [ "$COMMAND" = restart -o "$COMMAND" = refresh ]; then' ); emit ( 'if [ "$COMMAND" = restart -o "$COMMAND" = refresh ]; then' );
push_indent; push_indent;
if ( have_capability 'IPTABLES_S' ) { emit( 'if [ -n "$g_counters" ]; then' ,
$tool = $family == F_IPV4 ? '${IPTABLES}' : '${IP6TABLES}'; " ${tool}-save --counters | grep -vE '[ :]shorewall ' > \${VARDIR}/.${utility}-input",
"fi\n"
);
if ( have_capability 'IPTABLES_S' ) {
emit <<"EOF"; emit <<"EOF";
if chain_exists 'UPnP -t nat'; then if chain_exists 'UPnP -t nat'; then
$tool -t nat -S UPnP | tail -n +2 > \${VARDIR}/.UPnP $tool -t nat -S UPnP | tail -n +2 > \${VARDIR}/.UPnP
@@ -7897,11 +7985,12 @@ else
fi fi
if chain_exists dynamic; then if chain_exists dynamic; then
$tool -S dynamic | tail -n +2 > \${VARDIR}/.dynamic $tool -S dynamic | tail -n +2 | fgrep -v -- '-j ACCEPT' > \${VARDIR}/.dynamic
else else
rm -f \${VARDIR}/.dynamic rm -f \${VARDIR}/.dynamic
fi fi
EOF EOF
} else { } else {
$tool = $family == F_IPV4 ? '${IPTABLES}-save' : '${IP6TABLES}-save'; $tool = $family == F_IPV4 ? '${IPTABLES}-save' : '${IP6TABLES}-save';
@@ -7979,14 +8068,115 @@ sub ensure_ipset( $ ) {
} }
} }
#
# Generate the save_ipsets() function
#
sub create_save_ipsets() {
my @ipsets = all_ipsets;
emit( "#\n#Save the ipsets specified by the SAVE_IPSETS setting and by dynamic zones\n#",
'save_ipsets() {' );
if ( @ipsets || @{$globals{SAVED_IPSETS}} || ( $config{SAVE_IPSETS} && have_ipset_rules ) ) {
emit( ' local file' ,
'',
' file=${1:-${VARDIR}/save.ipsets}'
);
if ( @ipsets ) {
emit '';
ensure_ipset( $_ ) for @ipsets;
}
if ( $config{SAVE_IPSETS} ) {
if ( $family == F_IPV6 || $config{SAVE_IPSETS} eq 'ipv4' ) {
my $select = $family == F_IPV4 ? '^create.*family inet ' : 'create.*family inet6 ';
emit( '' ,
' rm -f $file' ,
' touch $file' ,
' local set' ,
);
if ( @ipsets ) {
emit '';
emit( " \$IPSET -S $_ >> \$file" ) for @ipsets;
}
emit( '',
" for set in \$(\$IPSET save | grep '$select' | cut -d' ' -f2); do" ,
" \$IPSET save \$set >> \$file" ,
" done" ,
'',
);
} elsif ( $config{WORKAROUNDS} ) {
emit ( '' ,
' if [ -f /etc/debian_version ] && [ $(cat /etc/debian_version) = 5.0.3 ]; then' ,
' #',
' # The \'grep -v\' is a hack for a bug in ipset\'s nethash implementation when xtables-addons is applied to Lenny' ,
' #',
' hack=\'| grep -v /31\'' ,
' else' ,
' hack=' ,
' fi' ,
'',
' if eval $IPSET -S $hack > ${VARDIR}/ipsets.tmp; then' ,
" grep -qE -- \"^(-N|create )\" \${VARDIR}/ipsets.tmp && mv -f \${VARDIR}/ipsets.tmp \$file" ,
' fi' );
} else {
emit (
'',
' if eval $IPSET -S > ${VARDIR}/ipsets.tmp; then' ,
" grep -qE -- \"^(-N|create )\" \${VARDIR}/ipsets.tmp && mv -f \${VARDIR}/ipsets.tmp \$file" ,
' fi' );
}
emit( " return 0",
'',
"}\n" );
} elsif ( @ipsets || $globals{SAVED_IPSETS} ) {
emit( '' ,
' rm -f ${VARDIR}/ipsets.tmp' ,
' touch ${VARDIR}/ipsets.tmp' ,
);
if ( @ipsets ) {
emit '';
emit( " \$IPSET -S $_ >> \${VARDIR}/ipsets.tmp" ) for @ipsets;
}
emit( '' ,
" if qt \$IPSET list $_; then" ,
" \$IPSET save $_ >> \${VARDIR}/ipsets.tmp" ,
' else' ,
" error_message 'ipset $_ not saved (not found)'" ,
" fi\n" ) for @{$globals{SAVED_IPSETS}};
emit( '' ,
" grep -qE -- \"(-N|^create )\" \${VARDIR}/ipsets.tmp && cat \${VARDIR}/ipsets.tmp >> \$file\n" ,
'' ,
' return 0',
'' ,
"}\n" );
}
} elsif ( $config{SAVE_IPSETS} ) {
emit( ' error_message "WARNING: No ipsets were saved"',
' return 1',
"}\n" );
} else {
emit( ' true',
"}\n" );
}
}
sub load_ipsets() { sub load_ipsets() {
my @ipsets = all_ipsets; my @ipsets = all_ipsets;
if ( @ipsets || ( $config{SAVE_IPSETS} && have_ipset_rules ) ) { if ( @ipsets || @{$globals{SAVED_IPSETS}} || ( $config{SAVE_IPSETS} && have_ipset_rules ) ) {
emit ( '', );
emit ( 'local hack' ) if $config{WORKAROUNDS};
emit ( '', emit ( '',
'local hack',
'',
'case $IPSET in', 'case $IPSET in',
' */*)', ' */*)',
' [ -x "$IPSET" ] || startup_error "IPSET=$IPSET does not exist or is not executable"', ' [ -x "$IPSET" ] || startup_error "IPSET=$IPSET does not exist or is not executable"',
@@ -8010,9 +8200,25 @@ sub load_ipsets() {
emit ( '' ); emit ( '' );
ensure_ipset( $_ ) for @ipsets; ensure_ipset( $_ ) for @ipsets;
emit ( '' ); emit ( '' );
emit ( ' if [ -f ${VARDIR}/ipsets.save ]; then' ,
' $IPSET flush' ,
' $IPSET destroy' ,
' $IPSET restore < ${VARDIR}/ipsets.save' ,
" fi\n" ) for @{$globals{SAVED_IPSETS}};
} }
} else { } else {
ensure_ipset( $_ ) for @ipsets; ensure_ipset( $_ ) for @ipsets;
if ( @{$globals{SAVED_IPSETS}} ) {
emit ( '' );
emit ( ' if [ -f ${VARDIR}/ipsets.save ]; then' ,
' $IPSET flush' ,
' $IPSET destroy' ,
' $IPSET restore < ${VARDIR}/ipsets.save' ,
" fi\n" ) for @{$globals{SAVED_IPSETS}};
}
} }
emit ( 'elif [ "$COMMAND" = restore -a -z "$g_recovering" ]; then' ); emit ( 'elif [ "$COMMAND" = restore -a -z "$g_recovering" ]; then' );
@@ -8036,6 +8242,12 @@ sub load_ipsets() {
} }
} else { } else {
ensure_ipset( $_ ) for @ipsets; ensure_ipset( $_ ) for @ipsets;
emit ( ' if [ -f ${VARDIR}/ipsets.save ]; then' ,
' $IPSET flush' ,
' $IPSET destroy' ,
' $IPSET restore < ${VARDIR}/ipsets.save' ,
" fi\n" ) for @{$globals{SAVED_IPSETS}};
} }
if ( @ipsets ) { if ( @ipsets ) {
@@ -8043,36 +8255,14 @@ sub load_ipsets() {
ensure_ipset( $_ ) for @ipsets; ensure_ipset( $_ ) for @ipsets;
} }
emit( 'elif [ "$COMMAND" = stop ]; then' ); emit( 'elif [ "$COMMAND" = stop ]; then' ,
' save_ipsets'
if ( @ipsets ) { );
ensure_ipset( $_ ) for @ipsets;
emit( '' );
}
if ( $family == F_IPV4 ) {
emit ( ' if [ -f /etc/debian_version ] && [ $(cat /etc/debian_version) = 5.0.3 ]; then' ,
' #',
' # The \'grep -v\' is a hack for a bug in ipset\'s nethash implementation when xtables-addons is applied to Lenny' ,
' #',
' hack=\'| grep -v /31\'' ,
' else' ,
' hack=' ,
' fi' ,
'',
' if eval $IPSET -S $hack > ${VARDIR}/ipsets.tmp; then' ,
' grep -qE -- "^(-N|create )" ${VARDIR}/ipsets.tmp && mv -f ${VARDIR}/ipsets.tmp ${VARDIR}/ipsets.save' ,
' fi' );
} else {
emit ( ' if eval $IPSET -S > ${VARDIR}/ipsets.tmp; then' ,
' grep -qE -- "^(-N|create )" ${VARDIR}/ipsets.tmp && mv -f ${VARDIR}/ipsets.tmp ${VARDIR}/ipsets.save' ,
' fi' );
}
if ( @ipsets ) { if ( @ipsets ) {
emit( 'elif [ "$COMMAND" = refresh ]; then' ); emit( 'elif [ "$COMMAND" = refresh ]; then' );
ensure_ipset( $_ ) for @ipsets; ensure_ipset( $_ ) for @ipsets;
} };
emit ( 'fi' , emit ( 'fi' ,
'' ); '' );
@@ -8084,7 +8274,7 @@ sub load_ipsets() {
# #
sub create_nfobjects() { sub create_nfobjects() {
my @objects = ( keys %nfobjects ); my @objects = ( sort keys %nfobjects );
if ( @objects ) { if ( @objects ) {
if ( $config{NFACCT} ) { if ( $config{NFACCT} ) {
@@ -8099,7 +8289,7 @@ sub create_nfobjects() {
} }
} }
for ( keys %nfobjects ) { for ( sort keys %nfobjects ) {
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) );
@@ -8118,17 +8308,29 @@ sub create_netfilter_load( $ ) {
'# Create the input to iptables-restore/ip6tables-restore and pass that input to the utility', '# Create the input to iptables-restore/ip6tables-restore and pass that input to the utility',
'#', '#',
'setup_netfilter()', 'setup_netfilter()',
'{' '{',
); ' local option',
);
push_indent; push_indent;
my $utility = $family == F_IPV4 ? 'iptables-restore' : 'ip6tables-restore'; my $utility = $family == F_IPV4 ? 'iptables-restore' : 'ip6tables-restore';
my $UTILITY = $family == F_IPV4 ? 'IPTABLES_RESTORE' : 'IP6TABLES_RESTORE'; my $UTILITY = $family == F_IPV4 ? 'IPTABLES_RESTORE' : 'IP6TABLES_RESTORE';
save_progress_message "Preparing $utility input..."; emit( '',
'if [ "$COMMAND" = restart -a -n "$g_counters" ] && chain_exists $g_sha1sum1 && chain_exists $g_sha1sum2 ; then',
' option="--counters"',
'',
' progress_message "Reusing existing ruleset..."',
'',
'else'
);
emit ''; push_indent;
emit 'option=';
save_progress_message "Preparing $utility input...";
emit "exec 3>\${VARDIR}/.${utility}-input"; emit "exec 3>\${VARDIR}/.${utility}-input";
@@ -8168,6 +8370,14 @@ sub create_netfilter_load( $ ) {
push @chains, $chainref; push @chains, $chainref;
} }
} }
#
# SHA1SUM chains for handling 'restart -s'
#
if ( $table eq 'filter' ) {
emit_unindented ':$g_sha1sum1 - [0:0]';
emit_unindented ':$g_sha1sum2 - [0:0]';
}
# #
# Then emit the rules # Then emit the rules
# #
@@ -8182,20 +8392,24 @@ sub create_netfilter_load( $ ) {
} }
enter_cmd_mode; enter_cmd_mode;
pop_indent, emit "fi\n";
# #
# Now generate the actual ip[6]tables-restore command # Now generate the actual ip[6]tables-restore command
# #
emit( 'exec 3>&-', emit( 'exec 3>&-',
'', '' );
'[ -n "$g_debug_iptables" ] && command=debug_restore_input || command=$' . $UTILITY,
'', emit( '[ -n "$g_debug_iptables" ] && command=debug_restore_input || command="$' . $UTILITY . ' $option"' );
'progress_message2 "Running $command..."',
'', emit( '',
"cat \${VARDIR}/.${utility}-input | \$command # Use this nonsensical form to appease SELinux", 'progress_message2 "Running $command..."',
'if [ $? != 0 ]; then', '',
qq( fatal_error "iptables-restore Failed. Input is in \${VARDIR}/.${utility}-input"), "cat \${VARDIR}/.${utility}-input | \$command # Use this nonsensical form to appease SELinux",
"fi\n" 'if [ $? != 0 ]; then',
); qq( fatal_error "iptables-restore Failed. Input is in \${VARDIR}/.${utility}-input"),
"fi\n"
);
pop_indent; pop_indent;
@@ -8493,7 +8707,8 @@ sub initialize_switches() {
if ( keys %switches ) { if ( keys %switches ) {
emit( 'if [ $COMMAND = start ]; then' ); emit( 'if [ $COMMAND = start ]; then' );
push_indent; push_indent;
while ( my ( $switch, $setting ) = each %switches ) { for my $switch ( sort keys %switches ) {
my $setting = $switches{$switch};
my $file = "/proc/net/nf_condition/$switch"; my $file = "/proc/net/nf_condition/$switch";
emit "[ -f $file ] && echo $setting->{setting} > $file"; emit "[ -f $file ] && echo $setting->{setting} > $file";
} }
@@ -8534,7 +8749,7 @@ sub get_inline_matches( $ ) {
# Split the passed target into the basic target and parameter # Split the passed target into the basic target and parameter
# #
sub get_target_param( $ ) { sub get_target_param( $ ) {
my ( $target, $param ) = split '/', $_[0]; my ( $target, $param ) = split '/', $_[0], 2;
unless ( defined $param ) { unless ( defined $param ) {
( $target, $param ) = ( $1, $2 ) if $target =~ /^(.*?)[(](.*)[)]$/; ( $target, $param ) = ( $1, $2 ) if $target =~ /^(.*?)[(](.*)[)]$/;

View File

@@ -274,10 +274,21 @@ sub generate_script_2() {
'detect_configuration()', 'detect_configuration()',
'{' ); '{' );
my $global_variables = have_global_variables; my $global_variables = have_global_variables;
my $optional_interfaces = find_interfaces_by_option( 'optional' );
push_indent; push_indent;
if ( have_address_variables || @$optional_interfaces ) {
emit( 'local interface',
'',
'interface="$1"',
''
);
}
map_provider_to_interface if have_providers;
if ( $global_variables ) { if ( $global_variables ) {
if ( $global_variables & NOT_RESTORE ) { if ( $global_variables & NOT_RESTORE ) {
@@ -292,7 +303,7 @@ sub generate_script_2() {
if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) { if ( $global_variables == ( ALL_COMMANDS | NOT_RESTORE ) ) {
set_global_variables(0); set_global_variables(0, 0);
handle_optional_interfaces(0); handle_optional_interfaces(0);
} }
@@ -306,15 +317,16 @@ sub generate_script_2() {
push_indent; push_indent;
} }
set_global_variables(1); set_global_variables(1,1);
handle_optional_interfaces(0);
if ( $global_variables & NOT_RESTORE ) { if ( $global_variables & NOT_RESTORE ) {
handle_optional_interfaces(1);
emit ';;'; emit ';;';
pop_indent; pop_indent;
pop_indent; pop_indent;
emit ( 'esac' ); emit ( 'esac' );
} else {
handle_optional_interfaces(1);
} }
} else { } else {
emit( 'true' ) unless handle_optional_interfaces(1); emit( 'true' ) unless handle_optional_interfaces(1);
@@ -347,10 +359,12 @@ sub generate_script_3($) {
create_netfilter_load( $test ); create_netfilter_load( $test );
create_arptables_load( $test ) if $have_arptables; create_arptables_load( $test ) if $have_arptables;
create_chainlist_reload( $_[0] ); create_chainlist_reload( $_[0] );
create_save_ipsets;
emit "#\n# Start/Restart the Firewall\n#"; emit "#\n# Start/Restart the Firewall\n#";
emit 'define_firewall() {'; emit( 'define_firewall() {',
' local options' );
push_indent; push_indent;
@@ -468,10 +482,12 @@ sub generate_script_3($) {
emit( '', emit( '',
'if [ $COMMAND = restore ]; then', 'if [ $COMMAND = restore ]; then',
' iptables_save_file=${VARDIR}/$(basename $0)-iptables', ' iptables_save_file=${VARDIR}/$(basename $0)-iptables',
' if [ -f $iptables_save_file ]; then' ); ' if [ -f $iptables_save_file ]; then',
' [ -n "$g_counters" ] && options=--counters'
);
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
emit( ' cat $iptables_save_file | $IPTABLES_RESTORE # Use this nonsensical form to appease SELinux' ); emit( ' cat $iptables_save_file | $IPTABLES_RESTORE $options # Use this nonsensical form to appease SELinux' );
emit( '', emit( '',
' arptables_save_file=${VARDIR}/$(basename $0)-arptables', ' arptables_save_file=${VARDIR}/$(basename $0)-arptables',
@@ -481,7 +497,7 @@ sub generate_script_3($) {
if $config{SAVE_ARPTABLES}; if $config{SAVE_ARPTABLES};
} else { } else {
emit ' cat $iptables_save_file | $IP6TABLES_RESTORE # Use this nonsensical form to appease SELinux' emit ' cat $iptables_save_file | $IP6TABLES_RESTORE $options # Use this nonsensical form to appease SELinux'
} }
emit( ' else', emit( ' else',
@@ -510,45 +526,39 @@ EOF
# #
# Use a parameter list rather than 'here documents' to avoid an extra blank line # Use a parameter list rather than 'here documents' to avoid an extra blank line
# #
emit( emit( ' run_refreshed_exit',
' run_refreshed_exit', ' do_iptables -N shorewall' );
' do_iptables -N shorewall' );
emit ( ' do_iptables -A shorewall -m recent --set --name %CURRENTTIME' ) if have_capability 'RECENT_MATCH'; emit( ' do_iptables -A shorewall -m recent --set --name %CURRENTTIME' ) if have_capability 'RECENT_MATCH';
emit( " set_state Started $config_dir",
' [ $0 = ${VARDIR}/firewall ] || cp -f $(my_pathname) ${VARDIR}/firewall',
'else',
' setup_netfilter' );
emit(
" set_state Started $config_dir",
' [ $0 = ${VARDIR}/firewall ] || cp -f $(my_pathname) ${VARDIR}/firewall',
'else',
' setup_netfilter'
);
push_indent; push_indent;
emit 'setup_arptables' if $have_arptables; emit 'setup_arptables' if $have_arptables;
setup_load_distribution; setup_load_distribution;
pop_indent; pop_indent;
emit<<'EOF'; emit( " conditionally_flush_conntrack\n" );
conditionally_flush_conntrack
EOF
push_indent; push_indent;
initialize_switches; initialize_switches;
setup_forwarding( $family , 0 ); setup_forwarding( $family , 0 );
pop_indent; pop_indent;
emit<<"EOF"; emit( ' run_start_exit',
run_start_exit ' do_iptables -N shorewall',
do_iptables -N shorewall '' );
EOF
emit ( ' do_iptables -A shorewall -m recent --set --name %CURRENTTIME' ) if have_capability 'RECENT_MATCH'; emit( ' do_iptables -A shorewall -m recent --set --name %CURRENTTIME' ) if have_capability 'RECENT_MATCH';
emit<<"EOF"; emit( " set_state Started $config_dir",
set_state Started $config_dir ' my_pathname=$(my_pathname)',
my_pathname=\$(my_pathname) ' [ $my_pathname = ${VARDIR}/firewall ] || cp -f $my_pathname ${VARDIR}/firewall',
[ \$my_pathname = \${VARDIR}/firewall ] || cp -f \$my_pathname \${VARDIR}/firewall ' run_started_exit',
run_started_exit "fi\n" );
fi
EOF
emit<<'EOF'; emit<<'EOF';
date > ${VARDIR}/restarted date > ${VARDIR}/restarted
@@ -582,8 +592,8 @@ EOF
# #
sub compiler { sub compiler {
my ( $scriptfilename, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity, $preview, $confess , $update , $annotate , $convert, $config_path, $shorewallrc , $shorewallrc1 , $directives, $inline, $tcrules ) = my ( $scriptfilename, $directory, $verbosity, $timestamp , $debug, $chains , $log , $log_verbosity, $preview, $confess , $update , $annotate , $convert, $config_path, $shorewallrc , $shorewallrc1 , $directives, $inline, $tcrules, $routestopped , $notrack ) =
( '', '', -1, '', 0, '', '', -1, 0, 0, 0, 0, , 0 , '' , '/usr/share/shorewall/shorewallrc', '' , 0 , 0 , 0 ); ( '', '', -1, '', 0, '', '', -1, 0, 0, 0, 0, , 0 , '' , '/usr/share/shorewall/shorewallrc', '' , 0 , 0 , 0 , 0 , 0 );
$export = 0; $export = 0;
$test = 0; $test = 0;
@@ -592,12 +602,12 @@ sub compiler {
sub validate_boolean( $ ) { sub validate_boolean( $ ) {
my $val = numeric_value( shift ); my $val = numeric_value( shift );
defined($val) && ($val >= 0) && ($val < 2); defined($val) && ($val >= 0) && ($val < 2);
} }
sub validate_verbosity( $ ) { sub validate_verbosity( $ ) {
my $val = numeric_value( shift ); my $val = numeric_value( shift );
defined($val) && ($val >= MIN_VERBOSITY) && ($val <= MAX_VERBOSITY); defined($val) && ($val >= MIN_VERBOSITY) && ($val <= MAX_VERBOSITY);
} }
sub validate_family( $ ) { sub validate_family( $ ) {
my $val = numeric_value( shift ); my $val = numeric_value( shift );
@@ -624,6 +634,8 @@ sub compiler {
inline => { store => \$inline, validate=> \&validate_boolean } , inline => { store => \$inline, validate=> \&validate_boolean } ,
directives => { store => \$directives, validate=> \&validate_boolean } , directives => { store => \$directives, validate=> \&validate_boolean } ,
tcrules => { store => \$tcrules, validate=> \&validate_boolean } , tcrules => { store => \$tcrules, validate=> \&validate_boolean } ,
routestopped => { store => \$routestopped, validate=> \&validate_boolean } ,
notrack => { store => \$notrack, validate=> \&validate_boolean } ,
config_path => { store => \$config_path } , config_path => { store => \$config_path } ,
shorewallrc => { store => \$shorewallrc } , shorewallrc => { store => \$shorewallrc } ,
shorewallrc1 => { store => \$shorewallrc1 } , shorewallrc1 => { store => \$shorewallrc1 } ,
@@ -648,10 +660,7 @@ sub compiler {
set_config_path( $config_path ) if $config_path; set_config_path( $config_path ) if $config_path;
if ( $directory ne '' ) { set_shorewall_dir( $directory ) if $directory ne '';
fatal_error "$directory is not an existing directory" unless -d $directory;
set_shorewall_dir( $directory );
}
$verbosity = 1 if $debug && $verbosity < 1; $verbosity = 1 if $debug && $verbosity < 1;
@@ -664,15 +673,6 @@ sub compiler {
# #
get_configuration( $export , $update , $annotate , $directives , $inline ); get_configuration( $export , $update , $annotate , $directives , $inline );
# #
# Create a temp file to hold the script
#
if ( $scriptfilename ) {
set_command( 'compile', 'Compiling', 'Compiled' );
create_temp_script( $scriptfilename , $export );
} else {
set_command( 'check', 'Checking', 'Checked' );
}
#
# Chain table initialization depends on shorewall.conf and capabilities. So it must be deferred until # Chain table initialization depends on shorewall.conf and capabilities. So it must be deferred until
# now when shorewall.conf has been processed and the capabilities have been determined. # now when shorewall.conf has been processed and the capabilities have been determined.
# #
@@ -682,6 +682,15 @@ sub compiler {
# #
run_user_exit1 'compile'; run_user_exit1 'compile';
# #
# Create a temp file to hold the script
#
if ( $scriptfilename ) {
set_command( 'compile', 'Compiling', 'Compiled' );
create_temp_script( $scriptfilename , $export );
} else {
set_command( 'check', 'Checking', 'Checked' );
}
#
# Z O N E D E F I N I T I O N # 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)
# #
@@ -730,7 +739,7 @@ sub compiler {
# #
# Do all of the zone-independent stuff (mostly /proc) # Do all of the zone-independent stuff (mostly /proc)
# #
add_common_rules( $convert, $tcrules ); add_common_rules( $convert, $tcrules , $routestopped );
# #
# More /proc # More /proc
# #
@@ -741,6 +750,8 @@ sub compiler {
} }
setup_source_routing($family); setup_source_routing($family);
setup_log_backend($family);
# #
# Proxy Arp/Ndp # Proxy Arp/Ndp
# #
@@ -835,13 +846,13 @@ sub compiler {
# #
# Process the conntrack file # Process the conntrack file
# #
setup_conntrack; setup_conntrack( $notrack );
# #
# Add Tunnel rules. # Add Tunnel rules.
# #
setup_tunnels; setup_tunnels;
# #
# Clear the current filename # Clear the current filename so that the last one processed doesn't appear in error and warning messages
# #
clear_currentfilename; clear_currentfilename;
# #
@@ -851,7 +862,7 @@ sub compiler {
# #
# Apply Policies # Apply Policies
# #
apply_policy_rules; complete_policy_chains;
# #
# Reject Action # Reject Action
# #
@@ -902,7 +913,7 @@ sub compiler {
# S T O P _ F I R E W A L L # S T O P _ F I R E W A L L
# (Writes the stop_firewall() function to the compiled script) # (Writes the stop_firewall() function to the compiled script)
# #
compile_stop_firewall( $test, $export , $have_arptables ); compile_stop_firewall( $test, $export , $have_arptables, $routestopped );
# #
# U P D O W N # U P D O W N
# (Writes the updown() function to the compiled script) # (Writes the updown() function to the compiled script)
@@ -967,14 +978,14 @@ sub compiler {
initialize_chain_table(0); initialize_chain_table(0);
if ( $debug ) { if ( $debug ) {
compile_stop_firewall( $test, $export, $have_arptables ); compile_stop_firewall( $test, $export, $have_arptables, $routestopped );
disable_script; disable_script;
} else { } else {
# #
# compile_stop_firewall() also validates the routestopped file. Since we don't # compile_stop_firewall() also validates the stoppedrules file. Since we don't
# call that function during normal 'check', we must validate routestopped here. # call that function during normal 'check', we must validate stoppedrules here.
# #
process_routestopped; convert_routestopped if $routestopped;
process_stoppedrules; process_stoppedrules;
} }
# #

View File

@@ -40,6 +40,7 @@ use Cwd qw(abs_path getcwd);
use autouse 'Carp' => qw(longmess confess); use autouse 'Carp' => qw(longmess confess);
use Scalar::Util 'reftype'; use Scalar::Util 'reftype';
use FindBin; use FindBin;
use Digest::SHA qw(sha1_hex);
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
# #
@@ -88,6 +89,7 @@ our @EXPORT = qw(
our @EXPORT_OK = qw( $shorewall_dir initialize shorewall); our @EXPORT_OK = qw( $shorewall_dir initialize shorewall);
our %EXPORT_TAGS = ( internal => [ qw( create_temp_script our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
generate_sha1
finalize_script finalize_script
enable_script enable_script
disable_script disable_script
@@ -122,6 +124,7 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
set_shorewall_dir set_shorewall_dir
set_debug set_debug
find_file find_file
find_writable_file
split_list split_list
split_list1 split_list1
split_list2 split_list2
@@ -230,7 +233,7 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
Exporter::export_ok_tags('internal'); Exporter::export_ok_tags('internal');
our $VERSION = '4.6.0-Beta1'; our $VERSION = 'MODULEVERSION';
# #
# describe the current command, it's present progressive, and it's completion. # describe the current command, it's present progressive, and it's completion.
@@ -299,7 +302,7 @@ our %renamed = ( AUTO_COMMENT => 'AUTOCOMMENT', BLACKLIST_LOGLEVEL => 'BLACKLIST
# #
# Config options and global settings that are to be copied to output script # Config options and global settings that are to be copied to output script
# #
our @propagateconfig = qw/ DISABLE_IPV6 MODULESDIR MODULE_SUFFIX LOAD_HELPERS_ONLY SUBSYSLOCK LOG_VERBOSITY/; our @propagateconfig = qw/ DISABLE_IPV6 MODULESDIR MODULE_SUFFIX LOAD_HELPERS_ONLY LOCKFILE SUBSYSLOCK LOG_VERBOSITY/;
# #
# From parsing the capabilities file or detecting capabilities # From parsing the capabilities file or detecting capabilities
# #
@@ -392,6 +395,9 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
MASQUERADE_TGT => 'MASQUERADE Target', MASQUERADE_TGT => 'MASQUERADE Target',
UDPLITEREDIRECT => 'UDPLITE Port Redirection', UDPLITEREDIRECT => 'UDPLITE Port Redirection',
NEW_TOS_MATCH => 'New tos Match', NEW_TOS_MATCH => 'New tos Match',
TARPIT_TARGET => 'TARPIT Target',
IFACE_MATCH => 'Iface Match',
TCPMSS_TARGET => 'TCPMSS Target',
AMANDA_HELPER => 'Amanda Helper', AMANDA_HELPER => 'Amanda Helper',
FTP_HELPER => 'FTP Helper', FTP_HELPER => 'FTP Helper',
@@ -408,7 +414,7 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
SIP0_HELPER => 'SIP-0 Helper', SIP0_HELPER => 'SIP-0 Helper',
SNMP_HELPER => 'SNMP Helper', SNMP_HELPER => 'SNMP Helper',
TFTP_HELPER => 'TFTP Helper', TFTP_HELPER => 'TFTP Helper',
TFTP0_HELPER => 'TFTP-0 Helper', TFTP0_HELPER => 'TFTP-0 Helper',
# #
# Constants # Constants
# #
@@ -613,6 +619,8 @@ our %deprecated = ( LOGRATE => '' ,
our %converted = ( WIDE_TC_MARKS => 1, our %converted = ( WIDE_TC_MARKS => 1,
HIGH_ROUTE_MARKS => 1, HIGH_ROUTE_MARKS => 1,
BLACKLISTNEWONLY => 1, BLACKLISTNEWONLY => 1,
LOGRATE => 1,
LOGBURST => 1,
); );
# #
# Variables involved in ?IF, ?ELSE ?ENDIF processing # Variables involved in ?IF, ?ELSE ?ENDIF processing
@@ -710,7 +718,7 @@ sub initialize( $;$$) {
EXPORT => 0, EXPORT => 0,
KLUDGEFREE => '', KLUDGEFREE => '',
VERSION => "4.5.19-Beta1", VERSION => "4.5.19-Beta1",
CAPVERSION => 40600 , CAPVERSION => 40609 ,
); );
# #
# From shorewall.conf file # From shorewall.conf file
@@ -741,6 +749,7 @@ sub initialize( $;$$) {
RPFILTER_LOG_LEVEL => undef, RPFILTER_LOG_LEVEL => undef,
INVALID_LOG_LEVEL => undef, INVALID_LOG_LEVEL => undef,
UNTRACKED_LOG_LEVEL => undef, UNTRACKED_LOG_LEVEL => undef,
LOG_BACKEND => undef,
# #
# Location of Files # Location of Files
# #
@@ -848,6 +857,7 @@ sub initialize( $;$$) {
REJECT_ACTION => undef, REJECT_ACTION => undef,
INLINE_MATCHES => undef, INLINE_MATCHES => undef,
BASIC_FILTERS => undef, BASIC_FILTERS => undef,
WORKAROUNDS => undef ,
# #
# Packet Disposition # Packet Disposition
# #
@@ -874,9 +884,6 @@ sub initialize( $;$$) {
# #
# Valid log levels # Valid log levels
# #
# Note that we don't include LOGMARK; that is so we can default its
# priority to 'info' (LOGMARK itself defaults to 'warn').
#
%validlevels = ( DEBUG => 7, %validlevels = ( DEBUG => 7,
INFO => 6, INFO => 6,
NOTICE => 5, NOTICE => 5,
@@ -976,6 +983,9 @@ sub initialize( $;$$) {
UDPLITEREDIRECT => undef, UDPLITEREDIRECT => undef,
NEW_TOS_MATCH => undef, NEW_TOS_MATCH => undef,
REAP_OPTION => undef, REAP_OPTION => undef,
TARPIT_TARGET => undef,
IFACE_MATCH => undef,
TCPMSS_TARGET => undef,
AMANDA_HELPER => undef, AMANDA_HELPER => undef,
FTP_HELPER => undef, FTP_HELPER => undef,
@@ -1105,7 +1115,8 @@ sub initialize( $;$$) {
$family == F_IPV4 ? 'shorewall' : 'shorewall6' $family == F_IPV4 ? 'shorewall' : 'shorewall6'
) if defined $shorewallrc; ) if defined $shorewallrc;
$globals{SHAREDIRPL} = "$shorewallrc{SHAREDIR}/shorewall/"; $globals{SHAREDIRPL} = "$shorewallrc{SHAREDIR}/shorewall/";
$globals{SAVED_IPSETS} = [];
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
$globals{SHAREDIR} = "$shorewallrc{SHAREDIR}/shorewall"; $globals{SHAREDIR} = "$shorewallrc{SHAREDIR}/shorewall";
@@ -1264,9 +1275,7 @@ sub cleanup_iptables() {
qt1( "$iptables $iptablesw -t raw -X $sillyname" ); qt1( "$iptables $iptablesw -t raw -X $sillyname" );
} }
$sillyname = $sillyname1 = undef; $sillyname = $sillyname1 = '';
$sillyname = '';
} }
# #
@@ -1587,7 +1596,7 @@ sub set_command( $$$ ) {
# #
# Print the current TOD to STDOUT. # Print the current TOD to STDOUT.
# #
sub timestamp() { sub get_localtime() {
our @localtime = localtime; our @localtime = localtime;
printf '%02d:%02d:%02d ', @localtime[2,1,0]; printf '%02d:%02d:%02d ', @localtime[2,1,0];
} }
@@ -1604,7 +1613,7 @@ sub progress_message {
$line =~ s/\s+/ /g; $line =~ s/\s+/ /g;
if ( $verbosity > 1 ) { if ( $verbosity > 1 ) {
timestamp, $havelocaltime = 1 if $timestamp; get_localtime, $havelocaltime = 1 if $timestamp;
# #
# We use this function to display messages containing raw config file images which may contains tabs (including multiple tabs in succession). # We use this function to display messages containing raw config file images which may contains tabs (including multiple tabs in succession).
# The following makes such messages look more readable and uniform # The following makes such messages look more readable and uniform
@@ -1627,7 +1636,7 @@ sub progress_message_nocompress {
my $havelocaltime = 0; my $havelocaltime = 0;
if ( $verbosity > 1 ) { if ( $verbosity > 1 ) {
timestamp, $havelocaltime = 1 if $timestamp; get_localtime, $havelocaltime = 1 if $timestamp;
print "@_\n"; print "@_\n";
} }
@@ -1648,7 +1657,7 @@ sub progress_message2 {
my $havelocaltime = 0; my $havelocaltime = 0;
if ( $verbosity > 0 ) { if ( $verbosity > 0 ) {
timestamp, $havelocaltime = 1 if $timestamp; get_localtime, $havelocaltime = 1 if $timestamp;
print "@_\n"; print "@_\n";
} }
@@ -1669,7 +1678,7 @@ sub progress_message3 {
my $havelocaltime = 0; my $havelocaltime = 0;
if ( $verbosity >= 0 ) { if ( $verbosity >= 0 ) {
timestamp, $havelocaltime = 1 if $timestamp; get_localtime, $havelocaltime = 1 if $timestamp;
print "@_\n"; print "@_\n";
} }
@@ -1758,6 +1767,13 @@ sub create_temp_script( $$ ) {
} }
# Generate the SHA1 digest of the (incomplete) script
#
sub generate_sha1() {
my $data = `cat $tempfile`;
sha1_hex $data;
}
# #
# Finalize the script file # Finalize the script file
# #
@@ -1767,6 +1783,19 @@ sub finalize_script( $ ) {
$script = 0; $script = 0;
if ( $file ne '-' ) { if ( $file ne '-' ) {
my $sha1sum = generate_sha1;
my $sha1sum1 = join( '-', 'sha-lh', substr( $sha1sum, 0, 20 ) );
my $sha1sum2 = join( '-', 'sha-rh', substr( $sha1sum, -20 ) );
@ARGV = ( $tempfile );
$^I = '';
while ( <> ) {
s/g_sha1sum1=/g_sha1sum1=$sha1sum1/;
s/g_sha1sum2=/g_sha1sum2=$sha1sum2/;
print;
}
rename $tempfile, $file or fatal_error "Cannot Rename $tempfile to $file: $!"; 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 "Shorewall configuration compiled to $file" unless $export;
@@ -1816,7 +1845,7 @@ sub set_config_path( $ ) {
} }
# #
# Set $debug # Set $debug and $confess
# #
sub set_debug( $$ ) { sub set_debug( $$ ) {
$debug = shift; $debug = shift;
@@ -1841,6 +1870,23 @@ sub find_file($)
"$config_path[0]$filename"; "$config_path[0]$filename";
} }
sub find_writable_file($) {
my ( $filename, $nosearch ) = @_;
return $filename if $filename =~ '/';
for my $directory ( @config_path ) {
next if $directory =~ m|^$globals{SHAREDIR}/configfiles/?$| || $directory =~ m|^$shorewallrc{SHAREDIR}/doc/default-config/?$|;
my $file = "$directory$filename";
return $file if -f $file && -w _;
}
"$config_path[0]$filename";
}
#
# Split a comma-separated list into a Perl array
#
sub split_list( $$;$ ) { sub split_list( $$;$ ) {
my ($list, $type, $origlist ) = @_; my ($list, $type, $origlist ) = @_;
@@ -1849,6 +1895,9 @@ sub split_list( $$;$ ) {
split /,/, $list; split /,/, $list;
} }
#
# This version handles parenthetical list elements with embedded commas. It removes the parentheses
#
sub split_list1( $$;$ ) { sub split_list1( $$;$ ) {
my ($list, $type, $keepparens ) = @_; my ($list, $type, $keepparens ) = @_;
@@ -2000,6 +2049,9 @@ sub split_list3( $$ ) {
@list2; @list2;
} }
#
# Splits the columns of a config file record
#
sub split_columns( $ ) { sub split_columns( $ ) {
my ($list) = @_; my ($list) = @_;
@@ -2108,7 +2160,7 @@ sub split_line2( $$;$$$ ) {
# #
# This file supports INLINE or IPTABLES # This file supports INLINE or IPTABLES
# #
if ( $currentline =~ /^\s*INLINE(?:\(.*\)|:.*)?\s/ || $currentline =~ /^\s*IP6?TABLES(?:\(.*\)|:.*)?\s/ ) { if ( $currentline =~ /^\s*INLINE(?:\(.*\)(:.*)?|:.*)?\s/ || $currentline =~ /^\s*IP6?TABLES(?:\(.*\)|:.*)?\s/ ) {
$inline_matches = $pairs; $inline_matches = $pairs;
if ( $columns =~ /^(\s*|.*[^&@%]){(.*)}\s*$/ ) { if ( $columns =~ /^(\s*|.*[^&@%]){(.*)}\s*$/ ) {
@@ -3364,7 +3416,7 @@ sub read_a_line($) {
# Must check for shell/perl before doing variable expansion # Must check for shell/perl before doing variable expansion
# #
if ( $options & EMBEDDED_ENABLED ) { if ( $options & EMBEDDED_ENABLED ) {
if ( $currentline =~ s/^\s*\??(BEGIN\s+)SHELL\s*;?//i || $currentline =~ s/^\s*\??SHELL\s*//i ) { if ( $currentline =~ s/^\s*\??(BEGIN\s+)SHELL\s*;?//i || $currentline =~ s/^\s*\?SHELL\s*//i || $currentline =~ s/^\s*SHELL\s+// ) {
handle_first_entry if $first_entry; handle_first_entry if $first_entry;
embedded_shell( $1 ); embedded_shell( $1 );
next; next;
@@ -3502,8 +3554,9 @@ sub default ( $$ ) {
# #
# Provide a default value for a yes/no configuration variable. # Provide a default value for a yes/no configuration variable.
# #
sub default_yes_no ( $$ ) { sub default_yes_no ( $$;$ ) {
my ( $var, $val ) = @_; my ( $var, $val, $other ) = @_;
my $result = 1;
my $curval = $config{$var}; my $curval = $config{$var};
@@ -3512,12 +3565,31 @@ sub default_yes_no ( $$ ) {
if ( $curval eq 'no' ) { if ( $curval eq 'no' ) {
$config{$var} = ''; $config{$var} = '';
} elsif ( defined( $other ) ) {
if ( $other eq '*' ) {
if ( $curval eq 'yes' ) {
$config{$var} = 'Yes';
} else {
$result = 0;
}
} elsif ( $curval eq $other ) {
#
# Downshift value for later comparison
#
$config{$var} = $curval;
}
} else { } else {
fatal_error "Invalid value for $var ($curval)" unless $curval eq 'yes'; fatal_error "Invalid value for $var ($curval)" unless $curval eq 'yes';
#
# Make Case same as default
#
$config{$var} = 'Yes';
} }
} else { } else {
$config{$var} = $val; $config{$var} = $val;
} }
$result;
} }
sub default_yes_no_ipv4 ( $$ ) { sub default_yes_no_ipv4 ( $$ ) {
@@ -3807,7 +3879,7 @@ sub load_kernel_modules( ) {
close LSMOD; close LSMOD;
$config{MODULE_SUFFIX} = 'o gz ko o.gz ko.gz' unless $config{MODULE_SUFFIX}; $config{MODULE_SUFFIX} = 'o gz xz ko o.gz o.xz ko.gz ko.xz' unless $config{MODULE_SUFFIX};
my @suffixes = split /\s+/ , $config{MODULE_SUFFIX}; my @suffixes = split /\s+/ , $config{MODULE_SUFFIX};
@@ -4175,6 +4247,10 @@ sub Addrtype() {
qt1( "$iptables $iptablesw -A $sillyname -m addrtype --src-type BROADCAST -j ACCEPT" ); qt1( "$iptables $iptablesw -A $sillyname -m addrtype --src-type BROADCAST -j ACCEPT" );
} }
sub Tarpit_Target() {
qt1( "$iptables $iptablesw -A $sillyname -p tcp -j TARPIT" );
}
sub Tcpmss_Match() { sub Tcpmss_Match() {
qt1( "$iptables $iptablesw -A $sillyname -p tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1000:1500 -j ACCEPT" ); qt1( "$iptables $iptablesw -A $sillyname -p tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1000:1500 -j ACCEPT" );
} }
@@ -4405,6 +4481,14 @@ sub Arptables_JF() {
} }
} }
sub Iface_Match() {
qt1( "$iptables $iptablesw -A $sillyname -m iface --iface lo --loopback" );
}
sub Tcpmss_Target() {
qt1( "$iptables $iptablesw -A $sillyname -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu" );
}
our %detect_capability = our %detect_capability =
( ACCOUNT_TARGET =>\&Account_Target, ( ACCOUNT_TARGET =>\&Account_Target,
AMANDA_HELPER => \&Amanda_Helper, AMANDA_HELPER => \&Amanda_Helper,
@@ -4437,6 +4521,7 @@ our %detect_capability =
HASHLIMIT_MATCH => \&Hashlimit_Match, HASHLIMIT_MATCH => \&Hashlimit_Match,
HEADER_MATCH => \&Header_Match, HEADER_MATCH => \&Header_Match,
HELPER_MATCH => \&Helper_Match, HELPER_MATCH => \&Helper_Match,
IFACE_MATCH => \&Iface_Match,
IMQ_TARGET => \&Imq_Target, IMQ_TARGET => \&Imq_Target,
IPMARK_TARGET => \&IPMark_Target, IPMARK_TARGET => \&IPMark_Target,
IPP2P_MATCH => \&Ipp2p_Match, IPP2P_MATCH => \&Ipp2p_Match,
@@ -4489,7 +4574,9 @@ our %detect_capability =
SIP0_HELPER => \&SIP0_Helper, SIP0_HELPER => \&SIP0_Helper,
SNMP_HELPER => \&SNMP_Helper, SNMP_HELPER => \&SNMP_Helper,
STATISTIC_MATCH => \&Statistic_Match, STATISTIC_MATCH => \&Statistic_Match,
TARPIT_TARGET => \&Tarpit_Target,
TCPMSS_MATCH => \&Tcpmss_Match, TCPMSS_MATCH => \&Tcpmss_Match,
TCPMSS_TARGET => \&Tcpmss_Target,
TFTP_HELPER => \&TFTP_Helper, TFTP_HELPER => \&TFTP_Helper,
TFTP0_HELPER => \&TFTP0_Helper, TFTP0_HELPER => \&TFTP0_Helper,
TIME_MATCH => \&Time_Match, TIME_MATCH => \&Time_Match,
@@ -4641,6 +4728,9 @@ sub determine_capabilities() {
$capabilities{MASQUERADE_TGT} = detect_capability( 'MASQUERADE_TGT' ); $capabilities{MASQUERADE_TGT} = detect_capability( 'MASQUERADE_TGT' );
$capabilities{UDPLITEREDIRECT} = detect_capability( 'UDPLITEREDIRECT' ); $capabilities{UDPLITEREDIRECT} = detect_capability( 'UDPLITEREDIRECT' );
$capabilities{NEW_TOS_MATCH} = detect_capability( 'NEW_TOS_MATCH' ); $capabilities{NEW_TOS_MATCH} = detect_capability( 'NEW_TOS_MATCH' );
$capabilities{TARPIT_TARGET} = detect_capability( 'TARPIT_TARGET' );
$capabilities{IFACE_MATCH} = detect_capability( 'IFACE_MATCH' );
$capabilities{TCPMSS_TARGET} = detect_capability( 'TCPMSS_TARGET' );
unless ( have_capability 'CT_TARGET' ) { unless ( have_capability 'CT_TARGET' ) {
$capabilities{HELPER_MATCH} = detect_capability 'HELPER_MATCH'; $capabilities{HELPER_MATCH} = detect_capability 'HELPER_MATCH';
@@ -4708,6 +4798,7 @@ sub ensure_config_path() {
# #
sub set_shorewall_dir( $ ) { sub set_shorewall_dir( $ ) {
$shorewall_dir = shift; $shorewall_dir = shift;
fatal_error "$shorewall_dir is not an existing directory" unless -d $shorewall_dir;
ensure_config_path; ensure_config_path;
} }
@@ -4731,6 +4822,12 @@ sub conditional_quote( $ ) {
# #
# Update the shorewall[6].conf file. Save the current file with a .bak suffix. # Update the shorewall[6].conf file. Save the current file with a .bak suffix.
# #
sub update_default($$) {
my ( $var, $val ) = @_;
$config{$var} = $val unless defined $config{$var};
}
sub update_config_file( $$ ) { sub update_config_file( $$ ) {
my ( $annotate, $directives ) = @_; my ( $annotate, $directives ) = @_;
@@ -4750,6 +4847,45 @@ sub update_config_file( $$ ) {
$config{PROVIDER_OFFSET} = ( $high ? $wide ? 16 : 8 : 0 ) unless defined $config{PROVIDER_OFFSET}; $config{PROVIDER_OFFSET} = ( $high ? $wide ? 16 : 8 : 0 ) unless defined $config{PROVIDER_OFFSET};
$config{PROVIDER_BITS} = 8 unless defined $config{PROVIDER_BITS}; $config{PROVIDER_BITS} = 8 unless defined $config{PROVIDER_BITS};
unless ( supplied $config{LOGLIMIT} ) {
if ( $config{LOGRATE} || $config{LOGBURST} ) {
my $limit;
if ( supplied $config{LOGRATE} ) {
fatal_error"Invalid LOGRATE ($config{LOGRATE})" unless $config{LOGRATE} =~ /^\d+\/(second|minute)$/;
$limit = $config{LOGRATE};
}
if ( supplied $config{LOGBURST} ) {
fatal_error"Invalid LOGBURST ($config{LOGBURST})" unless $config{LOGBURST} =~ /^\d+$/;
$limit .= ":$config{LOGBURST}";
}
$config{LOGLIMIT} = $limit;
$config{LOGRATE} = $config{LOGBURST} = undef;
}
}
unless ( supplied $config{BLACKLIST} ) {
if ( $config{BLACKLISTNEWONLY} ) {
default_yes_no 'BLACKLISTNEWONLY' , '';
if ( have_capability 'RAW_TABLE' ) {
$globals{BLACKLIST_STATES} = $config{BLACKLISTNEWONLY} ? 'NEW,INVALID,UNTRACKED' : 'NEW,ESTABLISHED,INVALID,UNTRACKED';
} else {
$globals{BLACKLIST_STATES} = $config{BLACKLISTNEWONLY} ? 'NEW,INVALID' : 'NEW,ESTABLISHED,INVALID';
}
$config{BLACKLIST} = $globals{BLACKLIST_STATES};
$config{BLACKLISTNEWONLY} = undef;
}
}
update_default( 'USE_DEFAULT_RT', 'No' );
update_default( 'EXPORTMODULES', 'No' );
my $fn; my $fn;
unless ( -d "$globals{SHAREDIR}/configfiles/" ) { unless ( -d "$globals{SHAREDIR}/configfiles/" ) {
@@ -4763,7 +4899,8 @@ sub update_config_file( $$ ) {
# #
$fn = $annotate ? "$globals{SHAREDIR}/configfiles/${product}.conf.annotated" : "$globals{SHAREDIR}/configfiles/${product}.conf"; $fn = $annotate ? "$globals{SHAREDIR}/configfiles/${product}.conf.annotated" : "$globals{SHAREDIR}/configfiles/${product}.conf";
} }
if ( -f $fn ) {
if ( -f $fn ) {
my ( $template, $output ); my ( $template, $output );
open $template, '<' , $fn or fatal_error "Unable to open $fn: $!"; open $template, '<' , $fn or fatal_error "Unable to open $fn: $!";
@@ -4851,8 +4988,12 @@ EOF
} }
exit 0 unless ( $directives || exit 0 unless ( $directives ||
-f find_file 'blacklist' || -f find_file 'blacklist' ||
-f find_file 'tcrules' ); -f find_file 'tcrules' ||
-f find_file 'routestopped' ||
-f find_file 'notrack' ||
-f find_file 'tos'
);
} }
} else { } else {
fatal_error "$fn does not exist"; fatal_error "$fn does not exist";
@@ -4944,6 +5085,10 @@ sub read_capabilities() {
warning_message "Your capabilities file does not contain a Kernel Version -- using 2.6.30"; warning_message "Your capabilities file does not contain a Kernel Version -- using 2.6.30";
$capabilities{KERNELVERSION} = 20630; $capabilities{KERNELVERSION} = 20630;
} }
#
# Assume that this is available when using an old capabilities files
#
$capabilities{TCPMSS_TARGET} = 1 if ( ( $capabilities{CAPVERSION} || 0 ) < 40609 );
$helpers_aliases{ftp} = 'ftp-0', $capabilities{FTP_HELPER} = 1 if $capabilities{FTP0_HELPER}; $helpers_aliases{ftp} = 'ftp-0', $capabilities{FTP_HELPER} = 1 if $capabilities{FTP0_HELPER};
$helpers_aliases{irc} = 'irc-0', $capabilities{IRC_HELPER} = 1 if $capabilities{IRC0_HELPER}; $helpers_aliases{irc} = 'irc-0', $capabilities{IRC_HELPER} = 1 if $capabilities{IRC0_HELPER};
@@ -4960,56 +5105,41 @@ sub read_capabilities() {
} }
# #
# Get the system's capabilities, either by probing or by reading a capabilities file # Get the system's capabilities by probing
# #
sub get_capabilities( $ ) sub get_capabilities($)
{ {
my $export = $_[0]; $iptables = $config{$toolNAME};
if ( ! $export && $> == 0 ) { # $> == $EUID if ( $iptables ) {
$iptables = $config{$toolNAME}; fatal_error "$toolNAME=$iptables does not exist or is not executable" unless -x $iptables;
if ( $iptables ) {
fatal_error "$toolNAME=$iptables does not exist or is not executable" unless -x $iptables;
} else {
fatal_error "Can't find $toolname executable" unless $iptables = which $toolname;
}
#
# Determine if iptables supports the -w option
#
$iptablesw = qt1( "$iptables -w -L -n") ? '-w' : '';
my $iptables_restore=$iptables . '-restore';
fatal_error "$iptables_restore does not exist or is not executable" unless -x $iptables_restore;
$tc = $config{TC} || which 'tc';
if ( $tc ) {
fatal_error "TC=$tc does not exist or is not executable" unless -x $tc;
}
$ip = $config{IP} || which 'ip';
if ( $ip ) {
fatal_error "IP=$ip does not exist or is not executable" unless -x $ip;
}
load_kernel_modules;
if ( open_file 'capabilities' ) {
read_capabilities;
} else {
determine_capabilities;
}
} else { } else {
unless ( open_file 'capabilities' ) { fatal_error "Can't find $toolname executable" unless $iptables = which $toolname;
fatal_error "The -e compiler option requires a capabilities file" if $export;
fatal_error "Compiling under non-root uid requires a capabilities file";
}
read_capabilities;
} }
#
# Determine if iptables supports the -w option
#
$iptablesw = qt1( "$iptables -w -L -n") ? '-w' : '';
my $iptables_restore=$iptables . '-restore';
fatal_error "$iptables_restore does not exist or is not executable" unless -x $iptables_restore;
$tc = $config{TC} || which 'tc';
if ( $tc ) {
fatal_error "TC=$tc does not exist or is not executable" unless -x $tc;
}
$ip = $config{IP} || which 'ip';
if ( $ip ) {
fatal_error "IP=$ip does not exist or is not executable" unless -x $ip;
}
load_kernel_modules;
determine_capabilities unless $_[0];
} }
# #
@@ -5034,15 +5164,24 @@ sub unsupported_yes_no_warning( $ ) {
# #
# Process the params file # Process the params file
# #
sub get_params() { sub get_params( $ ) {
my $export = $_[0];
my $cygwin = ( $shorewallrc{HOST} eq 'cygwin' );
my $fn = find_file 'params'; my $fn = find_file 'params';
my %reserved = ( COMMAND => 1, CONFDIR => 1, SHAREDIR => 1, VARDIR => 1 ); my %reserved = ( COMMAND => 1, CONFDIR => 1, SHAREDIR => 1, VARDIR => 1 );
if ( -f $fn ) { if ( -f $fn ) {
my $shellpath = $export ? '/bin/sh' : $config{SHOREWALL_SHELL} || '/bin/sh';
$shellpath = which( $shellpath ) unless $shellpath =~ '/';
fatal_error "SHOREWALL_SHELL ($shellpath) is not found or is not executable" unless -x $shellpath;
progress_message2 "Processing $fn ..."; progress_message2 "Processing $fn ...";
my $command = "$FindBin::Bin/getparams $fn " . join( ':', @config_path ) . " $family"; my $command = "$shellpath $FindBin::Bin/getparams $fn " . join( ':', @config_path ) . " $family";
# #
# getparams silently sources the params file under 'set -a', then executes 'export -p' # getparams silently sources the params file under 'set -a', then executes 'export -p'
# #
@@ -5069,14 +5208,16 @@ sub get_params() {
$shell = BASH; $shell = BASH;
for ( @params ) { for ( @params ) {
if ( /^declare -x (.*?)="(.*[^\\])"$/ ) { chomp;
if ( $cygwin && /^declare -x (.*?)="(.*)"$/ ) {
$params{$1} = $2 unless $1 eq '_';
} elsif ( /^declare -x (.*?)="(.*[^\\])"$/ ) {
$params{$1} = $2 unless $1 eq '_'; $params{$1} = $2 unless $1 eq '_';
} elsif ( /^declare -x (.*?)="(.*)$/ ) { } elsif ( /^declare -x (.*?)="(.*)$/ ) {
$params{$variable=$1} = $2 eq '"' ? '' : "${2}\n"; $params{$variable=$1} = $2 eq '"' ? '' : "${2}\n";
} elsif ( /^declare -x (.*)\s+$/ || /^declare -x (.*)=""$/ ) { } elsif ( /^declare -x (.*)\s+$/ || /^declare -x (.*)=""$/ ) {
$params{$1} = ''; $params{$1} = '';
} else { } else {
chomp;
if ($variable) { if ($variable) {
s/"$//; s/"$//;
$params{$variable} .= $_; $params{$variable} .= $_;
@@ -5097,14 +5238,16 @@ sub get_params() {
$shell = OLDBASH; $shell = OLDBASH;
for ( @params ) { for ( @params ) {
if ( /^export (.*?)="(.*[^\\])"$/ ) { chomp;
if ( $cygwin && /^export (.*?)="(.*)"$/ ) {
$params{$1} = $2 unless $1 eq '_';
} elsif ( /^export (.*?)="(.*[^\\])"$/ ) {
$params{$1} = $2 unless $1 eq '_'; $params{$1} = $2 unless $1 eq '_';
} elsif ( /^export (.*?)="(.*)$/ ) { } elsif ( /^export (.*?)="(.*)$/ ) {
$params{$variable=$1} = $2 eq '"' ? '' : "${2}\n"; $params{$variable=$1} = $2 eq '"' ? '' : "${2}\n";
} elsif ( /^export ([^\s=]+)\s*$/ || /^export (.*)=""$/ ) { } elsif ( /^export ([^\s=]+)\s*$/ || /^export (.*)=""$/ ) {
$params{$1} = ''; $params{$1} = '';
} else { } else {
chomp;
if ($variable) { if ($variable) {
s/"$//; s/"$//;
$params{$variable} .= $_; $params{$variable} .= $_;
@@ -5124,6 +5267,7 @@ sub get_params() {
$shell = ASH; $shell = ASH;
for ( @params ) { for ( @params ) {
chomp;
if ( /^export (.*?)='(.*'"'"')$/ ) { if ( /^export (.*?)='(.*'"'"')$/ ) {
$params{$variable=$1}="${2}\n"; $params{$variable=$1}="${2}\n";
} elsif ( /^export (.*?)='(.*)'$/ ) { } elsif ( /^export (.*?)='(.*)'$/ ) {
@@ -5131,7 +5275,6 @@ sub get_params() {
} elsif ( /^export (.*?)='(.*)$/ ) { } elsif ( /^export (.*?)='(.*)$/ ) {
$params{$variable=$1}="${2}\n"; $params{$variable=$1}="${2}\n";
} else { } else {
chomp;
if ($variable) { if ($variable) {
s/'$//; s/'$//;
$params{$variable} .= $_; $params{$variable} .= $_;
@@ -5143,9 +5286,23 @@ sub get_params() {
} }
for ( keys %params ) { for ( keys %params ) {
unless ( $_ eq 'SHOREWALL_INIT_SCRIPT' ) { if ( /[^\w]/ ) {
fatal_error "The variable name $_ is reserved and may not be set in the params file" #
if /^SW_/ || /^SHOREWALL_/ || ( exists $config{$_} && ! exists $ENV{$_} ) || exists $reserved{$_}; # Useless variable with special characters in its name
#
delete $params{$_};
} elsif ( /^(?:SHLVL|OLDPWD)$/ ) {
#
# The shell running getparams generates those
#
delete $params{$_};
} else {
unless ( $_ eq 'SHOREWALL_INIT_SCRIPT' ) {
fatal_error "The variable name $_ is reserved and may not be set in the params file"
if /^SW_/ || /^SHOREWALL_/ || ( exists $config{$_} && ! exists $ENV{$_} ) || exists $reserved{$_};
}
$params{$_} = '' unless defined $params{$_};
} }
} }
@@ -5195,6 +5352,8 @@ sub export_params() {
next if exists $compiler_params{$param}; next if exists $compiler_params{$param};
my $value = $params{$param}; my $value = $params{$param};
chomp $value;
# #
# Values in %params are generated from the output of 'export -p'. # Values in %params are generated from the output of 'export -p'.
# The different shells have different conventions for delimiting # The different shells have different conventions for delimiting
@@ -5205,19 +5364,27 @@ sub export_params() {
$value =~ s/\\"/"/g; $value =~ s/\\"/"/g;
} elsif ( $shell == OLDBASH ) { } elsif ( $shell == OLDBASH ) {
$value =~ s/\\'/'/g; $value =~ s/\\'/'/g;
$value =~ s/\\"/"/g;
$value =~ s/\\\\/\\/g;
} else { } else {
$value =~ s/'"'"'/'/g; $value =~ s/'"'"'/'/g;
} }
# #
# Don't export pairs from %ENV # Don't export pairs from %ENV
# #
next if defined $ENV{$param} && $value eq $ENV{$param}; if ( defined $ENV{$param} ) {
next if $value eq $ENV{$param};
} elsif ( exists $ENV{$param} ) {
next unless supplied $value;
}
emit "#\n# From the params file\n#" unless $count++; emit "#\n# From the params file\n#" unless $count++;
# #
# We will use double quotes and escape embedded quotes with \. # We will use double quotes and escape embedded quotes with \.
# #
if ( $value =~ /[\s()['"]/ ) { if ( $value =~ /^"[^"]*"$/ ) {
emit "$param=$value";
} elsif ( $value =~ /[\s()['"]/ ) {
$value =~ s/"/\\"/g; $value =~ s/"/\\"/g;
emit "$param='$value'"; emit "$param='$value'";
} else { } else {
@@ -5240,7 +5407,7 @@ sub convert_to_directives() {
my $dirtest = qr|^$sharedir/+shorewall6?(?:/.*)?$|; my $dirtest = qr|^$sharedir/+shorewall6?(?:/.*)?$|;
progress_message3 "Converting 'FORMAT' and 'COMMENT' lines to compiler directives..."; progress_message3 "Converting 'FORMAT', 'SECTION' and 'COMMENT' lines to compiler directives...";
for my $dir ( @path ) { for my $dir ( @path ) {
unless ( $dir =~ /$dirtest/ ) { unless ( $dir =~ /$dirtest/ ) {
@@ -5275,6 +5442,7 @@ EOF
if ( system( "diff -q $file ${file}.bak > /dev/null" ) ) { if ( system( "diff -q $file ${file}.bak > /dev/null" ) ) {
progress_message3 " File $file updated - old file renamed ${file}.bak"; progress_message3 " File $file updated - old file renamed ${file}.bak";
} elsif ( rename "${file}.bak" , $file ) { } elsif ( rename "${file}.bak" , $file ) {
progress_message " File $file not updated -- no bare 'COMMENT', 'SECTION' or 'FORMAT' lines found";
progress_message " File $file not updated -- no bare 'COMMENT' or 'FORMAT' lines found"; progress_message " File $file not updated -- no bare 'COMMENT' or 'FORMAT' lines found";
} else { } else {
warning message "Unable to rename ${file}.bak to $file:$!"; warning message "Unable to rename ${file}.bak to $file:$!";
@@ -5312,7 +5480,39 @@ sub get_configuration( $$$$$ ) {
ensure_config_path; ensure_config_path;
get_params; my $default_path = '/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin';
default 'PATH' , $default_path;
if ( supplied( $ENV{PATH} ) ) {
$ENV{PATH} .= ":$default_path";
} else {
$ENV{PATH} = $default_path;
}
my $have_capabilities;
if ( $export || $> != 0 ) {
#
# Compiling for export or user not root -- must use a capabilties file
# We read it before processing the .conf file so that 'update' has
# the capabilities.
#
unless ( open_file 'capabilities' ) {
fatal_error "The -e compiler option requires a capabilities file" if $export;
fatal_error "Compiling under non-root uid requires a capabilities file";
}
read_capabilities;
$have_capabilities = 1;
} elsif ( open_file 'capabilities' ) {
read_capabilities;
$have_capabilities = 1;
}
get_params( $export );
process_shorewall_conf( $update, $annotate, $directives ); process_shorewall_conf( $update, $annotate, $directives );
@@ -5322,14 +5522,15 @@ sub get_configuration( $$$$$ ) {
unshift @INC, @config_path; unshift @INC, @config_path;
default 'PATH' , '/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin';
# #
# get_capabilities requires that the true settings of these options be established # get_capabilities requires that the true settings of these options be established
# #
default 'MODULE_PREFIX', 'ko ko.gz o o.gz gz'; default 'MODULE_PREFIX', 'ko ko.gz o o.gz gz';
default_yes_no 'LOAD_HELPERS_ONLY' , 'Yes'; default_yes_no 'LOAD_HELPERS_ONLY' , 'Yes';
get_capabilities( $export ); if ( ! $export && $> == 0 ) {
get_capabilities($have_capabilities);
}
my ( $val, $all ); my ( $val, $all );
@@ -5409,13 +5610,13 @@ sub get_configuration( $$$$$ ) {
my $match = have_capability( 'OLD_HL_MATCH' ) ? 'hashlimit' : 'hashlimit-upto'; my $match = have_capability( 'OLD_HL_MATCH' ) ? 'hashlimit' : 'hashlimit-upto';
my $units; my $units;
if ( $rate =~ /^[sd]:((\d+)(\/(sec|min|hour|day))):(\d+)$/ ) { if ( $rate =~ /^[sd]:((\d+)(\/(sec|min|second|minute|hour|day))):(\d+)$/ ) {
fatal_error "Invalid rate ($1)" unless $2; fatal_error "Invalid rate ($1)" unless $2;
fatal_error "Invalid burst value ($5)" unless $5; fatal_error "Invalid burst value ($5)" unless $5;
$limit .= "--$match $1 --hashlimit-burst $5 --hashlimit-name lograte --hashlimit-mode "; $limit .= "--$match $1 --hashlimit-burst $5 --hashlimit-name lograte --hashlimit-mode ";
$units = $4; $units = $4;
} elsif ( $rate =~ /^[sd]:((\d+)(\/(sec|min|hour|day))?)$/ ) { } elsif ( $rate =~ /^[sd]:((\d+)(\/(sec|min|second|minute|hour|day))?)$/ ) {
fatal_error "Invalid rate ($1)" unless $2; fatal_error "Invalid rate ($1)" unless $2;
$limit .= "--$match $1 --hashlimit-name lograte --hashlimit-mode "; $limit .= "--$match $1 --hashlimit-name lograte --hashlimit-mode ";
$units = $4; $units = $4;
@@ -5435,11 +5636,11 @@ sub get_configuration( $$$$$ ) {
$limit .= "--hashlimit-htable-expire $expire "; $limit .= "--hashlimit-htable-expire $expire ";
} }
} elsif ( $rate =~ /^((\d+)(\/(sec|min|hour|day))):(\d+)$/ ) { } elsif ( $rate =~ /^((\d+)(\/(sec|min|second|minute|hour|day))):(\d+)$/ ) {
fatal_error "Invalid rate ($1)" unless $2; fatal_error "Invalid rate ($1)" unless $2;
fatal_error "Invalid burst value ($5)" unless $5; fatal_error "Invalid burst value ($5)" unless $5;
$limit = "-m limit --limit $1 --limit-burst $5 "; $limit = "-m limit --limit $1 --limit-burst $5 ";
} elsif ( $rate =~ /^(\d+)(\/(sec|min|hour|day))?$/ ) { } elsif ( $rate =~ /^(\d+)(\/(sec|min|second|minute|hour|day))?$/ ) {
fatal_error "Invalid rate (${1}${2})" unless $1; fatal_error "Invalid rate (${1}${2})" unless $1;
$limit = "-m limit --limit $rate "; $limit = "-m limit --limit $rate ";
} else { } else {
@@ -5505,7 +5706,9 @@ sub get_configuration( $$$$$ ) {
fatal_error "LOG_MARTIANS=On is not supported in IPv6" if $config{LOG_MARTIANS} eq 'on'; fatal_error "LOG_MARTIANS=On is not supported in IPv6" if $config{LOG_MARTIANS} eq 'on';
} }
default 'STARTUP_LOG' , ''; default 'SHOREWALL_SHELL', '/bin/sh';
default 'STARTUP_LOG' , '';
if ( $config{STARTUP_LOG} ne '' ) { if ( $config{STARTUP_LOG} ne '' ) {
if ( supplied $config{LOG_VERBOSITY} ) { if ( supplied $config{LOG_VERBOSITY} ) {
@@ -5530,8 +5733,9 @@ sub get_configuration( $$$$$ ) {
default_yes_no 'DETECT_DNAT_IPADDRS' , ''; default_yes_no 'DETECT_DNAT_IPADDRS' , '';
default_yes_no 'CLEAR_TC' , $family == F_IPV4 ? 'Yes' : ''; default_yes_no 'CLEAR_TC' , $family == F_IPV4 ? 'Yes' : '';
if ( supplied $config{CLAMPMSS} ) { if ( supplied( $val = $config{CLAMPMSS} ) ) {
default_yes_no 'CLAMPMSS' , '' unless $config{CLAMPMSS} =~ /^\d+$/; default_yes_no 'CLAMPMSS' , '' unless $val =~ /^\d+$/;
require_capability 'TCPMSS_TARGET', "CLAMPMSS=$val", 's' if $config{CLAMPMSS};
} else { } else {
$config{CLAMPMSS} = ''; $config{CLAMPMSS} = '';
} }
@@ -5549,7 +5753,16 @@ sub get_configuration( $$$$$ ) {
unsupported_yes_no 'BRIDGING'; unsupported_yes_no 'BRIDGING';
unsupported_yes_no_warning 'RFC1918_STRICT'; unsupported_yes_no_warning 'RFC1918_STRICT';
default_yes_no 'SAVE_IPSETS' , ''; unless (default_yes_no 'SAVE_IPSETS', '', '*' ) {
$val = $config{SAVE_IPSETS};
unless ( $val eq 'ipv4' ) {
my @sets = split_list( $val , 'ipset' );
$globals{SAVED_IPSETS} = \@sets;
require_capability 'IPSET_V5', 'A saved ipset list', 's';
$config{SAVE_IPSETS} = '';
}
}
default_yes_no 'SAVE_ARPTABLES' , ''; default_yes_no 'SAVE_ARPTABLES' , '';
default_yes_no 'STARTUP_ENABLED' , 'Yes'; default_yes_no 'STARTUP_ENABLED' , 'Yes';
default_yes_no 'DELAYBLACKLISTLOAD' , ''; default_yes_no 'DELAYBLACKLISTLOAD' , '';
@@ -5622,6 +5835,7 @@ sub get_configuration( $$$$$ ) {
default_yes_no 'TRACK_RULES' , ''; default_yes_no 'TRACK_RULES' , '';
default_yes_no 'INLINE_MATCHES' , ''; default_yes_no 'INLINE_MATCHES' , '';
default_yes_no 'BASIC_FILTERS' , ''; default_yes_no 'BASIC_FILTERS' , '';
default_yes_no 'WORKAROUNDS' , 'Yes';
require_capability( 'BASIC_EMATCH', 'BASIC_FILTERS=Yes', 's' ) if $config{BASIC_FILTERS}; require_capability( 'BASIC_EMATCH', 'BASIC_FILTERS=Yes', 's' ) if $config{BASIC_FILTERS};
@@ -5717,6 +5931,10 @@ sub get_configuration( $$$$$ ) {
$globals{USER_MASK} = $globals{USER_BITS} = 0; $globals{USER_MASK} = $globals{USER_BITS} = 0;
} }
$val = $config{PROVIDER_OFFSET};
$globals{SMALL_MASK} = $val ? make_mask( $val ) : $globals{TC_MASK};
if ( supplied ( $val = $config{ZONE2ZONE} ) ) { if ( supplied ( $val = $config{ZONE2ZONE} ) ) {
fatal_error "Invalid ZONE2ZONE value ( $val )" unless $val =~ /^[2-]$/; fatal_error "Invalid ZONE2ZONE value ( $val )" unless $val =~ /^[2-]$/;
} else { } else {
@@ -5747,6 +5965,20 @@ 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_BACKEND} ) ) {
if ( $family == F_IPV4 && $val eq 'ULOG' ) {
$val = 'ipt_ULOG';
} elsif ( $val eq 'netlink' ) {
$val = 'nfnetlink_log';
} elsif ( $val eq 'LOG' ) {
$val = $family == F_IPV4 ? 'ipt_LOG' : 'ip6t_LOG';
} else {
fatal_error "Invalid LOG Backend ($val)";
}
$config{LOG_BACKEND} = $val;
}
warning_message "RFC1918_LOG_LEVEL=$config{RFC1918_LOG_LEVEL} ignored. The 'norfc1918' interface/host option is no longer supported" if $config{RFC1918_LOG_LEVEL}; warning_message "RFC1918_LOG_LEVEL=$config{RFC1918_LOG_LEVEL} ignored. The 'norfc1918' interface/host option is no longer supported" if $config{RFC1918_LOG_LEVEL};
default_log_level 'SMURF_LOG_LEVEL', ''; default_log_level 'SMURF_LOG_LEVEL', '';
@@ -6152,7 +6384,7 @@ 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) ) { for my $option ( qw(VERBOSITY LOGFILE LOGFORMAT ARPTABLES IPTABLES IP6TABLES IP TC IPSET PATH SHOREWALL_SHELL SUBSYSLOCK LOCKFILE RESTOREFILE WORKAROUNDS) ) {
conditionally_add_option $option; conditionally_add_option $option;
} }

View File

@@ -779,6 +779,18 @@ sub normalize_6addr( $ ) {
sub validate_6range( $$ ) { sub validate_6range( $$ ) {
my ( $low, $high ) = @_; my ( $low, $high ) = @_;
if ( $low =~ /^\[(.+)\]$/ ) {
$low = $1;
} elsif ( $low =~ /^\[(.+)\]\/(\d+)$/ ) {
$low = join( '/', $1, $2 );
}
if ( $high =~ /^\[(.+)\]$/ ) {
$high = $1;
} elsif ( $high =~ /^\[(.+)\]\/(\d+)$/ ) {
$high = join( '/', $1, $2 );
}
validate_6address $low, 0; validate_6address $low, 0;
validate_6address $high, 0; validate_6address $high, 0;

View File

@@ -44,6 +44,7 @@ our @EXPORT = qw( process_tos
setup_mac_lists setup_mac_lists
process_routestopped process_routestopped
process_stoppedrules process_stoppedrules
convert_routestopped
compile_stop_firewall compile_stop_firewall
generate_matrix generate_matrix
); );
@@ -76,7 +77,7 @@ sub process_tos() {
my ( $pretosref, $outtosref ); my ( $pretosref, $outtosref );
first_entry( sub { progress_message2 "$doing $fn..."; first_entry( sub { progress_message2 "$doing $fn...";
warning_message "Use of the tos file is deprecated in favor of the TOS target in tcrules"; warning_message "Use of the tos file is deprecated in favor of the TOS target in the 'mangle' file";
$pretosref = ensure_chain 'mangle' , $chain; $pretosref = ensure_chain 'mangle' , $chain;
$outtosref = ensure_chain 'mangle' , 'outtos'; $outtosref = ensure_chain 'mangle' , 'outtos';
} }
@@ -176,7 +177,7 @@ sub setup_ecn()
} }
if ( @hosts ) { if ( @hosts ) {
my @interfaces = ( keys %interfaces ); my @interfaces = ( sort { interface_number($a) <=> interface_number($b) } keys %interfaces );
progress_message "$doing ECN control on @interfaces..."; progress_message "$doing ECN control on @interfaces...";
@@ -360,14 +361,16 @@ sub remove_blacklist( $ ) {
while ( read_a_line( EMBEDDED_ENABLED | EXPAND_VARIABLES ) ) { while ( read_a_line( EMBEDDED_ENABLED | EXPAND_VARIABLES ) ) {
my ( $rule, $comment ) = split '#', $currentline, 2; my ( $rule, $comment ) = split '#', $currentline, 2;
if ( $rule =~ /blacklist/ ) { if ( $rule && $rule =~ /blacklist/ ) {
$changed = 1; $changed = 1;
if ( $comment ) { if ( $comment ) {
$comment =~ s/^/ / while $rule =~ s/blacklist,//; $comment =~ s/^/ / while $rule =~ s/blacklist,// || $rule =~ s/,blacklist//;
$rule =~ s/blacklist/ /g; $rule =~ s/blacklist/ /g;
$currentline = join( '#', $rule, $comment ); $currentline = join( '#', $rule, $comment );
} else { } else {
$currentline =~ s/blacklist,//g;
$currentline =~ s/,blacklist//g;
$currentline =~ s/blacklist/ /g; $currentline =~ s/blacklist/ /g;
} }
} }
@@ -385,25 +388,33 @@ sub remove_blacklist( $ ) {
} }
# #
# Convert a pre-4.4.25 blacklist to a 4.4.25 blacklist # Convert a pre-4.4.25 blacklist to a 4.4.25 blrules file
# #
sub convert_blacklist() { sub convert_blacklist() {
my $zones = find_zones_by_option 'blacklist', 'in'; my $zones = find_zones_by_option 'blacklist', 'in';
my $zones1 = find_zones_by_option 'blacklist', 'out'; my $zones1 = find_zones_by_option 'blacklist', 'out';
my ( $level, $disposition ) = @config{'BLACKLIST_LOG_LEVEL', 'BLACKLIST_DISPOSITION' }; my ( $level, $disposition ) = @config{'BLACKLIST_LOG_LEVEL', 'BLACKLIST_DISPOSITION' };
my $audit = $disposition =~ /^A_/; my $audit = $disposition =~ /^A_/;
my $target = $disposition eq 'REJECT' ? 'reject' : $disposition; my $target = $disposition;
my $orig_target = $target; my $orig_target = $target;
my @rules; my @rules;
if ( @$zones || @$zones1 ) { if ( @$zones || @$zones1 ) {
if ( supplied $level ) { $target = "$target:$level" if supplied $level;
$target = 'blacklog';
} elsif ( $audit ) {
$target = verify_audit( $disposition );
}
my $fn = open_file 'blacklist'; my $fn = open_file( 'blacklist' );
unless ( $fn ) {
if ( -f ( $fn = find_file( 'blacklist' ) ) ) {
if ( unlink( $fn ) ) {
warning_message "Empty blacklist file ($fn) removed";
} else {
warning_message "Unable to remove empty blacklist file $fn: $!";
}
}
return 0;
}
first_entry "Converting $fn..."; first_entry "Converting $fn...";
@@ -439,8 +450,6 @@ sub convert_blacklist() {
} else { } else {
warning_message "Duplicate 'audit' option ignored" if $auditone > 1; warning_message "Duplicate 'audit' option ignored" if $auditone > 1;
} }
$tgt = verify_audit( 'A_' . $target, $orig_target, $target );
} }
for ( @options ) { for ( @options ) {
@@ -471,7 +480,7 @@ sub convert_blacklist() {
} }
if ( @rules ) { if ( @rules ) {
my $fn1 = find_file( 'blrules' ); my $fn1 = find_writable_file( 'blrules' );
my $blrules; my $blrules;
my $date = localtime; my $date = localtime;
@@ -682,6 +691,163 @@ sub process_routestopped() {
} }
} }
sub convert_routestopped() {
if ( my $fn = open_file 'routestopped' ) {
my ( @allhosts, %source, %dest , %notrack, @rule );
my $seq = 0;
my $date = localtime;
my ( $stoppedrules, $fn1 );
if ( -f ( $fn1 = find_writable_file( 'stoppedrules' ) ) ) {
open $stoppedrules, '>>', $fn1 or fatal_error "Unable to open $fn1: $!";
} else {
open $stoppedrules, '>', $fn1 or fatal_error "Unable to open $fn1: $!";
print $stoppedrules <<'EOF';
#
# Shorewall version 4 - Stopped Rules File
#
# For information about entries in this file, type "man shorewall-stoppedrules"
#
# The manpage is also online at
# http://www.shorewall.net/manpages/shorewall-stoppedrules.html
#
# See http://shorewall.net/starting_and_stopping_shorewall.htm for additional
# information.
#
###############################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE
# PORT(S) PORT(S)
EOF
}
first_entry(
sub {
my $date = localtime;
progress_message2 "$doing $fn...";
print( $stoppedrules
"#\n" ,
"# Rules generated from routestopped file $fn by Shorewall $globals{VERSION} - $date\n" ,
"#\n" );
}
);
while ( read_a_line ( NORMAL_READ ) ) {
my ($interface, $hosts, $options , $proto, $ports, $sports ) =
split_line( 'routestopped file',
{ interface => 0, hosts => 1, options => 2, proto => 3, dport => 4, sport => 5 } );
my $interfaceref;
fatal_error 'INTERFACE must be specified' if $interface eq '-';
fatal_error "Unknown interface ($interface)" unless $interfaceref = known_interface $interface;
$hosts = ALLIP unless $hosts && $hosts ne '-';
my $routeback = 0;
my @hosts;
$seq++;
my $rule = "$proto\t$ports\t$sports";
$hosts = ALLIP if $hosts eq '-';
for my $host ( split /,/, $hosts ) {
fatal_error "Ipsets not allowed with SAVE_IPSETS=Yes" if $host =~ /^!?\+/ && $config{SAVE_IPSETS};
validate_host $host, 1;
push @hosts, "$interface|$host|$seq";
push @rule, $rule;
}
unless ( $options eq '-' ) {
for my $option (split /,/, $options ) {
if ( $option eq 'routeback' ) {
if ( $routeback ) {
warning_message "Duplicate 'routeback' option ignored";
} else {
$routeback = 1;
}
} elsif ( $option eq 'source' ) {
for my $host ( split /,/, $hosts ) {
$source{"$interface|$host|$seq"} = 1;
}
} elsif ( $option eq 'dest' ) {
for my $host ( split /,/, $hosts ) {
$dest{"$interface|$host|$seq"} = 1;
}
} elsif ( $option eq 'notrack' ) {
for my $host ( split /,/, $hosts ) {
$notrack{"$interface|$host|$seq"} = 1;
}
} else {
warning_message "Unknown routestopped option ( $option ) ignored" unless $option eq 'critical';
warning_message "The 'critical' option is no longer supported (or needed)";
}
}
}
if ( $routeback || $interfaceref->{options}{routeback} ) {
my $chainref = $filter_table->{FORWARD};
for my $host ( split /,/, $hosts ) {
print $stoppedrules "ACCEPT\t$interface:$host\t$interface:$host\n";
}
}
push @allhosts, @hosts;
}
for my $host ( @allhosts ) {
my ( $interface, $h, $seq ) = split /\|/, $host;
my $rule = shift @rule;
print $stoppedrules "ACCEPT\t$interface:$h\t\$FW\t$rule\n";
print $stoppedrules "ACCEPT\t\$FW\t$interface:$h\t$rule\n" unless $config{ADMINISABSENTMINDED};
my $matched = 0;
if ( $source{$host} ) {
print $stoppedrules "ACCEPT\t$interface:$h\t-\t$rule\n";
$matched = 1;
}
if ( $dest{$host} ) {
print $stoppedrules "ACCEPT\t-\t$interface:$h\t$rule\n";
$matched = 1;
}
if ( $notrack{$host} ) {
print $stoppedrules "NOTRACK\t$interface:$h\t-\t$rule\n";
print $stoppedrules "NOTRACK\t\$FW\t$interface:$h\t$rule\n";
}
unless ( $matched ) {
for my $host1 ( @allhosts ) {
unless ( $host eq $host1 ) {
my ( $interface1, $h1 , $seq1 ) = split /\|/, $host1;
print $stoppedrules "ACCEPT\t$interface:$h\t$interface1:$h1\t$rule\n";
}
}
}
}
rename $fn, "$fn.bak";
progress_message2 "Routestopped file $fn saved in $fn.bak";
close $stoppedrules;
} elsif ( -f ( my $fn1 = find_file( 'routestopped' ) ) ) {
if ( unlink( $fn1 ) ) {
warning_message "Empty routestopped file ($fn1) removed";
} else {
warning_message "Unable to remove empty routestopped file $fn1: $!";
}
}
}
# #
# Process the stoppedrules file. Returns true if the file was non-empty. # Process the stoppedrules file. Returns true if the file was non-empty.
# #
@@ -690,11 +856,10 @@ sub process_stoppedrules() {
my $result; my $result;
if ( my $fn = open_file 'stoppedrules' , 1, 1 ) { if ( my $fn = open_file 'stoppedrules' , 1, 1 ) {
first_entry sub() { first_entry sub () {
progress_message2("$doing $fn..."); progress_message2( "$doing $fn..." );
unless ( $config{ADMINISABSENTMINDED} ) { unless ( $config{ADMINISABSENTMINDED} ) {
warning_message("Entries in the routestopped file are processed as if ADMINISABSENTMINDED=Yes"); insert_ijump $filter_table ->{$_}, j => 'ACCEPT', 0, state_imatch 'ESTABLISHED,RELATED' for qw/INPUT FORWARD/;
$config{ADMINISABSENTMINDED} = 'Yes';
} }
}; };
@@ -775,8 +940,8 @@ sub process_stoppedrules() {
sub setup_mss(); sub setup_mss();
sub add_common_rules ( $$ ) { sub add_common_rules ( $$$ ) {
my ( $upgrade_blacklist, $upgrade_tcrules ) = @_; my ( $upgrade_blacklist, $upgrade_tcrules , $upgrade_routestopped ) = @_;
my $interface; my $interface;
my $chainref; my $chainref;
my $target; my $target;
@@ -855,7 +1020,7 @@ sub add_common_rules ( $$ ) {
my $interfaceref = find_interface $interface; my $interfaceref = find_interface $interface;
unless ( $interfaceref->{physical} eq 'lo' ) { unless ( $interfaceref->{physical} eq loopback_interface ) {
unless ( $interfaceref->{options}{ignore} & NO_SFILTER || $interfaceref->{options}{rpfilter} ) { unless ( $interfaceref->{options}{ignore} & NO_SFILTER || $interfaceref->{options}{rpfilter} ) {
my @filters = @{$interfaceref->{filter}}; my @filters = @{$interfaceref->{filter}};
@@ -919,18 +1084,35 @@ sub add_common_rules ( $$ ) {
$target = $policy eq 'REJECT' ? 'reject' : $policy; $target = $policy eq 'REJECT' ? 'reject' : $policy;
} }
add_ijump( ensure_mangle_chain( 'rpfilter' ), my $rpfilterref = ensure_mangle_chain( 'rpfilter' );
if ( $family == F_IPV4 ) {
for $interface ( @$list ) {
if ( get_interface_option( $interface, 'dhcp' ) ) {
add_ijump( $rpfilterref,
j => 'RETURN',
s => NILIPv4,
p => UDP,
dport => 67,
sport => 68
);
last;
}
}
}
add_ijump( $rpfilterref,
j => $target, j => $target,
rpfilter => '--validmark --invert', rpfilter => '--validmark --invert',
state_imatch 'NEW,RELATED,INVALID', state_imatch 'NEW,RELATED,INVALID',
@ipsec @ipsec
); );
} }
run_user_exit1 'initdone'; run_user_exit1 'initdone';
if ( $upgrade_blacklist ) { if ( $upgrade_blacklist ) {
exit 0 unless convert_blacklist || $upgrade_tcrules; exit 0 unless convert_blacklist || $upgrade_tcrules || $upgrade_routestopped;
} else { } else {
setup_blacklist; setup_blacklist;
} }
@@ -994,7 +1176,7 @@ sub add_common_rules ( $$ ) {
for my $hostref ( @$list ) { for my $hostref ( @$list ) {
$interface = $hostref->[0]; $interface = $hostref->[0];
my $ipsec = $hostref->[1]; my $ipsec = $hostref->[1];
my @policy = have_ipsec ? ( policy => "--pol $ipsec --dir in" ) : (); my @policy = $ipsec && have_ipsec ? ( policy => "--pol $ipsec --dir in" ) : ();
my $target = source_exclusion( $hostref->[3], $chainref ); my $target = source_exclusion( $hostref->[3], $chainref );
for $chain ( option_chains $interface ) { for $chain ( option_chains $interface ) {
@@ -1118,7 +1300,8 @@ sub add_common_rules ( $$ ) {
for my $hostref ( @$list ) { for my $hostref ( @$list ) {
my $interface = $hostref->[0]; my $interface = $hostref->[0];
my $target = source_exclusion( $hostref->[3], $chainref ); my $target = source_exclusion( $hostref->[3], $chainref );
my @policy = have_ipsec ? ( policy => "--pol $hostref->[1] --dir in" ) : (); my $ipsec = $hostref->[1];
my @policy = $ipsec && have_ipsec ? ( policy => "--pol $ipsec --dir in" ) : ();
for $chain ( option_chains $interface ) { for $chain ( option_chains $interface ) {
add_ijump( $filter_table->{$chain} , j => $target, p => 'tcp', imatch_source_net( $hostref->[2] ), @policy ); add_ijump( $filter_table->{$chain} , j => $target, p => 'tcp', imatch_source_net( $hostref->[2] ), @policy );
@@ -1289,7 +1472,7 @@ sub setup_mac_lists( $ ) {
for my $hostref ( @$maclist_hosts ) { for my $hostref ( @$maclist_hosts ) {
my $interface = $hostref->[0]; my $interface = $hostref->[0];
my $ipsec = $hostref->[1]; my $ipsec = $hostref->[1];
my @policy = have_ipsec ? ( policy => "--pol $ipsec --dir in" ) : (); my @policy = $ipsec && have_ipsec ? ( policy => "--pol $ipsec --dir in" ) : ();
my @source = imatch_source_net $hostref->[2]; my @source = imatch_source_net $hostref->[2];
my @state = have_capability( 'RAW_TABLE' ) ? state_imatch 'NEW,UNTRACKED' : state_imatch 'NEW'; my @state = have_capability( 'RAW_TABLE' ) ? state_imatch 'NEW,UNTRACKED' : state_imatch 'NEW';
@@ -1452,7 +1635,7 @@ sub handle_loopback_traffic() {
my $rawout = $raw_table->{OUTPUT}; my $rawout = $raw_table->{OUTPUT};
my $rulenum = 0; my $rulenum = 0;
my $loopback = loopback_zones; my $loopback = loopback_zones;
my $loref = known_interface('lo'); my $loref = known_interface(loopback_interface);
my $unmanaged; my $unmanaged;
my $outchainref; my $outchainref;
@@ -1463,17 +1646,29 @@ sub handle_loopback_traffic() {
# We have a vserver zone -- route output through a separate chain # We have a vserver zone -- route output through a separate chain
# #
$outchainref = new_standard_chain 'loopback'; $outchainref = new_standard_chain 'loopback';
add_ijump $filter_table->{OUTPUT}, j => $outchainref, o => 'lo';
if ( have_capability 'IFACE_MATCH' ) {
add_ijump $filter_table->{OUTPUT}, j => $outchainref, iface => '--dev-out --loopback';
} else {
add_ijump $filter_table->{OUTPUT}, j => $outchainref, o => loopback_interface;
}
} else { } else {
# #
# Only the firewall -- just use the OUTPUT chain # Only the firewall -- just use the OUTPUT chain
# #
if ( $unmanaged = $loref && $loref->{options}{unmanaged} ) { if ( $unmanaged = $loref && $loref->{options}{unmanaged} ) {
add_ijump( $filter_table->{INPUT}, j => 'ACCEPT', i => 'lo' ); if ( have_capability 'IFACE_MATCH' ) {
add_ijump( $filter_table->{OUTPUT}, j => 'ACCEPT', o => 'lo' ); add_ijump( $filter_table->{OUTPUT}, j => 'ACCEPT', iface => '--dev-out --loopback' );
} else {
add_ijump( $filter_table->{OUTPUT}, j => 'ACCEPT', o => loopback_interface );
}
} else { } else {
$outchainref = $filter_table->{OUTPUT}; $outchainref = $filter_table->{OUTPUT};
@rule = ( o => 'lo'); if ( have_capability 'IFACE_MATCH' ) {
@rule = ( iface => '--dev-out --loopback' );
} else {
@rule = ( o => loopback_interface );
}
} }
} }
@@ -1506,7 +1701,7 @@ sub handle_loopback_traffic() {
# Handle conntrack rules # Handle conntrack rules
# #
if ( $notrackref->{referenced} ) { if ( $notrackref->{referenced} ) {
for my $hostref ( @{defined_zone( $z1 )->{hosts}{ip}{'%vserver%'}} ) { for my $hostref ( sort { $a->{type} cmp $b->{type} } @{defined_zone( $z1 )->{hosts}{ip}{'%vserver%'}} ) {
my $exclusion = source_exclusion( $hostref->{exclusions}, $notrackref); my $exclusion = source_exclusion( $hostref->{exclusions}, $notrackref);
my @ipsec_match = match_ipsec_in $z1 , $hostref; my @ipsec_match = match_ipsec_in $z1 , $hostref;
@@ -1527,8 +1722,8 @@ sub handle_loopback_traffic() {
# #
my $source_hosts_ref = defined_zone( $z1 )->{hosts}; my $source_hosts_ref = defined_zone( $z1 )->{hosts};
for my $typeref ( values %{$source_hosts_ref} ) { for my $typeref ( sort { $a->{type} cmp $b->{type} } values %{$source_hosts_ref} ) {
for my $hostref ( @{$typeref->{'%vserver%'}} ) { for my $hostref ( sort { $a->{type} cmp $b->{type} } @{$typeref->{'%vserver%'}} ) {
my $exclusion = source_exclusion( $hostref->{exclusions}, $natref); my $exclusion = source_exclusion( $hostref->{exclusions}, $natref);
for my $net ( @{$hostref->{hosts}} ) { for my $net ( @{$hostref->{hosts}} ) {
@@ -1550,9 +1745,9 @@ sub add_interface_jumps {
our %input_jump_added; our %input_jump_added;
our %output_jump_added; our %output_jump_added;
our %forward_jump_added; our %forward_jump_added;
my @interfaces = grep $_ ne '%vserver%', @_; my @interfaces = sort grep $_ ne '%vserver%', @_;
my $dummy; my $dummy;
my $lo_jump_added = interface_zone( 'lo' ) && ! get_interface_option( 'lo', 'destonly' ); my $lo_jump_added = interface_zone( loopback_interface ) && ! get_interface_option( loopback_interface, 'destonly' );
# #
# Add Nat jumps # Add Nat jumps
# #
@@ -1582,7 +1777,13 @@ sub add_interface_jumps {
my $outputref = $filter_table->{output_chain $interface}; my $outputref = $filter_table->{output_chain $interface};
my $interfaceref = find_interface($interface); my $interfaceref = find_interface($interface);
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', i => 'lo' if $interfaceref->{physical} eq '+' && ! $lo_jump_added++; if ( $interfaceref->{physical} eq '+' && ! $lo_jump_added++ ) {
if ( have_capability 'IFACE_MATCH' ) {
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', iface => '--dev-in --loopback';
} else {
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', i => loopback_interface;
}
}
if ( $interfaceref->{options}{port} ) { if ( $interfaceref->{options}{port} ) {
my $bridge = $interfaceref->{bridge}; my $bridge = $interfaceref->{bridge};
@@ -1621,7 +1822,13 @@ sub add_interface_jumps {
} }
} }
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', i => 'lo' unless $lo_jump_added++; unless ( $lo_jump_added++ ) {
if ( have_capability 'IFACE_MATCH' ) {
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', iface => '--dev-in --loopback';
} else {
add_ijump $filter_table->{INPUT} , j => 'ACCEPT', i => loopback_interface;
}
}
handle_loopback_traffic; handle_loopback_traffic;
} }
@@ -1785,7 +1992,7 @@ sub add_output_jumps( $$$$$$$ ) {
our @vservers; our @vservers;
our %output_jump_added; our %output_jump_added;
my $chain1 = rules_target firewall_zone , $zone; my $chain1 = rules_target( firewall_zone , $zone );
my $chain1ref = $filter_table->{$chain1}; my $chain1ref = $filter_table->{$chain1};
my $nextchain = dest_exclusion( $exclusions, $chain1 ); my $nextchain = dest_exclusion( $exclusions, $chain1 );
my $outputref; my $outputref;
@@ -2112,11 +2319,9 @@ sub optimize1_zones( $$@ ) {
# #
sub generate_matrix() { sub generate_matrix() {
my @interfaces = ( managed_interfaces ); my @interfaces = ( managed_interfaces );
# my @zones = off_firewall_zones;
# Should this be the real PREROUTING chain?
# our @vservers = vserver_zones;
my @zones = off_firewall_zones;
our @vservers = vserver_zones;
my $interface_jumps_added = 0; my $interface_jumps_added = 0;
@@ -2161,7 +2366,8 @@ sub generate_matrix() {
# #
# Take care of PREROUTING, INPUT and OUTPUT jumps # Take care of PREROUTING, INPUT and OUTPUT jumps
# #
for my $typeref ( values %$source_hosts_ref ) { for my $type ( sort keys %$source_hosts_ref ) {
my $typeref = $source_hosts_ref->{$type};
for my $interface ( sort { interface_number( $a ) <=> interface_number( $b ) } keys %$typeref ) { for my $interface ( sort { interface_number( $a ) <=> interface_number( $b ) } keys %$typeref ) {
if ( get_physical( $interface ) eq '+' ) { if ( get_physical( $interface ) eq '+' ) {
# #
@@ -2234,7 +2440,6 @@ sub generate_matrix() {
my $chain = rules_target $zone, $zone1; my $chain = rules_target $zone, $zone1;
next unless $chain; # CONTINUE policy with no rules next unless $chain; # CONTINUE policy with no rules
my $num_ifaces = 0; my $num_ifaces = 0;
if ( $zone eq $zone1 ) { if ( $zone eq $zone1 ) {
@@ -2246,8 +2451,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 $typeref ( values %{$zone1ref->{hosts}} ) { for my $type ( sort keys %{$zone1ref->{hosts}} ) {
my $typeref = $zone1ref->{hosts}{$type};
for my $interface ( sort { interface_number( $a ) <=> interface_number( $b ) } keys %$typeref ) { for my $interface ( sort { interface_number( $a ) <=> interface_number( $b ) } keys %$typeref ) {
for my $hostref ( @{$typeref->{$interface}} ) { for my $hostref ( @{$typeref->{$interface}} ) {
next if $hostref->{options}{sourceonly}; next if $hostref->{options}{sourceonly};
@@ -2368,20 +2574,29 @@ sub setup_mss( ) {
# #
# Compile the stop_firewall() function # Compile the stop_firewall() function
# #
sub compile_stop_firewall( $$$ ) { sub compile_stop_firewall( $$$$ ) {
my ( $test, $export, $have_arptables ) = @_; my ( $test, $export, $have_arptables, $routestopped ) = @_;
my $input = $filter_table->{INPUT}; my $input = $filter_table->{INPUT};
my $output = $filter_table->{OUTPUT}; my $output = $filter_table->{OUTPUT};
my $forward = $filter_table->{FORWARD}; my $forward = $filter_table->{FORWARD};
emit <<'EOF'; if ( $config{WORKAROUNDS} ) {
emit <<'EOF';
# #
# Stop/restore the firewall after an error or because of a 'stop' or 'clear' command # Stop/restore the firewall after an error or because of a 'stop' or 'clear' command
# #
stop_firewall() { stop_firewall() {
local hack local hack
EOF EOF
} else {
emit <<'EOF';
#
# Stop/restore the firewall after an error or because of a 'stop' or 'clear' command
#
stop_firewall() {
EOF
}
$output->{policy} = 'ACCEPT' if $config{ADMINISABSENTMINDED}; $output->{policy} = 'ACCEPT' if $config{ADMINISABSENTMINDED};
@@ -2394,7 +2609,7 @@ EOF
case $COMMAND in case $COMMAND in
stop|clear|restore) stop|clear|restore)
if chain_exists dynamic; then if chain_exists dynamic; then
${IPTABLES}-save -t filter | grep '^-A dynamic' > ${VARDIR}/.dynamic ${IPTABLES}-save -t filter | grep '^-A dynamic' | fgrep -v -- '-j ACCEPT' > ${VARDIR}/.dynamic
fi fi
;; ;;
*) *)
@@ -2409,7 +2624,7 @@ EOF
case $COMMAND in case $COMMAND in
stop|clear|restore) stop|clear|restore)
if chain_exists dynamic; then if chain_exists dynamic; then
${IP6TABLES}-save -t filter | grep '^-A dynamic' > ${VARDIR}/.dynamic ${IP6TABLES}-save -t filter | grep '^-A dynamic' | fgrep -v -- '-j ACCEPT' > ${VARDIR}/.dynamic
fi fi
;; ;;
*) *)
@@ -2549,10 +2764,20 @@ EOF
} }
} }
process_routestopped unless process_stoppedrules; if ( $routestopped ) {
convert_routestopped;
process_stoppedrules;
} else {
process_routestopped unless process_stoppedrules;
}
add_ijump $input, j => 'ACCEPT', i => 'lo'; if ( have_capability 'IFACE_MATCH' ) {
add_ijump $output, j => 'ACCEPT', o => 'lo' unless $config{ADMINISABSENTMINDED}; add_ijump $input, j => 'ACCEPT', iface => '--dev-in --loopback';
add_ijump $output, j => 'ACCEPT', iface => '--dev-out --loopback' unless $config{ADMINISABSENTMINDED};
} else {
add_ijump $input, j => 'ACCEPT', i => loopback_interface;
add_ijump $output, j => 'ACCEPT', o => loopback_interface unless $config{ADMINISABSENTMINDED};
}
my $interfaces = find_interfaces_by_option 'dhcp'; my $interfaces = find_interfaces_by_option 'dhcp';
@@ -2606,42 +2831,11 @@ EOF
my @ipsets = all_ipsets; my @ipsets = all_ipsets;
if ( @ipsets || ( $config{SAVE_IPSETS} && have_ipset_rules ) ) { if ( @ipsets || @{$globals{SAVED_IPSETS}} || ( $config{SAVE_IPSETS} && have_ipset_rules ) ) {
emit <<'EOF'; emit( '',
' save_ipsets ${VARDIR}/ipsets.save' );
case $IPSET in
*/*)
if [ ! -x "$IPSET" ]; then
error_message "ERROR: IPSET=$IPSET does not exist or is not executable - ipsets are not saved"
IPSET=
fi
;;
*)
IPSET="$(mywhich $IPSET)"
[ -n "$IPSET" ] || error_message "ERROR: The ipset utility cannot be located - ipsets are not saved"
;;
esac
if [ -n "$IPSET" ]; then
if [ -f /etc/debian_version ] && [ $(cat /etc/debian_version) = 5.0.3 ]; then
#
# The 'grep -v' is a hack for a bug in ipset's nethash implementation when xtables-addons is applied to Lenny
#
hack='| grep -v /31'
else
hack=
fi
if eval $IPSET -S $hack > ${VARDIR}/ipsets.tmp; then
#
# Don't save an 'empty' file
#
grep -qE '^(-N|create )' ${VARDIR}/ipsets.tmp && mv -f ${VARDIR}/ipsets.tmp ${VARDIR}/ipsets.save
fi
fi
EOF
} }
emit ' emit '
set_state "Stopped" set_state "Stopped"

View File

@@ -80,7 +80,7 @@ sub process_one_masq1( $$$$$$$$$$ )
if ( $interfacelist =~ /^INLINE\((.+)\)$/ ) { if ( $interfacelist =~ /^INLINE\((.+)\)$/ ) {
$interfacelist = $1; $interfacelist = $1;
$inlinematches = get_inline_matches(0); $inlinematches = get_inline_matches(0);
} elsif ( $config{INLINE_MATCHES} ) { } else {
$inlinematches = get_inline_matches(0); $inlinematches = get_inline_matches(0);
} }
# #

View File

@@ -42,6 +42,7 @@ our @EXPORT = qw(
setup_source_routing setup_source_routing
setup_accept_ra setup_accept_ra
setup_forwarding setup_forwarding
setup_log_backend
); );
our @EXPORT_OK = qw( setup_interface_proc ); our @EXPORT_OK = qw( setup_interface_proc );
our $VERSION = 'MODULEVERSION'; our $VERSION = 'MODULEVERSION';
@@ -348,5 +349,43 @@ sub setup_interface_proc( $ ) {
} }
} }
sub setup_log_backend($) {
if ( my $setting = $config{LOG_BACKEND} ) {
my $family = shift;
my $file = '/proc/sys/net/netfilter/nf_log/' . ( $family == F_IPV4 ? '2' : '10' );
emit( 'progress_message2 "Setting up log backend"',
'',
"if [ -f $file ]; then"
);
if ( $setting =~ /ip6?t_log/i ) {
my $alternative = 'nf_log_ipv' . $family;
emit( " setting=$setting",
'',
" fgrep -q $setting /proc/net/netfilter/nf_log || setting=$alternative",
'',
" if echo \$setting > $file; then",
' progress_message "Log Backend set to $setting"',
' else',
' error_message "WARNING: Unable to set log backend to $setting"',
' fi',
'else',
" error_message 'WARNING: $file does not exist - log backend not set'",
"fi\n"
);
} else {
emit( " if echo $setting > $file; then",
" progress_message 'Log Backend set to $setting'",
' else',
" error_message 'WARNING: Unable to set log backend to $setting'",
' fi',
'else',
" error_message 'WARNING: $file does not exist - log backend not set'",
"fi\n" );
}
}
}
1; 1;

View File

@@ -44,9 +44,10 @@ our @EXPORT = qw( process_providers
compile_updown compile_updown
setup_load_distribution setup_load_distribution
have_providers have_providers
map_provider_to_interface
); );
our @EXPORT_OK = qw( initialize provider_realm ); our @EXPORT_OK = qw( initialize provider_realm );
our $VERSION = '4.4_24'; our $VERSION = 'MODULEVERSION';
use constant { LOCAL_TABLE => 255, use constant { LOCAL_TABLE => 255,
MAIN_TABLE => 254, MAIN_TABLE => 254,
@@ -59,7 +60,6 @@ our @routemarked_providers;
our %routemarked_interfaces; our %routemarked_interfaces;
our @routemarked_interfaces; our @routemarked_interfaces;
our %provider_interfaces; our %provider_interfaces;
our @load_providers;
our @load_interfaces; our @load_interfaces;
our $balancing; our $balancing;
@@ -97,7 +97,6 @@ sub initialize( $ ) {
%routemarked_interfaces = (); %routemarked_interfaces = ();
@routemarked_interfaces = (); @routemarked_interfaces = ();
%provider_interfaces = (); %provider_interfaces = ();
@load_providers = ();
@load_interfaces = (); @load_interfaces = ();
$balancing = 0; $balancing = 0;
$fallback = 0; $fallback = 0;
@@ -373,7 +372,7 @@ sub start_provider( $$$$$ ) {
emit "\n#\n# Add $what $table ($number)\n#"; emit "\n#\n# Add $what $table ($number)\n#";
if ( $number ) { if ( $number >= 0 ) {
emit "start_provider_$table() {"; emit "start_provider_$table() {";
} else { } else {
emit "start_interface_$table() {"; emit "start_interface_$table() {";
@@ -383,7 +382,7 @@ sub start_provider( $$$$$ ) {
emit $test; emit $test;
push_indent; push_indent;
if ( $number ) { if ( $number >= 0 ) {
emit "qt ip -$family route flush table $id"; emit "qt ip -$family route flush table $id";
emit "echo \"\$IP -$family route flush table $id > /dev/null 2>&1\" > \${VARDIR}/undo_${table}_routing"; emit "echo \"\$IP -$family route flush table $id > /dev/null 2>&1\" > \${VARDIR}/undo_${table}_routing";
} else { } else {
@@ -460,6 +459,9 @@ sub process_a_provider( $ ) {
fatal_error "A bridge port ($interface) may not be configured as a provider interface" if port_to_bridge $interface; fatal_error "A bridge port ($interface) may not be configured as a provider interface" if port_to_bridge $interface;
#
# Switch to the logical name if a physical name was passed
#
my $physical; my $physical;
if ( $interface eq $interfaceref->{name} ) { if ( $interface eq $interfaceref->{name} ) {
@@ -527,8 +529,9 @@ sub process_a_provider( $ ) {
$track = 0; $track = 0;
} elsif ( $option =~ /^balance=(\d+)$/ ) { } elsif ( $option =~ /^balance=(\d+)$/ ) {
fatal_error q('balance=<weight>' is not available in IPv6) if $family == F_IPV6; fatal_error q('balance=<weight>' is not available in IPv6) if $family == F_IPV6;
fatal_error 'The balance setting must be non-zero' unless $1;
$balance = $1; $balance = $1;
} elsif ( $option eq 'balance' ) { } elsif ( $option eq 'balance' || $option eq 'primary') {
$balance = 1; $balance = 1;
} elsif ( $option eq 'loose' ) { } elsif ( $option eq 'loose' ) {
$loose = 1; $loose = 1;
@@ -563,8 +566,8 @@ sub process_a_provider( $ ) {
$track = 0 if $config{TRACK_PROVIDERS}; $track = 0 if $config{TRACK_PROVIDERS};
$default_balance = 0 if $config{USE_DEFAULT_RT}; $default_balance = 0 if $config{USE_DEFAULT_RT};
} elsif ( $option =~ /^load=(0?\.\d{1,8})/ ) { } elsif ( $option =~ /^load=(0?\.\d{1,8})/ ) {
$load = $1; $load = sprintf "%1.8f", $1;
require_capability 'STATISTIC_MATCH', "load=$load", 's'; require_capability 'STATISTIC_MATCH', "load=$1", 's';
} elsif ( $option eq 'autosrc' ) { } elsif ( $option eq 'autosrc' ) {
$noautosrc = 0; $noautosrc = 0;
} elsif ( $option eq 'noautosrc' ) { } elsif ( $option eq 'noautosrc' ) {
@@ -690,11 +693,9 @@ sub process_a_provider( $ ) {
$provider_interfaces{$interface} = $table unless $shared; $provider_interfaces{$interface} = $table unless $shared;
if ( $track ) { if ( $track ) {
fatal_error "The 'track' option requires a numeric value in the MARK column" if $mark eq '-';
if ( $routemarked_interfaces{$interface} ) { if ( $routemarked_interfaces{$interface} ) {
fatal_error "Interface $interface is tracked through an earlier provider" if $routemarked_interfaces{$interface} == ROUTEMARKED_UNSHARED; fatal_error "Interface $interface is tracked through an earlier provider" if $routemarked_interfaces{$interface} == ROUTEMARKED_UNSHARED;
fatal_error "Multiple providers through the same interface must their IP address specified in the INTERFACES" unless $shared; fatal_error "Multiple providers through the same interface must have their IP address specified in the INTERFACES column" unless $shared;
} else { } else {
$routemarked_interfaces{$interface} = $shared ? ROUTEMARKED_SHARED : ROUTEMARKED_UNSHARED; $routemarked_interfaces{$interface} = $shared ? ROUTEMARKED_SHARED : ROUTEMARKED_UNSHARED;
push @routemarked_interfaces, $interface; push @routemarked_interfaces, $interface;
@@ -843,12 +844,12 @@ CEOF
if ( $hostroute ) { if ( $hostroute ) {
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
emit "run_ip route replace $gateway src $address dev $physical ${mtu}"; emit qq(run_ip route replace $gateway src $address dev $physical ${mtu});
emit "run_ip route replace $gateway src $address dev $physical ${mtu}table $id $realm"; emit qq(run_ip route replace $gateway src $address dev $physical ${mtu}table $id $realm);
} else { } else {
emit "qt \$IP -6 route add $gateway src $address dev $physical ${mtu}"; emit qq(qt \$IP -6 route add $gateway src $address dev $physical ${mtu});
emit "qt \$IP -6 route del $gateway src $address dev $physical ${mtu}table $id $realm"; emit qq(qt \$IP -6 route del $gateway src $address dev $physical ${mtu}table $id $realm);
emit "run_ip route add $gateway src $address dev $physical ${mtu}table $id $realm"; emit qq(run_ip route add $gateway src $address dev $physical ${mtu}table $id $realm);
} }
} }
@@ -1082,10 +1083,8 @@ CEOF
} }
} }
sub add_an_rtrule( ) { sub add_an_rtrule1( $$$$$ ) {
my ( $source, $dest, $provider, $priority, $originalmark ) = my ( $source, $dest, $provider, $priority, $originalmark ) = @_;
split_line( 'rtrules file',
{ source => 0, dest => 1, provider => 2, priority => 3 , mark => 4 } );
our $current_if; our $current_if;
@@ -1174,6 +1173,17 @@ sub add_an_rtrule( ) {
progress_message " Routing rule \"$currentline\" $done"; progress_message " Routing rule \"$currentline\" $done";
} }
sub add_an_rtrule( ) {
my ( $sources, $dests, $provider, $priority, $originalmark ) =
split_line( 'rtrules file',
{ source => 0, dest => 1, provider => 2, priority => 3 , mark => 4 } );
for my $source ( split_list( $sources, "source" ) ) {
for my $dest (split_list( $dests , "dest" ) ) {
add_an_rtrule1( $source, $dest, $provider, $priority, $originalmark );
}
}
}
sub add_a_route( ) { sub add_a_route( ) {
my ( $provider, $dest, $gateway, $device ) = my ( $provider, $dest, $gateway, $device ) =
split_line( 'routes file', split_line( 'routes file',
@@ -1293,9 +1303,11 @@ sub start_providers() {
emit_unindented "$providers{$_}{number}\t$_" unless $providers{$_}{pseudo}; emit_unindented "$providers{$_}{number}\t$_" unless $providers{$_}{pseudo};
} }
emit_unindented "EOF\n"; emit_unindented 'EOF';
emit "fi\n"; emit( 'else',
' error_message "WARNING: /etc/iproute2/rt_tables is missing or is not writeable"',
"fi\n" );
} }
emit ( '#', emit ( '#',
@@ -1366,15 +1378,32 @@ sub finish_providers() {
emit( 'fi', emit( 'fi',
'' ); '' );
} else { } else {
if ( ( $fallback || @load_interfaces ) && $config{USE_DEFAULT_RT} ) {
emit ( q(#),
q(# Delete any default routes in the 'main' table),
q(#),
"while qt \$IP -$family route del default table $main; do",
' true',
'done',
''
);
} else {
emit ( q(#),
q(# We don't have any 'balance'. 'load=' or 'fallback=' providers so we restore any default route that we've saved),
q(#),
qq(restore_default_route $config{USE_DEFAULT_RT}),
''
);
}
emit ( '#', emit ( '#',
'# We don\'t have any \'balance\' providers so we restore any default route that we\'ve saved', '# Delete any routes in the \'balance\' table',
'#', '#',
"restore_default_route $config{USE_DEFAULT_RT}" , "while qt \$IP -$family route del default table $balance; do",
'#', ' true',
'# And delete any routes in the \'balance\' table', 'done',
'#', ''
"qt \$IP -$family route del default table $balance", );
'' );
} }
if ( $fallback ) { if ( $fallback ) {
@@ -1428,10 +1457,13 @@ sub process_providers( $ ) {
# #
# Treat optional interfaces as pseudo-providers # Treat optional interfaces as pseudo-providers
# #
my $num = -65536;
for ( grep interface_is_optional( $_ ) && ! $provider_interfaces{ $_ }, all_real_interfaces ) { for ( grep interface_is_optional( $_ ) && ! $provider_interfaces{ $_ }, all_real_interfaces ) {
$num++;
# #
# TABLE NUMBER MARK DUPLICATE INTERFACE GATEWAY OPTIONS COPY # TABLE NUMBER MARK DUPLICATE INTERFACE GATEWAY OPTIONS COPY
$currentline = var_base($_) ." 0 - - $_ - - -"; $currentline = var_base($_) . " $num - - $_ - - -";
# #
$pseudoproviders += process_a_provider(1); $pseudoproviders += process_a_provider(1);
} }
@@ -1500,7 +1532,7 @@ EOF
" start_provider_$provider" ); " start_provider_$provider" );
} }
emit ( ' else', emit ( ' elif [ -z "$2" ]; then',
" startup_error \"Interface $providerref->{physical} is already enabled\"", " startup_error \"Interface $providerref->{physical} is already enabled\"",
' fi', ' fi',
' ;;' ' ;;'
@@ -1548,7 +1580,7 @@ EOF
} }
emit( " stop_$providerref->{what}_$provider", emit( " stop_$providerref->{what}_$provider",
' else', ' elif [ -z "$2" ]; then',
" startup_error \"Interface $providerref->{physical} is already disabled\"", " startup_error \"Interface $providerref->{physical} is already disabled\"",
' fi', ' fi',
' ;;' ' ;;'
@@ -1573,10 +1605,45 @@ sub have_providers() {
return our $providers; return our $providers;
} }
sub map_provider_to_interface() {
my $haveoptional;
for my $providerref ( sort { $a->{number} cmp $b->{number} } values %providers ) {
if ( $providerref->{optional} ) {
unless ( $haveoptional++ ) {
emit( 'if [ -n "$interface" ]; then',
' case $interface in' );
push_indent;
push_indent;
}
emit( $providerref->{provider} . ')',
' interface=' . $providerref->{physical},
' ;;' );
}
}
if ( $haveoptional ) {
pop_indent;
pop_indent;
emit( ' esac',
"fi\n"
);
}
}
sub setup_providers() { sub setup_providers() {
our $providers; our $providers;
our $pseudoproviders;
if ( $providers ) { if ( $providers ) {
if ( $maxload ) {
warning_message "The sum of the provider interface loads exceeds 1.000000" if $maxload > 1;
warning_message "The sum of the provider interface loads is less than 1.000000" if $maxload < 1;
}
emit "\nif [ -z \"\$g_noroutes\" ]; then"; emit "\nif [ -z \"\$g_noroutes\" ]; then";
push_indent; push_indent;
@@ -1604,6 +1671,11 @@ sub setup_providers() {
push_indent; push_indent;
if ( $pseudoproviders ) {
emit '';
emit "start_$providers{$_}->{what}_$_" for @providers;
}
emit "\nundo_routing"; emit "\nundo_routing";
emit "restore_default_route $config{USE_DEFAULT_RT}"; emit "restore_default_route $config{USE_DEFAULT_RT}";
@@ -1714,12 +1786,12 @@ sub compile_updown() {
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), q( detect_configuration $1),
q( enable_provider $1), q( enable_provider $1),
q( elif [ "$PHASE" != post-down ]; then # pre-down or not Debian) , q( elif [ "$PHASE" != post-down ]; then # pre-down or not Debian) ,
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), q( detect_configuration $1),
q( disable_provider $1) , q( disable_provider $1) ,
q( fi) , q( fi) ,
q(elif [ "$COMMAND" = up ]; then) , q(elif [ "$COMMAND" = up ]; then) ,
@@ -1892,8 +1964,10 @@ sub handle_optional_interfaces( $ ) {
if ( @$interfaces ) { if ( @$interfaces ) {
my $require = $config{REQUIRE_INTERFACE}; my $require = $config{REQUIRE_INTERFACE};
my $gencase = shift;
verify_required_interfaces( shift ); verify_required_interfaces( $gencase );
emit '' if $gencase;
emit( 'HAVE_INTERFACE=', '' ) if $require; emit( 'HAVE_INTERFACE=', '' ) if $require;
# #
@@ -1924,6 +1998,19 @@ sub handle_optional_interfaces( $ ) {
emit( "$physical)" ), push_indent if $wildcards; emit( "$physical)" ), push_indent if $wildcards;
if ( $provider eq $physical ) {
#
# Just an optional interface, or provider and interface are the same
#
emit qq(if [ -z "\$interface" -o "\$interface" = "$physical" ]; then);
} else {
#
# Provider
#
emit qq(if [ -z "\$interface" -o "\$interface" = "$physical" ]; then);
}
push_indent;
if ( $providerref->{gatewaycase} eq 'detect' ) { if ( $providerref->{gatewaycase} eq 'detect' ) {
emit qq(if interface_is_usable $physical && [ -n "$providerref->{gateway}" ]; then); emit qq(if interface_is_usable $physical && [ -n "$providerref->{gateway}" ]; then);
} else { } else {
@@ -1935,6 +2022,10 @@ sub handle_optional_interfaces( $ ) {
emit( " SW_${base}_IS_USABLE=Yes" , emit( " SW_${base}_IS_USABLE=Yes" ,
'fi' ); 'fi' );
pop_indent;
emit( "fi\n" );
emit( ';;' ), pop_indent if $wildcards; emit( ';;' ), pop_indent if $wildcards;
} }
@@ -2041,7 +2132,7 @@ sub handle_stickiness( $ ) {
$rule1 = clone_irule( $_ ); $rule1 = clone_irule( $_ );
set_rule_target( $rule1, 'MARK', "--set-mark $mark" ); set_rule_target( $rule1, 'MARK', "--set-mark $mark" );
set_rule_option( $rule1, 'recent', "--name $list --update --seconds 300 --reap" ); set_rule_option( $rule1, 'recent', "--name $list --update --seconds $rule1->{t} --reap" );
$rule2 = clone_irule( $_ ); $rule2 = clone_irule( $_ );
@@ -2076,7 +2167,7 @@ sub handle_stickiness( $ ) {
$rule1 = clone_irule $_; $rule1 = clone_irule $_;
set_rule_target( $rule1, 'MARK', "--set-mark $mark" ); set_rule_target( $rule1, 'MARK', "--set-mark $mark" );
set_rule_option( $rule1, 'recent', " --name $list --rdest --update --seconds 300 --reap" ); set_rule_option( $rule1, 'recent', " --name $list --rdest --update --seconds $rule1->{t} --reap" );
$rule2 = clone_irule $_; $rule2 = clone_irule $_;

View File

@@ -154,7 +154,7 @@ sub setup_proxy_arp() {
emit ''; emit '';
for my $interface ( keys %reset ) { for my $interface ( sort keys %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" ,
@@ -163,7 +163,7 @@ sub setup_proxy_arp() {
} }
} }
for my $interface ( keys %set ) { for my $interface ( sort keys %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

@@ -113,7 +113,7 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
$action = $1; $action = $1;
$disposition = $1; $disposition = $1;
} }
} elsif ( $action =~ /^IP(6)?TABLES\((.+)\)(:(.*))$/ ) { } elsif ( $action =~ /^IP(6)?TABLES\((.+)\)(:(.*))?$/ ) {
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
fatal_error 'Invalid conntrack ACTION (IP6TABLES)' if $1; fatal_error 'Invalid conntrack ACTION (IP6TABLES)' if $1;
} else { } else {
@@ -125,8 +125,8 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
fatal_error "Unknown target ($tgt)" unless $target_type; fatal_error "Unknown target ($tgt)" unless $target_type;
fatal_error "The $tgt TARGET is not allowed in the raw table" unless $target_type & RAW_TABLE; fatal_error "The $tgt TARGET is not allowed in the raw table" unless $target_type & RAW_TABLE;
$disposition = $tgt; $disposition = $tgt;
$action = 2; $action = $2;
validate_level( $level = $3 ) if supplied $3; validate_level( $level = $4 ) if supplied $4;
} else { } else {
( $disposition, my ( $option, $args ), $level ) = split ':', $action, 4; ( $disposition, my ( $option, $args ), $level ) = split ':', $action, 4;
@@ -146,7 +146,7 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
if ( $option eq 'helper' ) { if ( $option eq 'helper' ) {
my $modifiers = ''; my $modifiers = '';
$disposition = "helper"; $disposition = 'helper';
if ( $args =~ /^([-\w.]+)\((.+)\)$/ ) { if ( $args =~ /^([-\w.]+)\((.+)\)$/ ) {
$args = $1; $args = $1;
@@ -156,8 +156,9 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
fatal_error "Invalid helper' ($args)" if $args =~ /,/; fatal_error "Invalid helper' ($args)" if $args =~ /,/;
validate_helper( $args, $proto ); validate_helper( $args, $proto );
$action = "CT --helper $helpers_aliases{$args}"; $action = "CT --helper $helpers_aliases{$args}";
$exception_rule = do_proto( $proto, '-', '-' );
$exception_rule = do_proto( $proto, '-', '-' );
for my $mod ( split_list1( $modifiers, 'ctevents' ) ) { for my $mod ( split_list1( $modifiers, 'ctevents' ) ) {
fatal_error "Invalid helper option ($mod)" unless $mod =~ /^(\w+)=(.+)$/; fatal_error "Invalid helper option ($mod)" unless $mod =~ /^(\w+)=(.+)$/;
$mod = $1; $mod = $1;
@@ -176,6 +177,17 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
fatal_error "Invalid helper option ($mod)"; fatal_error "Invalid helper option ($mod)";
} }
} }
} elsif ( $option eq 'ctevents' ) {
$disposition = 'helper';
for ( split_list( $args, 'ctevents' ) ) {
fatal_error "Invalid 'ctevents' event ($_)" unless $valid_ctevent{$_};
}
$action = "CT --ctevents $args";
} elsif ( $option eq 'expevents' ) {
fatal_error "Invalid expevent argument ($args)" unless $args eq 'new';
$action = 'CT --expevents new';
} else { } else {
fatal_error "Invalid CT option ($option)"; fatal_error "Invalid CT option ($option)";
} }
@@ -263,11 +275,13 @@ sub process_format( $ ) {
$file_format = $format; $file_format = $format;
} }
sub setup_conntrack() { sub setup_conntrack($) {
my $convert = shift;
my $fn;
for my $name ( qw/notrack conntrack/ ) { for my $name ( qw/notrack conntrack/ ) {
my $fn = open_file( $name, 3 , 1 ); $fn = open_file( $name, 3 , 1 );
if ( $fn ) { if ( $fn ) {
@@ -329,12 +343,76 @@ sub setup_conntrack() {
} else { } else {
warning_message "Unable to remove empty notrack file ($fn): $!"; warning_message "Unable to remove empty notrack file ($fn): $!";
} }
$convert = undef;
}
}
} elsif ( $name eq 'notrack' ) {
$convert = undef;
if ( -f ( my $fn1 = find_file( $name ) ) ) {
if ( unlink( $fn1 ) ) {
warning_message "Empty notrack file ($fn1) removed";
} else { } else {
warning_message "Non-empty notrack file ($fn); please move its contents to the conntrack file"; warning_message "Unable to remove empty notrack file ($fn1): $!";
} }
} }
} }
} }
if ( $convert ) {
my $conntrack;
my $empty = 1;
my $date = localtime;
if ( $fn ) {
open $conntrack, '>>', $fn or fatal_error "Unable to open $fn for notrack conversion: $!";
} else {
open $conntrack, '>', $fn = find_file 'conntrack' or fatal_error "Unable to open $fn for notrack conversion: $!";
print $conntrack <<'EOF';
#
# Shorewall version 5 - conntrack File
#
# For information about entries in this file, type "man shorewall-conntrack"
#
##############################################################################################################
EOF
print $conntrack '?' . "FORMAT 3\n";
print $conntrack <<'EOF';
#ACTION SOURCE DESTINATION PROTO DEST SOURCE USER/ SWITCH
# PORT(S) PORT(S) GROUP
EOF
}
print( $conntrack
"#\n" ,
"# Rules generated from notrack file $fn by Shorewall $globals{VERSION} - $date\n" ,
"#\n" );
$fn = open_file( 'notrack' , 3, 1 ) || fatal_error "Unable to open the notrack file for conversion: $!";
while ( read_a_line( PLAIN_READ ) ) {
#
# Don't copy the header comments from the old notrack file
#
next if $empty && ( $currentline =~ /^\s*#/ || $currentline =~ /^\s*$/ );
if ( $empty ) {
#
# First non-commentary line
#
$empty = undef;
print $conntrack '?' . "FORMAT 1\n" unless $currentline =~ /^\s*\??FORMAT/i;
}
print $conntrack "$currentline\n";
}
rename $fn, "$fn.bak" or fatal_error "Unable to rename $fn to $fn.bak: $!";
progress_message2 "notrack file $fn saved in $fn.bak"
}
} }
1; 1;

View File

@@ -44,7 +44,7 @@ use strict;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT = qw( our @EXPORT = qw(
process_policies process_policies
apply_policy_rules complete_policy_chains
complete_standard_chain complete_standard_chain
setup_syn_flood_chains setup_syn_flood_chains
save_policies save_policies
@@ -224,6 +224,7 @@ sub initialize( $ ) {
$family = shift; $family = shift;
# #
# Chains created as a result of entries in the policy file # Chains created as a result of entries in the policy file
#
@policy_chains = (); @policy_chains = ();
# #
# This is updated from the *_DEFAULT settings in shorewall.conf. Those settings were stored # This is updated from the *_DEFAULT settings in shorewall.conf. Those settings were stored
@@ -348,44 +349,44 @@ sub new_policy_chain($$$$$)
# #
sub set_policy_chain($$$$$$) sub set_policy_chain($$$$$$)
{ {
my ($source, $dest, $chain1, $chainref, $policy, $intrazone) = @_; my ( $chain, $source, $dest, $polchainref, $policy, $intrazone ) = @_;
my $chainref1 = $filter_table->{$chain1}; my $chainref = $filter_table->{$chain};
if ( $chainref1 ) { if ( $chainref ) {
if ( $intrazone && $source eq $dest && $chainref1->{provisional} ) { if ( $intrazone && $source eq $dest && $chainref->{provisional} ) {
$chainref1->{policychain} = ''; $chainref->{policychain} = '';
$chainref1->{provisional} = ''; $chainref->{provisional} = '';
} }
} else { } else {
$chainref1 = new_rules_chain $chain1; $chainref = new_rules_chain $chain;
} }
unless ( $chainref1->{policychain} ) { unless ( $chainref->{policychain} ) {
if ( $config{EXPAND_POLICIES} ) { if ( $config{EXPAND_POLICIES} ) {
# #
# We convert the canonical chain into a policy chain, using the settings of the # We convert the canonical chain into a policy chain, using the settings of the
# passed policy chain. # passed policy chain.
# #
$chainref1->{policychain} = $chain1; $chainref->{policychain} = $chain;
$chainref1->{loglevel} = $chainref->{loglevel} if defined $chainref->{loglevel}; $chainref->{loglevel} = $polchainref->{loglevel} if defined $polchainref->{loglevel};
$chainref1->{audit} = $chainref->{audit} if defined $chainref->{audit}; $chainref->{audit} = $polchainref->{audit} if defined $polchainref->{audit};
if ( defined $chainref->{synparams} ) { if ( defined $polchainref->{synparams} ) {
$chainref1->{synparams} = $chainref->{synparams}; $chainref->{synparams} = $polchainref->{synparams};
$chainref1->{synchain} = $chainref->{synchain}; $chainref->{synchain} = $polchainref->{synchain};
} }
$chainref1->{default} = $chainref->{default} if defined $chainref->{default}; $chainref->{default} = $polchainref->{default} if defined $polchainref->{default};
$chainref1->{is_policy} = 1; $chainref->{is_policy} = 1;
push @policy_chains, $chainref1; push @policy_chains, $chainref;
} else { } else {
$chainref1->{policychain} = $chainref->{name}; $chainref->{policychain} = $polchainref->{name};
} }
$chainref1->{policy} = $policy; $chainref->{policy} = $policy;
$chainref1->{policypair} = [ $source, $dest ]; $chainref->{policypair} = [ $source, $dest ];
$chainref1->{origin} = $chainref->{origin}; $chainref->{origin} = $polchainref->{origin};
} }
} }
@@ -454,13 +455,12 @@ sub process_default_action( $$$$ ) {
} elsif ( ( $targets{$def} || 0 ) == INLINE ) { } elsif ( ( $targets{$def} || 0 ) == INLINE ) {
$default = $def; $default = $def;
$default = "$def($param)" if supplied $param; $default = "$def($param)" if supplied $param;
$default = join( ':', $default, $level ) if $level ne 'none';
} elsif ( $default_option ) { } elsif ( $default_option ) {
fatal_error "Unknown Action ($default) in $policy setting"; fatal_error "Unknown Action ($default) in $policy setting";
} else { } else {
fatal_error "Unknown Default Action ($default)"; fatal_error "Unknown Default Action ($default)";
} }
$default = join( ':', $default, $level ) if $level ne 'none';
} else { } else {
$default = $default_actions{$policy} || 'none'; $default = $default_actions{$policy} || 'none';
} }
@@ -468,6 +468,64 @@ sub process_default_action( $$$$ ) {
$default; $default;
} }
#
# Verify an NFQUEUE specification and return the appropriate ip[6]tables target
#
sub handle_nfqueue( $$ ) {
my ($params, $allow_bypass ) = @_;
my ( $action, $bypass );
my ( $queue1, $queue2, $queuenum1, $queuenum2 );
require_capability( 'NFQUEUE_TARGET', 'NFQUEUE Rules and Policies', '' );
if ( supplied( $params ) ) {
( my $queue, $bypass, my $junk ) = split ',', $params, 3;
fatal_error "Invalid NFQUEUE parameter list ($params)" if defined $junk;
if ( supplied $queue ) {
if ( $queue eq 'bypass' ) {
fatal_error "'bypass' is not allowed in this context" unless $allow_bypass;
fatal_error "Invalid NFQUEUE options (bypass,$bypass)" if supplied $bypass;
return 'NFQUEUE --queue-bypass';
}
( $queue1, $queue2 ) = split ':', $queue, 2;
fatal_error "Invalid NFQUEUE parameter list ($params)" unless supplied $queue1;
$queuenum1 = numeric_value( $queue1 );
fatal_error "Invalid NFQUEUE queue number ($queue1)" unless defined( $queuenum1) && $queuenum1 >= 0 && $queuenum1 <= 65535;
if ( supplied $queue2 ) {
$queuenum2 = numeric_value( $queue2 );
fatal_error "Invalid NFQUEUE queue number ($queue2)" unless defined( $queuenum2) && $queuenum2 >= 0 && $queuenum2 <= 65535 && $queuenum1 < $queuenum2;
}
} else {
$queuenum1 = 0;
}
} else {
$queuenum1 = 0;
}
if ( supplied $bypass ) {
fatal_error "Invalid NFQUEUE option ($bypass)" if $bypass ne 'bypass';
fatal_error "'bypass' is not allowed in this context" unless $allow_bypass;
$bypass =' --queue-bypass';
} else {
$bypass = '';
}
if ( supplied $queue2 ) {
return "NFQUEUE --queue-balance ${queuenum1}:${queuenum2}${bypass}";
} else {
return "NFQUEUE --queue-num ${queuenum1}${bypass}";
}
}
# #
# Process an entry in the policy file. # Process an entry in the policy file.
# #
@@ -518,11 +576,9 @@ sub process_a_policy() {
$default = process_default_action( $originalpolicy, $policy, $default, $level ); $default = process_default_action( $originalpolicy, $policy, $default, $level );
if ( defined $queue ) { if ( defined $queue ) {
fatal_error "Invalid policy ($policy($queue))" unless $policy eq 'NFQUEUE'; $policy = handle_nfqueue( $queue,
require_capability( 'NFQUEUE_TARGET', 'An NFQUEUE Policy', 's' ); 0 # Don't allow 'bypass'
my $queuenum = numeric_value( $queue ); );
fatal_error "Invalid NFQUEUE queue number ($queue)" unless defined( $queuenum) && $queuenum <= 65535;
$policy = "NFQUEUE --queue-num $queuenum";
} elsif ( $policy eq 'NONE' ) { } elsif ( $policy eq 'NONE' ) {
fatal_error "NONE policy not allowed with \"all\"" fatal_error "NONE policy not allowed with \"all\""
if $clientwild || $serverwild; if $clientwild || $serverwild;
@@ -548,10 +604,10 @@ sub process_a_policy() {
$chainref->{provisional} = 0; $chainref->{provisional} = 0;
$chainref->{policy} = $policy; $chainref->{policy} = $policy;
} else { } else {
fatal_error qq(Policy "$client $server $policy" duplicates earlier policy "@{$chainref->{policypair}} $chainref->{policy}"); fatal_error qq(Policy "$client $server $originalpolicy" duplicates earlier policy "@{$chainref->{policypair}} $chainref->{policy}");
} }
} elsif ( $chainref->{policy} ) { } elsif ( $chainref->{policy} ) {
fatal_error qq(Policy "$client $server $policy" duplicates earlier policy "@{$chainref->{policypair}} $chainref->{policy}"); fatal_error qq(Policy "$client $server $originalpolicy" duplicates earlier policy "@{$chainref->{policypair}} $chainref->{policy}");
} else { } else {
convert_to_policy_chain( $chainref, $client, $server, $policy, 0 , $audit ); convert_to_policy_chain( $chainref, $client, $server, $policy, 0 , $audit );
push @policy_chains, ( $chainref ) unless $config{EXPAND_POLICIES} && ( $clientwild || $serverwild ); push @policy_chains, ( $chainref ) unless $config{EXPAND_POLICIES} && ( $clientwild || $serverwild );
@@ -582,24 +638,24 @@ sub process_a_policy() {
if ( $serverwild ) { if ( $serverwild ) {
for my $zone ( @zonelist ) { for my $zone ( @zonelist ) {
for my $zone1 ( @zonelist ) { for my $zone1 ( @zonelist ) {
set_policy_chain $client, $server, rules_chain( ${zone}, ${zone1} ), $chainref, $policy, $intrazone; set_policy_chain rules_chain( ${zone}, ${zone1} ), $client, $server, $chainref, $policy, $intrazone;
print_policy $zone, $zone1, $policy, $chain; print_policy $zone, $zone1, $originalpolicy, $chain;
} }
} }
} else { } else {
for my $zone ( all_zones ) { for my $zone ( all_zones ) {
set_policy_chain $client, $server, rules_chain( ${zone}, ${server} ), $chainref, $policy, $intrazone; set_policy_chain rules_chain( ${zone}, ${server} ), $client, $server, $chainref, $policy, $intrazone;
print_policy $zone, $server, $policy, $chain; print_policy $zone, $server, $originalpolicy, $chain;
} }
} }
} elsif ( $serverwild ) { } elsif ( $serverwild ) {
for my $zone ( @zonelist ) { for my $zone ( @zonelist ) {
set_policy_chain $client, $server, rules_chain( ${client}, ${zone} ), $chainref, $policy, $intrazone; set_policy_chain rules_chain( ${client}, ${zone} ), $client, $server, $chainref, $policy, $intrazone;
print_policy $client, $zone, $policy, $chain; print_policy $client, $zone, $originalpolicy, $chain;
} }
} else { } else {
print_policy $client, $server, $policy, $chain; print_policy $client, $server, $originalpolicy, $chain;
} }
} }
@@ -670,8 +726,8 @@ sub process_policies()
unless ( $zone eq $zone1 ) { unless ( $zone eq $zone1 ) {
my $name = rules_chain( $zone, $zone1 ); my $name = rules_chain( $zone, $zone1 );
my $name1 = rules_chain( $zone1, $zone ); my $name1 = rules_chain( $zone1, $zone );
set_policy_chain( $zone, $zone1, $name, ensure_rules_chain( $name ), 'NONE', 0 ); set_policy_chain( $name, $zone, $zone1, ensure_rules_chain( $name ), 'NONE', 0 );
set_policy_chain( $zone1, $zone, $name1, ensure_rules_chain( $name1 ), 'NONE', 0 ); set_policy_chain( $name1, $zone1, $zone, ensure_rules_chain( $name1 ), 'NONE', 0 );
} }
} }
} elsif ( $type == LOOPBACK ) { } elsif ( $type == LOOPBACK ) {
@@ -679,8 +735,8 @@ sub process_policies()
unless ( $zone eq $zone1 || zone_type( $zone1 ) == LOOPBACK ) { unless ( $zone eq $zone1 || zone_type( $zone1 ) == LOOPBACK ) {
my $name = rules_chain( $zone, $zone1 ); my $name = rules_chain( $zone, $zone1 );
my $name1 = rules_chain( $zone1, $zone ); my $name1 = rules_chain( $zone1, $zone );
set_policy_chain( $zone, $zone1, $name, ensure_rules_chain( $name ), 'NONE', 0 ); set_policy_chain( $name, $zone, $zone1, ensure_rules_chain( $name ), 'NONE', 0 );
set_policy_chain( $zone1, $zone, $name1, ensure_rules_chain( $name1 ), 'NONE', 0 ); set_policy_chain( $name1, $zone1, $zone, ensure_rules_chain( $name1 ), 'NONE', 0 );
} }
} }
} }
@@ -712,9 +768,9 @@ sub process_policies()
# #
# Policy Rule application # Policy Rule application
# #
sub process_inline ($$$$$$$$$$$$$$$$$$$$$); sub process_inline ($$$$$$$$$$$$$$$$$$$$$$);
sub policy_rules( $$$$$ ) { sub add_policy_rules( $$$$$ ) {
my ( $chainref , $target, $loglevel, $default, $dropmulticast ) = @_; my ( $chainref , $target, $loglevel, $default, $dropmulticast ) = @_;
unless ( $target eq 'NONE' ) { unless ( $target eq 'NONE' ) {
@@ -737,6 +793,7 @@ sub policy_rules( $$$$$ ) {
process_inline( $action, #Inline process_inline( $action, #Inline
$chainref, #Chain $chainref, #Chain
'', #Matches '', #Matches
'', #Matches1
$loglevel, #Log Level and Tag $loglevel, #Log Level and Tag
$default, #Target $default, #Target
$param || '', #Param $param || '', #Param
@@ -774,7 +831,7 @@ sub report_syn_flood_protection() {
# #
# Complete a policy chain - Add policy-enforcing rules and syn flood, if specified # Complete a policy chain - Add policy-enforcing rules and syn flood, if specified
# #
sub default_policy( $$$ ) { sub complete_policy_chain( $$$ ) { #Chainref, Source Zone, Destination Zone
my $chainref = $_[0]; my $chainref = $_[0];
my $policyref = $filter_table->{$chainref->{policychain}}; my $policyref = $filter_table->{$chainref->{policychain}};
my $synparams = $policyref->{synparams}; my $synparams = $policyref->{synparams};
@@ -785,20 +842,20 @@ sub default_policy( $$$ ) {
assert( $policyref ); assert( $policyref );
if ( $chainref eq $policyref ) { if ( $chainref eq $policyref ) {
policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST}; add_policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
} else { } else {
if ( $policy eq 'ACCEPT' || $policy eq 'QUEUE' || $policy =~ /^NFQUEUE/ ) { if ( $policy eq 'ACCEPT' || $policy eq 'QUEUE' || $policy =~ /^NFQUEUE/ ) {
if ( $synparams ) { if ( $synparams ) {
report_syn_flood_protection; report_syn_flood_protection;
policy_rules $chainref , $policy , $loglevel , $default, $config{MULTICAST}; add_policy_rules $chainref , $policy , $loglevel , $default, $config{MULTICAST};
} else { } else {
add_ijump $chainref, g => $policyref; add_ijump $chainref, g => $policyref;
$chainref = $policyref; $chainref = $policyref;
policy_rules( $chainref, $policy, $loglevel, $default, $config{MULTICAST} ) if $default =~/^macro\./; add_policy_rules( $chainref, $policy, $loglevel, $default, $config{MULTICAST} ) if $default =~/^macro\./;
} }
} elsif ( $policy eq 'CONTINUE' ) { } elsif ( $policy eq 'CONTINUE' ) {
report_syn_flood_protection if $synparams; report_syn_flood_protection if $synparams;
policy_rules $chainref , $policy , $loglevel , $default, $config{MULTICAST}; add_policy_rules $chainref , $policy , $loglevel , $default, $config{MULTICAST};
} else { } else {
report_syn_flood_protection if $synparams; report_syn_flood_protection if $synparams;
add_ijump $chainref , g => $policyref; add_ijump $chainref , g => $policyref;
@@ -814,7 +871,7 @@ sub ensure_rules_chain( $ );
# #
# Finish all policy Chains # Finish all policy Chains
# #
sub apply_policy_rules() { sub complete_policy_chains() {
progress_message2 'Applying Policies...'; progress_message2 'Applying Policies...';
for my $chainref ( @policy_chains ) { for my $chainref ( @policy_chains ) {
@@ -845,7 +902,7 @@ sub apply_policy_rules() {
if ( $name =~ /^all[-2]|[-2]all$/ ) { if ( $name =~ /^all[-2]|[-2]all$/ ) {
run_user_exit $chainref; run_user_exit $chainref;
policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST}; add_policy_rules $chainref , $policy, $loglevel , $default, $config{MULTICAST};
} }
} }
} }
@@ -856,7 +913,7 @@ sub apply_policy_rules() {
if ( $chainref->{referenced} ) { if ( $chainref->{referenced} ) {
run_user_exit $chainref; run_user_exit $chainref;
default_policy $chainref, $zone, $zone1; complete_policy_chain $chainref, $zone, $zone1;
} }
} }
} }
@@ -890,7 +947,7 @@ sub complete_standard_chain ( $$$$ ) {
} }
policy_rules $stdchainref , $policy , $loglevel, $defaultaction, 0; add_policy_rules $stdchainref , $policy , $loglevel, $defaultaction, 0;
} }
# #
@@ -1140,7 +1197,7 @@ sub normalize_action_name( $ ) {
# #
# Produce a recognizable target from a normalized action # Produce a recognizable target from a normalized action
# #
sub externalize( $ ) { sub external_name( $ ) {
my ( $target, $level, $tag, $params ) = split /:/, shift, 4; my ( $target, $level, $tag, $params ) = split /:/, shift, 4;
$target = join( '', $target, '(', $params , ')' ) if $params; $target = join( '', $target, '(', $params , ')' ) if $params;
@@ -1622,7 +1679,7 @@ my %builtinops = ( 'dropBcast' => \&dropBcast,
'Limit' => \&Limit, 'Limit' => \&Limit,
); );
sub process_rule ( $$$$$$$$$$$$$$$$$$$ ); sub process_rule ( $$$$$$$$$$$$$$$$$$$$ );
# #
# Populate an action invocation chain. As new action tuples are encountered, # Populate an action invocation chain. As new action tuples are encountered,
@@ -1686,6 +1743,7 @@ sub process_action($$) {
} }
process_rule( $chainref, process_rule( $chainref,
'',
'', '',
$nolog ? $target : merge_levels( join(':', @actparms{'chain','loglevel','logtag'}), $target ), $nolog ? $target : merge_levels( join(':', @actparms{'chain','loglevel','logtag'}), $target ),
'', '',
@@ -1748,14 +1806,31 @@ sub process_actions() {
undef, #Columns undef, #Columns
1 ); #Allow inline matches 1 ); #Allow inline matches
my $type = ( $action eq $config{REJECT_ACTION} ? INLINE : ACTION ); my $type = ( $action eq $config{REJECT_ACTION} ? INLINE : ACTION );
my $noinline = 0;
my $nolog = ( $type == INLINE ) || 0; use constant { INLINE_OPT => 1 ,
my $builtin = 0; NOINLINE_OPT => 2 ,
my $raw = 0; NOLOG_OPT => 4 ,
my $mangle = 0; BUILTIN_OPT => 8 ,
my $filter = 0; RAW_OPT => 16 ,
my $nat = 0; MANGLE_OPT => 32 ,
FILTER_OPT => 64 ,
NAT_OPT => 128 ,
TERMINATING_OPT => 256 ,
};
my %options = ( inline => INLINE_OPT ,
noinline => NOINLINE_OPT ,
nolog => NOLOG_OPT ,
builtin => BUILTIN_OPT ,
raw => RAW_OPT ,
mangle => MANGLE_OPT ,
filter => FILTER_OPT ,
nat => NAT_OPT ,
terminating => TERMINATING_OPT ,
);
my $opts = $type == INLINE ? NOLOG_OPT : 0;
if ( $action =~ /:/ ) { if ( $action =~ /:/ ) {
warning_message 'Default Actions are now specified in /etc/shorewall/shorewall.conf'; warning_message 'Default Actions are now specified in /etc/shorewall/shorewall.conf';
@@ -1766,29 +1841,14 @@ sub process_actions() {
if ( $options ne '-' ) { if ( $options ne '-' ) {
for ( split_list( $options, 'option' ) ) { for ( split_list( $options, 'option' ) ) {
if ( $_ eq 'inline' ) { fatal_error "Invalid option ($_)" unless $options{$_};
$type = INLINE; $opts |= $options{$_};
} elsif ( $_ eq 'noinline' ) {
$noinline = 1;
} elsif ( $_ eq 'nolog' ) {
$nolog = 1;
} elsif ( $_ eq 'builtin' ) {
$builtin = 1;
} elsif ( $_ eq 'mangle' ) {
$mangle = 1;
} elsif ( $_ eq 'raw' ) {
$raw = 1;
} elsif ( $_ eq 'filter' ) {
$filter = 1;
} elsif ( $_ eq 'nat' ) {
$nat = 1;
} else {
fatal_error "Invalid option ($_)";
}
} }
$type = INLINE if $opts & INLINE_OPT;
} }
fatal_error "Conflicting OPTIONS ($options)" if $noinline && $type == INLINE; fatal_error "Conflicting OPTIONS ($options)" if ( $opts & NOINLINE_OPT && $type == INLINE ) || ( $opts & INLINE_OPT && $opts & BUILTIN_OPT );
if ( my $actiontype = $targets{$action} ) { if ( my $actiontype = $targets{$action} ) {
if ( ( $actiontype & ACTION ) && ( $type == INLINE ) ) { if ( ( $actiontype & ACTION ) && ( $type == INLINE ) ) {
@@ -1805,15 +1865,15 @@ sub process_actions() {
} }
} }
if ( $builtin ) { if ( $opts & BUILTIN_OPT ) {
my $actiontype = USERBUILTIN | OPTIONS; my $actiontype = USERBUILTIN | OPTIONS;
$actiontype |= MANGLE_TABLE if $mangle; $actiontype |= MANGLE_TABLE if $opts & MANGLE_OPT;
$actiontype |= RAW_TABLE if $raw; $actiontype |= RAW_TABLE if $opts & RAW_OPT;
$actiontype |= NAT_TABLE if $nat; $actiontype |= NAT_TABLE if $opts & NAT_OPT;
# #
# For backward compatibility, we assume that user-defined builtins are valid in the filter table # For backward compatibility, we assume that user-defined builtins are valid in the filter table
# #
$actiontype |= FILTER_TABLE if $filter || ! ($mangle || $raw || $nat); $actiontype |= FILTER_TABLE if $opts & FILTER_OPT || ! ( $opts & ( MANGLE_OPT | RAW_OPT | NAT_OPT ) );
if ( $builtin_target{$action} ) { if ( $builtin_target{$action} ) {
$builtin_target{$action} |= $actiontype; $builtin_target{$action} |= $actiontype;
@@ -1822,15 +1882,18 @@ sub process_actions() {
} }
$targets{$action} = $actiontype; $targets{$action} = $actiontype;
make_terminating( $action ) if $opts & TERMINATING_OPT
} else { } else {
fatal_error "Table names are only allowed for builtin actions" if $mangle || $raw || $nat || $filter; fatal_error "Table names are only allowed for builtin actions" if $opts & ( MANGLE_OPT | RAW_OPT | NAT_OPT | FILTER_OPT );
new_action $action, $type, $noinline, $nolog;
new_action $action, $type, ( $opts & NOINLINE_OPT ) != 0 , ( $opts & NOLOG_OPT ) != 0;
my $actionfile = find_file( "action.$action" ); my $actionfile = find_file( "action.$action" );
fatal_error "Missing Action File ($actionfile)" unless -f $actionfile; fatal_error "Missing Action File ($actionfile)" unless -f $actionfile;
$inlines{$action} = { file => $actionfile, nolog => $nolog } if $type == INLINE; $inlines{$action} = { file => $actionfile, nolog => $opts & NOLOG_OPT } if $type == INLINE;
} }
} }
} }
@@ -1869,6 +1932,7 @@ sub process_reject_action() {
process_inline( $action, #Inline process_inline( $action, #Inline
$rejectref, #Chain $rejectref, #Chain
'', #Matches '', #Matches
'', #Matches1
'', #Log Level and Tag '', #Log Level and Tag
$action, #Target $action, #Target
'', #Param '', #Param
@@ -1897,8 +1961,8 @@ sub process_reject_action() {
# #
# Expand a macro rule from the rules file # Expand a macro rule from the rules file
# #
sub process_macro ($$$$$$$$$$$$$$$$$$$$) { sub process_macro ($$$$$$$$$$$$$$$$$$$$$) {
my ($macro, $chainref, $matches, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_; my ($macro, $chainref, $matches, $matches1, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_;
my $generated = 0; my $generated = 0;
@@ -1997,7 +2061,8 @@ sub process_macro ($$$$$$$$$$$$$$$$$$$$) {
$generated |= process_rule( $generated |= process_rule(
$chainref, $chainref,
$matches, $matches,
$matches1,
$mtarget, $mtarget,
$param, $param,
$msource, $msource,
@@ -2030,8 +2095,8 @@ sub process_macro ($$$$$$$$$$$$$$$$$$$$) {
# #
# Expand an inline action rule from the rules file # Expand an inline action rule from the rules file
# #
sub process_inline ($$$$$$$$$$$$$$$$$$$$$) { sub process_inline ($$$$$$$$$$$$$$$$$$$$$$) {
my ($inline, $chainref, $matches, $loglevel, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_; my ($inline, $chainref, $matches, $matches1, $loglevel, $target, $param, $source, $dest, $proto, $ports, $sports, $origdest, $rate, $user, $mark, $connlimit, $time, $headers, $condition, $helper, $wildcard ) = @_;
my $generated = 0; my $generated = 0;
@@ -2121,7 +2186,8 @@ sub process_inline ($$$$$$$$$$$$$$$$$$$$$) {
$generated |= process_rule( $generated |= process_rule(
$chainref, $chainref,
$matches, $matches,
$matches1,
$mtarget, $mtarget,
$param, $param,
$msource, $msource,
@@ -2174,9 +2240,10 @@ sub verify_audit($;$$) {
# reference is also passed when rules are being generated during processing of a macro used as a default action. # reference is also passed when rules are being generated during processing of a macro used as a default action.
# #
sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) { sub process_rule ( $$$$$$$$$$$$$$$$$$$$ ) {
my ( $chainref, #reference to Action Chain if we are being called from process_action(); undef otherwise my ( $chainref, #reference to Action Chain if we are being called from process_action(); undef otherwise
$rule, #Matches $rule, #Matches
$matches1, #Matches after the ones generated by the columns
$target, $target,
$current_param, $current_param,
$source, $source,
@@ -2206,6 +2273,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
my $blacklist = ( $section == BLACKLIST_SECTION ); my $blacklist = ( $section == BLACKLIST_SECTION );
my $matches = $rule; my $matches = $rule;
my $raw_matches = ''; my $raw_matches = '';
my $exceptionrule = '';
if ( $inchain = defined $chainref ) { if ( $inchain = defined $chainref ) {
( $inaction, undef, undef, undef ) = split /:/, $normalized_action = $chainref->{action}, 4 if $chainref->{action}; ( $inaction, undef, undef, undef ) = split /:/, $normalized_action = $chainref->{action}, 4 if $chainref->{action};
@@ -2215,7 +2283,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
if ( $basictarget eq 'INLINE' ) { if ( $basictarget eq 'INLINE' ) {
( $action, $basictarget, $param, $loglevel, $raw_matches ) = handle_inline( FILTER_TABLE, 'filter', $action, $basictarget, $param, $loglevel ); ( $action, $basictarget, $param, $loglevel, $raw_matches ) = handle_inline( FILTER_TABLE, 'filter', $action, $basictarget, $param, $loglevel );
} elsif ( $config{INLINE_MATCHES} ) { } else {
$raw_matches = get_inline_matches(0); $raw_matches = get_inline_matches(0);
} }
# #
@@ -2240,6 +2308,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
my $generated = process_macro( $basictarget, my $generated = process_macro( $basictarget,
$chainref, $chainref,
$rule . $raw_matches, $rule . $raw_matches,
$matches1,
$target, $target,
$current_param, $current_param,
$source, $source,
@@ -2263,10 +2332,9 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
return $generated; return $generated;
} elsif ( $actiontype & NFQ ) { } elsif ( $actiontype & NFQ ) {
require_capability( 'NFQUEUE_TARGET', 'NFQUEUE Rules', '' ); $action = handle_nfqueue( $param,
my $paramval = $param eq '' ? 0 : numeric_value( $param ); 1 # Allow 'bypass'
fatal_error "Invalid value ($param) for NFQUEUE queue number" unless defined($paramval) && $paramval <= 65535; );
$action = "NFQUEUE --queue-num $paramval";
} elsif ( $actiontype & SET ) { } elsif ( $actiontype & SET ) {
require_capability( 'IPSET_MATCH', 'SET and UNSET rules', '' ); require_capability( 'IPSET_MATCH', 'SET and UNSET rules', '' );
fatal_error "$action rules require a set name parameter" unless $param; fatal_error "$action rules require a set name parameter" unless $param;
@@ -2279,7 +2347,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
validate_level( $action ); validate_level( $action );
$loglevel = supplied $loglevel ? join( ':', $action, $loglevel ) : $action; $loglevel = supplied $loglevel ? join( ':', $action, $loglevel ) : $action;
$action = 'LOG'; $action = 'LOG';
} elsif ( ! ( $actiontype & (ACTION | INLINE | IPTABLES ) ) ) { } elsif ( ! ( $actiontype & (ACTION | INLINE | IPTABLES | TARPIT ) ) ) {
fatal_error "'builtin' actions may only be used in INLINE rules" if $actiontype == USERBUILTIN; fatal_error "'builtin' actions may only be used in INLINE rules" if $actiontype == USERBUILTIN;
fatal_error "The $basictarget TARGET does not accept a parameter" unless $param eq ''; fatal_error "The $basictarget TARGET does not accept a parameter" unless $param eq '';
} }
@@ -2289,7 +2357,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
# #
fatal_error "The +, - and ! modifiers are not allowed in the blrules file" if $action =~ s/[-+!]$// && $blacklist; fatal_error "The +, - and ! modifiers are not allowed in the blrules file" if $action =~ s/[-+!]$// && $blacklist;
unless ( $actiontype & ( ACTION | INLINE | IPTABLES ) ) { unless ( $actiontype & ( ACTION | INLINE | IPTABLES | TARPIT ) ) {
# #
# Catch empty parameter list # Catch empty parameter list
# #
@@ -2393,6 +2461,22 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
$action = ''; $action = '';
} }
}, },
TARPIT => sub {
require_capability 'TARPIT_TARGET', 'TARPIT', 's';
fatal_error "TARPIT is only valid with PROTO tcp (6)" if ( resolve_proto( $proto ) || 0 ) != TCP;
if ( supplied $param ) {
fatal_error "TARPIT Parameter must be 'tarpit', 'honeypot' or 'reset'" unless $param =~ /^(tarpit|honeypot|reset)$/;
$action = "TARPIT --$param";
$log_action = 'TARPIT';
} else {
$action = $log_action = 'TARPIT';
}
$exceptionrule = '-p 6 ';
},
); );
my $function = $functions{ $bt }; my $function = $functions{ $bt };
@@ -2461,11 +2545,9 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
$destzone = ''; $destzone = '';
} }
} }
} else { } elsif ( ! $inchain ) {
unless ( $inchain ) { fatal_error "Missing destination zone" if $destzone eq '-' || $destzone eq '';
fatal_error "Missing destination zone" if $destzone eq '-' || $destzone eq ''; fatal_error "Unknown destination zone ($destzone)" unless $destref = defined_zone( $destzone );
fatal_error "Unknown destination zone ($destzone)" unless $destref = defined_zone( $destzone );
}
} }
my $restriction = NO_RESTRICT; my $restriction = NO_RESTRICT;
@@ -2585,7 +2667,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
# #
$normalized_target = normalize_action( $basictarget, $loglevel, $param ); $normalized_target = normalize_action( $basictarget, $loglevel, $param );
fatal_error( "Action $basictarget invoked Recursively (" . join( '->', map( externalize( $_ ), @actionstack , $normalized_target ) ) . ')' ) if $active{$basictarget}; fatal_error( "Action $basictarget invoked Recursively (" . join( '->', map( external_name( $_ ), @actionstack , $normalized_target ) ) . ')' ) if $active{$basictarget};
if ( my $ref = use_action( $normalized_target ) ) { if ( my $ref = use_action( $normalized_target ) ) {
# #
@@ -2629,6 +2711,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
my $generated = process_inline( $basictarget, my $generated = process_inline( $basictarget,
$chainref, $chainref,
$rule . $raw_matches, $rule . $raw_matches,
$matches1,
$loglevel, $loglevel,
$target, $target,
$current_param, $current_param,
@@ -2683,7 +2766,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
do_headers( $headers ) , do_headers( $headers ) ,
do_condition( $condition , $chain ) , do_condition( $condition , $chain ) ,
do_helper( $helper ) , do_helper( $helper ) ,
$raw_matches , $matches1 . $raw_matches ,
); );
} else { } else {
$rule .= join( '', $rule .= join( '',
@@ -2695,7 +2778,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
do_time( $time ) , do_time( $time ) ,
do_headers( $headers ) , do_headers( $headers ) ,
do_condition( $condition , $chain ) , do_condition( $condition , $chain ) ,
$raw_matches , $matches1 . $raw_matches ,
); );
} }
@@ -2828,7 +2911,7 @@ sub process_rule ( $$$$$$$$$$$$$$$$$$$ ) {
$action , $action ,
$loglevel , $loglevel ,
$log_action , $log_action ,
'' ) $exceptionrule )
unless unreachable_warning( $wildcard || $section == DEFAULTACTION_SECTION, $chainref ); unless unreachable_warning( $wildcard || $section == DEFAULTACTION_SECTION, $chainref );
} }
@@ -2940,8 +3023,8 @@ sub merge_target( $$ ) {
# #
# May be called by Perl code in action bodies (regular and inline) to generate a rule. # May be called by Perl code in action bodies (regular and inline) to generate a rule.
# #
sub perl_action_helper($$;$) { sub perl_action_helper($$;$$) {
my ( $target, $matches, $isstatematch ) = @_; my ( $target, $matches, $isstatematch , $matches1 ) = @_;
my $action = $actparms{action}; my $action = $actparms{action};
my $chainref = $actparms{0}; my $chainref = $actparms{0};
my $result; my $result;
@@ -2950,6 +3033,12 @@ sub perl_action_helper($$;$) {
$matches .= ' ' unless $matches =~ /^(?:.+\s)?$/; $matches .= ' ' unless $matches =~ /^(?:.+\s)?$/;
if ( $matches1 ) {
$matches1 .= ' ' unless $matches1 =~ /^(?:.+\s)?$/;
} else {
$matches1 = '';
}
set_inline_matches( $target =~ /^INLINE(?::.*)?$/ ? $matches : '' ); set_inline_matches( $target =~ /^INLINE(?::.*)?$/ ? $matches : '' );
if ( $isstatematch ) { if ( $isstatematch ) {
@@ -2973,6 +3062,7 @@ sub perl_action_helper($$;$) {
if ( my $ref = $inlines{$action} ) { if ( my $ref = $inlines{$action} ) {
$result = &process_rule( $chainref, $result = &process_rule( $chainref,
$matches, $matches,
$matches1,
merge_target( $ref, $target ), merge_target( $ref, $target ),
'', # CurrentParam '', # CurrentParam
@columns ); @columns );
@@ -2981,6 +3071,7 @@ sub perl_action_helper($$;$) {
$result = process_rule( $chainref, $result = process_rule( $chainref,
$matches, $matches,
$matches1,
merge_target( $actions{$action}, $target ), merge_target( $actions{$action}, $target ),
'', # Current Param '', # Current Param
'-', # Source '-', # Source
@@ -3032,6 +3123,7 @@ sub perl_action_tcp_helper($$) {
if ( my $ref = $inlines{$action} ) { if ( my $ref = $inlines{$action} ) {
$result = &process_rule( $chainref, $result = &process_rule( $chainref,
$proto, $proto,
'',
merge_target( $ref, $target ), merge_target( $ref, $target ),
'', '',
@columns[0,1], @columns[0,1],
@@ -3041,6 +3133,7 @@ sub perl_action_tcp_helper($$) {
} else { } else {
$result = process_rule( $chainref, $result = process_rule( $chainref,
$proto, $proto,
'',
merge_target( $actions{$action}, $target ), merge_target( $actions{$action}, $target ),
'', # Current Param '', # Current Param
'-', # Source '-', # Source
@@ -3234,6 +3327,7 @@ sub process_raw_rule ( ) {
for my $proto ( @protos ) { for my $proto ( @protos ) {
for my $user ( @users ) { for my $user ( @users ) {
if ( process_rule( undef, if ( process_rule( undef,
'',
'', '',
$target, $target,
'', '',

View File

@@ -27,7 +27,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>. # along with this program; if not, see <http://www.gnu.org/licenses/>.
# #
# This module deals with Traffic Shaping and the tcrules file. # This module deals with Traffic Shaping and the mangle file.
# #
package Shorewall::Tc; package Shorewall::Tc;
require Exporter; require Exporter;
@@ -135,7 +135,7 @@ our %restrictions = ( tcpre => PREROUTE_RESTRICT ,
our $family; our $family;
our $tcrules; our $convert;
our $mangle; our $mangle;
@@ -225,6 +225,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
my $device = ''; my $device = '';
our $cmd; our $cmd;
our $designator; our $designator;
our $ttl = 0;
my $fw = firewall_zone; my $fw = firewall_zone;
sub handle_mark_param( $$ ) { sub handle_mark_param( $$ ) {
@@ -260,6 +261,8 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
$chain ||= $designator; $chain ||= $designator;
$chain ||= $default_chain; $chain ||= $default_chain;
$option ||= ( $and_or eq '|' ? '--or-mark' : $and_or ? '--and-mark' : '--set-mark' );
my $chainref = ensure_chain( 'mangle', $chain = $chainnames{$chain} ); my $chainref = ensure_chain( 'mangle', $chain = $chainnames{$chain} );
for ( my $packet = 0; $packet < $marks; $packet++, $markval += $increment ) { for ( my $packet = 0; $packet < $marks; $packet++, $markval += $increment ) {
@@ -331,7 +334,31 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
} }
} }
sub ipset_command() {
my %xlate = ( ADD => 'add-set' , DEL => 'del-set' );
require_capability( 'IPSET_MATCH', "$cmd rules", '' );
fatal_error "$cmd rules require a set name parameter" unless $params;
my ( $setname, $flags, $rest ) = split ':', $params, 3;
fatal_error "Invalid ADD/DEL parameter ($params)" if $rest;
$setname =~ s/^\+//;
fatal_error "Expected ipset name ($setname)" unless $setname =~ /^(6_)?[a-zA-Z][-\w]*$/;
fatal_error "Invalid flags ($flags)" unless defined $flags && $flags =~ /^(dst|src)(,(dst|src)){0,5}$/;
$target = join( ' ', 'SET --' . $xlate{$cmd} , $setname , $flags );
}
my %commands = ( my %commands = (
ADD => {
defaultchain => PREROUTING,
allowedchains => ALLCHAINS,
minparams => 1,
maxparams => 1,
function => sub() {
ipset_command();
}
},
CHECKSUM => { CHECKSUM => {
defaultchain => 0, defaultchain => 0,
allowedchains => ALLCHAINS, allowedchains => ALLCHAINS,
@@ -394,6 +421,16 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
}, },
}, },
DEL => {
defaultchain => PREROUTING,
allowedchains => ALLCHAINS,
minparams => 1,
maxparams => 1,
function => sub() {
ipset_command();
}
},
DIVERT => { DIVERT => {
defaultchain => REALPREROUTING, defaultchain => REALPREROUTING,
allowedchains => PREROUTING | REALPREROUTING, allowedchains => PREROUTING | REALPREROUTING,
@@ -562,7 +599,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
RESTORE => { RESTORE => {
defaultchain => 0, defaultchain => 0,
allowedchains => PREROUTING | FORWARD | OUTPUT | POSTROUTING, allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING,
minparams => 0, minparams => 0,
maxparams => 1, maxparams => 1,
function => sub () { function => sub () {
@@ -585,13 +622,20 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
$target = ( $chain == OUTPUT ? 'sticko' : 'sticky' ); $target = ( $chain == OUTPUT ? 'sticko' : 'sticky' );
$restriction = DESTIFACE_DISALLOW; $restriction = DESTIFACE_DISALLOW;
ensure_mangle_chain( $target ); ensure_mangle_chain( $target );
if (supplied $params) {
$ttl = numeric_value( $params );
fatal_error "The SAME timeout must be positive" unless $ttl;
} else {
$ttl = 300;
}
$sticky++; $sticky++;
}, },
}, },
SAVE => { SAVE => {
defaultchain => 0, defaultchain => 0,
allowedchains => PREROUTING | FORWARD | OUTPUT | POSTROUTING, allowedchains => PREROUTING | INPUT | FORWARD | OUTPUT | POSTROUTING,
minparams => 0, minparams => 0,
maxparams => 1, maxparams => 1,
function => sub () { function => sub () {
@@ -599,7 +643,6 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
if ( supplied $params ) { if ( supplied $params ) {
handle_mark_param( '--save-mark --mask ' , handle_mark_param( '--save-mark --mask ' ,
$config{TC_EXPERT} ? HIGHMARK : SMALLMARK ); $config{TC_EXPERT} ? HIGHMARK : SMALLMARK );
} else { } else {
$target .= '--save-mark --mask ' . in_hex( $globals{TC_MASK} ); $target .= '--save-mark --mask ' . in_hex( $globals{TC_MASK} );
} }
@@ -706,7 +749,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
if ( $cmd eq 'INLINE' ) { if ( $cmd eq 'INLINE' ) {
( $target, $cmd, $params, $junk, $raw_matches ) = handle_inline( MANGLE_TABLE, 'mangle', $action, $cmd, $params, '' ); ( $target, $cmd, $params, $junk, $raw_matches ) = handle_inline( MANGLE_TABLE, 'mangle', $action, $cmd, $params, '' );
} elsif ( $config{INLINE_MATCHES} ) { } else {
$raw_matches = get_inline_matches(0); $raw_matches = get_inline_matches(0);
} }
@@ -754,7 +797,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
if ( $commandref->{maxparams} == 1 ) { if ( $commandref->{maxparams} == 1 ) {
fatal_error "The $cmd requires a parameter"; fatal_error "The $cmd requires a parameter";
} else { } else {
fatal_error "The $cmd ACTION only requires at least $commandref->{maxparams} parmeters"; fatal_error "The $cmd ACTION requires at least $commandref->{maxparams} parmeters";
} }
} }
if ( $state ne '-' ) { if ( $state ne '-' ) {
@@ -763,7 +806,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
for ( @state ) { for ( @state ) {
fatal_error "Invalid STATE ($_)" unless exists $state{$_}; fatal_error "Invalid STATE ($_)" unless exists $state{$_};
fatal_error "Duplicate STATE ($_)" if $state{$_}; fatal_error "Duplicate STATE ($_)" if $state{$_}++;
} }
} else { } else {
$state = 'ALL'; $state = 'ALL';
@@ -799,6 +842,7 @@ sub process_mangle_rule1( $$$$$$$$$$$$$$$$$$ ) {
do_dscp( $dscp ) . do_dscp( $dscp ) .
state_match( $state ) . state_match( $state ) .
do_time( $time ) . do_time( $time ) .
( $ttl ? "-t $ttl " : '' ) .
$raw_matches , $raw_matches ,
$source , $source ,
$dest , $dest ,
@@ -850,13 +894,17 @@ sub process_tc_rule1( $$$$$$$$$$$$$$$$ ) {
our %tccmd; our %tccmd;
unless ( %tccmd ) { unless ( %tccmd ) {
%tccmd = ( SAVE => { match => sub ( $ ) { $_[0] eq 'SAVE' } , %tccmd = ( ADD => { match => sub ( $ ) { $_[0] =~ /^ADD/ }
},
DEL => { match => sub ( $ ) { $_[0] =~ /^DEL/ }
},
SAVE => { match => sub ( $ ) { $_[0] eq 'SAVE' } ,
} , } ,
RESTORE => { match => sub ( $ ) { $_[0] eq 'RESTORE' }, RESTORE => { match => sub ( $ ) { $_[0] eq 'RESTORE' },
} , } ,
CONTINUE => { match => sub ( $ ) { $_[0] eq 'CONTINUE' }, CONTINUE => { match => sub ( $ ) { $_[0] eq 'CONTINUE' },
} , } ,
SAME => { match => sub ( $ ) { $_[0] eq 'SAME' }, SAME => { match => sub ( $ ) { $_[0] =~ /^SAME(?:\(d+\))?$/ },
} , } ,
IPMARK => { match => sub ( $ ) { $_[0] =~ /^IPMARK/ }, IPMARK => { match => sub ( $ ) { $_[0] =~ /^IPMARK/ },
} , } ,
@@ -950,7 +998,7 @@ sub process_tc_rule1( $$$$$$$$$$$$$$$$ ) {
} }
} }
if ( $tcrules ) { if ( $convert ) {
$command = ( $command ? "$command($mark)" : $mark ) . $designator; $command = ( $command ? "$command($mark)" : $mark ) . $designator;
my $line = ( $family == F_IPV6 ? my $line = ( $family == F_IPV6 ?
"$command\t$source\t$dest\t$proto\t$ports\t$sports\t$user\t$testval\t$length\t$tos\t$connbytes\t$helper\t$headers\t$probability\t$dscp\t$state" : "$command\t$source\t$dest\t$proto\t$ports\t$sports\t$user\t$testval\t$length\t$tos\t$connbytes\t$helper\t$headers\t$probability\t$dscp\t$state" :
@@ -1053,7 +1101,7 @@ sub process_mangle_rule( ) {
my ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time ); my ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability , $dscp , $state, $time );
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp, $state, $time ) = ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $probability, $dscp, $state, $time ) =
split_line2( 'tcrules file', split_line2( 'mangle file',
{ mark => 0, { mark => 0,
action => 0, action => 0,
source => 1, source => 1,
@@ -1078,7 +1126,7 @@ sub process_mangle_rule( ) {
$headers = '-'; $headers = '-';
} else { } else {
( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp, $state, $time ) = ( $originalmark, $source, $dest, $protos, $ports, $sports, $user, $testval, $length, $tos , $connbytes, $helper, $headers, $probability, $dscp, $state, $time ) =
split_line2( 'tcrules file', split_line2( 'mangle file',
{ mark => 0, { mark => 0,
action => 0, action => 0,
source => 1, source => 1,
@@ -3113,11 +3161,129 @@ sub process_secmark_rule() {
} }
} }
sub convert_tos($$) {
my ( $mangle, $fn1 ) = @_;
my $have_tos = 0;
sub unlink_tos( $ ) {
my $fn = shift;
if ( unlink $fn ) {
warning_message "Empty tos file ($fn) removed";
} else {
warning_message "Unable to remove empty tos file $fn: $!";
}
}
if ( my $fn = open_file 'tos' ) {
first_entry(
sub {
my $date = localtime;
progress_message2 "Converting $fn...";
print( $mangle
"#\n" ,
"# Rules generated from tos file $fn by Shorewall $globals{VERSION} - $date\n" ,
"#\n" );
}
);
while ( read_a_line( NORMAL_READ ) ) {
$have_tos = 1;
my ($src, $dst, $proto, $ports, $sports , $tos, $mark ) =
split_line( 'tos file entry',
{ source => 0, dest => 1, proto => 2, dport => 3, sport => 4, tos => 5, mark => 6 } );
my $chain_designator = 'P';
decode_tos($tos, 1);
my ( $srczone , $source , $remainder );
if ( $family == F_IPV4 ) {
( $srczone , $source , $remainder ) = split( /:/, $src, 3 );
fatal_error 'Invalid SOURCE' if defined $remainder;
} elsif ( $src =~ /^(.+?):<(.*)>\s*$/ || $src =~ /^(.+?):\[(.*)\]\s*$/ ) {
$srczone = $1;
$source = $2;
} else {
$srczone = $src;
}
if ( $srczone eq firewall_zone ) {
$chain_designator = 'O';
$src = $source || '-';
} else {
$src =~ s/^all:?//;
}
$dst =~ s/^all:?//;
$src = '-' unless supplied $src;
$dst = '-' unless supplied $dst;
$proto = '-' unless supplied $proto;
$ports = '-' unless supplied $ports;
$sports = '-' unless supplied $sports;
$mark = '-' unless supplied $mark;
print $mangle "TOS($tos):$chain_designator\t$src\t$dst\t$proto\t$ports\t$sports\t-\t$mark\n"
}
if ( $have_tos ) {
progress_message2 "Converted $fn to $fn1";
if ( rename $fn, "$fn.bak" ) {
progress_message2 "$fn renamed $fn.bak";
} else {
fatal_error "Cannot Rename $fn to $fn.bak: $!";
}
} else {
unlink_tos( $fn );
}
} elsif ( -f ( $fn = find_file( 'tos' ) ) ) {
if ( unlink $fn ) {
warning_message "Empty tos file ($fn) removed";
} else {
warning_message "Unable to remove empty tos file $fn: $!";
}
}
}
sub open_mangle_for_output() {
my ( $mangle, $fn1 );
if ( -f ( $fn1 = find_writable_file( 'mangle' ) ) ) {
open( $mangle , '>>', $fn1 ) || fatal_error "Unable to open $fn1:$!";
} else {
open( $mangle , '>', $fn1 ) || fatal_error "Unable to open $fn1:$!";
print $mangle <<'EOF';
# #
# Process the tcrules file and setup traffic shaping # Shorewall version 4 - Mangle File
#
# For information about entries in this file, type "man shorewall-mangle"
#
# See http://shorewall.net/traffic_shaping.htm for additional information.
# For usage in selecting among multiple ISPs, see
# http://shorewall.net/MultiISP.html
#
# See http://shorewall.net/PacketMarking.html for a detailed description of
# the Netfilter/Shorewall packet marking mechanism.
####################################################################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE USER TEST LENGTH TOS CONNBYTES HELPER PROBABILITY DSCP
# PORT(S) PORT(S)
EOF
}
return ( $mangle, $fn1 );
}
#
# Process the mangle file and setup traffic shaping
# #
sub setup_tc( $ ) { sub setup_tc( $ ) {
$tcrules = $_[0]; $convert = $_[0];
if ( $config{MANGLE_ENABLED} ) { if ( $config{MANGLE_ENABLED} ) {
ensure_mangle_chain 'tcpre'; ensure_mangle_chain 'tcpre';
@@ -3173,33 +3339,69 @@ sub setup_tc( $ ) {
if ( $fn = open_file( 'tcrules' , 2, 1 ) ) { if ( $fn = open_file( 'tcrules' , 2, 1 ) ) {
my $fn1; my $fn1;
if ( $tcrules ) { if ( $convert ) {
# #
# We are going to convert this tcrules file to the equivalent mangle file # We are going to convert this tcrules file to the equivalent mangle file
# #
open( $mangle , '>>', $fn1 = find_file('mangle') ) || fatal_error "Unable to open $fn1:$!"; ( $mangle, $fn1 ) = open_mangle_for_output;
directive_callback( sub () { print $mangle "$_[1]\n" unless $_[0] eq 'FORMAT'; 0; } ); directive_callback( sub () { print $mangle "$_[1]\n" unless $_[0] eq 'FORMAT'; 0; } );
} }
first_entry "$doing $fn..."; first_entry(
sub {
if ( $convert ) {
my $date = localtime;
progress_message2 "Converting $fn...";
print( $mangle
"#\n" ,
"# Rules generated from tcrules file $fn by Shorewall $globals{VERSION} - $date\n" ,
"#\n" );
} else {
progress_message2 "$doing $fn...";
}
}
);
process_tc_rule, $have_tcrules++ while read_a_line( NORMAL_READ ); process_tc_rule, $have_tcrules++ while read_a_line( NORMAL_READ );
if ( $have_tcrules ) { if ( $convert ) {
if ( $mangle ) { if ( $have_tcrules ) {
progress_message2 "Converted $fn to $fn1"; progress_message2 "Converted $fn to $fn1";
if ( rename $fn, "$fn.bak" ) { if ( rename $fn, "$fn.bak" ) {
progress_message2 "$fn renamed $fn.bak"; progress_message2 "$fn renamed $fn.bak";
} else { } else {
fatal_error "Cannot Rename $fn to $fn.bak: $!"; fatal_error "Cannot Rename $fn to $fn.bak: $!";
} }
} elsif ( -f ( my $fn = find_file( 'tcrules' ) ) ) {
if ( unlink $fn ) {
warning_message "Empty tcrules file ($fn) removed";
} else {
warning_message "Unable to remove empty tcrules file $fn: $!";
}
}
convert_tos( $mangle, $fn1 );
close $mangle, directive_callback( 0 );
}
} elsif ( $convert ) {
if ( -f ( my $fn = find_file( 'tcrules' ) ) ) {
if ( unlink $fn ) {
warning_message "Empty tcrules file ($fn) removed";
} else { } else {
warning_message "Non-empty tcrules file ($fn); consider running '$product update -t'"; warning_message "Unable to remove empty tcrules file $fn: $!";
} }
} }
close $mangle, directive_callback( 0 ) if $tcrules; if ( -f ( my $fn = find_file( 'tos' ) ) ) {
#
# We are going to convert this tos file to the equivalent mangle file
#
( $mangle, my $fn1 ) = open_mangle_for_output;
convert_tos( $mangle, $fn1 );
close $mangle;
}
} }
if ( my $fn = open_file( 'mangle', 1, 1 ) ) { if ( my $fn = open_file( 'mangle', 1, 1 ) ) {

View File

@@ -132,6 +132,15 @@ sub setup_tunnels() {
add_tunnel_rule $inchainref, p => 'tcp --dport 1723', @$source add_tunnel_rule $inchainref, p => 'tcp --dport 1723', @$source
} }
sub setup_one_tinc {
my ( $inchainref, $outchainref, $kind, $source, $dest ) = @_;
add_tunnel_rule $inchainref, p => 'udp --dport 655', @$source;
add_tunnel_rule $outchainref, p => 'udp --dport 655', @$dest;
add_tunnel_rule $inchainref, p => 'tcp --dport 655', @$source;
add_tunnel_rule $outchainref, p => 'tcp --dport 655', @$dest;
}
sub setup_one_openvpn { sub setup_one_openvpn {
my ($inchainref, $outchainref, $kind, $source, $dest) = @_; my ($inchainref, $outchainref, $kind, $source, $dest) = @_;
@@ -154,7 +163,7 @@ sub setup_tunnels() {
} }
add_tunnel_rule $inchainref, p => "$protocol --dport $port", @$source; add_tunnel_rule $inchainref, p => "$protocol --dport $port", @$source;
add_tunnel_rule $outchainref, p => "$protocol --dport $port", @$dest;; add_tunnel_rule $outchainref, p => "$protocol --dport $port", @$dest;
} }
sub setup_one_openvpn_client { sub setup_one_openvpn_client {
@@ -263,6 +272,7 @@ sub setup_tunnels() {
'6in4' => { function => \&setup_one_other, params => [ \@source, \@dest , 41 ] } , '6in4' => { function => \&setup_one_other, params => [ \@source, \@dest , 41 ] } ,
'pptpclient' => { function => \&setup_pptp_client, params => [ $kind, \@source, \@dest ] } , 'pptpclient' => { function => \&setup_pptp_client, params => [ $kind, \@source, \@dest ] } ,
'pptpserver' => { function => \&setup_pptp_server, params => [ $kind, \@source, \@dest ] } , 'pptpserver' => { function => \&setup_pptp_server, params => [ $kind, \@source, \@dest ] } ,
'tinc' => { function => \&setup_one_tinc, params => [ $kind, \@source, \@dest ] } ,
'openvpn' => { function => \&setup_one_openvpn, params => [ $kind, \@source, \@dest ] } , 'openvpn' => { function => \&setup_one_openvpn, params => [ $kind, \@source, \@dest ] } ,
'openvpnclient' => { function => \&setup_one_openvpn_client, params => [ $kind, \@source, \@dest ] } , 'openvpnclient' => { function => \&setup_one_openvpn_client, params => [ $kind, \@source, \@dest ] } ,
'openvpnserver' => { function => \&setup_one_openvpn_server, params => [ $kind, \@source, \@dest ] } , 'openvpnserver' => { function => \&setup_one_openvpn_server, params => [ $kind, \@source, \@dest ] } ,

View File

@@ -55,6 +55,7 @@ our @EXPORT = ( qw( NOTHING
find_zone find_zone
firewall_zone firewall_zone
loopback_zones loopback_zones
loopback_interface
local_zones local_zones
defined_zone defined_zone
zone_type zone_type
@@ -219,6 +220,7 @@ our $minroot;
our $zonemark; our $zonemark;
our $zonemarkincr; our $zonemarkincr;
our $zonemarklimit; our $zonemarklimit;
our $loopback_interface;
use constant { FIREWALL => 1, use constant { FIREWALL => 1,
IP => 2, IP => 2,
@@ -329,6 +331,7 @@ sub initialize( $$ ) {
%mapbase1 = (); %mapbase1 = ();
$baseseq = 0; $baseseq = 0;
$minroot = 0; $minroot = 0;
$loopback_interface = '';
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
%validinterfaceoptions = (arp_filter => BINARY_IF_OPTION, %validinterfaceoptions = (arp_filter => BINARY_IF_OPTION,
@@ -341,6 +344,7 @@ sub initialize( $$ ) {
ignore => NUMERIC_IF_OPTION + IF_OPTION_WILDOK, ignore => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
maclist => SIMPLE_IF_OPTION + IF_OPTION_HOST, maclist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
logmartians => BINARY_IF_OPTION, logmartians => BINARY_IF_OPTION,
loopback => BINARY_IF_OPTION,
nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER, nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER,
norfc1918 => OBSOLETE_IF_OPTION, norfc1918 => OBSOLETE_IF_OPTION,
nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST, nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST,
@@ -386,6 +390,7 @@ sub initialize( $$ ) {
destonly => SIMPLE_IF_OPTION + IF_OPTION_HOST, destonly => SIMPLE_IF_OPTION + IF_OPTION_HOST,
dhcp => SIMPLE_IF_OPTION, dhcp => SIMPLE_IF_OPTION,
ignore => NUMERIC_IF_OPTION + IF_OPTION_WILDOK, ignore => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
loopback => BINARY_IF_OPTION,
maclist => SIMPLE_IF_OPTION + IF_OPTION_HOST, maclist => SIMPLE_IF_OPTION + IF_OPTION_HOST,
nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER, nets => IPLIST_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_VSERVER,
nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST, nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST,
@@ -460,6 +465,7 @@ sub parse_zone_option_list($$\$$)
} else { } else {
fatal_error "Missing value for option \"$e\"" unless defined $val; fatal_error "Missing value for option \"$e\"" unless defined $val;
fatal_error "Invalid value ($val) for option \"$e\"" unless $val =~ /^($fmt)$/; fatal_error "Invalid value ($val) for option \"$e\"" unless $val =~ /^($fmt)$/;
require_capability 'TCPMSS_TARGET', "mss=$val", 's' if $e eq 'mss';
} }
my $key = $zonekey{$e}; my $key = $zonekey{$e};
@@ -1202,18 +1208,20 @@ sub process_interface( $$ ) {
fatal_error "Invalid Interface option ($option)" unless my $type = $validinterfaceoptions{$option}; fatal_error "Invalid Interface option ($option)" unless my $type = $validinterfaceoptions{$option};
if ( $zone ) {
fatal_error qq(The "$option" option may not be specified for a Vserver zone") if $zoneref->{type} & VSERVER && ! ( $type & IF_OPTION_VSERVER );
} else {
fatal_error "The \"$option\" option may not be specified on a multi-zone interface" if $type & IF_OPTION_ZONEONLY;
}
my $hostopt = $type & IF_OPTION_HOST; my $hostopt = $type & IF_OPTION_HOST;
fatal_error "The \"$option\" option is not allowed on a bridge port" if $port && ! $hostopt;
$type &= MASK_IF_OPTION; $type &= MASK_IF_OPTION;
unless ( $type == BINARY_IF_OPTION && defined $value && $value eq '0' ) {
if ( $zone ) {
fatal_error qq(The "$option" option may not be specified for a Vserver zone") if $zoneref->{type} & VSERVER && ! ( $type & IF_OPTION_VSERVER );
} else {
fatal_error "The \"$option\" option may not be specified on a multi-zone interface" if $type & IF_OPTION_ZONEONLY;
}
}
fatal_error "The \"$option\" option is not allowed on a bridge port" if $port && ! $hostopt;
if ( $type == SIMPLE_IF_OPTION ) { if ( $type == SIMPLE_IF_OPTION ) {
fatal_error "Option $option does not take a value" if defined $value; fatal_error "Option $option does not take a value" if defined $value;
if ( $option eq 'blacklist' ) { if ( $option eq 'blacklist' ) {
@@ -1253,6 +1261,7 @@ sub process_interface( $$ ) {
fatal_error "The '$option' option requires a value" unless defined $value; fatal_error "The '$option' option requires a value" unless defined $value;
my $numval = numeric_value $value; my $numval = numeric_value $value;
fatal_error "Invalid value ($value) for option $option" unless defined $numval && $numval <= $maxoptionvalue{$option}; fatal_error "Invalid value ($value) for option $option" unless defined $numval && $numval <= $maxoptionvalue{$option};
require_capability 'TCPMSS_TARGET', "mss=$value", 's' if $option eq 'mss';
$options{$option} = $numval; $options{$option} = $numval;
$hostoptions{$option} = $numval if $hostopt; $hostoptions{$option} = $numval if $hostopt;
} elsif ( $type == IPLIST_IF_OPTION ) { } elsif ( $type == IPLIST_IF_OPTION ) {
@@ -1353,8 +1362,15 @@ sub process_interface( $$ ) {
$options{ignore} ||= 0; $options{ignore} ||= 0;
} }
$options{loopback} ||= ( $physical eq 'lo' );
if ( $options{loopback} ) {
fatal_error "Only one 'loopback' interface is allowed" if $loopback_interface;
$loopback_interface = $physical;
}
if ( $options{unmanaged} ) { if ( $options{unmanaged} ) {
fatal_error "The 'lo' interface may not be unmanaged when there are vserver zones" if $physical eq 'lo' && vserver_zones; fatal_error "The loopback interface ($loopback_interface) may not be unmanaged when there are vserver zones" if $options{loopback} && vserver_zones;
while ( my ( $option, $value ) = each( %options ) ) { while ( my ( $option, $value ) = each( %options ) ) {
fatal_error "The $option option may not be specified with 'unmanaged'" if $prohibitunmanaged{$option}; fatal_error "The $option option may not be specified with 'unmanaged'" if $prohibitunmanaged{$option};
@@ -1382,9 +1398,9 @@ sub process_interface( $$ ) {
if ( $zone ) { if ( $zone ) {
fatal_error "Unmanaged interfaces may not be associated with a zone" if $options{unmanaged}; fatal_error "Unmanaged interfaces may not be associated with a zone" if $options{unmanaged};
if ( $physical eq 'lo' ) { if ( $options{loopback} ) {
fatal_error "Only a loopback zone may be assigned to 'lo'" unless $zoneref->{type} == LOOPBACK; fatal_error "Only a loopback zone may be assigned to '$physical'" unless $zoneref->{type} == LOOPBACK;
fatal_error "Invalid definition of 'lo'" if $bridge ne $interface; fatal_error "Invalid definition of '$physical'" if $bridge ne $interface;
for ( qw/arp_filter for ( qw/arp_filter
arp_ignore arp_ignore
@@ -1406,10 +1422,10 @@ sub process_interface( $$ ) {
upnpclient upnpclient
mss mss
/ ) { / ) {
fatal_error "The 'lo' interface may not specify the '$_' option" if supplied $options{$_}; fatal_error "The '$config{LOOPBACK}' interface may not specify the '$_' option" if supplied $options{$_};
} }
} else { } else {
fatal_error "A loopback zone may only be assigned to 'lo'" if $zoneref->{type} == LOOPBACK; fatal_error "A loopback zone may only be assigned to the loopback interface" if $zoneref->{type} == LOOPBACK;
} }
$netsref ||= [ allip ]; $netsref ||= [ allip ];
@@ -1466,6 +1482,22 @@ sub validate_interfaces_file( $ ) {
# #
fatal_error "No network interfaces defined" unless @interfaces; fatal_error "No network interfaces defined" unless @interfaces;
#
# Define the loopback interface if it hasn't been already
#
unless ( $loopback_interface ) {
$interfaces{lo} = { name => 'lo',
bridge => 'lo',
nets => 0,
number => $nextinum++,
root => 'lo',
broadcasts => undef,
options => { loopback => 1 , ignore => 1 },
zone => '',
physical => 'lo' };
push @interfaces, $loopback_interface = 'lo';
}
if ( vserver_zones ) { if ( vserver_zones ) {
# #
# While the user thinks that vservers are associated with a particular interface, they really are not. # While the user thinks that vservers are associated with a particular interface, they really are not.
@@ -1481,7 +1513,7 @@ sub validate_interfaces_file( $ ) {
broadcasts => undef , broadcasts => undef ,
options => {} , options => {} ,
zone => '', zone => '',
physical => 'lo', physical => $loopback_interface,
}; };
push @interfaces, $interface; push @interfaces, $interface;
@@ -1519,10 +1551,16 @@ sub known_interface($)
my $iface = $interface; my $iface = $interface;
if ( $minroot ) { if ( $minroot ) {
#
# We have wildcard interfaces -- see if this interface matches one of their roots
#
while ( length $iface > $minroot ) { while ( length $iface > $minroot ) {
chop $iface; chop $iface;
if ( my $i = $roots{$iface} ) { if ( my $i = $roots{$iface} ) {
#
# Found one
#
$interfaceref = $interfaces{$i}; $interfaceref = $interfaces{$i};
my $physical = map_physical( $interface, $interfaceref ); my $physical = map_physical( $interface, $interfaceref );
@@ -1543,6 +1581,13 @@ sub known_interface($)
$physical{$interface} || 0; $physical{$interface} || 0;
} }
#
# Return the loopback interface physical name
#
sub loopback_interface() {
$loopback_interface;
}
# #
# Return interface number # Return interface number
# #
@@ -1589,7 +1634,7 @@ sub managed_interfaces() {
# Return a list of unmanaged interfaces (skip 'lo' since it is implicitly unmanaged when there are no loopback zones). # Return a list of unmanaged interfaces (skip 'lo' since it is implicitly unmanaged when there are no loopback zones).
# #
sub unmanaged_interfaces() { sub unmanaged_interfaces() {
grep ( $interfaces{$_}{options}{unmanaged} && $_ ne 'lo', @interfaces ); grep ( $interfaces{$_}{options}{unmanaged} && ! $interfaces{$_}{options}{loopback}, @interfaces );
} }
# #
@@ -1645,9 +1690,8 @@ sub source_port_to_bridge( $ ) {
return $portref ? $portref->{bridge} : ''; return $portref ? $portref->{bridge} : '';
} }
# #
# Returns a hash reference for the zones interface through the interface # Returns a hash reference for the zones interfaced through the interface
# #
sub interface_zones( $ ) { sub interface_zones( $ ) {
my $interfaceref = known_interface( $_[0] ); my $interfaceref = known_interface( $_[0] );
@@ -1682,7 +1726,7 @@ sub interface_is_required($) {
} }
# #
# Return true if the interface is 'plain' # Return true if the interface is 'plain' (not optional, required or ignored and not a bridge port).
# #
sub interface_is_plain($) { sub interface_is_plain($) {
my $interfaceref = $interfaces{$_[0]}; my $interfaceref = $interfaces{$_[0]};
@@ -1763,7 +1807,7 @@ sub find_interfaces_by_option1( $ ) {
my @ints = (); my @ints = ();
my $wild = 0; my $wild = 0;
for my $interface ( sort { $interfaces{$a}->{number} <=> $interfaces{$b}->{number} } keys %interfaces ) { for my $interface ( @interfaces ) {
my $interfaceref = $interfaces{$interface}; my $interfaceref = $interfaces{$interface};
next unless defined $interfaceref->{physical}; next unless defined $interfaceref->{physical};
@@ -1989,10 +2033,10 @@ sub process_host( ) {
fatal_error "Unknown interface ($interface)" unless ($interfaceref = $interfaces{$interface}) && $interfaceref->{root}; fatal_error "Unknown interface ($interface)" unless ($interfaceref = $interfaces{$interface}) && $interfaceref->{root};
fatal_error "Unmanaged interfaces may not be associated with a zone" if $interfaceref->{unmanaged}; fatal_error "Unmanaged interfaces may not be associated with a zone" if $interfaceref->{unmanaged};
if ( $interfaceref->{name} eq 'lo' ) { if ( $interfaceref->{physical} eq $loopback_interface ) {
fatal_error "Only a loopback zone may be associated with the loopback interface (lo)" if $type != LOOPBACK; fatal_error "Only a loopback zone may be associated with the loopback interface ($loopback_interface)" if $type != LOOPBACK;
} else { } else {
fatal_error "Loopback zones may only be associated with the loopback interface (lo)" if $type == LOOPBACK; fatal_error "Loopback zones may only be associated with the loopback interface ($loopback_interface)" if $type == LOOPBACK;
} }
} else { } else {
fatal_error "Invalid HOST(S) column contents: $hosts" fatal_error "Invalid HOST(S) column contents: $hosts"
@@ -2032,6 +2076,7 @@ sub process_host( ) {
$zoneref->{options}{in}{blacklist} = 1; $zoneref->{options}{in}{blacklist} = 1;
} elsif ( $option =~ /^mss=(\d+)$/ ) { } elsif ( $option =~ /^mss=(\d+)$/ ) {
fatal_error "Invalid mss ($1)" unless $1 >= 500; fatal_error "Invalid mss ($1)" unless $1 >= 500;
require_capability 'TCPMSS_TARGET', $option, 's';
$options{mss} = $1; $options{mss} = $1;
$zoneref->{options}{complex} = 1; $zoneref->{options}{complex} = 1;
} elsif ( $validhostoptions{$option}) { } elsif ( $validhostoptions{$option}) {
@@ -2121,14 +2166,28 @@ sub have_ipsec() {
sub find_hosts_by_option( $ ) { sub find_hosts_by_option( $ ) {
my $option = $_[0]; my $option = $_[0];
my @hosts; my @hosts;
my %done;
for my $interface ( @interfaces ) {
my $value = $interfaces{$interface}{options}{$option};
if ( ! $interfaces{$interface}{zone} && $value ) {
push @hosts, [ $interface, '', ALLIP , [], $value ];
$done{$interface} = 1;
}
}
for my $zone ( grep ! ( $zones{$_}{type} & FIREWALL ) , @zones ) { for my $zone ( grep ! ( $zones{$_}{type} & FIREWALL ) , @zones ) {
while ( my ($type, $interfaceref) = each %{$zones{$zone}{hosts}} ) { for my $type (sort keys %{$zones{$zone}{hosts}} ) {
while ( my ( $interface, $arrayref) = ( each %{$interfaceref} ) ) { my $interfaceref = $zones{$zone}{hosts}->{$type};
for my $interface ( sort keys %$interfaceref ) {
my $arrayref = $interfaceref->{$interface};
for my $host ( @{$arrayref} ) { for my $host ( @{$arrayref} ) {
if ( my $value = $host->{options}{$option} ) { my $ipsec = $host->{ipsec};
for my $net ( @{$host->{hosts}} ) { unless ( $done{$interface} ) {
push @hosts, [ $interface, $host->{ipsec} , $net , $host->{exclusions}, $value ]; if ( my $value = $host->{options}{$option} ) {
for my $net ( @{$host->{hosts}} ) {
push @hosts, [ $interface, $ipsec , $net , $host->{exclusions}, $value ];
}
} }
} }
} }
@@ -2136,12 +2195,6 @@ sub find_hosts_by_option( $ ) {
} }
} }
for my $interface ( @interfaces ) {
if ( ! $interfaces{$interface}{zone} && $interfaces{$interface}{options}{$option} ) {
push @hosts, [ $interface, 'none', ALLIP , [] ];
}
}
\@hosts; \@hosts;
} }
@@ -2153,8 +2206,10 @@ sub find_zone_hosts_by_option( $$ ) {
my @hosts; my @hosts;
unless ( $zones{$zone}{type} & FIREWALL ) { unless ( $zones{$zone}{type} & FIREWALL ) {
while ( my ($type, $interfaceref) = each %{$zones{$zone}{hosts}} ) { for my $type (sort keys %{$zones{$zone}{hosts}} ) {
while ( my ( $interface, $arrayref) = ( each %{$interfaceref} ) ) { my $interfaceref = $zones{$zone}{hosts}->{$type};
for my $interface ( sort keys %$interfaceref ) {
my $arrayref = $interfaceref->{$interface};
for my $host ( @{$arrayref} ) { for my $host ( @{$arrayref} ) {
if ( my $value = $host->{options}{$option} ) { if ( my $value = $host->{options}{$option} ) {
for my $net ( @{$host->{hosts}} ) { for my $net ( @{$host->{hosts}} ) {
@@ -2166,7 +2221,7 @@ sub find_zone_hosts_by_option( $$ ) {
} }
} }
\@hosts; \@hosts
} }
# #

View File

@@ -42,6 +42,8 @@
# --config_path=<path-list> # Search path for config files # --config_path=<path-list> # Search path for config files
# --inline # Update alternative column specifications # --inline # Update alternative column specifications
# --tcrules # Create mangle from tcrules # --tcrules # Create mangle from tcrules
# --routestopped # Create stoppedrules from routestopped
# --notrack # Create conntrack from notrack
# #
use strict; use strict;
use FindBin; use FindBin;
@@ -77,6 +79,8 @@ usage: compiler.pl [ <option> ... ] [ <filename> ]
[ --config_path=<path-list> ] [ --config_path=<path-list> ]
[ --inline ] [ --inline ]
[ --tcrules ] [ --tcrules ]
[ --routestopped ]
[ --notrack ]
_EOF_ _EOF_
exit shift @_; exit shift @_;
@@ -107,6 +111,8 @@ my $shorewallrc = '';
my $shorewallrc1 = ''; my $shorewallrc1 = '';
my $inline = 0; my $inline = 0;
my $tcrules = 0; my $tcrules = 0;
my $routestopped = 0;
my $notrack = 0;
Getopt::Long::Configure ('bundling'); Getopt::Long::Configure ('bundling');
@@ -141,6 +147,8 @@ my $result = GetOptions('h' => \$help,
'convert' => \$convert, 'convert' => \$convert,
'inline' => \$inline, 'inline' => \$inline,
'tcrules' => \$tcrules, 'tcrules' => \$tcrules,
'routestopped' => \$routestopped,
'notrack' => \$notrack,
'config_path=s' => \$config_path, 'config_path=s' => \$config_path,
'shorewallrc=s' => \$shorewallrc, 'shorewallrc=s' => \$shorewallrc,
'shorewallrc1=s' => \$shorewallrc1, 'shorewallrc1=s' => \$shorewallrc1,
@@ -171,4 +179,6 @@ compiler( script => $ARGV[0] || '',
shorewallrc1 => $shorewallrc1, shorewallrc1 => $shorewallrc1,
inline => $inline, inline => $inline,
tcrules => $tcrules, tcrules => $tcrules,
routestopped => $routestopped,
notrack => $notrack,
); );

View File

@@ -1,11 +1,11 @@
# (c) 1999-2014 - Tom Eastep (teastep@shorewall.net) # (c) 1999-2015 - Tom Eastep (teastep@shorewall.net)
# #
# This program is part of Shorewall. # This program is part of Shorewall.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the # it under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 2 of the license or, at your # Free Software Foundation, either version 2 of the license or, at your
# option, any later version. # option, any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,30 +17,41 @@
# #
# Options are: # Options are:
# #
# -n Don't alter Routing # -n Do not alter Routing
# -v and -q Standard Shorewall Verbosity control # -v and -q Standard Shorewall Verbosity control
# -t Timestamp progress messages # -t Timestamp progress messages
# -p Purge conntrack table # -p Purge conntrack table
# -r Recover from failed start/restart # -r Recover from failed start/restart
# -V <verbosity> Set verbosity level explicitly # -V <verbosity> Set verbosity level explicitly
# -R <restore> Overrides RESTOREFILE setting # -R <restore> Overrides RESTOREFILE setting
# #
# Commands are: # Commands are:
# #
# start Starts the firewall # clear Removes all firewall rules
# refresh Refresh the firewall # disable Disable an optional interface
# restart Restarts the firewall # down Stop an optional interface
# reload Reload the firewall # enable Enable an optional interface
# clear Removes all firewall rules # help Show command syntax
# stop Stops the firewall # reenable Disable then nable an optional
# status Displays firewall status # interface
# version Displays the version of Shorewall that # refresh Refresh the firewall
# generated this program # reload Reload the firewall
# restart Restarts the firewall
# restore Restore a saved configuration
# reset Reset byte and packet counters
# run Call a function in this program
# savesets Save the ipset contents
# status Displays firewall status
# start Starts the firewall
# stop Stops the firewall
# up Start an optional interface
# version Displays the version of Shorewall that
# generated this program
# #
################################################################################ ################################################################################
# Functions imported from /usr/share/shorewall/lib.core # Functions imported from /usr/share/shorewall/lib.core
################################################################################ ################################################################################
# Address family-neutral Functions # Address family-neutral Functions
################################################################################ ################################################################################
# #
# Conditionally produce message # Conditionally produce message
@@ -587,54 +598,67 @@ debug_restore_input() {
done done
} }
interface_up() { interface_enabled() {
return $(cat ${VARDIR}/$1.status) return $(cat ${VARDIR}/$1.status)
} }
distribute_load() { distribute_load() {
local interface local interface
local totalload local currentload # Total load of enabled interfaces
local load local load # Specified load of an enabled interface
local mark local mark # Mark of an enabled interface
local maxload local totalload # Total load of all interfaces - usually 1.000000
local nload # Normalized load of an enabled interface
local var # Interface name to embed in a variable name
maxload=$1 totalload=$1
shift shift
totalload=0 currentload=0
for interface in $@; do for interface in $@; do
if interface_up $interface; then if interface_enabled $interface; then
var=$(echo $interface | sed 's/[.-]/_/g')
load=$(cat ${VARDIR}/${interface}_load) load=$(cat ${VARDIR}/${interface}_load)
eval ${interface}_load=$load eval ${var}_load=$load
mark=$(cat ${VARDIR}/${interface}_mark) mark=$(cat ${VARDIR}/${interface}_mark)
eval ${interface}_mark=$mark eval ${var}_mark=$mark
totalload=$( bc <<EOF currentload=$( bc <<EOF
scale=8 scale=8
$totalload + $load $currentload + $load
EOF EOF
) )
fi fi
done done
if [ $totalload ]; then if [ $currentload ]; then
for interface in $@; do for interface in $@; do
qt $g_tool -t mangle -F ~$interface qt $g_tool -t mangle -F ~$interface
eval load=\$${interface}_load
eval mark=\$${interface}_mark var=$(echo $interface | sed 's/[.-]/_/g')
eval load=\$${var}_load
eval mark=\$${var}_mark
if [ -n "$load" ]; then if [ -n "$load" ]; then
load=$(bc <<EOF nload=$(bc <<EOF
scale=8 scale=8
( $load / $totalload ) * $maxload ( $load / $currentload ) * $totalload
EOF EOF
) )
totalload=$(bc <<EOF currentload=$(bc <<EOF
scale=8 scale=8
$totalload - $load $currentload - $load
EOF EOF
) )
run_iptables -t mangle -A ~$interface -m statistic --mode random --probability $load -j MARK --set-mark $mark
case $nload in
.*|0.*)
run_iptables -t mangle -A ~$interface -m statistic --mode random --probability $nload -j MARK --set-mark $mark
;;
*)
run_iptables -t mangle -A ~$interface -j MARK --set-mark $mark
;;
esac
fi fi
done done
fi fi
@@ -652,7 +676,7 @@ interface_is_usable() # $1 = interface
local status; local status;
status=0 status=0
if [ "$1" != lo ]; then if ! loopback_interface $1; then
if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != 0.0.0.0 ]; then if interface_is_up $1 && [ "$(find_first_interface_address_if_any $1)" != 0.0.0.0 ]; then
[ "$COMMAND" = enable ] || run_isusable_exit $1 [ "$COMMAND" = enable ] || run_isusable_exit $1
status=$? status=$?
@@ -845,6 +869,7 @@ detect_dynamic_gateway() { # $1 = interface
local GATEWAYS local GATEWAYS
GATEWAYS= GATEWAYS=
local gateway local gateway
local file
gateway=$(run_findgw_exit $1); gateway=$(run_findgw_exit $1);
@@ -852,14 +877,21 @@ detect_dynamic_gateway() { # $1 = interface
gateway=$( find_peer $($IP addr list $interface ) ) gateway=$( find_peer $($IP addr list $interface ) )
fi fi
if [ -z "$gateway" -a -f ${VARLIB}/dhcpcd/dhcpcd-${1}.info ]; then file="${VARLIB}/dhcpcd/dhcpcd-${1}.info"
eval $(grep ^GATEWAYS= ${VARLIB}/dhcpcd/dhcpcd-${1}.info 2> /dev/null) if [ -z "$gateway" -a -f "${file}" ]; then
eval $(grep ^GATEWAYS= "${file}" 2> /dev/null)
[ -n "$GATEWAYS" ] && GATEWAYS=${GATEWAYS%,*} && gateway=$GATEWAYS [ -n "$GATEWAYS" ] && GATEWAYS=${GATEWAYS%,*} && gateway=$GATEWAYS
fi fi
if [ -z "$gateway" -a -f ${VARLIB}/dhcp/dhclient-${1}.lease ]; then for file in \
gateway=$(grep 'option routers' ${VARLIB}/dhcp/dhclient-${1}.lease | tail -n 1 | while read j1 j2 gateway; do echo $gateway ; return 0; done) "${VARLIB}/dhcp/dhclient-${1}.lease" \
fi "${VARLIB}/dhcp/dhclient.${1}.leases"
do
[ -n "$gateway" ] && break
if [ -f "${file}" ]; then
gateway=$(grep 'option routers' "${file}" | tail -n 1 | while read j1 j2 gateway; do echo "${gateway%\;}" ; return 0; done)
fi
done
[ -n "$gateway" ] && echo $gateway [ -n "$gateway" ] && echo $gateway
} }
@@ -894,18 +926,21 @@ detect_gateway() # $1 = interface
# Disable IPV6 # Disable IPV6
# #
disable_ipv6() { disable_ipv6() {
local foo local temp
foo="$($IP -f inet6 addr list 2> /dev/null)" temp="$($IP -f inet6 addr list 2> /dev/null)"
if [ -n "$foo" ]; then if [ -n "$temp" ]; then
if [ -x "$IP6TABLES" ]; then if [ -x "$IP6TABLES" ]; then
$IP6TABLES -P FORWARD DROP $IP6TABLES -P FORWARD DROP
$IP6TABLES -P INPUT DROP $IP6TABLES -P INPUT DROP
$IP6TABLES -P OUTPUT DROP $IP6TABLES -P OUTPUT DROP
$IP6TABLES -F $IP6TABLES -F
$IP6TABLES -X $IP6TABLES -X
$IP6TABLES -A OUTPUT -o lo -j ACCEPT
$IP6TABLES -A INPUT -i lo -j ACCEPT for temp in $(find_loopback_interfaces); do
$IP6TABLES -A OUTPUT -o $temp -j ACCEPT
$IP6TABLES -A INPUT -i $temp -j ACCEPT
done
else else
error_message "WARNING: DISABLE_IPV6=Yes in shorewall.conf but this system does not appear to have ip6tables" error_message "WARNING: DISABLE_IPV6=Yes in shorewall.conf but this system does not appear to have ip6tables"
fi fi

View File

@@ -15,11 +15,14 @@ usage() {
echo " down <interface>" echo " down <interface>"
echo " enable <interface>" echo " enable <interface>"
echo " reset" echo " reset"
echo " reenable <interface>"
echo " refresh" echo " refresh"
echo " restart" echo " restart"
echo " run <command> [ <parameter> ... ]" echo " run <command> [ <parameter> ... ]"
echo " status" echo " status"
echo " up <interface>" echo " up <interface>"
echo " savesets <file>"
echo " call <function> [ <parameter> ... ]"
echo " version" echo " version"
echo echo
echo "Options are:" echo "Options are:"
@@ -28,6 +31,7 @@ usage() {
echo " -n Don't update routing configuration" echo " -n Don't update routing configuration"
echo " -p Purge Conntrack Table" echo " -p Purge Conntrack Table"
echo " -t Timestamp progress Messages" echo " -t Timestamp progress Messages"
echo " -c Save/restore iptables counters"
echo " -V <verbosity> Set verbosity explicitly" echo " -V <verbosity> Set verbosity explicitly"
echo " -R <file> Override RESTOREFILE setting" echo " -R <file> Override RESTOREFILE setting"
exit $1 exit $1
@@ -85,6 +89,19 @@ g_purge=$PURGE
g_noroutes=$NOROUTES g_noroutes=$NOROUTES
g_timestamp=$TIMESTAMP g_timestamp=$TIMESTAMP
g_recovering=$RECOVERING g_recovering=$RECOVERING
#
# These two variables contain the high-order and low-order parts respectively of
# an SHA1 digest of this file. The digest is generated before the two following
# lines are updated to contain the value of that digest.
#
g_sha1sum1=
g_sha1sum2=
#
# Other Globals
#
g_counters=
g_compiled=
g_file=
initialize initialize
@@ -136,6 +153,10 @@ while [ $finished -eq 0 -a $# -gt 0 ]; do
g_recovering=Yes g_recovering=Yes
option=${option#r} option=${option#r}
;; ;;
c*)
g_counters=Yes
option=${option#c}
;;
V*) V*)
option=${option#V} option=${option#V}
@@ -246,7 +267,7 @@ case "$COMMAND" in
status=0 status=0
for chain in $@; do for chain in $@; do
if chain_exists $chain; then if chain_exists $chain; then
if qt $g_tool-Z $chain; then if qt $g_tool -Z $chain; then
progress_message3 "Filter $chain Counters Reset" progress_message3 "Filter $chain Counters Reset"
else else
error_message "ERROR: Reset of chain $chain failed" error_message "ERROR: Reset of chain $chain failed"
@@ -356,20 +377,37 @@ case "$COMMAND" in
[ $# -eq 1 ] && exit 0 [ $# -eq 1 ] && exit 0
shift shift
[ $# -ne 1 ] && usage 2 [ $# -ne 1 ] && usage 2
mutex_on
if product_is_started; then if product_is_started; then
detect_configuration detect_configuration $1
enable_provider $1 enable_provider $1 Yes
fi fi
mutex_off
status=0 status=0
;; ;;
disable) disable)
[ $# -eq 1 ] && exit 0 [ $# -eq 1 ] && exit 0
shift shift
[ $# -ne 1 ] && usage 2 [ $# -ne 1 ] && usage 2
mutex_on
if product_is_started; then if product_is_started; then
detect_configuration detect_configuration $1
disable_provider $1 disable_provider $1 Yes
fi fi
mutex_off
status=0
;;
reenable)
[ $# -eq 1 ] && exit 0
shift
[ $# -ne 1 ] && usage 2
mutex_on
if product_is_started; then
detect_configuration $1
COMMAND=enable disable_provider $1 Yes
COMMAND=disable enable_provider $1 Yes
fi
mutex_off
status=0 status=0
;; ;;
run) run)
@@ -383,6 +421,38 @@ case "$COMMAND" in
error_message "ERROR: Missing command" error_message "ERROR: Missing command"
fi fi
;; ;;
savesets)
if [ $# -eq 2 ]; then
save_ipsets $2
status=$?
else
usage 2
fi
;;
call)
#
# Way to call functions in the generated script directly
#
detect_configuration
shift
if [ $# -gt 0 ]; then
#
# See what it is
#
if type $1 2> /dev/null | fgrep -q 'is a function'; then
#
# It's a shell function -- call it
#
$@
else
fatal_error "$1 is not a known shell function"
fi
else
usage 1
fi
;;
version) version)
[ $# -ne 1 ] && usage 2 [ $# -ne 1 ] && usage 2
echo $SHOREWALL_VERSION echo $SHOREWALL_VERSION

View File

@@ -11,4 +11,4 @@
############################################################################### ###############################################################################
#ZONE INTERFACE OPTIONS #ZONE INTERFACE OPTIONS
- lo ignore - lo ignore
net all dhcp,physical=+,routeback,optional net all dhcp,physical=+,routeback

View File

@@ -25,6 +25,8 @@ BLACKLIST_LOG_LEVEL=
INVALID_LOG_LEVEL= INVALID_LOG_LEVEL=
LOG_BACKEND=
LOG_MARTIANS=Yes LOG_MARTIANS=Yes
LOG_VERBOSITY=2 LOG_VERBOSITY=2
@@ -186,7 +188,7 @@ MAPOLDACTIONS=No
MARK_IN_FORWARD_CHAIN=No MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX=ko MODULE_SUFFIX="ko ko.xz"
MULTICAST=No MULTICAST=No
@@ -232,6 +234,8 @@ USE_RT_NAMES=No
WARNOLDCAPVERSION=Yes WARNOLDCAPVERSION=Yes
WORKAROUNDS=No
ZONE2ZONE=- ZONE2ZONE=-
############################################################################### ###############################################################################

View File

@@ -36,6 +36,8 @@ BLACKLIST_LOG_LEVEL=
INVALID_LOG_LEVEL= INVALID_LOG_LEVEL=
LOG_BACKEND=
LOG_MARTIANS=Yes LOG_MARTIANS=Yes
LOG_VERBOSITY=2 LOG_VERBOSITY=2
@@ -197,7 +199,7 @@ MAPOLDACTIONS=No
MARK_IN_FORWARD_CHAIN=No MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX=ko MODULE_SUFFIX="ko ko.xz"
MULTICAST=No MULTICAST=No
@@ -243,6 +245,8 @@ USE_RT_NAMES=No
WARNOLDCAPVERSION=Yes WARNOLDCAPVERSION=Yes
WORKAROUNDS=No
ZONE2ZONE=- ZONE2ZONE=-
############################################################################### ###############################################################################

View File

@@ -33,6 +33,8 @@ BLACKLIST_LOG_LEVEL=
INVALID_LOG_LEVEL= INVALID_LOG_LEVEL=
LOG_BACKEND=
LOG_MARTIANS=Yes LOG_MARTIANS=Yes
LOG_VERBOSITY=2 LOG_VERBOSITY=2
@@ -194,7 +196,7 @@ MAPOLDACTIONS=No
MARK_IN_FORWARD_CHAIN=No MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX=ko MODULE_SUFFIX="ko ko.xz"
MULTICAST=No MULTICAST=No
@@ -240,6 +242,8 @@ USE_RT_NAMES=No
WARNOLDCAPVERSION=Yes WARNOLDCAPVERSION=Yes
WORKAROUNDS=No
ZONE2ZONE=- ZONE2ZONE=-
############################################################################### ###############################################################################

View File

@@ -36,6 +36,8 @@ BLACKLIST_LOG_LEVEL=
INVALID_LOG_LEVEL= INVALID_LOG_LEVEL=
LOG_BACKEND=
LOG_MARTIANS=Yes LOG_MARTIANS=Yes
LOG_VERBOSITY=2 LOG_VERBOSITY=2
@@ -197,7 +199,7 @@ MAPOLDACTIONS=No
MARK_IN_FORWARD_CHAIN=No MARK_IN_FORWARD_CHAIN=No
MODULE_SUFFIX=ko MODULE_SUFFIX="ko ko.xz"
MULTICAST=No MULTICAST=No
@@ -243,6 +245,8 @@ USE_RT_NAMES=No
WARNOLDCAPVERSION=Yes WARNOLDCAPVERSION=Yes
WORKAROUNDS=No
ZONE2ZONE=- ZONE2ZONE=-
############################################################################### ###############################################################################

View File

@@ -33,7 +33,7 @@ fatal_error "Invalid successive interval ($succesive) passed to AutoBL" unless $
fatal_error "Invalid packet count ($count) passed to AutoBL" unless $count =~ /^\d+$/ && $count; fatal_error "Invalid packet count ($count) passed to AutoBL" unless $count =~ /^\d+$/ && $count;
fatal_error "Invalid blacklist time ($bltime) passed to AutoBL" unless $bltime =~ /^\d+$/ && $bltime; fatal_error "Invalid blacklist time ($bltime) passed to AutoBL" unless $bltime =~ /^\d+$/ && $bltime;
validate_level( $level ); validate_level( $level );
1;
?end perl ?end perl
############################################################################### ###############################################################################
#TARGET SOURCE DEST PROTO DPORT SPORT #TARGET SOURCE DEST PROTO DPORT SPORT

View File

@@ -41,9 +41,9 @@ set_action_disposition( $disposition) if supplied $disposition;
set_action_name_to_caller; set_action_name_to_caller;
if ( $destination eq 'dst' ) { if ( $destination eq 'dst' ) {
perl_action_helper( $action, "-m recent --name $event --remove --rdest" ); perl_action_helper( $action, '', '', "-m recent --name $event --remove --rdest" );
} else { } else {
perl_action_helper( $action, "-m recent --name $event --remove --rsource" ); perl_action_helper( $action, '', '', "-m recent --name $event --remove --rsource" );
} }
1; 1;

View File

@@ -41,9 +41,9 @@ set_action_disposition( $disposition) if supplied $disposition;
set_action_name_to_caller; set_action_name_to_caller;
if ( $destination eq 'dst' ) { if ( $destination eq 'dst' ) {
perl_action_helper( $action, "-m recent --name $event --set --rdest" ); perl_action_helper( $action, '', '', "-m recent --name $event --set --rdest" );
} else { } else {
perl_action_helper( $action, "-m recent --name $event --set --rsource" ); perl_action_helper( $action, '', '', "-m recent --name $event --set --rsource" );
} }
1; 1;

View File

@@ -25,6 +25,8 @@ BLACKLIST_LOG_LEVEL=
INVALID_LOG_LEVEL= INVALID_LOG_LEVEL=
LOG_BACKEND=
LOG_MARTIANS=Yes LOG_MARTIANS=Yes
LOG_VERBOSITY=2 LOG_VERBOSITY=2
@@ -164,7 +166,7 @@ HELPERS=
IMPLICIT_CONTINUE=No IMPLICIT_CONTINUE=No
INLINE_MATCHES=Yes INLINE_MATCHES=No
IPSET_WARNINGS=Yes IPSET_WARNINGS=Yes
@@ -232,6 +234,8 @@ USE_RT_NAMES=No
WARNOLDCAPVERSION=Yes WARNOLDCAPVERSION=Yes
WORKAROUNDS=Yes
ZONE2ZONE=- ZONE2ZONE=-
############################################################################### ###############################################################################

View File

@@ -16,7 +16,7 @@ startup=0
# wait_interface= # wait_interface=
# #
# Global start/restart/stop options # Global start/restart options
# #
OPTIONS="" OPTIONS=""

View File

@@ -57,3 +57,15 @@ loadmodule nf_nat_proto_gre
loadmodule nf_nat_sip loadmodule nf_nat_sip
loadmodule nf_nat_snmp_basic loadmodule nf_nat_snmp_basic
loadmodule nf_nat_tftp loadmodule nf_nat_tftp
#
# While not actually helpers, these are included here so that
# LOG_BACKEND can work correctly. Not all of them will be
# loaded, since at least one of them will be an alias on any
# given system.
#
loadmodule ipt_LOG
loadmodule nf_log_ipv4
loadmodule xt_LOG
loadmodule xt_NFLOG
loadmodule ipt_ULOG
loadmodule nfnetlink_log

View File

@@ -39,7 +39,7 @@ fi
start() { start() {
echo -n $"Starting Shorewall: " echo -n $"Starting Shorewall: "
$shorewall $OPTIONS start 2>&1 | $logger $shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
retval=${PIPESTATUS[0]} retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then if [[ $retval == 0 ]]; then
touch $lockfile touch $lockfile
@@ -69,7 +69,7 @@ restart() {
# Note that we don't simply stop and start since shorewall has a built in # Note that we don't simply stop and start since shorewall has a built in
# restart which stops the firewall if running and then starts it. # restart which stops the firewall if running and then starts it.
echo -n $"Restarting Shorewall: " echo -n $"Restarting Shorewall: "
$shorewall $OPTIONS restart 2>&1 | $logger $shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
retval=${PIPESTATUS[0]} retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then if [[ $retval == 0 ]]; then
touch $lockfile touch $lockfile

View File

@@ -10,15 +10,16 @@
OPTIONS="" OPTIONS=""
# Use /etc/default shorewall to specify $OPTIONS to run at startup, however this # Use /etc/default shorewall to specify $OPTIONS and STARTOPTIONS to
# this might prevent shorewall from starting. use at your own risk # run at startup, however this this might prevent shorewall from
# starting. use at your own risk
if [ -f /etc/default/shorewall ] ; then if [ -f /etc/default/shorewall ] ; then
. /etc/default/shorewall . /etc/default/shorewall
fi fi
start() { start() {
echo "Starting IPv4 shorewall rules..." echo "Starting IPv4 shorewall rules..."
exec /sbin/shorewall $OPTIONS start exec /sbin/shorewall $OPTIONS start $STARTOPTIONS
} }
stop() { stop() {
@@ -28,7 +29,7 @@ stop() {
restart() { restart() {
echo "Restarting IPv4 shorewall rules..." echo "Restarting IPv4 shorewall rules..."
exec /sbin/shorewall restart exec /sbin/shorewall restart $RESTARTOPTIONS
} }
status() { status() {

View File

@@ -35,6 +35,7 @@ usage() # $1 = exit status
echo " $ME -h" echo " $ME -h"
echo " $ME -s" echo " $ME -s"
echo " $ME -a" echo " $ME -a"
echo " $ME -n"
exit $1 exit $1
} }
@@ -118,6 +119,7 @@ T="-T"
INSTALLD='-D' INSTALLD='-D'
finished=0 finished=0
configure=1
while [ $finished -eq 0 ]; do while [ $finished -eq 0 ]; do
option=$1 option=$1
@@ -147,6 +149,10 @@ while [ $finished -eq 0 ]; do
ANNOTATED= ANNOTATED=
option=${option#p} option=${option#p}
;; ;;
n*)
configure=0
option=${option#n}
;;
*) *)
usage 1 usage 1
;; ;;
@@ -203,6 +209,8 @@ done
[ -n "${INITFILE}" ] && require INITSOURCE && require INITDIR [ -n "${INITFILE}" ] && require INITSOURCE && require INITDIR
[ -n "$SANDBOX" ] && configure=0
if [ -z "$BUILD" ]; then if [ -z "$BUILD" ]; then
case $(uname) in case $(uname) in
cygwin*|CYGWIN*) cygwin*|CYGWIN*)
@@ -216,7 +224,7 @@ if [ -z "$BUILD" ]; then
eval $(cat /etc/os-release | grep ^ID) eval $(cat /etc/os-release | grep ^ID)
case $ID in case $ID in
fedora|rhel) fedora|rhel|centos|foobar)
BUILD=redhat BUILD=redhat
;; ;;
debian) debian)
@@ -315,6 +323,7 @@ if [ $PRODUCT = shorewall ]; then
fi fi
eval sed -i \'s/Digest::SHA/Digest::$DIGEST/\' Perl/Shorewall/Chains.pm eval sed -i \'s/Digest::SHA/Digest::$DIGEST/\' Perl/Shorewall/Chains.pm
eval sed -i \'s/Digest::SHA/Digest::$DIGEST/\' Perl/Shorewall/Config.pm
fi fi
elif [ "$BUILD" = "$HOST" ]; then elif [ "$BUILD" = "$HOST" ]; then
# #
@@ -324,6 +333,7 @@ if [ $PRODUCT = shorewall ]; then
if ! perl -e 'use Digest::SHA;' 2> /dev/null ; then if ! perl -e 'use Digest::SHA;' 2> /dev/null ; then
if perl -e 'use Digest::SHA1;' 2> /dev/null ; then if perl -e 'use Digest::SHA1;' 2> /dev/null ; then
sed -i 's/Digest::SHA/Digest::SHA1/' Perl/Shorewall/Chains.pm sed -i 's/Digest::SHA/Digest::SHA1/' Perl/Shorewall/Chains.pm
sed -i 's/Digest::SHA/Digest::SHA1/' Perl/Shorewall/Config.pm
DIGEST=SHA1 DIGEST=SHA1
else else
echo "ERROR: Shorewall $VERSION requires either Digest::SHA or Digest::SHA1" >&2 echo "ERROR: Shorewall $VERSION requires either Digest::SHA or Digest::SHA1" >&2
@@ -379,7 +389,7 @@ if [ -z "${DESTDIR}" -a $PRODUCT = shorewall -a ! -f ${SHAREDIR}/$PRODUCT/coreve
fi fi
install_file $PRODUCT ${DESTDIR}${SBINDIR}/$PRODUCT 0755 install_file $PRODUCT ${DESTDIR}${SBINDIR}/$PRODUCT 0755
[ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${SBINDIR}/${PRODUCT} [ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SBINDIR}/${PRODUCT}
echo "$PRODUCT control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT" echo "$PRODUCT control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT"
# #
@@ -387,7 +397,7 @@ echo "$PRODUCT control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT"
# #
if [ -n "$INITFILE" ]; then if [ -n "$INITFILE" ]; then
if [ -f "${INITSOURCE}" ]; then if [ -f "${INITSOURCE}" ]; then
initfile="${DESTDIR}/${INITDIR}/${INITFILE}" initfile="${DESTDIR}${INITDIR}/${INITFILE}"
install_file $INITSOURCE "$initfile" 0544 install_file $INITSOURCE "$initfile" 0544
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' "$initfile" [ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' "$initfile"
@@ -417,39 +427,45 @@ fi
# #
# Install the .service file # Install the .service file
# #
if [ -n "$SYSTEMD" ]; then if [ -z "${SERVICEDIR}" ]; then
mkdir -p ${DESTDIR}${SYSTEMD} SERVICEDIR="$SYSTEMD"
fi
if [ -n "$SERVICEDIR" ]; then
mkdir -p ${DESTDIR}${SERVICEDIR}
[ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service [ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service
run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SYSTEMD}/$PRODUCT.service run_install $OWNERSHIP -m 644 $SERVICEFILE ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SYSTEMD}/$PRODUCT.service [ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SYSTEMD}/$PRODUCT.service" echo "Service file $SERVICEFILE installed as ${DESTDIR}${SERVICEDIR}/$PRODUCT.service"
fi fi
# if [ -z "$first_install" ]; then
# These use absolute path names since the files that they are removing existed #
# prior to the use of directory variables # These use absolute path names since the files that they are removing existed
# # prior to the use of directory variables
delete_file ${DESTDIR}/usr/share/$PRODUCT/compiler #
delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.accounting delete_file ${DESTDIR}/usr/share/$PRODUCT/compiler
delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.actions delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.accounting
delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.dynamiczones delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.actions
delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.maclist delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.dynamiczones
delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.nat delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.maclist
delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.providers delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.nat
delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.proxyarp delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.providers
delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.tc delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.proxyarp
delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.tcrules delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.tc
delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.tunnels delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.tcrules
delete_file ${DESTDIR}/usr/share/$PRODUCT/lib.tunnels
if [ $PRODUCT = shorewall6 ]; then if [ $PRODUCT = shorewall6 ]; then
delete_file ${DESTDIR}/usr/share/shorewall6/lib.cli delete_file ${DESTDIR}/usr/share/shorewall6/lib.cli
delete_file ${DESTDIR}/usr/share/shorewall6/lib.common delete_file ${DESTDIR}/usr/share/shorewall6/lib.common
delete_file ${DESTDIR}/usr/share/shorewall6/wait4ifup delete_file ${DESTDIR}/usr/share/shorewall6/wait4ifup
fi
delete_file ${DESTDIR}/usr/share/$PRODUCT/prog.header6
delete_file ${DESTDIR}/usr/share/$PRODUCT/prog.footer6
fi fi
delete_file ${DESTDIR}/usr/share/$PRODUCT/prog.header6
delete_file ${DESTDIR}/usr/share/$PRODUCT/prog.footer6
# #
# Install the Modules file # Install the Modules file
# #
@@ -493,7 +509,7 @@ run_install $OWNERSHIP -m 0644 $PRODUCT.conf ${DESTDIR}${SHAREDIR}/$PR
run_install $OWNERSHIP -m 0644 $PRODUCT.conf.annotated ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles/ run_install $OWNERSHIP -m 0644 $PRODUCT.conf.annotated ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles/
if [ ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/$PRODUCT.conf ]; then if [ ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/$PRODUCT.conf ]; then
run_install $OWNERSHIP -m 0644 ${PRODUCT}.conf${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/$PRODUCT.conf run_install $OWNERSHIP -m 0600 ${PRODUCT}.conf${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/$PRODUCT.conf
if [ "$SHAREDIR" != /usr/share -o "$CONFDIR" != /etc ]; then if [ "$SHAREDIR" != /usr/share -o "$CONFDIR" != /etc ]; then
if [ $PRODUCT = shorewall ]; then if [ $PRODUCT = shorewall ]; then
@@ -532,7 +548,7 @@ run_install $OWNERSHIP -m 0644 zones ${DESTDIR}${SHAREDIR}/$PRODUCT/co
run_install $OWNERSHIP -m 0644 zones.annotated ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles/ run_install $OWNERSHIP -m 0644 zones.annotated ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles/
if [ -z "$SPARSE" -a ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/zones ]; then if [ -z "$SPARSE" -a ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/zones ]; then
run_install $OWNERSHIP -m 0644 zones${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/zones run_install $OWNERSHIP -m 0600 zones${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/zones
echo "Zones file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/zones" echo "Zones file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/zones"
fi fi
@@ -610,7 +626,7 @@ run_install $OWNERSHIP -m 0644 params.annotated ${DESTDIR}${SHAREDIR}/$PRODUCT/c
if [ -f ${DESTDIR}${CONFDIR}/$PRODUCT/params ]; then if [ -f ${DESTDIR}${CONFDIR}/$PRODUCT/params ]; then
chmod 0644 ${DESTDIR}${CONFDIR}/$PRODUCT/params chmod 0644 ${DESTDIR}${CONFDIR}/$PRODUCT/params
else else
run_install $OWNERSHIP -m 0644 params${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/params run_install $OWNERSHIP -m 0600 params${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/params
echo "Parameter file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/params" echo "Parameter file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/params"
fi fi
@@ -1004,7 +1020,7 @@ run_install $OWNERSHIP -m 0644 actions ${DESTDIR}${SHAREDIR}/$PRODUCT/
run_install $OWNERSHIP -m 0644 actions.annotated ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles/ run_install $OWNERSHIP -m 0644 actions.annotated ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles/
if [ -z "$SPARSE" -a ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/actions ]; then if [ -z "$SPARSE" -a ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/actions ]; then
run_install $OWNERSHIP -m 0644 actions${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/actions run_install $OWNERSHIP -m 0600 actions${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/actions
echo "Actions file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/actions" echo "Actions file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/actions"
fi fi
@@ -1015,7 +1031,7 @@ run_install $OWNERSHIP -m 0644 routes ${DESTDIR}${SHAREDIR}/$PRODUCT/c
run_install $OWNERSHIP -m 0644 routes.annotated ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles/ run_install $OWNERSHIP -m 0644 routes.annotated ${DESTDIR}${SHAREDIR}/$PRODUCT/configfiles/
if [ -z "$SPARSE" -a ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/routes ]; then if [ -z "$SPARSE" -a ! -f ${DESTDIR}${CONFDIR}/$PRODUCT/routes ]; then
run_install $OWNERSHIP -m 0644 routes${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/routes run_install $OWNERSHIP -m 0600 routes${suffix} ${DESTDIR}${CONFDIR}/$PRODUCT/routes
echo "Routes file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/routes" echo "Routes file installed as ${DESTDIR}${CONFDIR}/$PRODUCT/routes"
fi fi
@@ -1062,7 +1078,7 @@ if [ $PRODUCT = shorewall6 ]; then
# Symbolically link 'functions' to lib.base # Symbolically link 'functions' to lib.base
# #
ln -sf lib.base ${DESTDIR}${SHAREDIR}/$PRODUCT/functions ln -sf lib.base ${DESTDIR}${SHAREDIR}/$PRODUCT/functions
[ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}/${SHAREDIR}/${PRODUCT}/lib.base [ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/${PRODUCT}/lib.base
fi fi
if [ -d Perl ]; then if [ -d Perl ]; then
@@ -1120,7 +1136,7 @@ chmod 644 ${DESTDIR}${SHAREDIR}/$PRODUCT/version
# Remove and create the symbolic link to the init script # Remove and create the symbolic link to the init script
# #
if [ -z "$DESTDIR" ]; then if [ -z "${DESTDIR}" -a -n "${INITFILE}" ]; then
rm -f ${SHAREDIR}/$PRODUCT/init rm -f ${SHAREDIR}/$PRODUCT/init
ln -s ${INITDIR}/${INITFILE} ${SHAREDIR}/$PRODUCT/init ln -s ${INITDIR}/${INITFILE} ${SHAREDIR}/$PRODUCT/init
fi fi
@@ -1167,8 +1183,8 @@ if [ -n "$SYSCONFFILE" -a -f "$SYSCONFFILE" -a ! -f ${DESTDIR}${SYSCONFDIR}/${PR
echo "$SYSCONFFILE installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}" echo "$SYSCONFFILE installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}"
fi fi
if [ -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then if [ $configure -eq 1 -a -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${mac}" ]; then
if [ -n "$SYSTEMD" ]; then if [ -n "$SERVICEDIR" ]; then
if systemctl enable ${PRODUCT}.service; then if systemctl enable ${PRODUCT}.service; then
echo "$Product will start automatically at boot" echo "$Product will start automatically at boot"
fi fi

View File

@@ -70,15 +70,7 @@ get_config() {
# This block is avoided for compile for export and when the user isn't root # This block is avoided for compile for export and when the user isn't root
# #
if [ "$3" = Yes ]; then if [ "$3" = Yes ]; then
if [ -n "$LOGFILE" ]; then setup_logread
if [ -n "$(syslog_circular_buffer)" ]; then
g_logread="logread | tac"
elif [ -r $LOGFILE ]; then
g_logread="tac $LOGFILE"
else
fatal_error "LOGFILE ($LOGFILE) does not exist!"
fi
fi
fi fi
if [ $g_family -eq 4 ]; then if [ $g_family -eq 4 ]; then
@@ -109,25 +101,6 @@ get_config() {
g_tool=$IP6TABLES g_tool=$IP6TABLES
fi fi
if [ -n "$IP" ]; then
case "$IP" in
*/*)
if [ ! -x "$IP" ] ; then
fatal_error "The program specified in IP ($IP) does not exist or is not executable"
fi
;;
*)
prog="$(mywhich $IP 2> /dev/null)"
if [ -z "$prog" ] ; then
fatal_error "Can't find $IP executable"
fi
IP=$prog
;;
esac
else
IP='ip'
fi
if [ -n "$IPSET" ]; then if [ -n "$IPSET" ]; then
case "$IPSET" in case "$IPSET" in
*/*) */*)
@@ -181,14 +154,13 @@ get_config() {
if [ "$2" = Yes ]; then if [ "$2" = Yes ]; then
case $STARTUP_ENABLED in case $STARTUP_ENABLED in
No|no|NO) No|no|NO)
fatal_error "$g_product startup is disabled. To enable startup, set STARTUP_ENABLED=Yes in ${g_confdir}/${g_program}.conf" not_configured_error "$g_product startup is disabled. To enable startup, set STARTUP_ENABLED=Yes in ${g_confdir}/${g_program}.conf"
;; ;;
Yes|yes|YES) Yes|yes|YES)
;; ;;
*) *)
if [ -n "$STARTUP_ENABLED" ]; then if [ -n "$STARTUP_ENABLED" ]; then
fatal_error "Invalid Value for STARTUP_ENABLED: $STARTUP_ENABLED" not_configured_error "Invalid Value for STARTUP_ENABLED: $STARTUP_ENABLED"
exit 2
fi fi
;; ;;
esac esac
@@ -245,6 +217,25 @@ get_config() {
fi fi
fi fi
if [ -n "$IP" ]; then
case "$IP" in
*/*)
if [ ! -x "$IP" ] ; then
fatal_error "The program specified in IP ($IP) does not exist or is not executable"
fi
;;
*)
prog="$(mywhich $IP 2> /dev/null)"
if [ -z "$prog" ] ; then
fatal_error "Can't find $IP executable"
fi
IP=$prog
;;
esac
else
IP='ip'
fi
case $VERBOSITY in case $VERBOSITY in
-1|0|1|2) -1|0|1|2)
;; ;;
@@ -323,6 +314,21 @@ get_config() {
LEGACY_FASTSTART=Yes LEGACY_FASTSTART=Yes
;; ;;
esac esac
if [ -n "$WORKAROUNDS" ]; then
case $WORKAROUNDS in
[Yy]es)
;;
[Nn]o)
WORKAROUNDS=''
;;
*)
fatal_error "Invalid setting ($WORKAROUNDS) for WORKAROUNDS"
;;
esac
fi
g_loopback=$(find_loopback_interfaces)
} }
# #
@@ -349,6 +355,21 @@ uptodate() {
return 0 return 0
} }
#
# Run the postcompile user exit
#
run_postcompile() { # $1 is the compiled script
local script
script=$(find_file postcompile)
if [ -f $script ]; then
. $script $1
else
return 0
fi
}
# #
# Run the compiler # Run the compiler
# #
@@ -356,11 +377,12 @@ compiler() {
local pc local pc
local shorewallrc local shorewallrc
local shorewallrc1 local shorewallrc1
local options
pc=${LIBEXECDIR}/shorewall/compiler.pl pc=${LIBEXECDIR}/shorewall/compiler.pl
if [ $(id -u) -ne 0 ]; then if [ $(id -u) -ne 0 ]; then
if [ -z "$g_shorewalldir" -o "$g_shorewalldir" = /etc/$g_program ]; then if [ -z "$g_shorewalldir" -o "$g_shorewalldir" = $CONFDIR/$g_program ]; then
startup_error "Ordinary users may not $COMMAND the $CONFDIR/$g_program configuration" startup_error "Ordinary users may not $COMMAND the $CONFDIR/$g_program configuration"
fi fi
fi fi
@@ -373,8 +395,6 @@ compiler() {
# #
get_config Yes get_config Yes
[ -n "$g_doing" ] && progress_message3 "$g_doing..."
case $COMMAND in case $COMMAND in
*start|try|refresh) *start|try|refresh)
;; ;;
@@ -386,11 +406,11 @@ compiler() {
debugflags="-w" debugflags="-w"
[ -n "$g_debug" ] && debugflags='-wd' [ -n "$g_debug" ] && debugflags='-wd'
[ -n "$g_profile" ] && debugflags='-wd:DProf' [ -n "$g_profile" ] && debugflags='-wd:NYTProf'
# Perl compiler only takes the output file as a argument # Perl compiler only takes the output file as a argument
[ "$1" = debug -o "$1" = trace ] && shift; [ "$1" = debug -o "$1" = trace ] && shift;
[ "$1" = nolock ] && shift; [ "$1" = nolock ] && shift;
shift shift
@@ -401,8 +421,9 @@ compiler() {
[ -f "$shorewallrc1" ] || fatal_error "Compiling for export requires a shorewallrc file" [ -f "$shorewallrc1" ] || fatal_error "Compiling for export requires a shorewallrc file"
fi fi
if [ -n "$g_conditional" ] && uptodate $g_file; then if [ -n "$g_conditional" ] && uptodate "$g_file"; then
echo "$g_file is up to date -- no compilation required" echo "$g_file is up to date -- no compilation required"
g_compiled="$g_file"
return 0 return 0
fi fi
@@ -424,6 +445,8 @@ compiler() {
[ -n "$g_directives" ] && options="$options --directives" [ -n "$g_directives" ] && options="$options --directives"
[ -n "$g_tcrules" ] && options="$options --tcrules" [ -n "$g_tcrules" ] && options="$options --tcrules"
[ -n "$g_inline" ] && options="$options --inline" [ -n "$g_inline" ] && options="$options --inline"
[ -n "$g_routestopped" ] && options="$options --routestopped"
[ -n "$g_notrack" ] && options="$options --notrack"
if [ -n "$PERL" ]; then if [ -n "$PERL" ]; then
if [ ! -x "$PERL" ]; then if [ ! -x "$PERL" ]; then
@@ -434,28 +457,33 @@ compiler() {
PERL=/usr/bin/perl PERL=/usr/bin/perl
fi fi
case "$g_doing" in
Compiling|Checking)
progress_message3 "$g_doing using $g_product $SHOREWALL_VERSION..."
;;
Updating)
progress_message3 "Updating $g_product configuration to $SHOREWALL_VERSION..."
;;
*)
[ -n "$g_doing" ] && progress_message3 "$g_doing using $g_product $SHOREWALL_VERSION..."
;;
esac
if [ ${PERLLIBDIR} = ${LIBEXECDIR}/shorewall ]; then if [ ${PERLLIBDIR} = ${LIBEXECDIR}/shorewall ]; then
$PERL $debugflags $pc $options $@ $PERL $debugflags $pc $options $@
else else
PERL5LIB=${PERLLIBDIR} PERL5LIB=${PERLLIBDIR} $PERL $debugflags $pc $options $@
export PERL5LIB
$PERL $debugflags $pc $options $@
fi fi
}
# status=$?
# Run the postcompile user exit
#
run_postcompile() { # $1 is the compiled script
local script
script=$(find_file postcompile) if [ $status -eq 0 -a $COMMAND != check -a $COMMAND != update ]; then
g_compiled="$g_file"
if [ -f $script ]; then run_postcompile "$g_compiled"
. $script $1 return
else
return 0
fi fi
return $status
} }
# #
@@ -475,8 +503,8 @@ start_command() {
rc=$? rc=$?
[ -n "$nolock" ] || mutex_off [ -n "$nolock" ] || mutex_off
else else
if compiler $g_debugging $nolock compile ${VARDIR}/.start; then g_file="${VARDIR}/.start"
run_postcompile ${VARDIR}/.start if compiler $g_debugging $nolock compile "$g_file"; then
[ -n "$nolock" ] || mutex_on [ -n "$nolock" ] || mutex_on
run_it ${VARDIR}/.start $g_debugging start run_it ${VARDIR}/.start $g_debugging start
rc=$? rc=$?
@@ -495,7 +523,7 @@ start_command() {
exit 0 exit 0
fi fi
[ -n "$STARTUP_ENABLED" ] || fatal_error "Startup is disabled" [ -n "$STARTUP_ENABLED" ] || not_configured_error "Startup is disabled"
while [ $finished -eq 0 -a $# -gt 0 ]; do while [ $finished -eq 0 -a $# -gt 0 ]; do
option=$1 option=$1
@@ -534,6 +562,10 @@ start_command() {
g_inline=Yes g_inline=Yes
option=${option#i} option=${option#i}
;; ;;
C*)
g_counters=Yes
option=${option#C}
;;
*) *)
usage 1 usage 1
;; ;;
@@ -570,14 +602,14 @@ start_command() {
esac esac
if [ -n "${g_fast}${AUTOMAKE}" ]; then if [ -n "${g_fast}${AUTOMAKE}" ]; then
if [ -z "$g_fast" -o -z "$LEGACY_FASTSTART" ]; then if [ -z "$g_fast" -o -z "${LEGACY_FASTSTART}${g_counters}" ]; then
# #
# Automake or LEGACY_FASTSTART=No -- use the last compiled script # Automake or ( LEGACY_FASTSTART=No and not -C ) -- use the last compiled script
# #
object=firewall object=firewall
else else
# #
# 'start -f' with LEGACY_FASTSTART=Yes -- use last saved configuration # 'start -f' with ( LEGACY_FASTSTART=Yes or -C ) -- use last saved configuration
# #
object=$RESTOREFILE object=$RESTOREFILE
fi fi
@@ -676,7 +708,7 @@ compile_command() {
;; ;;
1) 1)
g_file=$1 g_file=$1
[ -d $g_file ] && fatal_error "$g_file is a directory" [ -d "$g_file" ] && fatal_error "$g_file is a directory"
;; ;;
2) 2)
[ -n "$g_shorewalldir" -a -z "$g_export" ] && usage 2 [ -n "$g_shorewalldir" -a -z "$g_export" ] && usage 2
@@ -699,7 +731,7 @@ compile_command() {
[ "x$g_file" = x- ] && g_doing='' [ "x$g_file" = x- ] && g_doing=''
compiler $g_debugging compile $g_file && run_postcompile $g_file compiler $g_debugging compile "$g_file"
} }
# #
@@ -846,11 +878,21 @@ update_command() {
g_tcrules=Yes g_tcrules=Yes
option=${option#t} option=${option#t}
;; ;;
s*)
g_routestopped=Yes
option=${option#s}
;;
n*)
g_notrack=Yes
option=${option#n}
;;
A*) A*)
g_inline=Yes g_inline=Yes
g_convert=Yes g_convert=Yes
g_directives=Yes g_directives=Yes
g_tcrules=Yes g_tcrules=Yes
g_routestopped=Yes
g_notrack=Yes
option=${option#A} option=${option#A}
;; ;;
*) *)
@@ -887,7 +929,7 @@ update_command() {
;; ;;
esac esac
g_doing="Updating..." g_doing="Updating"
compiler $g_debugging $nolock check compiler $g_debugging $nolock check
} }
@@ -943,6 +985,10 @@ restart_command() {
g_inline=Yes g_inline=Yes
option=${option#i} option=${option#i}
;; ;;
C*)
g_counters=Yes
option=${option#C}
;;
*) *)
usage 1 usage 1
;; ;;
@@ -979,15 +1025,16 @@ restart_command() {
;; ;;
esac esac
[ -n "$STARTUP_ENABLED" ] || fatal_error "Startup is disabled" [ -n "$STARTUP_ENABLED" ] || not_configured_error "Startup is disabled"
if [ -z "$g_fast" -a -n "$AUTOMAKE" ]; then if [ -z "$g_fast" -a -n "$AUTOMAKE" ]; then
uptodate ${VARDIR}/firewall && g_fast=Yes uptodate ${VARDIR}/firewall && g_fast=Yes
fi fi
g_file="${VARDIR}/.restart"
if [ -z "$g_fast" ]; then if [ -z "$g_fast" ]; then
if compiler $g_debugging $nolock compile ${VARDIR}/.restart; then if compiler $g_debugging $nolock compile "$g_file"; then
run_postcompile ${VARDIR}/.restart
[ -n "$nolock" ] || mutex_on [ -n "$nolock" ] || mutex_on
run_it ${VARDIR}/.restart $g_debugging restart run_it ${VARDIR}/.restart $g_debugging restart
rc=$? rc=$?
@@ -1078,10 +1125,11 @@ refresh_command() {
product_is_started || fatal_error "$g_product is not running" product_is_started || fatal_error "$g_product is not running"
[ -n "$STARTUP_ENABLED" ] || fatal_error "Startup is disabled" [ -n "$STARTUP_ENABLED" ] || not_configured_error "Startup is disabled"
if compiler $g_debugging $nolock compile ${VARDIR}/.refresh; then g_file="${VARDIR}/.refresh"
run_postcompile ${VARDIR}/.refresh
if compiler $g_debugging $nolock compile "$g_file"; then
[ -n "$nolock" ] || mutex_on [ -n "$nolock" ] || mutex_on
run_it ${VARDIR}/.refresh $g_debugging refresh run_it ${VARDIR}/.refresh $g_debugging refresh
rc=$? rc=$?
@@ -1167,7 +1215,7 @@ safe_commands() {
;; ;;
esac esac
[ -n "$STARTUP_ENABLED" ] || fatal_error "Startup is disabled" [ -n "$STARTUP_ENABLED" ] || not_configured_error "Startup is disabled"
if product_is_started; then if product_is_started; then
running=Yes running=Yes
@@ -1189,13 +1237,13 @@ safe_commands() {
command="restart" command="restart"
fi fi
if ! compiler $g_debugging nolock compile ${VARDIR}/.$command; then g_file="${VARDIR}/.$command"
if ! compiler $g_debugging nolock compile "$g_file"; then
status=$? status=$?
exit $status exit $status
fi fi
run_postcompile ${VARDIR}/.$command
case $command in case $command in
start) start)
RESTOREFILE=NONE RESTOREFILE=NONE
@@ -1304,7 +1352,7 @@ try_command() {
;; ;;
esac esac
[ -n "$STARTUP_ENABLED" ] || fatal_error "Startup is disabled" [ -n "$STARTUP_ENABLED" ] || not_configured_error "Startup is disabled"
if product_is_started; then if product_is_started; then
running=Yes running=Yes
@@ -1320,7 +1368,9 @@ try_command() {
command="restart" command="restart"
fi fi
if ! compiler $g_debugging $nolock compile ${VARDIR}/.$command; then g_file="${VARDIR}/.$command"
if ! compiler $g_debugging $nolock compile "$g_file"; then
status=$? status=$?
exit $status exit $status
fi fi
@@ -1514,7 +1564,9 @@ reload_command() # $* = original arguments less the command.
[ -n "$litedir" ] || litedir=${VARLIB}/${g_program}-lite [ -n "$litedir" ] || litedir=${VARLIB}/${g_program}-lite
if compiler $g_debugging compiler $g_shorewalldir/firewall && \ g_file="$g_shorewalldir/firewall"
if compiler $g_debugging compiler "$g_file" && \
progress_message3 "Copying $file and ${file}.conf to ${system}:${litedir}..." && \ progress_message3 "Copying $file and ${file}.conf to ${system}:${litedir}..." && \
rcp_command "$g_shorewalldir/firewall $g_shorewalldir/firewall.conf" ${litedir} rcp_command "$g_shorewalldir/firewall $g_shorewalldir/firewall.conf" ${litedir}
then then
@@ -1603,7 +1655,9 @@ export_command() # $* = original arguments less the command.
g_export=Yes g_export=Yes
if compiler $g_debugging compile $g_shorewalldir/firewall && \ g_file="$g_shorewalldir/firewall"
if compiler $g_debugging compile "$g_file" && \
echo "Copying $file and ${file}.conf to ${target#*@}..." && \ echo "Copying $file and ${file}.conf to ${target#*@}..." && \
scp $g_shorewalldir/firewall $g_shorewalldir/firewall.conf $target scp $g_shorewalldir/firewall $g_shorewalldir/firewall.conf $target
then then
@@ -1624,97 +1678,6 @@ run_command() {
fi fi
} }
#
# Give Usage Information
#
usage() # $1 = exit status
{
echo "Usage: $(basename $0) [debug|trace] [nolock] [ -q ] [ -v[-1|{0-2}] ] [ -t ] <command>"
echo "where <command> is one of:"
echo " add <interface>[:<host-list>] ... <zone>"
echo " allow <address> ..."
echo " [ check | ck ] [ -e ] [ -r ] [ -p ] [ -r ] [ -T ] [ -i ] [ <directory> ]"
echo " clear"
echo " [ compile | co ] [ -e ] [ -p ] [ -t ] [ -c ] [ -d ] [ -T ] [ -i ] [ <directory name> ] [ <path name> ]"
echo " delete <interface>[:<host-list>] ... <zone>"
echo " disable <interface>"
echo " drop <address> ..."
echo " dump [ -x ] [ -l ] [ -m ]"
echo " enable <interface>"
echo " export [ <directory1> ] [<user>@]<system>[:<directory2>]"
echo " forget [ <file name> ]"
echo " help"
if [ $g_family -eq 4 ]; then
echo " hits [ -t ]"
echo " ipcalc { <address>/<vlsm> | <address> <netmask> }"
echo " ipdecimal { <address> | <integer> }"
echo " iprange <address>-<address>"
fi
if [ $g_family -eq 4 ]; then
echo " iptrace <iptables match expression>"
else
echo " iptrace <ip6tables match expression>"
fi
echo " load [ -s ] [ -c ] [ -r <root user> ] [ -T ] [ -i ] [ <directory> ] <system>"
echo " logdrop <address> ..."
echo " logreject <address> ..."
echo " logwatch [<refresh interval>]"
if [ $g_family -eq 4 ]; then
echo " noiptrace <iptables match expression>"
else
echo " noiptrace <ip6tables match expression>"
fi
echo " refresh [ -d ] [ -n ] [ -T ] [ -D <directory> ] [ <chain>... ]"
echo " reject <address> ..."
echo " reload [ -s ] [ -c ] [ -r <root user> ] [ -T ] [ -i ] [ <directory> ] <system>"
echo " reset [ <chain> ... ]"
echo " restart [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ <directory> ]"
echo " restore [ -n ] [ <file name> ]"
echo " run <command> [ <parameter> ... ]"
echo " safe-restart [ -t <timeout> ] [ <directory> ]"
echo " safe-start [ -t <timeout> ] [ <directory> ]"
echo " save [ <file name> ]"
echo " [ show | list | ls ] [ -x ] [ -t {filter|mangle|nat|raw|rawpost} ] [ {chain [<chain> [ <chain> ... ]"
echo " [ show | list | ls ] actions"
echo " [ show | list | ls ] [ -x ] {bl|blacklists}"
echo " [ show | list | ls ] [ -f ] capabilities"
echo " [ show | list | ls ] classifiers"
echo " [ show | list | ls ] config"
echo " [ show | list | ls ] connections"
echo " [ show | list | ls ] dynamic <zone>"
echo " [ show | list | ls ] filters"
echo " [ show | list | ls ] ip"
if [ $g_family -eq 4 ]; then
echo " [ show | list | ls ] ipa"
fi
echo " [ show | list | ls ] [ -m ] log [<regex>]"
echo " [ show | list | ls ] macro <macro>"
echo " [ show | list | ls ] macros"
echo " [ show | list | ls ] marks"
echo " [ show | list | ls ] [ -x ] mangle|nat|raw|rawpost|routing"
echo " [ show | list | ls ] nfacct"
echo " [ show | list | ls ] policies"
echo " [ show | list | ls ] routing"
echo " [ show | list | ls ] tc [ device ]"
echo " [ show | list | ls ] vardir"
echo " [ show | list | ls ] zones"
echo " start [ -f ] [ -n ] [ -p ] [ -c ] [ -T ] [ -i ] [ <directory> ]"
echo " status [ -i ]"
echo " stop"
echo " try <directory> [ <timeout> ]"
echo " update [ -a ] [ -b ] [ -r ] [ -T ] [ -D ] [ -i ] [-t] [-A] [ <directory> ]"
echo " version [ -a ]"
echo
exit $1
}
compiler_command() { compiler_command() {
case $COMMAND in case $COMMAND in

View File

@@ -71,10 +71,17 @@
role="bold">raw</emphasis>. If no table name(s) are given, role="bold">raw</emphasis>. If no table name(s) are given,
then <emphasis role="bold">filter</emphasis> is assumed. The then <emphasis role="bold">filter</emphasis> is assumed. The
table names follow <emphasis role="bold">builtin</emphasis> table names follow <emphasis role="bold">builtin</emphasis>
and are separated by commas; for example, and are separated by commas; for example, "FOOBAR
"FOOBAR,filter,mangle" would specify FOOBAR as a builtin builtin,filter,mangle" would specify FOOBAR as a builtin
target that can be used in the filter and mangle target that can be used in the filter and mangle
tables.</para> tables.</para>
<para>Beginning with Shorewall 4.6.4, you may specify the
<emphasis role="bold">terminating</emphasis> option with
<emphasis role="bold">builtin</emphasis> to indicate to the
Shorewall optimizer that the action is terminating (the
current packet will not be passed to the next rule in the
chain).</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -133,6 +140,17 @@
a subset of the rules.</para> a subset of the rules.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>terminating</term>
<listitem>
<para>Added in Shorewall 4.6.4. When used with
<replaceable>builtin</replaceable>, indicates that the
built-in action is termiating (i.e., if the action is jumped
to, the next rule in the chain is not evaluated).</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@@ -90,7 +90,8 @@
role="bold">NOTRACK</emphasis>|<emphasis role="bold">NOTRACK</emphasis>|<emphasis
role="bold">CT</emphasis>:<emphasis role="bold">CT</emphasis>:<emphasis
role="bold">helper</emphasis>:<replaceable>name</replaceable>[(<replaceable>arg</replaceable>=<replaceable>val</replaceable>[,...])|<emphasis role="bold">helper</emphasis>:<replaceable>name</replaceable>[(<replaceable>arg</replaceable>=<replaceable>val</replaceable>[,...])|<emphasis
role="bold">CT:notrack</emphasis>|DROP|LOG|ULOG(<replaceable>ulog-parameters</replaceable>):NFLOG(<replaceable>nflog-parameters</replaceable>)|IPTABLES(<replaceable>target</replaceable>)}[<replaceable>log-level</replaceable>[:<replaceable>log-tag</replaceable>]][:<replaceable>chain-designator</replaceable>]</term> role="bold">CT:ctevents:<replaceable>event</replaceable>[,...]|CT:expevents:new</emphasis><emphasis
role="bold">|CT:notrack</emphasis>|DROP|LOG|ULOG(<replaceable>ulog-parameters</replaceable>):NFLOG(<replaceable>nflog-parameters</replaceable>)|IPTABLES(<replaceable>target</replaceable>)}[<replaceable>log-level</replaceable>[:<replaceable>log-tag</replaceable>]][:<replaceable>chain-designator</replaceable>]</term>
<listitem> <listitem>
<para>This column is only present when FORMAT &gt;= 2. Values other <para>This column is only present when FORMAT &gt;= 2. Values other
@@ -114,7 +115,8 @@
<replaceable>name</replaceable> to this connection. This is more <replaceable>name</replaceable> to this connection. This is more
flexible than loading the conntrack helper with preset ports. If flexible than loading the conntrack helper with preset ports. If
a <replaceable>log-level</replaceable> is specified, the packet a <replaceable>log-level</replaceable> is specified, the packet
will also be logged at that level.</para> will also be logged at that level. Beginning with Shorewall
4.6.10, the helper name is optional</para>
<para>At this writing, the available helpers are:</para> <para>At this writing, the available helpers are:</para>
@@ -244,6 +246,31 @@
</itemizedlist> </itemizedlist>
</listitem> </listitem>
<listitem>
<para>ctevents:<replaceable>event</replaceable>[,...]</para>
<para>Added in Shorewall 4.6.10. Only generate the specified
conntrack events for this connection. Possible event types are:
<emphasis role="bold">new</emphasis>, <emphasis
role="bold">related</emphasis>, <emphasis
role="bold">destroy</emphasis>, <emphasis
role="bold">reply</emphasis>, <emphasis
role="bold">assured</emphasis>, <emphasis
role="bold">protoinfo</emphasis>, <emphasis
role="bold">helper</emphasis>, <emphasis
role="bold">mark</emphasis> (this is connection mark, not packet
mark), <emphasis role="bold">natseqinfo</emphasis>, and
<emphasis role="bold">secmark</emphasis>.</para>
</listitem>
<listitem>
<para>expevents=new</para>
<para>Added in Shorewall 4.6.10. Only generate <emphasis
role="bold">new</emphasis> expectation events for this
connection.</para>
</listitem>
<listitem> <listitem>
<para><option>DROP</option></para> <para><option>DROP</option></para>

View File

@@ -213,7 +213,7 @@ loc eth2 -</programlisting>
changed; the value assigned to the setting will be the value changed; the value assigned to the setting will be the value
specified (if any) or 1 if no value is given.</para> specified (if any) or 1 if no value is given.</para>
<para></para> <para/>
<note> <note>
<para>This option does not work with a wild-card <para>This option does not work with a wild-card
@@ -247,7 +247,7 @@ loc eth2 -</programlisting>
<para>8 - do not reply for all local addresses</para> <para>8 - do not reply for all local addresses</para>
<para></para> <para/>
<note> <note>
<para>This option does not work with a wild-card <para>This option does not work with a wild-card
@@ -255,7 +255,7 @@ loc eth2 -</programlisting>
the INTERFACE column.</para> the INTERFACE column.</para>
</note> </note>
<para></para> <para/>
<warning> <warning>
<para>Do not specify <emphasis <para>Do not specify <emphasis
@@ -382,6 +382,17 @@ loc eth2 -</programlisting>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>loopback</term>
<listitem>
<para>Added in Shorewall 4.6.6. Designates the interface as
the loopback interface. This option is assumed if the
interface's physical name is 'lo'. Only one interface man have
the <option>loopback</option> option specified.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis <term><emphasis
role="bold">logmartians[={0|1}]</emphasis></term> role="bold">logmartians[={0|1}]</emphasis></term>
@@ -414,7 +425,7 @@ loc eth2 -</programlisting>
1 1
teastep@lists:~$ </programlisting> teastep@lists:~$ </programlisting>
<para></para> <para/>
<note> <note>
<para>This option does not work with a wild-card <para>This option does not work with a wild-card
@@ -749,7 +760,7 @@ loc eth2 -</programlisting>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>unmanaged</term> <term><emphasis role="bold">unmanaged</emphasis></term>
<listitem> <listitem>
<para>Added in Shorewall 4.5.18. Causes all traffic between <para>Added in Shorewall 4.5.18. Causes all traffic between
@@ -902,7 +913,7 @@ net ppp0 -</programlisting>
<programlisting>FORMAT 2 <programlisting>FORMAT 2
#ZONE INTERFACE OPTIONS #ZONE INTERFACE OPTIONS
- br0 routeback</programlisting> - br0 bridge</programlisting>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>

View File

@@ -124,7 +124,29 @@
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term>CHECKSUM</term> <term><emphasis
role="bold">ADD(<replaceable>ipset</replaceable>:<replaceable>flags</replaceable>)</emphasis></term>
<listitem>
<para>Added in Shorewall 4.6.7. Causes addresses and/or port
numbers to be added to the named
<replaceable>ipset</replaceable>. The
<replaceable>flags</replaceable> specify the address or tuple
to be added to the set and must match the type of ipset
involved. For example, for an iphash ipset, either the SOURCE
or DESTINATION address can be added using
<replaceable>flags</replaceable> <emphasis
role="bold">src</emphasis> or <emphasis
role="bold">dst</emphasis> respectively (see the -A command in
ipset (8)).</para>
<para>ADD is non-terminating. Even if a packet matches the
rule, it is passed on to the next rule.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">CHECKSUM</emphasis></term>
<listitem> <listitem>
<para>Compute and fill in the checksum in a packet that lacks <para>Compute and fill in the checksum in a packet that lacks
@@ -139,7 +161,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>CLASSIFY(<replaceable>classid</replaceable>)</term> <term><emphasis
role="bold">CLASSIFY(<replaceable>classid</replaceable>)</emphasis></term>
<listitem> <listitem>
<para>A classification Id (classid) is of the form <para>A classification Id (classid) is of the form
@@ -189,7 +212,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>CONMARK({mark|range})</term> <term><emphasis
role="bold">CONMARK({mark|range})</emphasis></term>
<listitem> <listitem>
<para>Identical to MARK with the exception that the mark is <para>Identical to MARK with the exception that the mark is
@@ -212,6 +236,27 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis
role="bold">DEL(<replaceable>ipset</replaceable>:<replaceable>flags</replaceable>)</emphasis></term>
<listitem>
<para>Added in Shorewall 4.6.7. Causes an entry to be deleted
from the named <replaceable>ipset</replaceable>. The
<replaceable>flags</replaceable> specify the address or tuple
to be deleted from the set and must match the type of ipset
involved. For example, for an iphash ipset, either the SOURCE
or DESTINATION address can be deleted using
<replaceable>flags</replaceable> <emphasis
role="bold">src</emphasis> or <emphasis
role="bold">dst</emphasis> respectively (see the -D command in
ipset (8)).</para>
<para>DEL is non-terminating. Even if a packet matches the
rule, it is passed on to the next rule.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">DIVERT</emphasis></term> <term><emphasis role="bold">DIVERT</emphasis></term>
@@ -306,23 +351,23 @@
<para>The following rules are equivalent:</para> <para>The following rules are equivalent:</para>
<programlisting>2:P eth0 - tcp 22 <programlisting>2:P eth0 - tcp 22
INLINE(2):P eth0 - tcp 22 INLINE(MARK(2)):P eth0 - tcp 22
INLINE(2):P eth0 - ; -p tcp INLINE(MARK(2)):P eth0 - ; -p tcp
INLINE eth0 - tcp 22 ; -j MARK --set-mark 2 INLINE eth0 - tcp 22 ; -j MARK --set-mark 2
INLINE eth0 - ; -p tcp -j MARK --set-mark 2 INLINE eth0 - ; -p tcp -j MARK --set-mark 2
</programlisting> </programlisting>
<para>If INLINE_MATCHES=Yes in <ulink <para>If INLINE_MATCHES=Yes in <ulink
url="/manpages/shorewall.conf.html">shorewall6.conf(5)</ulink> url="/manpages/shorewall.conf.html">shorewall6.conf(5)</ulink>
then the third rule above can be specified as follows:</para> then the third rule above can be specified as follows:</para>
<programlisting>2:P eth0 - ; -p tcp</programlisting> <programlisting>MARK(2):P eth0 - ; -p tcp</programlisting>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>IPMARK</term> <term><emphasis role="bold">IPMARK</emphasis></term>
<listitem> <listitem>
<para>Assigns a mark to each matching packet based on the <para>Assigns a mark to each matching packet based on the
@@ -430,8 +475,9 @@ INLINE eth0 - ; -p tcp -j MARK --set-mark
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>IPTABLES({<replaceable>target</replaceable> <term><emphasis
[<replaceable>option</replaceable> ...])</term> role="bold">IPTABLES({<replaceable>target</replaceable>
[<replaceable>option</replaceable> ...])</emphasis></term>
<listitem> <listitem>
<para>This action allows you to specify an iptables target <para>This action allows you to specify an iptables target
@@ -452,7 +498,8 @@ INLINE eth0 - ; -p tcp -j MARK --set-mark
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>MARK({<replaceable>mark</replaceable>|<replaceable>range</replaceable>})</term> <term><emphasis
role="bold">MARK({<replaceable>mark</replaceable>|<replaceable>range</replaceable>})</emphasis></term>
<listitem> <listitem>
<para>where <replaceable>mark</replaceable> is a packet mark <para>where <replaceable>mark</replaceable> is a packet mark
@@ -495,7 +542,7 @@ INLINE eth0 - ; -p tcp -j MARK --set-mark
<varlistentry> <varlistentry>
<term><emphasis <term><emphasis
role="bold">RESTORE</emphasis>[(/<emphasis>mask</emphasis>)]</term> role="bold">RESTORE</emphasis>[(<emphasis>mask</emphasis>)]</term>
<listitem> <listitem>
<para>Restore the packet's mark from the connection's mark <para>Restore the packet's mark from the connection's mark
@@ -505,7 +552,8 @@ INLINE eth0 - ; -p tcp -j MARK --set-mark
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">SAME</emphasis></term> <term><emphasis
role="bold">SAME[(<replaceable>timeout</replaceable>)]</emphasis></term>
<listitem> <listitem>
<para>Some websites run applications that require multiple <para>Some websites run applications that require multiple
@@ -529,17 +577,22 @@ SAME:P 192.168.1.0/24 0.0.0.0/0 tcp 80,443</programlisting>
connections to an individual remote system to all use the same connections to an individual remote system to all use the same
provider. For example:<programlisting>#ACTION SOURCE DEST PROTO DEST provider. For example:<programlisting>#ACTION SOURCE DEST PROTO DEST
# PORT(S) # PORT(S)
SAME $FW 0.0.0.0/0 tcp 80,443</programlisting> SAME $FW 0.0.0.0/0 tcp 80,443</programlisting>The
If the firewall attempts a connection on TCP port 80 or 443 optional <replaceable>timeout</replaceable> parameter was
and it has sent a packet on either of those ports in the last added in Shorewall 4.6.7 and specifies a number of seconds .
five minutes to the same remote system then the new connection When not specified, a value of 300 seconds (5 minutes) is
will use the same provider as the connection over which that assumed. If the firewall attempts a connection on TCP port 80
last packet was sent.</para> or 443 and it has sent a packet on either of those ports in
the last <replaceable>timeout</replaceable> seconds to the
same remote system then the new connection will use the same
provider as the connection over which that last packet was
sent.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">SAVE[(/<emphasis>mask)</emphasis>] <term><emphasis
role="bold">SAVE[(<emphasis><replaceable>mask</replaceable>)</emphasis>]
</emphasis></term> </emphasis></term>
<listitem> <listitem>
@@ -1230,12 +1283,12 @@ Normal-Service =&gt; 0x00</programlisting>
<programlisting> #ACTION SOURCE DEST PROTO PORT(S) SOURCE USER TEST <programlisting> #ACTION SOURCE DEST PROTO PORT(S) SOURCE USER TEST
# PORT(S) # PORT(S)
1:T 0.0.0.0/0 0.0.0.0/0 icmp echo-request MARK(1):T 0.0.0.0/0 0.0.0.0/0 icmp echo-request
1:T 0.0.0.0/0 0.0.0.0/0 icmp echo-reply MARK(1):T 0.0.0.0/0 0.0.0.0/0 icmp echo-reply
RESTORE:T 0.0.0.0/0 0.0.0.0/0 all - - - 0 RESTORE:T 0.0.0.0/0 0.0.0.0/0 all - - - 0
CONTINUE:T 0.0.0.0/0 0.0.0.0/0 all - - - !0 CONTINUE:T 0.0.0.0/0 0.0.0.0/0 all - - - !0
4:T 0.0.0.0/0 0.0.0.0/0 ipp2p:all MARK(4):T 0.0.0.0/0 0.0.0.0/0 ipp2p:all
SAVE:T 0.0.0.0/0 0.0.0.0/0 all - - - !0</programlisting> SAVE:T 0.0.0.0/0 0.0.0.0/0 all - - - !0</programlisting>
<para>If a packet hasn't been classified (packet mark is 0), copy <para>If a packet hasn't been classified (packet mark is 0), copy
the connection mark to the packet mark. If the packet mark is set, the connection mark to the packet mark. If the packet mark is set,
@@ -1254,9 +1307,9 @@ Normal-Service =&gt; 0x00</programlisting>
<programlisting>/etc/shorewall/tcrules: <programlisting>/etc/shorewall/tcrules:
#ACTION SOURCE DEST PROTO PORT(S) SOURCE USER TEST #ACTION SOURCE DEST PROTO PORT(S) SOURCE USER TEST
# PORT(S) # PORT(S)
1-3:CF 192.168.1.0/24 eth0 ; state=NEW CONNMARK(1-3):F 192.168.1.0/24 eth0 ; state=NEW
/etc/shorewall/masq: /etc/shorewall/masq:

View File

@@ -105,7 +105,7 @@
role="bold">REJECT</emphasis>|<emphasis role="bold">REJECT</emphasis>|<emphasis
role="bold">CONTINUE</emphasis>|<emphasis role="bold">CONTINUE</emphasis>|<emphasis
role="bold">QUEUE</emphasis>|<emphasis role="bold">QUEUE</emphasis>|<emphasis
role="bold">NFQUEUE</emphasis>[(<emphasis>queuenumber</emphasis>)]|<emphasis role="bold">NFQUEUE</emphasis>[(<emphasis>queuenumber1</emphasis>[:<replaceable>queuenumber2</replaceable>])]|<emphasis
role="bold">NONE</emphasis>}[<emphasis role="bold">NONE</emphasis>}[<emphasis
role="bold">:</emphasis>{<emphasis>default-action-or-macro</emphasis>[:level]|<emphasis role="bold">:</emphasis>{<emphasis>default-action-or-macro</emphasis>[:level]|<emphasis
role="bold">None</emphasis>}]</term> role="bold">None</emphasis>}]</term>
@@ -180,8 +180,14 @@
<listitem> <listitem>
<para>Queue the request for a user-space application using the <para>Queue the request for a user-space application using the
nfnetlink_queue mechanism. If a nfnetlink_queue mechanism. If a
<replaceable>queuenumber</replaceable> is not given, queue <replaceable>queuenumber1</replaceable> is not given, queue
zero (0) is assumed.</para> zero (0) is assumed. Beginning with Shorewall 4.6.10, a second
queue number (queuenumber2) may be given. This specifies a
range of queues to use. Packets are then balanced across the
given queues. This is useful for multicore systems: start
multiple instances of the userspace program on queues x, x+1,
.. x+n and use "x:x+n". Packets belonging to the same
connection are put into the same nfqueue.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -242,13 +248,34 @@
<varlistentry> <varlistentry>
<term><emphasis role="bold">BURST:LIMIT</emphasis> (limit) - <term><emphasis role="bold">BURST:LIMIT</emphasis> (limit) -
[{<emphasis>s</emphasis>|<emphasis [-|<replaceable>limit</replaceable>]</term>
role="bold">d</emphasis>}:[[<replaceable>name</replaceable>]:]]]<emphasis>rate</emphasis><emphasis
role="bold">/</emphasis>{<emphasis
role="bold">second</emphasis>|<emphasis
role="bold">minute</emphasis>}[:<emphasis>burst</emphasis>]</term>
<listitem> <listitem>
<para>where limit is one of:</para>
<simplelist>
<member>[<emphasis
role="bold">-</emphasis>|[{<emphasis>s</emphasis>|<emphasis
role="bold">d</emphasis>}:[[<replaceable>name</replaceable>]:]]]<emphasis>rate</emphasis><emphasis
role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis
role="bold">hour</emphasis>|<emphasis
role="bold">day</emphasis>}[:<emphasis>burst</emphasis>]</member>
<member>[<replaceable>name</replaceable>1]:<emphasis>rate1</emphasis><emphasis
role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis
role="bold">hour</emphasis>|<emphasis
role="bold">day</emphasis>}[:<emphasis>burst1</emphasis>],[<replaceable>name</replaceable>2]:<emphasis>rate2</emphasis><emphasis
role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis
role="bold">hour</emphasis>|<emphasis
role="bold">day</emphasis>}[:<emphasis>burst2</emphasis>]</member>
</simplelist>
<para>If passed, specifies the maximum TCP connection <para>If passed, specifies the maximum TCP connection
<emphasis>rate</emphasis> and the size of an acceptable <emphasis>rate</emphasis> and the size of an acceptable
<emphasis>burst</emphasis>. If not specified, TCP connections are <emphasis>burst</emphasis>. If not specified, TCP connections are
@@ -261,9 +288,19 @@
the user and specifies a hash table to be used to count matching the user and specifies a hash table to be used to count matching
connections. If not give, the name <emphasis connections. If not give, the name <emphasis
role="bold">shorewall</emphasis> is assumed. Where more than one role="bold">shorewall</emphasis> is assumed. Where more than one
POLICY specifies the same name, the connections counts for the POLICY or rule specifies the same name, the connections counts for
policies are aggregated and the individual rates apply to the the policies are aggregated and the individual rates apply to the
aggregated count.</para> aggregated count.</para>
<para>Beginning with Shorewall 4.6.5, two<replaceable>
limit</replaceable>s may be specified, separated by a comma. In this
case, the first limit (<replaceable>name1</replaceable>,
<replaceable>rate1</replaceable>, burst1) specifies the per-source
IP limit and the second limit specifies the per-destination IP
limit.</para>
<para>Example: <emphasis
role="bold">client:10/sec:20,:60/sec:100</emphasis></para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@@ -220,7 +220,22 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>noautosrc</term> <term><emphasis
role="bold">load=<replaceable>probability</replaceable></emphasis></term>
<listitem>
<para>Added in Shorewall 4.6.0. This option provides an
alternative method of load balancing based on probabilities.
Providers to be balanced are given a
<replaceable>probability</replaceable> (a number 0 &gt; n
&gt;= 1) with up to 8 digits to the right of the decimal
point. Beginning with Shorewall 4.6.10, a warning is issued if
the sum of the probabilities is not 1.00000000.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><emphasis role="bold">noautosrc</emphasis></term>
<listitem> <listitem>
<para>Added in Shorewall 4.5.17. Prevents the addition of a <para>Added in Shorewall 4.5.17. Prevents the addition of a
@@ -255,6 +270,19 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis role="bold">primary</emphasis></term>
<listitem>
<para>Added in Shorewall 4.6.6, <emphasis
role="bold">primary</emphasis> is equivalent to <emphasis
role="bold">balance=1</emphasis> and is preferred when the
remaining providers specify <emphasis
role="bold">fallback</emphasis> or <emphasis
role="bold">tproxy</emphasis>.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis <term><emphasis
role="bold">src=</emphasis><replaceable>source-address</replaceable></term> role="bold">src=</emphasis><replaceable>source-address</replaceable></term>

View File

@@ -48,6 +48,9 @@
&amp;<replaceable>interface</replaceable> in this column to indicate &amp;<replaceable>interface</replaceable> in this column to indicate
that the source is the primary IP address of the named that the source is the primary IP address of the named
interface.</para> interface.</para>
<para>Beginning with Shorewall 4.6.8, you may specify a
comma-separated list of addresses in this column.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -64,6 +67,9 @@
role="bold">DEST</emphasis>, place "-" in that column. Note that you role="bold">DEST</emphasis>, place "-" in that column. Note that you
may not omit both <emphasis role="bold">SOURCE</emphasis> and may not omit both <emphasis role="bold">SOURCE</emphasis> and
<emphasis role="bold">DEST</emphasis>.</para> <emphasis role="bold">DEST</emphasis>.</para>
<para>Beginning with Shorewall 4.6.8, you may specify a
comma-separated list of addresses in this column.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@@ -129,8 +129,10 @@
<term><emphasis role="bold">NEW</emphasis></term> <term><emphasis role="bold">NEW</emphasis></term>
<listitem> <listitem>
<para>Packets in the NEW, INVALID and UNTRACKED states are processed <para>Packets in the NEW state are processed by rules in this
by rules in this section.</para> section. If the INVALID and/or UNTRACKED sections are empty or not
included, then the packets in the corresponding state(s) are also
processed in this section.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
@@ -264,7 +266,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>AUDIT[(accept|drop|reject)]</term> <term><emphasis
role="bold">AUDIT</emphasis>[(accept|drop|reject)]</term>
<listitem> <listitem>
<para>Added in Shorewall 4.5.10. Audits the packet with the <para>Added in Shorewall 4.5.10. Audits the packet with the
@@ -275,7 +278,11 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>A_ACCEPT, A_ACCEPT+ and A_ACCEPT!</term> <term><emphasis role="bold">A_ACCEPT</emphasis>, <emphasis
role="bold">A_ACCEPT</emphasis><emphasis
role="bold">+</emphasis> and <emphasis
role="bold">A_ACCEPT</emphasis><emphasis
role="bold">!</emphasis></term>
<listitem> <listitem>
<para>Added in Shorewall 4.4.20. Audited versions of ACCEPT, <para>Added in Shorewall 4.4.20. Audited versions of ACCEPT,
@@ -285,7 +292,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>A_DROP and A_DROP!</term> <term><emphasis role="bold">A_DROP</emphasis> and<emphasis
role="bold"> A_DROP!</emphasis></term>
<listitem> <listitem>
<para>Added in Shorewall 4.4.20. Audited versions of DROP and <para>Added in Shorewall 4.4.20. Audited versions of DROP and
@@ -295,7 +303,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>A_REJECT AND A_REJECT!</term> <term><emphasis role="bold">A_REJECT</emphasis> AND <emphasis
role="bold">A_REJECT!</emphasis></term>
<listitem> <listitem>
<para>Added in Shorewall 4.4.20. Audited versions of REJECT <para>Added in Shorewall 4.4.20. Audited versions of REJECT
@@ -422,7 +431,7 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>HELPER</term> <term><emphasis role="bold">HELPER</emphasis></term>
<listitem> <listitem>
<para>Added in Shorewall 4.5.7. This action requires that the <para>Added in Shorewall 4.5.7. This action requires that the
@@ -476,7 +485,8 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>IPTABLES({<replaceable>iptables-target</replaceable> <term><emphasis
role="bold">IPTABLES</emphasis>({<replaceable>iptables-target</replaceable>
[<replaceable>option</replaceable> ...])</term> [<replaceable>option</replaceable> ...])</term>
<listitem> <listitem>
@@ -559,24 +569,36 @@
<varlistentry> <varlistentry>
<term><emphasis <term><emphasis
role="bold">NFQUEUE</emphasis>[(<replaceable>queuenumber</replaceable>)]</term> role="bold">NFQUEUE</emphasis>[([<replaceable>queuenumber</replaceable>1[:<replaceable>queuenumber2</replaceable>][,bypass]]|bypass)]</term>
<listitem> <listitem>
<para>Queues the packet to a user-space application using the <para>Queues the packet to a user-space application using the
nfnetlink_queue mechanism. If a nfnetlink_queue mechanism. If a
<replaceable>queuenumber</replaceable> is not specified, queue <replaceable>queuenumber</replaceable>1 is not specified,
zero (0) is assumed.</para> queue zero (0) is assumed. Beginning with Shorewall 4.6.10,
the keyword <emphasis role="bold">bypass</emphasis> can be
given. By default, if no userspace program is listening on an
NFQUEUE, then all packets that are to be queued are dropped.
When this option is used, the NFQUEUE rule is silently
bypassed instead. The packet will move on to the next rule.
Also beginning in Shorewall 4.6.10, a second queue number
(<replaceable>queuenumber2</replaceable>) may be specified.
This specifies a range of queues to use. Packets are then
balanced across the given queues. This is useful for multicore
systems: start multiple instances of the userspace program on
queues x, x+1, .. x+n and use "x:x+n". Packets belonging to
the same connection are put into the same nfqueue.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis <term><emphasis role="bold"><emphasis
role="bold">NFQUEUE![(<replaceable>queuenumber</replaceable>)]</emphasis></term> role="bold">NFQUEUE</emphasis>[([<replaceable>queuenumber1</replaceable>[,<replaceable>queuenumber2</replaceable>][,bypass]]|bypass)]</emphasis></term>
<listitem> <listitem>
<para>like NFQUEUE but exempts the rule from being suppressed <para>like NFQUEUE but exempts the rule from being suppressed
by OPTIMIZE=1 in <ulink by OPTIMIZE=1 in <ulink
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5).</para> url="/manpages6/shorewall6.conf.html">shorewall6.conf</ulink>(5).</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -652,6 +674,77 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis role="bold">TARPIT</emphasis> [(<emphasis
role="bold">tarpit</emphasis> | <emphasis
role="bold">honeypot</emphasis> | <emphasis
role="bold">reset</emphasis>)]</term>
<listitem>
<para>Added in Shorewall 4.6.6.</para>
<para>TARPIT captures and holds incoming TCP connections using
no local per-connection resources.</para>
<para>TARPIT only works with the PROTO column set to tcp (6),
and is totally application agnostic. This module will answer a
TCP request and play along like a listening server, but aside
from sending an ACK or RST, no data is sent. Incoming packets
are ignored and dropped. The attacker will terminate the
session eventually. This module allows the initial packets of
an attack to be captured by other software for inspection. In
most cases this is sufficient to determine the nature of the
attack.</para>
<para>This offers similar functionality to LaBrea
&lt;http://www.hackbusters.net/LaBrea/&gt; but does not
require dedicated hardware or IPs. Any TCP port that you would
normally DROP or REJECT can instead become a tarpit.</para>
<para>The target accepts a single optional parameter:</para>
<variablelist>
<varlistentry>
<term>tarpit</term>
<listitem>
<para>This mode is the default and completes a
connection with the attacker but limits the window size
to 0, thus keeping the attacker waiting long periods of
time. While he is maintaining state of the connection
and trying to continue every 60-240 seconds, we keep
none, so it is very lightweight. Attempts to close the
connection are ignored, forcing the remote side to time
out the connection in 12-24 minutes.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>honeypot</term>
<listitem>
<para>This mode completes a connection with the
attacker, but signals a normal window size, so that the
remote side will attempt to send data, often with some
very nasty exploit attempts. We can capture these
packets for decoding and further analysis. The module
does not send any data, so if the remote expects an
application level response, the game is up.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>reset</term>
<listitem>
<para>This mode is handy because we can send an inline
RST (reset). It has no other function.</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis <term><emphasis
role="bold">ULOG</emphasis>[(<replaceable>ulog-parameters</replaceable>)]</term> role="bold">ULOG</emphasis>[(<replaceable>ulog-parameters</replaceable>)]</term>
@@ -786,7 +879,10 @@
When there are nested zones, <emphasis role="bold">any</emphasis> When there are nested zones, <emphasis role="bold">any</emphasis>
only refers to top-level zones (those with no parent zones). Note only refers to top-level zones (those with no parent zones). Note
that <emphasis role="bold">any</emphasis> excludes all vserver that <emphasis role="bold">any</emphasis> excludes all vserver
zones, since those zones are nested within the firewall zone.</para> zones, since those zones are nested within the firewall zone.
Beginning with Shorewall 4.4.13, exclusion is supported with
<emphasis role="bold">any</emphasis> -- see see <ulink
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5).</para>
<para>Hosts may also be specified as an IP address range using the <para>Hosts may also be specified as an IP address range using the
syntax syntax
@@ -892,18 +988,28 @@
(Shorewall 4.4.17 and later).</para> (Shorewall 4.4.17 and later).</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>loc,dmz</term>
<listitem>
<para>Both the <emphasis role="bold">loc</emphasis> and
<emphasis role="bold">dmz</emphasis> zones.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>all!dmz</term>
<listitem>
<para>All but the <emphasis role="bold">dmz</emphasis>
zone.</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term></term>
<listitem>
<para></para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">DEST</emphasis> - <term><emphasis role="bold">DEST</emphasis> -
{<emphasis>zone</emphasis>|<emphasis>zone-list</emphasis>[+]|{<emphasis {<emphasis>zone</emphasis>|<emphasis>zone-list</emphasis>[+]|{<emphasis
@@ -947,6 +1053,35 @@
the <emphasis role="bold">SOURCE</emphasis> or <emphasis the <emphasis role="bold">SOURCE</emphasis> or <emphasis
role="bold">DEST</emphasis> column, the rule is ignored.</para> role="bold">DEST</emphasis> column, the rule is ignored.</para>
<para><emphasis role="bold">all</emphasis> means "All Zones",
including the firewall itself. <emphasis role="bold">all-</emphasis>
means "All Zones, except the firewall itself". When <emphasis
role="bold">all</emphasis>[<emphasis role="bold">-</emphasis>] is
used either in the <emphasis role="bold">SOURCE</emphasis> or
<emphasis role="bold">DEST</emphasis> column intra-zone traffic is
not affected. When <emphasis role="bold">all+</emphasis>[<emphasis
role="bold">-</emphasis>] is "used, intra-zone traffic is affected.
Beginning with Shorewall 4.4.13, exclusion is supported -- see see
<ulink
url="/manpages6/shorewall6-exclusion.html">shorewall6-exclusion</ulink>(5).</para>
<para><emphasis role="bold">any</emphasis> is equivalent to
<emphasis role="bold">all</emphasis> when there are no nested zones.
When there are nested zones, <emphasis role="bold">any</emphasis>
only refers to top-level zones (those with no parent zones). Note
that <emphasis role="bold">any</emphasis> excludes all vserver
zones, since those zones are nested within the firewall zone.</para>
<para>Except when <emphasis role="bold">all</emphasis>[<emphasis
role="bold">+</emphasis>][<emphasis role="bold">-</emphasis>] or
<emphasis role="bold">any</emphasis>[<emphasis
role="bold">+</emphasis>][<emphasis role="bold">-</emphasis>] is
specified, clients may be further restricted to a list of networks
and/or hosts by appending ":" and a comma-separated list of network
and/or host addresses. Hosts may be specified by IP or MAC address;
mac addresses must begin with "~" and must use "-" as a
separator.</para>
<para>When <emphasis role="bold">all</emphasis> is used either in <para>When <emphasis role="bold">all</emphasis> is used either in
the <emphasis role="bold">SOURCE</emphasis> or <emphasis the <emphasis role="bold">SOURCE</emphasis> or <emphasis
role="bold">DEST</emphasis> column intra-zone traffic is not role="bold">DEST</emphasis> column intra-zone traffic is not
@@ -955,11 +1090,6 @@
exclusion is supported -- see see <ulink exclusion is supported -- see see <ulink
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5).</para> url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5).</para>
<para><emphasis role="bold">any</emphasis> is equivalent to
<emphasis role="bold">all</emphasis> when there are no nested zones.
When there are nested zones, <emphasis role="bold">any</emphasis>
only refers to top-level zones (those with no parent zones).</para>
<para>The <replaceable>zone</replaceable> should be omitted in <para>The <replaceable>zone</replaceable> should be omitted in
DNAT-, REDIRECT- and NONAT rules.</para> DNAT-, REDIRECT- and NONAT rules.</para>
@@ -980,7 +1110,8 @@
</listitem> </listitem>
</orderedlist></para> </orderedlist></para>
<para>Except when <emphasis role="bold">all</emphasis>[<emphasis <para>Except when <emphasis
role="bold">{all|any}</emphasis>[<emphasis
role="bold">+]|[-</emphasis>] is specified, the server may be role="bold">+]|[-</emphasis>] is specified, the server may be
further restricted to a particular network, host or interface by further restricted to a particular network, host or interface by
appending ":" and the network, host or interface. See <emphasis appending ":" and the network, host or interface. See <emphasis
@@ -1001,7 +1132,7 @@
role="bold">DNAT-</emphasis>, the connections will be assigned to role="bold">DNAT-</emphasis>, the connections will be assigned to
addresses in the range in a round-robin fashion.</para> addresses in the range in a round-robin fashion.</para>
<para>If you kernel and iptables have ipset match support then you <para>If your kernel and iptables have ipset match support then you
may give the name of an ipset prefaced by "+". The ipset name may be may give the name of an ipset prefaced by "+". The ipset name may be
optionally followed by a number from 1 to 6 enclosed in square optionally followed by a number from 1 to 6 enclosed in square
brackets ([]) to indicate the number of levels of destination brackets ([]) to indicate the number of levels of destination
@@ -1226,22 +1357,41 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">RATE LIMIT</emphasis> (rate) - [<emphasis <term><emphasis role="bold">RATE LIMIT</emphasis> (rate) -
role="bold">-</emphasis>|[{<emphasis>s</emphasis>|<emphasis <replaceable>limit</replaceable></term>
role="bold">d</emphasis>}:[[<replaceable>name</replaceable>]:]]]<emphasis>rate</emphasis><emphasis
role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis
role="bold">hour</emphasis>|<emphasis
role="bold">day</emphasis>}[:<emphasis>burst</emphasis>]</term>
<listitem> <listitem>
<para>where <replaceable>limit</replaceable> is one of:</para>
<simplelist>
<member>[<emphasis
role="bold">-</emphasis>|[{<emphasis>s</emphasis>|<emphasis
role="bold">d</emphasis>}:[[<replaceable>name</replaceable>]:]]]<emphasis>rate</emphasis><emphasis
role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis
role="bold">hour</emphasis>|<emphasis
role="bold">day</emphasis>}[:<emphasis>burst</emphasis>]</member>
<member>[<replaceable>name</replaceable>1]:<emphasis>rate1</emphasis><emphasis
role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis
role="bold">hour</emphasis>|<emphasis
role="bold">day</emphasis>}[:<emphasis>burst1</emphasis>],[<replaceable>name</replaceable>2]:<emphasis>rate2</emphasis><emphasis
role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis
role="bold">hour</emphasis>|<emphasis
role="bold">day</emphasis>}[:<emphasis>burst2</emphasis>]</member>
</simplelist>
<para>You may optionally rate-limit the rule by placing a value in <para>You may optionally rate-limit the rule by placing a value in
this column:</para> this column:</para>
<para><emphasis>rate</emphasis> is the number of connections per <para><emphasis>rate*</emphasis> is the number of connections per
interval (<emphasis role="bold">sec</emphasis> or <emphasis interval (<emphasis role="bold">sec</emphasis> or <emphasis
role="bold">min</emphasis>) and <emphasis>burst</emphasis> is the role="bold">min</emphasis>) and <emphasis>burst</emphasis>* is the
largest burst permitted. If no <emphasis>burst</emphasis> is given, largest burst permitted. If no <emphasis>burst</emphasis> is given,
a value of 5 is assumed. There may be no no white-space embedded in a value of 5 is assumed. There may be no no white-space embedded in
the specification.</para> the specification.</para>
@@ -1250,15 +1400,28 @@
<para>When <option>s:</option> or <option>d:</option> is specified, <para>When <option>s:</option> or <option>d:</option> is specified,
the rate applies per source IP address or per destination IP address the rate applies per source IP address or per destination IP address
respectively. The <replaceable>name</replaceable> may be chosen by respectively. The <replaceable>name</replaceable>s may be chosen by
the user and specifies a hash table to be used to count matching the user and specifiy a hash table to be used to count matching
connections. If not given, the name <emphasis connections. If not given, the name <emphasis
role="bold">shorewallN</emphasis> (where N is a unique integer) is role="bold">shorewallN</emphasis> (where N is a unique integer) is
assumed. Where more than one rule specifies the same name, the assumed. Where more than one rule or POLICY specifies the same name,
connections counts for the rules are aggregated and the individual the connections counts for the rules are aggregated and the
rates apply to the aggregated count.</para> individual rates apply to the aggregated count.</para>
<para>Example: <emphasis role="bold">s:ssh:3/min:5</emphasis></para> <para>Beginning with Shorewall 4.6.5, two<replaceable>
limit</replaceable>s may be specified, separated by a comma. In this
case, the first limit (<replaceable>name1</replaceable>,
<replaceable>rate1</replaceable>, burst1) specifies the per-source
IP limit and the second limit specifies the per-destination IP
limit.</para>
<para>Example: <emphasis
role="bold">client:10/sec:20,:60/sec:100</emphasis></para>
<para>In this example, the 'client' hash table will be used to
enforce the per-source limit and the compiler will pick a unique
name for the hash table that tracks the per-destination
limit.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>

View File

@@ -70,7 +70,8 @@
<emphasis role="bold">openvpn</emphasis> - OpenVPN in point-to-point mode <emphasis role="bold">openvpn</emphasis> - OpenVPN in point-to-point mode
<emphasis role="bold">openvpnclient</emphasis> - OpenVPN client runs on the firewall <emphasis role="bold">openvpnclient</emphasis> - OpenVPN client runs on the firewall
<emphasis role="bold">openvpnserver</emphasis> - OpenVPN server runs on the firewall <emphasis role="bold">openvpnserver</emphasis> - OpenVPN server runs on the firewall
<emphasis role="bold">generic</emphasis> - Other tunnel type</programlisting> <emphasis role="bold">generic</emphasis> - Other tunnel type
<emphasis role="bold">tinc</emphasis> - TINC (added in Shorewall 4.6.6)</programlisting>
<para>If the type is <emphasis role="bold">ipsec</emphasis>, it may <para>If the type is <emphasis role="bold">ipsec</emphasis>, it may
be followed by <emphasis role="bold">:ah</emphasis> to indicate that be followed by <emphasis role="bold">:ah</emphasis> to indicate that
@@ -270,6 +271,19 @@
generic:udp:4444 net 4.3.99.124</programlisting> generic:udp:4444 net 4.3.99.124</programlisting>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>Example 9:</term>
<listitem>
<para>TINC tunnel where the remote gateways are not specified. If
you wish to specify a list of gateways, you can do so in the GATEWAY
column.</para>
<programlisting> #TYPE ZONE GATEWAY GATEWAY ZONES
tinc net 0.0.0.0/0</programlisting>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>

View File

@@ -112,7 +112,7 @@
role="bold">none</emphasis>}</term> role="bold">none</emphasis>}</term>
<listitem> <listitem>
<para></para> <para/>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -122,7 +122,7 @@
role="bold">none</emphasis>}</term> role="bold">none</emphasis>}</term>
<listitem> <listitem>
<para></para> <para/>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -132,7 +132,7 @@
role="bold">none</emphasis>}</term> role="bold">none</emphasis>}</term>
<listitem> <listitem>
<para></para> <para/>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -142,7 +142,7 @@
role="bold">none</emphasis>}</term> role="bold">none</emphasis>}</term>
<listitem> <listitem>
<para></para> <para/>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -309,17 +309,22 @@
<term>stoppedrules</term> <term>stoppedrules</term>
<listitem> <listitem>
<para>If ADMINISABSENTMINDED=No, a warning message is issued <para>All existing connections continue to work. To sever all
and the setting is ignored.</para> existing connections when the firewall is stopped, install the
conntrack utility and place the command <command>conntrack
<para>In addition to connections matching entries in -F</command> in the stopped user exit
<filename>stoppedrules</filename>, existing connections
continue to work and all new connections from the firewall
system itself are allowed. To sever all existing connections
when the firewall is stopped, install the conntrack utility
and place the command <command>conntrack -F</command> in the
stopped user exit
(<filename>/etc/shorewall/stopped</filename>).</para> (<filename>/etc/shorewall/stopped</filename>).</para>
<para>If ADMINISABSENTMINDED=No, only new connections matching
entries in <filename>stoppedrules</filename> are accepted when
Shorewall is stopped. Response packets and related connections
are automatically accepted.</para>
<para>If ADMINISABSENTMINDED=Yes, in addition to connections
matching entries in <filename>stoppedrules</filename>, all new
connections from the firewall system itself are allowed when
the firewall is stopped. Response packets and related
connections are automatically accepted.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
@@ -379,6 +384,11 @@
<para>Set AUTOHELPERS=No.</para> <para>Set AUTOHELPERS=No.</para>
</listitem> </listitem>
<listitem>
<para>Modify the HELPERS setting (see below) to list the helpers
that you need.</para>
</listitem>
<listitem> <listitem>
<para>Either:</para> <para>Either:</para>
@@ -897,9 +907,10 @@ net all DROP info</programlisting>then the chain name is 'net-all'
role="bold">HELPERS</emphasis>=[<emphasis>helper</emphasis>[,<replaceable>helper</replaceable>...]]</term> role="bold">HELPERS</emphasis>=[<emphasis>helper</emphasis>[,<replaceable>helper</replaceable>...]]</term>
<listitem> <listitem>
<para>Added in Shorewall 4.5.7. This option lists the Netfilter <para>Added in Shorewall 4.5.7. This option specifies a
application helpers that are to be enabled. If not specified, the comma-separated list naming the Netfilter application helpers that
default is to enable all helpers.</para> are to be enabled. If not specified, the default is to enable all
helpers.</para>
<para>Possible values for <replaceable>helper</replaceable> <para>Possible values for <replaceable>helper</replaceable>
are:</para> are:</para>
@@ -1169,7 +1180,7 @@ net all DROP info</programlisting>then the chain name is 'net-all'
</varlistentry> </varlistentry>
</variablelist> </variablelist>
<para></para> <para/>
<blockquote> <blockquote>
<para>If this variable is not set or is given an empty value <para>If this variable is not set or is given an empty value
@@ -1306,6 +1317,45 @@ net all DROP info</programlisting>then the chain name is 'net-all'
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis
role="bold">LOG_BACKEND=</emphasis>[<emphasis>backend</emphasis>]</term>
<listitem>
<para>Added in Shorewall 4.6.4. LOG_BACKEND determines the logging
backend to be used for the <command>iptrace</command> command (see
<ulink url="manpages/shorewall.html">shorewall(8)</ulink>).</para>
<para><replaceable>backend</replaceable> is one of:</para>
<variablelist>
<varlistentry>
<term>LOG</term>
<listitem>
<para>Use standard kernel logging.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>ULOG</term>
<listitem>
<para>Use ULOG logging to ulogd.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>netlink</term>
<listitem>
<para>Use netlink logging to ulogd version 2 or later.</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">LOG_MARTIANS=</emphasis>[<emphasis <term><emphasis role="bold">LOG_MARTIANS=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">Yes</emphasis>|<emphasis
@@ -1379,7 +1429,7 @@ net all DROP info</programlisting>then the chain name is 'net-all'
</listitem> </listitem>
</itemizedlist> </itemizedlist>
<para></para> <para/>
<blockquote> <blockquote>
<para>For example, using the default LOGFORMAT, the log prefix for <para>For example, using the default LOGFORMAT, the log prefix for
@@ -1396,7 +1446,7 @@ net all DROP info</programlisting>then the chain name is 'net-all'
control your firewall after you enable this option.</para> control your firewall after you enable this option.</para>
</important> </important>
<para></para> <para/>
<caution> <caution>
<para>Do not use this option if the resulting log messages will <para>Do not use this option if the resulting log messages will
@@ -1457,8 +1507,8 @@ net all DROP info</programlisting>then the chain name is 'net-all'
role="bold">d</emphasis>}:]<emphasis>rate</emphasis><emphasis role="bold">d</emphasis>}:]<emphasis>rate</emphasis><emphasis
role="bold">/</emphasis>{<emphasis role="bold">/</emphasis>{<emphasis
role="bold">sec</emphasis>|<emphasis role="bold">sec</emphasis>|<emphasis
role="bold">min</emphasis>|<emphasis role="bold">second|min</emphasis>|<emphasis
role="bold">hour</emphasis>|<emphasis role="bold">minute|hour</emphasis>|<emphasis
role="bold">day</emphasis>}[:<emphasis>burst</emphasis>]]</term> role="bold">day</emphasis>}[:<emphasis>burst</emphasis>]]</term>
<listitem> <listitem>
@@ -1472,6 +1522,10 @@ net all DROP info</programlisting>then the chain name is 'net-all'
<para>If <replaceable>burst</replaceable> is not specified, then a <para>If <replaceable>burst</replaceable> is not specified, then a
value of 5 is assumed.</para> value of 5 is assumed.</para>
<para>The keywords <emphasis role="bold">second</emphasis> and
<emphasis role="bold">minute</emphasis> are accepted beginning with
Shorewall 4.6.13.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -1740,8 +1794,8 @@ LOG:info:,bar net fw</programlisting>
<listitem> <listitem>
<para>The value of this option determines the possible file <para>The value of this option determines the possible file
extensions of kernel modules. The default value is "ko ko.gz o o.gz extensions of kernel modules. The default value is "ko ko.gz ko.xz o
gz".</para> o.gz o.xz gz xz".</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -2118,7 +2172,7 @@ LOG:info:,bar net fw</programlisting>
role="bold">"</emphasis></term> role="bold">"</emphasis></term>
<listitem> <listitem>
<para></para> <para/>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -2425,7 +2479,8 @@ INLINE - - - ; -j REJECT
<varlistentry> <varlistentry>
<term><emphasis role="bold">SAVE_IPSETS=</emphasis>{<emphasis <term><emphasis role="bold">SAVE_IPSETS=</emphasis>{<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>}</term> role="bold">Yes</emphasis>|<emphasis
role="bold">No|ipv4|<replaceable>setlist</replaceable></emphasis>}</term>
<listitem> <listitem>
<para>Re-enabled in Shorewall 4.4.6. If SAVE_IPSETS=Yes, then the <para>Re-enabled in Shorewall 4.4.6. If SAVE_IPSETS=Yes, then the
@@ -2434,6 +2489,11 @@ INLINE - - - ; -j REJECT
role="bold">shorewall save</emphasis> commands and restored by the role="bold">shorewall save</emphasis> commands and restored by the
<emphasis role="bold">shorewall start</emphasis> and <emphasis <emphasis role="bold">shorewall start</emphasis> and <emphasis
role="bold">shorewall restore</emphasis> commands.</para> role="bold">shorewall restore</emphasis> commands.</para>
<para>Beginning with Shorewall 4.6.4, you can restrict the set of
ipsets saved by specifying a setlist (a comma-separated list of ipv4
ipset names). You may also restrict the saved sets to just the ipv4
ones by specifying <emphasis role="bold">ipv4</emphasis>.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@@ -2917,8 +2977,8 @@ INLINE - - - ; -j REJECT
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><emphasis role="bold">WIDE_TC_MARKS=</emphasis>{<emphasis <term><emphasis role="bold">WIDE_TC_MARKS=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>}</term> role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
<listitem> <listitem>
<para>Deprecated in Shorewall 4.4.26 in favor of TC_BITS and <para>Deprecated in Shorewall 4.4.26 in favor of TC_BITS and
@@ -2932,6 +2992,27 @@ INLINE - - - ; -j REJECT
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><emphasis role="bold">WORKAROUNDS=</emphasis>[<emphasis
role="bold">Yes</emphasis>|<emphasis role="bold">No</emphasis>]</term>
<listitem>
<para>Added in Shorewall 4.6.11. Over time, there have been a number
of changes in Shorewall that work around defects in other products
such as iptables and ipset. When WORKAROUNDS=Yes, these workarounds
are enabled; when WORKAROUNDS=No, they are disabled. If not
specified or if specified as empty, WORKAROUNDS=Yes is
assumed.</para>
<warning>
<para>Do not set WORKAROUNDS=Yes if you need to be able to use
Shorewall-generated scripts (such as created by the
<command>save</command> command) built by Shorewall 4.4.7 or
older.</para>
</warning>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><emphasis <term><emphasis
role="bold">ZONE_BITS</emphasis>=[<replaceable>number</replaceable>]</term> role="bold">ZONE_BITS</emphasis>=[<replaceable>number</replaceable>]</term>
@@ -2946,7 +3027,7 @@ INLINE - - - ; -j REJECT
<varlistentry> <varlistentry>
<term><emphasis <term><emphasis
role="bold">ZONE2ZONE</emphasis>={<option>2</option>|<option>-</option>}</term> role="bold">ZONE2ZONE</emphasis>=[<option>2</option>|<option>-</option>]</term>
<listitem> <listitem>
<para>Added in Shorewall 4.4.4. This option determines how Shorewall <para>Added in Shorewall 4.4.4. This option determines how Shorewall

File diff suppressed because it is too large Load Diff

View File

@@ -28,4 +28,3 @@ loadmodule iptable_nat
loadmodule iptable_raw loadmodule iptable_raw
loadmodule xt_state loadmodule xt_state
loadmodule xt_tcpudp loadmodule xt_tcpudp
loadmodule ipt_LOG

View File

@@ -32,7 +32,6 @@ loadmodule ipt_ipp2p
loadmodule ipt_iprange loadmodule ipt_iprange
loadmodule ipt_length loadmodule ipt_length
loadmodule ipt_limit loadmodule ipt_limit
loadmodule ipt_LOG
loadmodule ipt_mac loadmodule ipt_mac
loadmodule ipt_mark loadmodule ipt_mark
loadmodule ipt_MARK loadmodule ipt_MARK
@@ -58,4 +57,3 @@ loadmodule ipt_tos
loadmodule ipt_TOS loadmodule ipt_TOS
loadmodule ipt_ttl loadmodule ipt_ttl
loadmodule ipt_TTL loadmodule ipt_TTL
loadmodule ipt_ULOG

View File

@@ -31,7 +31,6 @@ loadmodule xt_mac
loadmodule xt_mark loadmodule xt_mark
loadmodule xt_MARK loadmodule xt_MARK
loadmodule xt_multiport loadmodule xt_multiport
loadmodule xt_NFLOG
loadmodule xt_NFQUEUE loadmodule xt_NFQUEUE
loadmodule xt_owner loadmodule xt_owner
loadmodule xt_physdev loadmodule xt_physdev

View File

@@ -1,20 +1,21 @@
# #
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall - V4.4 # The Shoreline Firewall (Shorewall) Packet Filtering Firewall
# #
# Copyright 2011 Jonathan Underwood (jonathan.underwood@gmail.com) # Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
# #
[Unit] [Unit]
Description=Shorewall IPv4 firewall Description=Shorewall IPv4 firewall
After=syslog.target Wants=network-online.target
After=network.target After=network-online.target
Conflicts=iptables.service firewalld.service
[Service] [Service]
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
EnvironmentFile=-/etc/sysconfig/shorewall EnvironmentFile=-/etc/sysconfig/shorewall
StandardOutput=syslog StandardOutput=syslog
ExecStart=/sbin/shorewall $OPTIONS start ExecStart=/sbin/shorewall $OPTIONS start $STARTOPTIONS
ExecStop=/sbin/shorewall $OPTIONS stop ExecStop=/sbin/shorewall $OPTIONS stop
[Install] [Install]
WantedBy=multi-user.target WantedBy=basic.target

View File

@@ -0,0 +1,21 @@
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
#
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
#
[Unit]
Description=Shorewall IPv4 firewall
Wants=network-online.target
After=network-online.target
Conflicts=iptables.service firewalld.service
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=-/etc/sysconfig/shorewall
StandardOutput=syslog
ExecStart=/sbin/shorewall $OPTIONS start $STARTOPTIONS
ExecStop=/sbin/shorewall $OPTIONS stop
[Install]
WantedBy=basic.target

View File

@@ -0,0 +1,22 @@
#
# The Shoreline Firewall (Shorewall) Packet Filtering Firewall
#
# Copyright 2011 Jonathan Underwood <jonathan.underwood@gmail.com>
# Copyright 2015 Tom Eastep <teastep@shorewall.net>
#
[Unit]
Description=Shorewall IPv4 firewall
Wants=network-online.target
After=network-online.target
Conflicts=iptables.service firewalld.service
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=-/etc/default/shorewall
StandardOutput=syslog
ExecStart=/sbin/shorewall $OPTIONS start $STARTOPTIONS
ExecStop=/sbin/shorewall $OPTIONS stop
[Install]
WantedBy=basic.target

View File

@@ -27,14 +27,25 @@
# shown below. Simply run this script to remove Shorewall Firewall # shown below. Simply run this script to remove Shorewall Firewall
VERSION=xxx #The Build script inserts the actual version VERSION=xxx #The Build script inserts the actual version
PRODUCT=shorewall
usage() # $1 = exit status usage() # $1 = exit status
{ {
ME=$(basename $0) ME=$(basename $0)
echo "usage: $ME [ <shorewallrc file> ]" echo "usage: $ME [ <option> ] [ <shorewallrc file> ]"
echo "where <option> is one of"
echo " -h"
echo " -v"
echo " -n"
exit $1 exit $1
} }
fatal_error()
{
echo " ERROR: $@" >&2
exit 1
}
qt() qt()
{ {
"$@" >/dev/null 2>&1 "$@" >/dev/null 2>&1
@@ -69,6 +80,43 @@ remove_file() # $1 = file to restore
fi fi
} }
finished=0
configure=1
while [ $finished -eq 0 ]; do
option=$1
case "$option" in
-*)
option=${option#-}
while [ -n "$option" ]; do
case $option in
h)
usage 0
;;
v)
echo "$Product Firewall Installer Version $VERSION"
exit 0
;;
n*)
configure=0
option=${option#n}
;;
*)
usage 1
;;
esac
done
shift
;;
*)
finished=1
;;
esac
done
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
if [ -f ./shorewallrc ]; then if [ -f ./shorewallrc ]; then
. ./shorewallrc . ./shorewallrc
@@ -110,37 +158,54 @@ fi
echo "Uninstalling shorewall $VERSION" echo "Uninstalling shorewall $VERSION"
if qt iptables -L shorewall -n && [ ! -f ${SBINDIR}/shorewall-lite ]; then [ -n "$SANDBOX" ] && configure=0
shorewall clear
if [ $configure -eq 1 ]; then
if qt iptables -L shorewall -n && [ ! -f ${SBINDIR}/shorewall-lite ]; then
shorewall clear
fi
fi fi
rm -f ${SBINDIR}/shorewall rm -f ${SBINDIR}/shorewall
if [ -f "$INITSCRIPT" ]; then if [ -L ${SHAREDIR}/shorewall/init ]; then
if mywhich updaterc.d ; then FIREWALL=$(readlink -m -q ${SHAREDIR}/shorewall/init)
updaterc.d ${PRODUCT} remove elif [ -n "$INITFILE" ]; then
elif mywhich insserv ; then FIREWALL=${INITDIR}/${INITFILE}
insserv -r $INITSCRIPT fi
elif mywhich chkconfig ; then
chkconfig --del $(basename $INITSCRIPT) if [ -f "$FIREWALL" ]; then
elif mywhich systemctl ; then if [ $configure -eq 1 ]; then
systemctl disable ${PRODUCT} if mywhich updaterc.d ; then
updaterc.d ${PRODUCT} remove
elif mywhich insserv ; then
insserv -r $FIREWALL
elif mywhich chkconfig ; then
chkconfig --del $(basename $FIREWALL)
fi
fi fi
remove_file $INITSCRIPT remove_file $FIREWALL
fi
if [ -z "${SERVICEDIR}" ]; then
SERVICEDIR="$SYSTEMD"
fi
if [ -n "$SERVICEDIR" ]; then
[ $configure -eq 1 ] && systemctl disable ${PRODUCT}
rm -f $SERVICEDIR/shorewall.service
fi fi
rm -rf ${SHAREDIR}/shorewall/version rm -rf ${SHAREDIR}/shorewall/version
rm -rf ${CONFDIR}/shorewall rm -rf ${CONFDIR}/shorewall
if [ -n "$SYSCONFDIR" ]; then if [ -n "$SYSCONFDIR" ]; then
[ -n "$SYSCONFFILE" ] || SYSCONFFILE=${PRODUCT}; [ -n "$SYSCONFFILE" ] && rm -f ${SYSCONFDIR}/${PRODUCT}
rm -f ${SYSCONFDIR}/${SYSCONFFILE}
fi fi
rm -rf ${VARDIR}/shorewall rm -rf ${VARDIR}/shorewall
rm -rf ${PERLLIB}/Shorewall/* rm -rf ${PERLLIBDIR}/Shorewall/*
rm -rf ${LIBEXEC}/shorewall [ ${LIBEXECDIR} = ${SHAREDIR} ] || rm -rf ${LIBEXECDIR}/shorewall
rm -rf ${SHAREDIR}/shorewall/configfiles/ rm -rf ${SHAREDIR}/shorewall/configfiles/
rm -rf ${SHAREDIR}/shorewall/Samples/ rm -rf ${SHAREDIR}/shorewall/Samples/
rm -rf ${SHAREDIR}/shorewall/Shorewall/ rm -rf ${SHAREDIR}/shorewall/Shorewall/

View File

@@ -39,7 +39,7 @@ fi
start() { start() {
echo -n $"Starting Shorewall: " echo -n $"Starting Shorewall: "
$shorewall $OPTIONS start 2>&1 | $logger $shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
retval=${PIPESTATUS[0]} retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then if [[ $retval == 0 ]]; then
touch $lockfile touch $lockfile
@@ -69,7 +69,7 @@ restart() {
# Note that we don't simply stop and start since shorewall has a built in # Note that we don't simply stop and start since shorewall has a built in
# restart which stops the firewall if running and then starts it. # restart which stops the firewall if running and then starts it.
echo -n $"Restarting Shorewall: " echo -n $"Restarting Shorewall: "
$shorewall $OPTIONS restart 2>&1 | $logger $shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
retval=${PIPESTATUS[0]} retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then if [[ $retval == 0 ]]; then
touch $lockfile touch $lockfile

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