Compare commits

...

626 Commits

Author SHA1 Message Date
Tom Eastep
675e41e6a6 Merge branch 'master' into 5.1.10 2017-12-27 11:15:25 -08:00
Tom Eastep
28f6379956 Fix broken links in the blacklisting article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-26 16:57:44 -08:00
Tom Eastep
c9b58e203b Fix broken links in the blacklisting article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-26 16:56:37 -08:00
Tom Eastep
9afe8daae0 Merge branch '5.1.10'
# Conflicts:
#	Shorewall-core/install.sh
#	Shorewall/install.sh
2017-12-26 15:45:20 -08:00
Tom Eastep
43adcd26a1 Make the /etc and the configfiles .conf files the same
Signed-off-by: Tom Eastep <teastep@shorewall.net>

# Conflicts:
#	Shorewall/install.sh
2017-12-26 15:39:26 -08:00
Tom Eastep
65371437b5 Correct installer for case where SHAREDIR != /usr/share/
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-26 15:36:38 -08:00
Tom Eastep
cc2022e172 Correct installer for case where SHAREDIR != /usr/share/
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-26 15:00:15 -08:00
Tom Eastep
f2a565729f Replace $PRODUCT with ${PRODUCT}
- Also correct one incidence of PRODUCT that should have been $PRODUCT

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-26 14:00:00 -08:00
Tom Eastep
ea8b2a803a Make the /etc and the configfiles .conf files the same
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-26 11:48:33 -08:00
Tom Eastep
16832149ca Remove unneeded modification of $CONFDIR/$PRODUCT/$PRODUCT.conf
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-26 11:35:56 -08:00
Tom Eastep
7edf4918d7 Remove leading ":" from CONFIG_PATH in active shorewall[6].conf
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-26 10:27:19 -08:00
Tom Eastep
d3a1dc1e2a Delete superfluous semicolon.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-25 08:45:42 -08:00
Matt Darfeuille
f68f47d01b Init: Fix when to compile the firewall on Debian
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-25 08:37:00 -08:00
Tom Eastep
b1d1fa862a Add comment noting that the 'physwild' interface member is currently unused
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-23 10:58:16 -08:00
Tom Eastep
24acf25451 Delete unused find_interfaces_by_option1()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-23 10:53:16 -08:00
Tom Eastep
229c47ac6c Don't delete options that are to be ignored from %options
- specifying some options can have side-effects that cause
  $interfaceref->{options}{$option} to be accessed

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-23 10:47:22 -08:00
Tom Eastep
38de9c1732 Make wildcard/option checks order-independent WRT the options
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-23 10:24:08 -08:00
Tom Eastep
17f4fd7cd2 Initialize $physwild to $wildcard
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-22 15:42:16 -08:00
Tom Eastep
cfd02c1bb6 More $minroot changes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-22 13:58:38 -08:00
Tom Eastep
02caeb5aa0 Remove sourceroute=0 from IPv6 Universal interface options
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-22 13:44:11 -08:00
Tom Eastep
19b7601c72 Improve handling of wildcard interfaces and options
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-22 13:43:45 -08:00
Tom Eastep
5a8e9cd0a3 Correct $minroot logic
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-22 09:08:27 -08:00
Tom Eastep
b5a6067588 Describe default interval and decay for rate estimator policing filters
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-20 09:04:52 -08:00
Tom Eastep
45468af2d2 Correct ingress policing for later releases of iproute2
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-18 11:52:19 -08:00
Tom Eastep
6c018f478c Avoid unnecessary recompilation by Shorewall-init
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-18 10:25:56 -08:00
Tom Eastep
dec3cacb2a Correct typo in the Helpers Article
Port 1729 -> port 1723 for PPTP

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-08 15:28:01 -08:00
Tom Eastep
4ab8e1f0a2 Remove PSH from the FIN action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-05 15:25:54 -08:00
Tom Eastep
821d72093a Rename DEFAULTACTION_SECTION to POLICYACTION_SECTION.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-02 16:25:15 -08:00
Tom Eastep
42d5d13780 Retain proto setting when switching inline <-> noinline
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-02 13:40:41 -08:00
Tom Eastep
7121a0f1b1 Disallow a protocol on the Reject Action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-02 12:58:05 -08:00
Tom Eastep
ab12d63a4f Change 'default action' to 'policy action' in comments and messages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-02 12:55:17 -08:00
Tom Eastep
6ba1d5413b Allow a protocol to be associated with an action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-02 11:24:08 -08:00
Tom Eastep
4fc572f664 Exit the IPv6 AllowICMPs chain if packet isn't ipv6-icmp
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-01 14:50:17 -08:00
Tom Eastep
138e64c54a Improve the documentation surrounding DNS names.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-12-01 09:25:20 -08:00
Tom Eastep
b04b65cac8 Clear counters in all tables during 'reset'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-30 14:31:59 -08:00
Tom Eastep
c907748b52 Correct typo in 'dump'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-30 14:31:33 -08:00
Tom Eastep
7f3414e3d8 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2017-11-29 08:19:57 -08:00
Roberto C. Sánchez
c75fe2ea8d Fix typo 2017-11-29 06:56:06 -05:00
Tom Eastep
5dcb684efc Don't be specific when deleting IPv6 balanced/fallback default routes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-28 15:26:17 -08:00
Tom Eastep
3e87e5004a Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2017-11-27 09:36:13 -08:00
Roberto C. Sánchez
c89b113a61 Fix typos 2017-11-26 15:39:59 -05:00
Tom Eastep
7289175070 Chop first config dir if non-root or if compiling for export.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-23 09:57:12 -08:00
Tom Eastep
5aaf1e53de IPv6 Samples use logical interface names
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-22 09:56:45 -08:00
Tom Eastep
a9373d727b Use logical interface names in the samples.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-22 09:40:15 -08:00
Tom Eastep
528b473f6b Add some additional documentation to the Config module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-22 08:41:37 -08:00
Tom Eastep
d22210c074 Set g_export before calling get_config()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-14 13:46:41 -08:00
Tom Eastep
89d6009200 Revert "Fix for copying SYSCONFFILE. Gave a Permission denied on OpenWRT"
This reverts commit f0cb3f50e4.
2017-11-14 10:48:56 -08:00
Tom Eastep
f411f7dd31 Remove redundant test
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-14 10:45:10 -08:00
Tom Eastep
502e98eb9f Add Redfish console to the IPMI macro
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-14 10:44:54 -08:00
Tom Eastep
f73bad440d Don't verify IP and SHOREWALL_SHELL when compiling/checking for test
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-14 10:02:15 -08:00
W. van den Akker
f0cb3f50e4 Fix for copying SYSCONFFILE. Gave a Permission denied on OpenWRT
Signed-off-by: W. van den Akker <wvdakker@wilsoft.nl>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-14 09:01:06 -08:00
W. van den Akker
23bc019a82 Add OpenWRT options.
Signed-off-by: W. van den Akker <wvdakker@wilsoft.nl>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-14 09:00:46 -08:00
Tom Eastep
9d299ef866 Don't verify IP and SHOREWALL_SHELL setting when compiling for export
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-14 08:50:05 -08:00
Tom Eastep
2a9272ccd1 Clean up RAs involving "|"
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-14 08:26:17 -08:00
Tom Eastep
130ddff9de Correct a typo in an error message
- Includes cosmetic changes to Providers.pm

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-10 11:25:52 -08:00
Tom Eastep
9cf298482d Merge branch '5.1.8' 2017-11-09 12:59:59 -08:00
Tom Eastep
c5a586aa37 Allow [...] around gateway address in the providers file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-09 12:20:01 -08:00
Tom Eastep
0670ecaf5e Update Shared Configuration Article
- Add network graphic

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-08 18:47:23 -08:00
Tom Eastep
d3eebde464 Add another restriction for SAVE_IPSETS=Yes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-08 10:56:57 -08:00
Tom Eastep
832418585a Don't make persistent routes and rules dependent on autosrc.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-08 09:46:25 -08:00
Tom Eastep
605f61fb3c Don't make persistent routes and rules dependent on autosrc.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-08 09:45:59 -08:00
Tom Eastep
824f4ca570 Update Shared Configuration document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-08 09:44:40 -08:00
Tom Eastep
9acdbb5acf Unify online manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-03 10:43:48 -07:00
Tom Eastep
8dfa0be611 Add shorewall-logging(5)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-02 15:26:14 -07:00
Tom Eastep
ef8b85fc3e Implement support for logging in the SNAT file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-11-02 12:44:42 -07:00
Tom Eastep
2b5613026a Merge branch '5.1.8' 2017-10-25 09:14:20 -07:00
Tom Eastep
c7c318c0e7 Align columns in actions.std
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-25 09:13:37 -07:00
Tom Eastep
b48e5a8932 Create new Netfilter diagram using Dia
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-25 09:13:08 -07:00
Tom Eastep
d1976189aa Correct a couple of typos in the manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-22 12:59:31 -07:00
Tom Eastep
6b4905c2c0 Replace 'tcp' with '6' in action.TCPFlags
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-20 12:33:36 -07:00
Tom Eastep
774b707352 Inline Multicast when Address Type Match is available
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-20 12:01:41 -07:00
Tom Eastep
c3bd58827f Align columns in actions.std
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-20 11:44:10 -07:00
Tom Eastep
b35f1112f4 Allow 'noinline' in /etc/shorewall[6]/actions to override 'inline'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-20 09:19:50 -07:00
Tom Eastep
a0eb91cb90 Inline the Broadcast action when ADDRTYPE match is available
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-20 08:49:14 -07:00
Tom Eastep
105e6a3d01 Create new Netfilter diagram using Dia
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-19 14:51:36 -07:00
Tom Eastep
77d9eeb915 Eliminate extra parameter editing of TPROXY parameter list.
- Clarify syntax for actions with multiple parameters

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-19 13:08:12 -07:00
Tom Eastep
17838c1443 Add TCPMSS to the allowed mangle actions.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-19 12:58:38 -07:00
Tom Eastep
5867ce6c3b CLAMPMSS now done in the mangle table.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-18 15:55:07 -07:00
Tom Eastep
84cd80eba9 Update the Shared Config document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-17 16:51:35 -07:00
Tom Eastep
9b02f7a922 Update Shared config article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-15 19:15:13 -07:00
Tom Eastep
f1975ae9b0 More robust detection of empty SPD entries.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-15 08:26:27 -07:00
Tom Eastep
7b9f7c095d Don't dump SPD entries for the other address family
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-14 13:39:00 -07:00
Tom Eastep
8ea96098bf Warning when 'persistent' used with RESTORE_DEFAULT_ROUTE=Yes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-11 15:22:07 -07:00
Tom Eastep
02ed36332a Revert "Warn when RESTORE_DEFAULT_ROUTE=Yes and a persistent provider is defined"
This reverts commit 39a3c72057.
2017-10-11 11:24:54 -07:00
Tom Eastep
15a3b29a32 Revert "Document warning when RESTORE_DEFAULT_ROUTE=Yes and 'persistent'"
This reverts commit bfab002dda.
2017-10-11 11:24:39 -07:00
Tom Eastep
cb4f9e7261 Don't restore default routes when there is an enabled fallback provider
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-11 11:24:13 -07:00
Tom Eastep
bfab002dda Document warning when RESTORE_DEFAULT_ROUTE=Yes and 'persistent'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-11 11:01:09 -07:00
Tom Eastep
ddb12fcad9 Add/correct comments
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-11 11:00:46 -07:00
Tom Eastep
42ce754961 Don't restore default routes when a fallback= provider is enabled
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-11 11:00:05 -07:00
Tom Eastep
5cd4d63bc5 Delete main default routes when a fallback provider is enabled
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-11 10:59:31 -07:00
Tom Eastep
5b567f2d8b Correct delete_default_routes() in tables other than main
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-11 10:58:48 -07:00
Tom Eastep
39a3c72057 Warn when RESTORE_DEFAULT_ROUTE=Yes and a persistent provider is defined
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-11 10:58:09 -07:00
Tom Eastep
b47e633c38 Use 'route replace' rather than 'route add' to avoid persistence issues
Previous failure case was:

- disable interface
- reload
- enable interface

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-09 08:58:10 -07:00
Tom Eastep
1b55a37a28 Ensure that 'rule add' commands don't fail with persistent interfaces
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-08 08:53:53 -07:00
Tom Eastep
a97dcd23d0 Allow merging of rules that specify an IPSEC policy
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-07 13:17:43 -07:00
Tom Eastep
108b169d8d Treat LOG_TARGET like all other capabilities
- Previous implementation could generate unworkable script when
  LOAD_HELPERS_ONLY=Yes

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-06 08:01:52 -07:00
Tom Eastep
a9fbaa57ed Pass -$g_family to 'ip xfrm' commands
- This currently doesn't work correctly, but maybe it will in the future

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-10-06 08:00:29 -07:00
Tom Eastep
317f12041b Strengthen the test for empty SPD entries
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-30 15:43:17 -07:00
Tom Eastep
8469f983d8 Merge branch '5.1.7'
# Conflicts:
#	Shorewall/Perl/prog.footer
2017-09-29 15:25:37 -07:00
Tom Eastep
f54acb665a Correct handling of mark range in MARK target.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-29 14:44:33 -07:00
Tom Eastep
3d2e9eb93e Improve the fix for SELinux "getattr" denials
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-28 15:16:50 -07:00
Tom Eastep
c6a939301f Improve the fix for SELinux "getattr" denials
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-28 15:16:00 -07:00
Tom Eastep
1cb98254cc Handle SELinux getattr denials in open() processing
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-26 16:42:54 -07:00
Tom Eastep
baa791a1e3 Handle SELinux getattr denials in open() processing
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-26 16:41:50 -07:00
Tom Eastep
8b4b965f63 Remove unnecessary disable/enable of script generation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-21 14:36:30 -07:00
Tom Eastep
8ee2d6246c Update a comment in the compiler
- get_configuration() also processes the shorewallrc file(s)

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-21 12:32:34 -07:00
Tom Eastep
a7be3dfece Align progress messages produced by 'reenable'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-19 13:29:13 -07:00
Tom Eastep
846e8c4ece Correct reenable logic
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-19 13:29:08 -07:00
Tom Eastep
e2bf7e6584 Align progress messages produced by 'reenable'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-19 13:28:09 -07:00
Tom Eastep
ff3994f6a1 Correct reenable logic
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-19 13:17:50 -07:00
Tom Eastep
494ec9c59c Avoid extra comparison in reload_command()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-19 10:49:11 -07:00
Tom Eastep
1cde92e8f3 Initialize g_dockeringress
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-19 10:43:44 -07:00
Tom Eastep
721a1e3b33 Initialize g_dockeringress
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-19 10:39:52 -07:00
Tom Eastep
84fa774cb7 Change copyright dates in lib.runtime
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-19 09:03:00 -07:00
Tom Eastep
c39bc7b65f Update version of lib.*installer
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-18 13:09:35 -07:00
Tom Eastep
2548e8741d Update version and copyright dates in lib.common
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-18 13:07:37 -07:00
Tom Eastep
0a31fba6bb Update version and copyright dates in lib.core
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-18 13:00:50 -07:00
Tom Eastep
9701c9c522 Update version and copyright dates in lib.base
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-18 12:57:02 -07:00
Tom Eastep
973d352209 Update shorewall script
- Update copyright dates
- Add a comment about PRODUCT setting

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-18 12:51:27 -07:00
Tom Eastep
91e59c2ed4 Remove the Lite Makefiles
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-18 11:56:04 -07:00
Tom Eastep
be5aabcbfb Correct typo in Chains.pm
&g_dockeringress -> $g_dockeringress

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-18 10:14:22 -07:00
Tom Eastep
a8937e6bc8 Correct harmless typo
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-18 10:06:41 -07:00
Tom Eastep
e91bd9a0e9 Remove useless/empty .tmp file when SAVE_IPSETS is set
- Add SAVE_IPSETS support to the Redhat/Fedora sysv init script

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-18 09:28:43 -07:00
Tom Eastep
5e1cf17ebc DOCKER-INGRESS support
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-17 10:57:29 -07:00
Tom Eastep
85a7ec6fe5 Correct module loading in the compiler
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-14 15:08:38 -07:00
Tom Eastep
fb831e3128 Remove empty/useless ipsets tmp file in Shorewall-init
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-12 11:56:24 -07:00
Tom Eastep
2ed11c7e15 Default ADD_IP_ALIASES to 'No' in Shorewall6
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-12 11:55:53 -07:00
Tom Eastep
ef1353790e Correct VLSM editing in the 'ipcalc' command.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-12 10:53:41 -07:00
Tom Eastep
4f79d2e82b Move and simplify handling of nat columns
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-12 10:53:04 -07:00
Tom Eastep
e6a2ba78a4 Correct handling of DEST column during action invocation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-08 10:05:37 -07:00
Tom Eastep
41ea3bdeda Modify the Event actions to handle NAT rules
- Separate DNAT and REDIRECT into DNAT- and REDIRECT- plus ACCEPT

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-08 09:47:12 -07:00
Tom Eastep
1065c2951b Allow NAT targets to be passed to the Event actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-08 09:46:03 -07:00
Tom Eastep
3b373f3f21 Correct handling of ipsets in the DEST column of the snat file
- Also corrected handling of exclusion

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-06 11:30:42 -07:00
Tom Eastep
0c05ab3bff Correct typo in shorewall-snat(5)
- missing ':' in IPv4 Example 4.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-09-05 10:29:19 -07:00
Tom Eastep
ef3a33e3f4 Merge branch '5.1.6'
# Conflicts:
#	Shorewall-core/lib.common

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-30 15:02:23 -07:00
Tom Eastep
8a78fb6e77 Correct -p check for the conntrack utility's availability
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-29 09:06:36 -07:00
Tom Eastep
b54a691110 Improve dynamic gateway detection
- Use provider's routing table, if any

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-23 15:04:47 -07:00
Tom Eastep
90f33dd436 Eliminate MODULE_SUFFIX
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-23 12:48:14 -07:00
Tom Eastep
b7aef24d7c Delete useless line of code
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-23 12:18:29 -07:00
Tom Eastep
6f475cde3f Eliminate MODULE_SUFFIX
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-23 10:19:25 -07:00
Tom Eastep
6053a40af0 Apply Tuomo Soini's loadmodule patch
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-23 09:20:50 -07:00
Tom Eastep
7e4dba7623 Revert "Correct check for module already loaded"
This reverts commit 2e98d4375b.
2017-08-23 08:01:25 -07:00
Tom Eastep
3d322d31b7 Add UDP rule to macro.RDP
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-22 08:07:32 -07:00
Tom Eastep
34e4fffd7d Module suffix changes
- Re-order default list in the compiler to match lib.common
- MODULE_SUFFIX="ko ko.xz" in standard .conf files.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-21 12:44:23 -07:00
Tom Eastep
2e98d4375b Correct check for module already loaded
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-21 10:27:29 -07:00
Tom Eastep
419ff8903b Invert logic in Shorewall::Chains::delete_reference() - better readability
- similar change in Shorewall::Chains::adjust_reference_counts()

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-19 12:25:27 -07:00
Tom Eastep
390ac30be8 Remove a superfluous line of code from Shorewall::Chains::format_rule()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-19 12:12:54 -07:00
Tom Eastep
8cb98f16ea Add a comment in Shorewall::Chains::optimize_level8()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-19 08:08:24 -07:00
Tom Eastep
5a9f179e25 Allow port variables as the server port in DNAT rules
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-16 15:36:18 -07:00
Tom Eastep
d8eca457de Correct typo in the Aliased Interfaces article.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-16 08:24:44 -07:00
Tom Eastep
8641d53bd1 Use MUTEX_TIMEOUT for ip[6]tables --wait interval
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-15 14:02:08 -07:00
Tom Eastep
7e3521e221 RESTORE_WAIT_OPTION
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-13 18:56:40 -07:00
Tom Eastep
0603f8e355 Serialize start of IPv4 and IPv6 under systemd
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-13 12:48:18 -07:00
Tom Eastep
ddefde2d10 Correct handling of address variables in DNAT rule.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-13 08:30:11 -07:00
Tom Eastep
2beeedd8fe Remove incorrect '+' info from shorewall-interfaces(5)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-12 12:19:00 -07:00
Tom Eastep
1a2647618e Allow runtime address variables as the server IP in DNAT rules
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-12 12:18:16 -07:00
Tom Eastep
72293883dd Tabify the Zones module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-12 11:28:14 -07:00
Tom Eastep
c31397532c Verify that parent and child zones have a common interface
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-12 09:24:05 -07:00
Tom Eastep
d0861e813b Make Shorewall's handling of '+' consistent with that of iptables
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-12 08:22:57 -07:00
Tom Eastep
5d5bef105a Remove reference to swping from the shorewall-init article.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-11 13:38:58 -07:00
Tom Eastep
da62bd2b32 Use a hash slice in recently-added code
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-11 13:38:34 -07:00
Tom Eastep
a83c19cc33 Adjust some default values in shorewall.conf(5)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-10 15:48:16 -07:00
Tom Eastep
96a33395e8 Correct typo in the Squid document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-09 15:42:19 -07:00
Tom Eastep
dabe8abe52 Add 'action' to the conntrack columns for alternate input
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-09 12:41:45 -07:00
Tom Eastep
a504820d19 Correct optimize level 8 handling of policy and policychain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-07 16:56:30 -07:00
Matt Darfeuille
8db4265ccc docs: Clarify path for locating Shorewall files
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-07 13:48:47 -07:00
Tom Eastep
4c2c1bcdf1 Export CONFDIR and SHAREDIR to the generated script.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-06 13:42:01 -07:00
Tom Eastep
f2ee8013fc Update the providers manpage re balanced IPv6 routes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-05 10:12:42 -07:00
Tom Eastep
56c8f70b52 Describe the parameters passed to the enable and disable extension scripts
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-04 12:38:14 -07:00
Tom Eastep
657215f9b5 Add sample enabled and disabled scripts
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-03 12:50:49 -07:00
Tom Eastep
5589ab76d9 Add arguments to the enabled and disabled user exits
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-03 12:44:15 -07:00
Tom Eastep
ec0e6763e4 add 'enabled' and 'disabled' to the Extension Script Article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-02 15:44:48 -07:00
Tom Eastep
6425e5ae5d Remove superfluous white space in the generated script
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-02 14:09:05 -07:00
Tom Eastep
8521c6f750 Merge branch '5.1.5' 2017-08-02 14:02:03 -07:00
Tom Eastep
c57edb0fbf Update FAQ2* to use address variables
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-08-01 14:56:20 -07:00
Tom Eastep
80e6cd8a2f Add enabled and disabled user exits
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-29 15:15:57 -07:00
Tom Eastep
69a0061d0f Correct handling of MAC addresses in the accounting file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-27 14:55:19 -07:00
Tom Eastep
5a24953e6c Merge branch '5.1.5' 2017-07-27 09:14:50 -07:00
Tom Eastep
eea3cca90c Correct handling of USER/GROUP in the OUTPUT accounting section
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-27 09:01:46 -07:00
Tom Eastep
a420ef04d9 Correct tcfilter source port handling when BASIC_FILTERS=Yes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-26 16:48:53 -07:00
Tom Eastep
e573436b12 Correct tcfilter source port handling when BASIC_FILTERS=Yes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-23 12:14:57 -07:00
Tom Eastep
7f44473387 Correct some typos in the Install article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-23 10:44:46 -07:00
Tom Eastep
cf9773c4de Update FAQ 76 to make it non-Debian specific
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-21 16:56:08 -07:00
Tom Eastep
939f0e92a5 Allow configure.pl to recognize $SOURCE_DATE_EPOCH
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-20 15:18:50 -07:00
Tom Eastep
320d448684 Apply Bernhard M. Wiedemann's patch for configure...
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-20 15:18:41 -07:00
Tom Eastep
975a14b94f Allow configure.pl to recognize $SOURCE_DATE_EPOCH
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-20 14:48:40 -07:00
Tom Eastep
cf3c304078 Apply Bernhard M. Wiedemann's patch for configure...
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-20 14:19:39 -07:00
Tom Eastep
d1a21fb678 Revert "Add SHARED_CONFIG option to shorewallrc"
This reverts commit 4e978b687d.
2017-07-20 12:23:59 -07:00
Tom Eastep
b9b7baf98d Merge branch '5.1.5' 2017-07-20 10:37:53 -07:00
Tom Eastep
92e725de97 Remove link to non-existent blog
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-16 09:23:02 -07:00
Tom Eastep
922bd9eeca Implement SPARSE=Very
- Only installs the .conf file.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-09 16:18:09 -07:00
Tom Eastep
d2b3fa476a Correct VLSM (56->60) in the Shared Config Document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-09 16:17:16 -07:00
Tom Eastep
4e978b687d Add SHARED_CONFIG option to shorewallrc
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-07 08:25:33 -07:00
Tom Eastep
2d0cb5c2d8 Process the snat file if the masq file is empty
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-06 09:09:52 -07:00
Tom Eastep
d9dc6bcfe2 Merge branch 'master' into 5.1.5 2017-07-06 07:48:51 -07:00
Tom Eastep
ff51915b4f Add the shared config document to the index
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-06 07:48:03 -07:00
Tom Eastep
1ad796ba5d Add Warning to Squid document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-02 18:11:42 -07:00
Tom Eastep
c8e2b4ae28 Add Shared Configs Document
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-07-02 18:11:16 -07:00
Tom Eastep
9d160d4342 Add RESTORE_DEFAULT_ROUTE to shorewall6.conf samples
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-27 15:50:56 -07:00
Tom Eastep
1301848315 Change .conf files to specify USE_NFLOG_SIZE=No
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-26 10:46:16 -07:00
Tom Eastep
f050fc6e05 Avoid issues with Perl 5.30
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-25 20:57:48 -07:00
Tom Eastep
61b6898782 Add dropBcasts action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-25 18:36:54 -07:00
Tom Eastep
aee8c14ea6 Correct update setting of USE_NFLOG_SIZE
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-25 17:10:44 -07:00
Tom Eastep
ff2323b249 Add the USE_NFLOG_SIZE option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-25 16:54:14 -07:00
Tom Eastep
b4a06e9656 NFLOG_SIZE capability
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-25 13:44:26 -07:00
Tom Eastep
4122021344 Improve editing of port numbers/service names
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-25 07:44:23 -07:00
Tom Eastep
71d50e0217 Use --nflog-size rather than --nflog-range
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-25 07:43:39 -07:00
Tom Eastep
1b6f15d577 Correct multiple fallback providers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-23 07:41:23 -07:00
Tom Eastep
7515520b46 Don't use symlinks for shorewall6 manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-22 13:57:00 -07:00
Tom Eastep
1e2030fd6f Document leading "+" in inline matches
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-22 13:56:39 -07:00
Tom Eastep
708644f7c9 Clarify isusable and persistent providers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-21 14:26:11 -07:00
Tom Eastep
2f5687c65a Don't generate multihop routes unnecessarily
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-18 09:37:41 -07:00
Tom Eastep
66d1fbd3aa Clean up shorewall[6].conf(5)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-17 10:39:46 -07:00
Tom Eastep
c410459e27 Correct install of section 5 manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-17 10:30:49 -07:00
Tom Eastep
987e54cd54 Move shorewall6-proxyndp.xml to Shorewall/manpages/shorewall-proxyndp.xml
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-17 09:07:28 -07:00
Tom Eastep
42a46d42b6 Centralize the complete list of manpages in shorewall(8)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-16 17:11:43 -07:00
Tom Eastep
d8ef934f24 Consolidate manpages between Shorewall and Shorewall6
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-16 15:01:41 -07:00
Tom Eastep
62a60ad995 Add comments around functions moved from IPAddrs.pm to Chains.pm.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-14 12:26:22 -07:00
Tom Eastep
b1ba05db2b Correct handling of port ranges and port variables
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-12 17:07:55 -07:00
Tom Eastep
57f7cb4f3c Runtime Port Variables
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-12 11:55:56 -07:00
Tom Eastep
4cf60258af Correct a runtime error with NFQUEUE.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-12 11:07:54 -07:00
Tom Eastep
1061644ac7 Clean up links in the manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-06-08 15:43:59 -07:00
Tom Eastep
4a262c0e1b Add FIN action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-05-31 08:28:27 -07:00
Tom Eastep
29ffb7eb4b Merge branch '5.1.4' 2017-05-31 08:23:07 -07:00
Tom Eastep
a775fdcb7c Remove stutter from the .conf manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-05-31 08:21:45 -07:00
Tom Eastep
6338aa42b0 Add BLACKLIST to IPv6 actions.std file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-05-26 07:39:09 -07:00
Tom Eastep
12a32d3a6b Update LOGFORMAT documentation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-05-26 07:33:34 -07:00
Tom Eastep
45d96a5d64 Clean up the introductory part of shorewall-rules.xml
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-05-19 08:02:42 -07:00
Tom Eastep
f21d6de4d6 Clean up the introductory part of shorewall-rules.xml
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-05-17 15:28:51 -07:00
Tom Eastep
965a8e8f68 Minor cleanup of the Config module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-05-15 09:29:12 -07:00
Tom Eastep
eb26a467e9 Add snat and mangle to %config_files
- Tabify initialization of %config_files

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-05-12 08:37:54 -07:00
Tom Eastep
28e3218041 Update the copyrights on the two- and three-interface HOWTOs
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-05-11 15:51:28 -07:00
Tom Eastep
bb70a3637b Add PERL_HASH_SEED option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-05-02 07:51:37 -07:00
Tom Eastep
6c20cc7c4f Inline the start_command::do_it() function in lib.cli-std
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-05-01 13:51:53 -07:00
Tom Eastep
d4e05f6163 Correct handling of IPv6 tunnel-src and tunnel-dst
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-04-23 08:36:22 -07:00
Tom Eastep
6201f37913 Clarify <filename> in the generated script's header
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-04-18 16:45:17 -07:00
Tom Eastep
7ee44d6b4b Correct a typo in the generated script's header syntax description
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-04-18 16:31:51 -07:00
Tom Eastep
363b8f9802 Correct validation of string interface options.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-04-13 06:48:14 -07:00
Tom Eastep
d365a9ff18 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2017-04-05 20:15:10 -07:00
Tom Eastep
00d4724fd8 Some cleanup of the Chains module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-04-05 20:14:13 -07:00
Matt Darfeuille
749c8047d8 Explain the 'ipset' package
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Roberto C. Sánchez <roberto@connexer.com>
2017-04-05 11:50:36 -04:00
Tom Eastep
a00f2e6365 Update Copyright on the Documentation Index
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-31 20:34:43 -07:00
Tom Eastep
a46f19899b Correct typo in links to the logging article.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-27 16:12:56 -07:00
Tom Eastep
d2392c3a9b Add IPv6 UPnP Support
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-24 09:54:36 -07:00
Tom Eastep
0763b27b0b Correct a comment
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-22 15:59:55 -07:00
Tom Eastep
8b90827611 Minor cleanup of split_columns()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-22 10:18:07 -07:00
Tom Eastep
8507c97b5a Clean up column/value pair editing.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-22 09:46:52 -07:00
Tom Eastep
a6306f2c08 ?reset action param now sets parmsmodified.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-18 12:53:05 -07:00
Tom Eastep
a79dc194a4 Re-factor the directive message change
- results in much more compact code
- Document change in the config basics doc

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-18 11:42:53 -07:00
Tom Eastep
ccf9d73c72 Clarify line continuation WRT params and .conf
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-17 19:13:29 -07:00
Tom Eastep
bdcf93f92c Report the call site when issuing messages from an action.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-17 17:08:19 -07:00
Tom Eastep
6b84727886 Delete useless blank line
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-17 13:26:07 -07:00
Tom Eastep
5f445d9c2b Merge branch '5.1.3' 2017-03-16 14:14:20 -07:00
Tom Eastep
31bd10ffdd Correct two-interface sample snat file
- s/92/192/

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-15 21:18:23 -07:00
Tom Eastep
c3303067fc Correct all+ handling in the policy file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-15 11:20:37 -07:00
Tom Eastep
55cf06d0a8 Correct all+ handling in the policy file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-15 10:09:53 -07:00
Tom Eastep
c36a7cd35b Correct typo in the Shorewall6 sample .conf files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-15 08:57:18 -07:00
Tom Eastep
561efa595c Correct typo in the Shorewall6 sample .conf files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-15 08:55:41 -07:00
Tom Eastep
158f6305b1 Correct install fix
- Also remove extra logic from action.Broadcast

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-14 14:39:25 -07:00
Tom Eastep
6407520a35 Add warning messages to the deprecated actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-14 14:32:28 -07:00
Tom Eastep
54336eaa80 Delete IPv6 actions that are now handled by their IPv4 counterparts
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-14 14:24:17 -07:00
Tom Eastep
5b85627fb8 Merge branch '5.1.3'
Conflicts:
	Shorewall/Perl/Shorewall/Config.pm
	Shorewall6/Actions/action.Multicast
2017-03-14 14:16:47 -07:00
Tom Eastep
a00d7217e3 Correct last commit
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-14 13:58:59 -07:00
Tom Eastep
54ef4e4ced Delete deprecated actions during install
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-14 13:46:24 -07:00
Tom Eastep
a447d726fa Revert change which screwed up ?begin perl ... ?end perl line numbering
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-14 12:44:33 -07:00
Tom Eastep
c6050f9fbb Correct log message from IPv6 Multicast action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-13 16:55:45 -07:00
Tom Eastep
fe29adbd66 Correct use of $family in combined actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-13 16:52:16 -07:00
Tom Eastep
4dc6be6b3b Deprecate A_AllowICMPs
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-13 15:09:07 -07:00
Tom Eastep
6ebc8f4266 Merge branch '5.1.3' 2017-03-13 14:55:23 -07:00
Tom Eastep
c5c4211081 Unify actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-13 14:54:25 -07:00
Tom Eastep
4010f9bce4 Add multicast to the Deprecated A_Drop and A_Reject actions
- Move A_Drop to deprecated/ directory

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-13 14:18:23 -07:00
Tom Eastep
02bb717d7d Quote SMURF_LOG_LEVEL setting
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-13 11:21:13 -07:00
Tom Eastep
046998ed84 Tabification of new actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-13 11:19:35 -07:00
Tom Eastep
24a014655b Quote all _DEFAULT settings in the sample .conf files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-13 11:00:29 -07:00
Tom Eastep
0b8945da8e Correctly handle expansion of option names
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-13 10:20:15 -07:00
Tom Eastep
da363880a9 Always quote the LEVEL and DEFAULT settings when updating
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-13 09:51:58 -07:00
Tom Eastep
b049d1805d Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code
Conflicts:
	Shorewall/Perl/Shorewall/Config.pm
2017-03-13 08:52:01 -07:00
Tom Eastep
037fe490f3 Process config options in file order during update.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-12 17:09:41 -07:00
Tom Eastep
a8d7675322 Process config options in file order during update.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-12 09:01:22 -07:00
Tom Eastep
b13014c9ab Expand variables in .conf except when upgrading
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-11 11:21:07 -08:00
Tom Eastep
76aef6cb04 Correct generation of '! --syn'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-11 08:43:04 -08:00
Tom Eastep
4c72b3ee58 Make sure that $LOG_LEVEL is defined
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-10 11:06:23 -08:00
Tom Eastep
d9071c5308 Correct $LOG_LEVEL expansion
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-10 10:24:24 -08:00
Tom Eastep
5729be6431 Add dropInvalid to BLACKLIST_DEFAULT
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-10 09:06:41 -08:00
Tom Eastep
1a381f717c Revert "Remove Multicast from the shorewall6.conf samples"
This reverts commit 655f260cb6.
2017-03-10 08:54:05 -08:00
Tom Eastep
c534c458dd Revert "Remove Multicast from IPv6 Policy Actions"
This reverts commit 85d571d013.
2017-03-10 08:53:54 -08:00
Tom Eastep
61435936fe Correct CONFIG_PATH in IPv6 Universal sample
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-09 14:06:47 -08:00
Tom Eastep
2d4c1411bd Delete the -n option from remote-reload in shorewall(8)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-09 13:17:23 -08:00
Tom Eastep
655f260cb6 Remove Multicast from the shorewall6.conf samples
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-09 13:16:52 -08:00
Tom Eastep
85d571d013 Remove Multicast from IPv6 Policy Actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-09 13:12:03 -08:00
Tom Eastep
fdb78898fc Make TC_ENABLED=Shared the default in the samples
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-09 13:06:55 -08:00
Tom Eastep
d4c016d9c5 'reload' documentation corrections
- Add command synopsis to the manpage
- Correct command synopsis in help output

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-09 12:50:30 -08:00
Tom Eastep
3d8d5aa469 quote $LOG_LEVEL in shorewall[6].conf files
- Delete AllowICMPs from IPv4 policy action settings

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-08 14:16:24 -08:00
Tom Eastep
49811d24fa Correct convertion of tcrules->mangle when a writable mangle exists
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 15:21:45 -08:00
Tom Eastep
fe4aaee1b4 Fix typos in action.dropNotSyn
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 14:37:08 -08:00
Tom Eastep
0ec7bc846e Correct logging in inline policy actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 13:58:14 -08:00
Tom Eastep
dbcd4d9d16 Correct typo in action.AllowICMPs
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 13:57:05 -08:00
Tom Eastep
5a996cbda7 Change AllowICMPs to an inline action
Signed-off-by: Tom Eastep <teastep@shorewall.net>

Conflicts:
	Shorewall/actions.std
2017-03-07 13:56:44 -08:00
Tom Eastep
6019adaae5 Change macro.ICMPs to an inline action
Signed-off-by: Tom Eastep <teastep@shorewall.net>

Conflicts:
	Shorewall/actions.std
2017-03-07 13:54:52 -08:00
Tom Eastep
4f869c3506 More manpage updates for tcp:!syn
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 11:13:58 -08:00
Tom Eastep
e3c2874b21 Modify dropNotSyn to use {proto=6:!syn}
- also make the same change in the rejNotSyn audited case
2017-03-07 11:00:39 -08:00
Tom Eastep
e8a0142480 Document tcp:!syn support
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 10:48:24 -08:00
Tom Eastep
a4768776f7 Modify rejNotSyn to use new/corrected features
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 10:34:15 -08:00
Tom Eastep
8e000b158e Correct the handling of tcp-reset
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 10:33:51 -08:00
Tom Eastep
f1d1ab6411 Implement tcp:!syn in PROTO column
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 10:33:20 -08:00
Tom Eastep
cd103bb715 Correct rejNotSyn
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-06 16:01:31 -08:00
Tom Eastep
5f1370f1b4 Clear the firewall on Debian systemd 'stop' command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-06 11:22:55 -08:00
Tom Eastep
dc53fa2665 Correct file/line from ?error
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-06 11:02:06 -08:00
Tom Eastep
71d9a03697 Update shorewall[6]-rules.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-05 14:29:57 -08:00
Tom Eastep
137d4bcc90 Alter logging behavior of Limit
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-05 13:03:57 -08:00
Tom Eastep
356d3fa2dd Correct new directives with respect to omitting
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-05 12:09:54 -08:00
Tom Eastep
80d93235b5 Eliminate builtin actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-05 12:09:33 -08:00
Tom Eastep
c1e7fce1c5 Report the file/line where action invoked
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-05 09:29:00 -08:00
Tom Eastep
63ec936f21 Remove determinism sorts 2017-03-04 19:05:33 -08:00
Tom Eastep
dabe0bd205 Set PERL_HASH_SEED to make compilation deterministic.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-04 18:48:48 -08:00
Tom Eastep
63cf7dd699 Revert "Move $test to the config module."
This reverts commit 876d76b294.
2017-03-04 18:45:40 -08:00
Matt Darfeuille
0b3a32b365 Change the preferred way to remove sysvinit script
- Correct typo in command
 - Correct spacing

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-04 09:03:59 -08:00
Matt Darfeuille
a839a6f7d0 init: Add parameter files for Debian
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-04 09:03:49 -08:00
Matt Darfeuille
fec967a41d Do not display where an executable is located
Use only the exit status of the function mywhich to determine which
command should be used to remove sysvinit script.

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-04 09:03:29 -08:00
Tom Eastep
a7d45e9566 Restore logging to the BLACKLIST action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-03 10:14:30 -08:00
Tom Eastep
876d76b294 Move $test to the config module.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-02 11:42:07 -08:00
Tom Eastep
9075a6dd7a Copy libs and footer when compiling for test
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-02 10:49:49 -08:00
Tom Eastep
c900e3e51c Merge branch '5.1.2' 2017-03-02 10:17:50 -08:00
Tom Eastep
e585ce04f4 Rename action.allowUPnP to action.allowinUPnP
- Allows 'show action allowinUPnP' to work correctly.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-02 10:06:01 -08:00
Tom Eastep
61f5e3531c Rename action.allowUPnP to action.allowinUPnP
- Allows 'show action allowinUPnP' to work correctly.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-02 10:05:31 -08:00
Tom Eastep
e8a5c45aae Correct FAQ 1e
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-25 09:10:40 -08:00
Tom Eastep
d20ad64739 Correct FAQ 1e
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-25 08:54:14 -08:00
Matt Darfeuille
7ffe8e4e4b shorewall: Document the -p option in installer
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-23 09:33:35 -08:00
Matt Darfeuille
7644e1d49f Update version and fix comment lines in rc files
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:56:29 -08:00
Matt Darfeuille
06c6a017d5 Use a specific parameter file for systemd script
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:56:25 -08:00
Matt Darfeuille
75fd8ccb37 Use a specific parameter file for sysvinit script
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:56:21 -08:00
Matt Darfeuille
c04845534a Use a common uninstaller for Lite and Lite6
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:56:15 -08:00
Matt Darfeuille
8c7e6fddfd Use a common uninstaller for Sw and Sw6
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:56:11 -08:00
Matt Darfeuille
e6ed4d425d core: Uninstall manpages
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:56:06 -08:00
Matt Darfeuille
783e438b4a Be more verbose while uninstalling Shorewall
- Remove version file as a file and not as a directory.

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:56:00 -08:00
Matt Darfeuille
27a620347a shorewall: Fail if Shorewall-core is not installed
Shorewall-core's version file resides in ${SHAREDIR}/shorewall.

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:55:56 -08:00
Matt Darfeuille
a496edef54 Use a function to fail on fatal error
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:55:50 -08:00
Matt Darfeuille
50a9b4cc6a core: Fail without a rc file and correct error msg
Abort Shorewall-core's installer execution if no Rc file is detected.

 - Correct the error message

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:55:46 -08:00
Matt Darfeuille
22b044f350 shorewall: Use a function to install file
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:55:41 -08:00
Matt Darfeuille
c58efe7698 Unify the uninstallers
- Clean up code
 - Use the .service suffix

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:55:36 -08:00
Matt Darfeuille
f48b2e715f Unify the installers
- Clean up code

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:55:31 -08:00
Matt Darfeuille
f6f7e691d0 Fail if the rc file can not be loaded
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:54:40 -08:00
Matt Darfeuille
a9048b63f2 Correct typos
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:54:36 -08:00
Matt Darfeuille
bc1df90829 Group comment lines with corresponding command
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:54:33 -08:00
Matt Darfeuille
09462cf92b Use 4 octal digits as numeric mode in installers
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:54:29 -08:00
Matt Darfeuille
315d4c39b8 Create and set directory mode using a function
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:54:04 -08:00
Matt Darfeuille
42554f8f31 Add cant_autostart() to the installers's library
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:53:59 -08:00
Matt Darfeuille
f0debcb6fb Copy only required libraries to run Shorewall
Copy only libraries that are required by Shorewall to operate properly.

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:53:54 -08:00
Matt Darfeuille
e8a9b8ddc8 lite: Change into the uninstaller's script dir
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:53:48 -08:00
Matt Darfeuille
20cc56f2f1 Load uninstallers's common functions
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 17:53:39 -08:00
Matt Darfeuille
4e771083c7 Load installers's common functions
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 16:42:38 -08:00
Matt Darfeuille
a3fc110dc9 Add the library file for the uninstallers
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 16:41:55 -08:00
Matt Darfeuille
813f592b46 Add the library file for the installers
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 16:41:25 -08:00
Matt Darfeuille
a6eebc8ecf Replace product names by product vars
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-22 16:40:41 -08:00
Tom Eastep
6966270822 Allow 'show action' on buitin actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-19 13:43:23 -08:00
Tom Eastep
118e4f73c9 Correct validation of LOG_LEVEL
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-19 10:25:44 -08:00
Tom Eastep
10b39f3855 Correct typo (allowMast -> allowMcast)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-19 10:25:27 -08:00
Tom Eastep
c4f21ffefb Additional documentation changes.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-15 13:11:52 -08:00
Tom Eastep
a71b61c238 Delete the deprecated macros and actions during install
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-15 10:16:53 -08:00
Tom Eastep
944888c04f Handle broadcast and muticast separately
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-15 10:16:20 -08:00
Tom Eastep
48d301b2cf Rename the policy LIMIT column to RATE
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-12 10:17:43 -08:00
Tom Eastep
735919d8d3 Add LOG_LEVEL option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-12 09:52:55 -08:00
Tom Eastep
b4561e97c8 Deprecate Drop and Reject in actions.std
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-12 09:28:38 -08:00
Tom Eastep
66a63a4da5 Fix instances of $LOGrmation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-12 08:33:56 -08:00
Tom Eastep
8c9fb501fd Adjust .conf files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-11 13:41:28 -08:00
Tom Eastep
977fa81d46 Make 'none' case-insensitive in policy action specifications
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-10 11:43:51 -08:00
Tom Eastep
09fda9eb6c Manpage updates:
- interfaces: Clarify the 'bridge' option
- rtrules:    Warn about similar rules with same priority
2017-02-10 11:43:04 -08:00
Tom Eastep
7e984af094 Some cleanup of policy actions
- Allow '+' in policy file action list

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-07 13:19:53 -08:00
Tom Eastep
af8d4e32c2 Replace 'info' with '$LOG' in the sample policy files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-07 08:27:19 -08:00
Tom Eastep
ca33a7ef65 Fix Sample .conf files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-06 18:28:05 -08:00
Tom Eastep
e91f414223 Document policy action changes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-06 17:09:23 -08:00
Tom Eastep
5cd2f26b51 Correct shorewall.conf(5)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-06 14:46:10 -08:00
Tom Eastep
dab9e1d7c4 Assume no default actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-06 14:45:43 -08:00
Tom Eastep
b9471a2499 Correct parsing of the POLICY column
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-06 14:15:24 -08:00
Tom Eastep
3b82721956 Update Shorewall6 default-action defaults
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-06 13:56:45 -08:00
Tom Eastep
95ffada759 Change sample IPv4 default actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-06 13:47:02 -08:00
Tom Eastep
b2553fb008 Another change to allow builtin actions as default actions.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-06 13:25:10 -08:00
Tom Eastep
8bc70674f3 Make DropDNSrep an inline action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-06 11:21:56 -08:00
Tom Eastep
cecb8a1950 Deprecate the Drop and Reject actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-06 10:52:31 -08:00
Tom Eastep
079d862bb3 Document default-action lists
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-06 10:51:57 -08:00
Tom Eastep
d50fdea2a7 Merge branch '5.1.1' 2017-02-06 10:26:55 -08:00
Tom Eastep
4c97c58981 Apply Tuomo's fix for CLI run with no command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-06 10:25:20 -08:00
Tom Eastep
92133e5a6b Default-action lists
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-06 10:11:48 -08:00
Tom Eastep
686ca9d3a3 Allow builtin actions in xxx_DEFAULT settings.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-05 15:21:57 -08:00
Tom Eastep
fa7ad6bd74 Update blacklisting article:
- ipset-based blacklisting
- BLACKLIST policy and action

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-26 13:17:46 -08:00
Tom Eastep
e45b96ca20 Update blacklisting article:
- ipset-based blacklisting
- BLACKLIST policy and action

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-26 13:17:11 -08:00
Matt Darfeuille
eac2639684 core: Correct the path being displayed for the CLI
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-24 16:19:08 -08:00
Tom Eastep
70a395892f Make BLACKLIST work correctly in the blrules file
- Add the 'section' action option

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-23 15:03:02 -08:00
Tom Eastep
d2d11df4f6 Make action.BLACKLIST behave correctly in the blrules file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-23 13:35:10 -08:00
Tom Eastep
b985654600 Correct typo in heading of Reject and Drop actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-23 11:54:40 -08:00
Tom Eastep
62ff6d3fa5 Remove obsolete macros
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-23 09:26:19 -08:00
Tom Eastep
2bbb5c8c1e Add hack to distinguish between the BLACKLIST macro and action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-23 09:23:26 -08:00
Tom Eastep
33b4ee4d31 Don't quote variable values in ERROR/WARNING/INFO directives
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-23 09:00:18 -08:00
Tom Eastep
889ca756a1 Document @action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-23 08:58:42 -08:00
Tom Eastep
d111e4f186 Handle built-in actions in 'show action'
- Remove a couple of non-actions from IPv4 actions.std

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-22 15:40:36 -08:00
Tom Eastep
634c8debda Use ?REQUIRE in several actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-22 14:59:37 -08:00
Tom Eastep
71dd5d016b Add ?REQUIRE compiler directive
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-22 14:48:18 -08:00
Tom Eastep
6b408869d2 Correct the synopsis in two action files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-22 11:47:12 -08:00
Tom Eastep
edf08bf408 Cosmetic change in compiler()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-21 19:47:50 -08:00
Tom Eastep
4a01e910ff Delete unused iptablesbug() function
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-21 14:42:24 -08:00
Tom Eastep
2a010f827b Add 'show action' command.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-19 15:58:18 -08:00
Tom Eastep
9c3a82f628 Add BLACKLIST action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-19 14:08:15 -08:00
Tom Eastep
e6933f4c8d Add BLACKLIST policy
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-18 10:55:15 -08:00
Tom Eastep
cc3b8793e0 Make BALANCE_PROVIDERS default the setting of USE_DEFAULT_RT
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-17 15:02:16 -08:00
Tom Eastep
ac5fd195ec Correct provider/routefilter check wrt optional interfaces
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-17 09:34:13 -08:00
Tom Eastep
45b9ddf188 Add BALANCE_PROVIDERS option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-17 08:58:09 -08:00
Tom Eastep
2d16fac9ed Revert "Implement USE_DEFAULT_RT=Exact"
This reverts commit 2ca1ae734a.
2017-01-17 08:25:33 -08:00
Tom Eastep
f23970b4f7 Include LOG_MARTIANS in test for setting log_martians with routefilter
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-14 13:03:24 -08:00
Tom Eastep
04112647d3 Correct provider/routefilter checking
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-14 12:40:39 -08:00
Tom Eastep
2ca1ae734a Implement USE_DEFAULT_RT=Exact
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-14 08:14:08 -08:00
Tom Eastep
b36b07b567 Correct 'show macros'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-12 08:35:03 -08:00
Tom Eastep
64c249a174 Set logmartians along with routefilter.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-11 15:53:55 -08:00
Tom Eastep
0019ca53e5 Include ROUTE_FILTER in routefilter/provider checks
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-11 15:39:13 -08:00
Tom Eastep
0d2a5089a9 Merge branch '5.1.0' 2017-01-11 12:29:57 -08:00
Tom Eastep
50d09e76cb Catch 'routefilter' with provider interfaces.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-11 11:47:10 -08:00
Tom Eastep
73772efb85 Correct typo in shorewall-interfaces(5)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-11 11:20:07 -08:00
Tom Eastep
568f461763 Propogate PAGER to -lite systems
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-11 11:18:57 -08:00
Tom Eastep
f12b78d518 Correct Shorewall6-lite .service file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-10 09:55:16 -08:00
Tom Eastep
a15b2918a4 Remove ipsec-tools/Racoon config info from the IPSEC-2.6 Article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-08 13:32:34 -08:00
Tom Eastep
cb150f9c09 Allow compact IPv6 addresses in IP6TABLES() rules
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-07 10:01:03 -08:00
Tom Eastep
19ce2093d8 Correct splitting of IP(6)TABLES options
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-07 10:00:37 -08:00
Tom Eastep
b8c322a05f Ignore SUBSYSLOCK when $SERVICEDIR is non-empty
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-06 15:50:26 -08:00
Tom Eastep
f68d3fd9fa Revert "Remove SUBSYSLOCK"
This reverts commit 386b137e9b.
2017-01-06 09:49:40 -08:00
Tom Eastep
386b137e9b Remove SUBSYSLOCK
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-05 10:03:03 -08:00
Tom Eastep
ce68f84d9d Remove Makefile from Shorewall[6][-lite]
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-05 08:22:02 -08:00
Tom Eastep
5aed31d37a Restore SUBSYSLOCK setting
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-04 19:39:08 -08:00
Tom Eastep
0b3d1b1d36 Revert code that assumed no CLI symlinks
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-04 17:12:20 -08:00
Tom Eastep
6be89b4e2d Add command correspondence to shorewall(8)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-02 13:40:32 -08:00
Tom Eastep
75a9e45caf Documentation cleanup
- Update Copyright years
- Tweaks to the Anatomy article

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-01-02 09:17:59 -08:00
Tom Eastep
2f9ef4dda7 Update kernel module files
- Include additional nat modules

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-30 10:56:16 -08:00
Tom Eastep
26f181ef2a Add SERVICEDIR to the init file paragraph titles
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-29 14:28:46 -08:00
Tom Eastep
b0ea9db0bd Update the Anatomy article for 5.1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-28 11:28:09 -08:00
Tom Eastep
7a3865bcfc Eliminate duplicate id tags in the Anatomy article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-28 11:24:30 -08:00
Tom Eastep
5174fe0161 Avoid echo options
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-28 11:09:08 -08:00
Tom Eastep
65bf33bcf3 Correct handling of safe-restart with SAVE_IPSETS
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-27 16:29:01 -08:00
Tom Eastep
638c7c5bca Implement NETMAP_TARGET capability
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-27 08:26:51 -08:00
Tom Eastep
c4bbb46e3f Eliminate rawpost table support
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-26 14:20:08 -08:00
Tom Eastep
7b96d41065 Correct typo in the Shorewall 5 article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-24 13:01:44 -08:00
Tom Eastep
1b97783c23 Implement 'show ipsec'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-23 10:01:40 -08:00
Tom Eastep
c9f45277b8 Move the action files to their own directory
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-23 09:05:37 -08:00
Tom Eastep
7ce0cc3e2e Describe 5.0/5.1 differences in shorewall(8)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-22 15:51:15 -08:00
Tom Eastep
541291b729 Add do_condition() call in process_mangle_rule1()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-21 08:46:16 -08:00
Tom Eastep
9dcac6012b Remove redundent test
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-20 14:41:29 -08:00
Tom Eastep
1a95db73e9 Revert idiotic change to lib.cli
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-20 08:39:26 -08:00
Tom Eastep
dcade04fba Update Shorewall5 article for 5.1
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-20 08:38:49 -08:00
Tom Eastep
7717de872d Correct typo in shorewall(8)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-19 12:55:55 -08:00
Tom Eastep
be5a8c440f Delete duplicated info from shorewall(8)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-19 10:52:29 -08:00
Tom Eastep
7c63428e82 Revert "lite: Add 'file' var and set path of .shorewallrc"
This reverts commit 2ec17ce608.
2016-12-19 10:27:35 -08:00
Tom Eastep
4c03aaa0fc Revert "lite: Don't set the 'file' var needlessly"
This reverts commit a86ea0c00a.
2016-12-19 10:26:55 -08:00
Tom Eastep
8dce87e129 Revert "core: Don't set the 'file' var needlessly"
This reverts commit eaf58d18aa.
2016-12-19 10:26:33 -08:00
Tom Eastep
cabef548a6 Revert "init: Don't set the 'file' var needlessly"
This reverts commit 44e9c7780f.
2016-12-19 10:25:30 -08:00
Tom Eastep
4af278338f Correct intra-zone handling in policies
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-19 09:11:41 -08:00
Matt Darfeuille
fa6167797d init: Don't set the 'file' var needlessly
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-19 08:14:49 -08:00
Matt Darfeuille
44e9c7780f init: Don't set the 'file' var needlessly
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-19 08:14:49 -08:00
Matt Darfeuille
3caedbbbef lite6: Don't set the 'file' var needlessly
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-19 08:14:49 -08:00
Matt Darfeuille
b2f07b0e44 lite: Don't set the 'file' var needlessly
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-19 08:14:48 -08:00
Matt Darfeuille
a86ea0c00a lite: Don't set the 'file' var needlessly
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-19 08:14:48 -08:00
Matt Darfeuille
20c764ca5c shorewall6: Don't set the 'file' var needlessly
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-19 08:14:48 -08:00
Matt Darfeuille
b33d853703 shorewall: Don't set the 'file' var needlessly
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-19 08:14:48 -08:00
Matt Darfeuille
30331fecda shorewall: Don't set the 'file' var needlessly
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-19 08:14:48 -08:00
Matt Darfeuille
6ff1833ae0 core: Don't set the 'file' var needlessly
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-19 08:14:48 -08:00
Matt Darfeuille
eaf58d18aa core: Don't set the 'file' var needlessly
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-19 08:14:32 -08:00
Tom Eastep
a9583aaf3a Correct merge compatibility change
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 19:00:37 -08:00
Tom Eastep
c2c2dc0b22 Exercise care when merging rules including -m multiport
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 18:39:19 -08:00
Tom Eastep
e3951cb5a3 Re-add volume 8 manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 16:16:50 -08:00
Matt Darfeuille
eb3067c006 init: Correct the filepath of .shorewallrc
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 12:14:25 -08:00
Matt Darfeuille
e4ec1c81ec init: Add 'file' var and set path of shorewallrc
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 12:14:25 -08:00
Matt Darfeuille
d2890df8b9 init: Correct the filepath of .shorewallrc
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 12:14:25 -08:00
Matt Darfeuille
73f74ad576 init: Correct the filepath of shorewallrc
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 12:14:25 -08:00
Matt Darfeuille
7be8c579a7 lite6: Correct the filepath of .shorewallrc
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 12:14:25 -08:00
Matt Darfeuille
28359c40f3 lite: Correct the filepath of .shorewallrc
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 12:14:25 -08:00
Matt Darfeuille
2ec17ce608 lite: Add 'file' var and set path of .shorewallrc
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 12:14:25 -08:00
Matt Darfeuille
1cb32e3127 shorewall6: Correct the filepath of .shorewallrc
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 12:14:25 -08:00
Matt Darfeuille
bac6848362 shorewall: Correct the filepath of .shorewallrc
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 12:14:25 -08:00
Matt Darfeuille
fa8e92cbd3 shorewall: Correct the filepath of .shorewallrc
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 12:14:24 -08:00
Matt Darfeuille
56d4d01984 core: Correct the filepath of .shorewallrc
Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 12:14:24 -08:00
Matt Darfeuille
f502e5b2e3 shorewall: Correct displaying of shorewall version
Add the Product name variable to properly display the product name
when the '-v' option is passed to the script.

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 12:14:24 -08:00
Tom Eastep
154395c20f Create symbolic links for the CLI programs
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 11:48:05 -08:00
Tom Eastep
089ff4eb33 Establish default product based on $0
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-18 11:18:07 -08:00
Tom Eastep
7ce5c31c68 Use 'ip -s xfrm' to dump the SPD and SAD
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-17 14:43:16 -08:00
Tom Eastep
273b02c6da Add IPCOMP information to the IPSEC article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-17 12:31:17 -08:00
Tom Eastep
095c9212f4 Fatal error for empty action file
- Issue error if a file with the name of the action exists on the
  CONFIG_PATH

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-12 16:31:46 -08:00
Tom Eastep
612eee64d1 Merge branch '5.0.15' 2016-12-12 14:20:41 -08:00
Tom Eastep
e98abac706 Define MYNET in the QOS example
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-12 09:35:03 -08:00
Tom Eastep
5ea78b8078 Correct typo in the snat manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-11 14:36:04 -08:00
Tom Eastep
08c6b80e1e Correct typo in the snat manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-11 14:32:27 -08:00
Tom Eastep
cb7ab3908a SOURCE/DEST changes in the mangle manpages
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-11 14:06:59 -08:00
Tom Eastep
b4d42507b2 Another SOURCE/DEST manpage change.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-10 16:22:47 -08:00
Tom Eastep
094ccbf978 Merge branch '5.0.15' 2016-12-10 15:07:31 -08:00
Michele Baldessari
036a6e5a83 Add an IPv6 bidirectional mDNS macro
Add the missing corresponding IPv6 bidirectional mDNSbi macro.

Closes-Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1295844

Signed-off-by: Michele Baldessari <michele@acksyn.org>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-10 14:44:10 -08:00
Tom Eastep
b756c63b1e More SOURCE/DEST manpage updates
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-10 14:41:08 -08:00
Tom Eastep
eea9882953 Implement CPU Fanout for NFQUEUE.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-09 10:46:39 -08:00
Tom Eastep
cc937ffaba NFQUEUE should be non-terminating
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-09 09:49:23 -08:00
Tom Eastep
192486eb0a Bring shorewall6-actions(5) up to date
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-09 09:47:14 -08:00
Tom Eastep
6a43dd1564 Bring shorewall6-actions(5) up to date
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-09 09:46:29 -08:00
Tom Eastep
5ea3334a66 Support a richer SOURCE and DEST syntax
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-09 09:43:10 -08:00
Tom Eastep
e4804e1900 NFQUEUE should be non-terminating
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-09 08:46:39 -08:00
Tom Eastep
6c8dae45c4 Install the core manpage(s)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-05 10:10:27 -08:00
Tom Eastep
a2e040998b Move shorewall(8) to shorewall.core
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-04 18:03:18 -08:00
Tom Eastep
53adfbe863 Normalize parameters by removing trailing omitted args
- Avoids needless duplicate action chains
2016-12-03 11:34:02 -08:00
Tom Eastep
4a0a906510 Correct progress message in optimize_level4()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-03 08:28:14 -08:00
Tom Eastep
7ceb0228e9 Merge branch 'master' into 5.1.0 2016-12-02 15:27:16 -08:00
Tom Eastep
f537e3e15c Fix optimization bug in merge_rules()
- Reset the simple member if a unique option is merged

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-02 14:47:03 -08:00
Tom Eastep
4949569383 Correct 'restore' exit status
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-02 09:33:16 -08:00
Tom Eastep
4a410c7b4c Correct 'restore' exit status
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-02 09:32:00 -08:00
Tom Eastep
5ae062317f Merge branch 'master' into 5.1.0 2016-12-01 19:35:14 -08:00
Tom Eastep
a1981823f4 Correct typo (syntax error!)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-12-01 15:21:25 -08:00
Tom Eastep
0e40c5a4a1 Shorewall-init changes for unified CLI
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-30 15:04:40 -08:00
Tom Eastep
77e83f0afd Eliminate the CHAIN_SCRIPTS option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-29 16:33:23 -08:00
Tom Eastep
a45fe692cc Add a SWITCH column to the mangle files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-29 16:13:44 -08:00
Tom Eastep
799b17210c Enhanced syntax for SOURCE and DEST columns in the rules file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-25 15:10:14 -08:00
Tom Eastep
01306e1230 Try another approach to the RCP_/RSH_COMMAND formatting issue
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-23 14:48:28 -08:00
Tom Eastep
963dea54c5 Modify update defaults for LOGPREFIX and LOGLIMIT
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-23 14:30:07 -08:00
Tom Eastep
fbbcc812a1 Remove archaic LAST LINE comments from sample .conf files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-23 14:17:28 -08:00
Tom Eastep
87870ac46e Clean up formatting of the RCP_/RSH_COMMAND manpage descriptions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-23 14:08:13 -08:00
Tom Eastep
d895a5d67c Correct version in IPv4 universal shorewall.conf
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-22 09:28:44 -08:00
Tom Eastep
414c5c7b0c Change default shorewall6.conf settings.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-22 09:05:04 -08:00
Tom Eastep
c561f8eb03 Default shorewall.conf changes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-22 08:57:47 -08:00
Tom Eastep
ff81980552 Merge branch 'master' of ssh://git.code.sf.net/p/shorewall/code 2016-11-21 15:16:30 -08:00
Tom Eastep
38c9165c39 More shorewall(8) documentation updates
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-21 13:57:06 -08:00
Tom Eastep
bd2df4836d Break lib.base into two libraries
- Allows separation of default product determination and
  establishment of the product environment

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-21 13:25:57 -08:00
Tom Eastep
875c352473 Unify the CLI
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-21 10:00:55 -08:00
Roberto C. Sánchez
8a6dcc469b Fix typo 2016-11-21 11:59:57 -05:00
Tom Eastep
dae060bbb4 Update shorewall(8) for single CLI
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-20 13:03:13 -08:00
Tom Eastep
ccab75e69a Avoid unnecessary change in the generated script
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-20 09:17:39 -08:00
Tom Eastep
de553e7b18 Add the -l option
- Update shorewall(8)

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-20 09:16:16 -08:00
Tom Eastep
36517cdb1e Rename setup_environment to setup_product_environment
- Default to first detected product
- Verify that specified product is installed

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-20 08:48:18 -08:00
Tom Eastep
bb5c3a50f5 Avoid unnecessary change in the generated script
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-19 21:39:49 -08:00
Tom Eastep
8b99fe20b5 Pave the way for unifying the CLI
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-19 21:17:35 -08:00
Tom Eastep
137b051e52 Centralize setting of product-dependent g_* variables
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-19 17:17:03 -08:00
Tom Eastep
9eb390403b Implement -p option to disable PAGER
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-17 10:58:10 -08:00
Tom Eastep
ab9f340c55 use $PAGER in the 'show macro' command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-17 10:57:39 -08:00
Tom Eastep
88284ed568 Delete version from the heading of compiler.pl
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-16 13:03:00 -08:00
Tom Eastep
481afef2c3 Don't insist that route deletion succeeds
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-12 08:38:09 -08:00
Tom Eastep
6b38b3a515 Revert "More IPv6 routing cleanup"
This reverts commit 1e7f63834c.
2016-11-12 08:25:38 -08:00
Tom Eastep
80951d23c2 add/delete multi-nexthop IPv6 routes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-12 08:24:46 -08:00
Tom Eastep
1e7f63834c More IPv6 routing cleanup
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-09 10:34:19 -08:00
Tom Eastep
74b94f71f8 Always return $omitting from process_compiler_directive()
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-09 08:07:17 -08:00
Tom Eastep
ef4ab62dd3 Disable directive callbacks after file conversion.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-09 07:47:19 -08:00
Tom Eastep
42c1c2a205 Don't copy link-level address routes into provider tables.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-08 14:42:44 -08:00
Tom Eastep
6095d05af9 Update manpages for 'update' improvements
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-07 13:50:11 -08:00
Tom Eastep
d989241712 Retain shell variables during routestopped and blacklist conversions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-07 11:26:17 -08:00
Tom Eastep
652bc75448 Omit Shorewall version from converted files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-07 11:12:36 -08:00
Tom Eastep
d105da3964 Preserve shell variables when converting tos->mangle
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-06 17:25:35 -08:00
Tom Eastep
c5b393a074 Preserve shell variables when converting tcrules->mangle
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-06 17:25:01 -08:00
Tom Eastep
1b82dedb77 Preserve shell variables when converting masq -> snat
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-06 13:53:05 -08:00
Tom Eastep
6398756647 Add a routine to split the raw current line image
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-06 08:44:24 -08:00
Tom Eastep
daa2440d9a Ensure that $directive_callback->() gets an unaltered image
- pass omitted lines to that function as well

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-06 08:03:31 -08:00
Tom Eastep
6a89fd1367 Merge branch 'master' into 5.0.14 2016-11-04 08:37:55 -07:00
Tom Eastep
ffe1e1d335 Fix typo in the two-interface sample snat file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-04 08:36:24 -07:00
Tom Eastep
cecfe54ef6 Avoid shell errors when /proc/net/xt_recent/ is empty.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-03 21:29:01 -07:00
Tom Eastep
8441ac5c5f Handle another issue with ADD_SNAT_ALIASES=Yes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-03 15:06:38 -07:00
Tom Eastep
01a6881f4f Catch total lack of address/port in SNAT argument
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-02 19:30:55 -07:00
Tom Eastep
f917670fbd Tighten editing of SNAT/MASQ port ranges.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-02 19:30:18 -07:00
Tom Eastep
c376740329 Detect degenerate addr:port[-range] in SNAT rules.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-02 15:28:00 -07:00
Tom Eastep
4169520d63 Handle exceptionrule correctly with MASQUERADE.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-02 14:36:51 -07:00
Tom Eastep
53d97bbcc8 Correct handling of masquerade port range when ADD_SNAT_ALIASES=Yes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-02 12:28:00 -07:00
Tom Eastep
9ae36e1989 Correct error message when multiple SNAT addresses are present.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-02 12:27:32 -07:00
Tom Eastep
60619fb3cb Correct part of a recent patch to Nat.pm
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-02 09:00:19 -07:00
Tom Eastep
41ecee356b Correct earlier faulty patch to Nat.pm.
- Similar Rules.pm patch was okay.

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-01 19:39:52 -07:00
Tom Eastep
e188bde6c4 Fix additional masq/snat issues.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-01 18:42:16 -07:00
Tom Eastep
6e08717089 Formatting changes to snat files.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-01 17:11:43 -07:00
Tom Eastep
d37967f32f Replace --to-ports <ports> with --to-source :<ports>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-01 16:52:08 -07:00
Tom Eastep
10c1ad245a Handle omitted port[-range] in SNAT correctly.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-01 12:59:44 -07:00
Tom Eastep
032a16eb43 Detect incorrect port-range separator in SNAT(...)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-11-01 11:28:19 -07:00
Tom Eastep
a89d8b3af4 Fix Shorewall installer re: snat file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-31 16:13:48 -07:00
Tom Eastep
3f68814a38 Disallow more than one address[-range] in SNAT rules
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-31 15:15:35 -07:00
Tom Eastep
3a70185284 A couple of documentation updates
- Anatomy
- Bridge (Perl)

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-31 11:09:06 -07:00
Tom Eastep
95a1e65016 Clear target modifiers in interface loop
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-30 16:25:17 -07:00
Tom Eastep
282253022e Correct handling of address variables out of the Providers module
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-29 14:59:34 -07:00
Tom Eastep
174f46f3e6 More snat documentation changes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-28 14:56:44 -07:00
Tom Eastep
4d77d673e8 Be sure NAT is enabled before processing an snat file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-28 09:30:17 -07:00
Tom Eastep
e4e424bbdc Disallow '+' in inline SNAT action bodies
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-28 08:58:47 -07:00
Tom Eastep
71fb1a8cbd Correct error message ( s/\*/+/ )
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-27 14:32:43 -07:00
Tom Eastep
46c8147521 Deprecate INLINE_MATCHES=Yes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-27 13:55:11 -07:00
Tom Eastep
de3b05ea41 Correctly translate +INLINE(...)
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-27 12:21:07 -07:00
Tom Eastep
ae9b57d854 Correct NONAT translation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-26 16:06:28 -07:00
Tom Eastep
1a06765d14 Add Bill Shirley's logging suggestions to the logging article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-26 16:06:15 -07:00
Tom Eastep
579910fdb8 Fix MASQUERADE+ Handling
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-26 14:40:16 -07:00
Tom Eastep
21877d5fcb Force a reload when enabling an interface whose IP address has changed
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-26 13:39:50 -07:00
Tom Eastep
0b9387f09c Force address Detection on optional interfaces
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-25 14:42:03 -07:00
Tom Eastep
ee8ffc3ceb Add SNAT action example to the Actions article
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-25 10:57:32 -07:00
Tom Eastep
fdfd8b919b Merge branch '5.0.13' 2016-10-24 12:52:01 -07:00
Tom Eastep
3d3ae81bce Restore old wording for Version 4 ipset creation message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-24 12:51:43 -07:00
Tom Eastep
3b6b89336e Eliminate superfluous test
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-24 11:57:56 -07:00
Tom Eastep
fc0ad7cd2e Be sure that the 'restriction' member exists for the FORWARD chain
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-24 11:37:40 -07:00
Tom Eastep
c9b1b7684c Correct handling of dest IPSET.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-24 09:06:05 -07:00
Tom Eastep
b8ec460a1a Correct grammar in the ipset creation message
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-24 08:49:51 -07:00
Tom Eastep
46b8e2e957 Avoid exception when validating 'occurs' in TC
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-24 08:14:12 -07:00
Tom Eastep
0ed813972b Auto-create ipsets used in tcfilters
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-23 16:44:07 -07:00
Tom Eastep
f9cfde91e5 Correctly handle ipset in tcfilter DEST
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-23 16:43:49 -07:00
Tom Eastep
3df488e710 Correct handling of ipsets in tcfilters
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-23 16:28:36 -07:00
Tom Eastep
0efc7a4899 Correct restriction and chain number handling in the mangle files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-23 15:36:04 -07:00
Tom Eastep
d241421630 Merge branch '5.0.13' 2016-10-23 08:34:47 -07:00
Tom Eastep
e0203bca87 Correct nill address check in handling of 'origdest=detect'
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-23 08:34:24 -07:00
Tom Eastep
6e30c286c3 Reword Address Variable Warning
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-22 19:06:56 -07:00
Tom Eastep
3874bb9fa6 Delete duplicate line of code
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-22 15:41:26 -07:00
Tom Eastep
9c749731c5 Add caution regarding Address Varibles
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-22 14:39:40 -07:00
Tom Eastep
34f2aeacea Correct 'sed' command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-22 09:59:30 -07:00
Tom Eastep
5b26f1939b Correct 'sed' command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-22 09:56:59 -07:00
Tom Eastep
13a321726c Fix typo
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-21 09:22:30 -07:00
Tom Eastep
b160845713 Avoid compiler crash when LOAD_HELPERS_ONLY=Yes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-20 15:22:43 -07:00
Tom Eastep
71566f0ab0 Avoid compiler crash when LOAD_HELPERS_ONLY=Yes
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-20 14:54:01 -07:00
Tom Eastep
e4169ede4a Merge branch '5.0.13' 2016-10-20 13:29:05 -07:00
Tom Eastep
b44628ddc8 Only specify 'counters' to ipset of IPSET_MATCH_COUNTERS is present
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-20 09:07:36 -07:00
Tom Eastep
0e7d5f3972 Support '+' in SNAT action invocation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-18 16:00:36 -07:00
Tom Eastep
5b5f91f75f SNAT option documentation
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-18 15:32:22 -07:00
Tom Eastep
ab496987e0 Prevent 'nat' and 'mangle' being specified together
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-18 15:32:05 -07:00
Tom Eastep
c92ebc3908 Make merge_inline_source_dest() a little safer
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-18 14:32:56 -07:00
Tom Eastep
bc3573fcbc Correct handling of interface lists in masq->snat conversion
- Also restore logic for ADD_SNAT_ALIASES
- Correct some interface-list errors in snat processing
- Restore whitespace after '--to-source'

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-18 14:19:09 -07:00
Tom Eastep
6b7beaadaf Merge branch '5.0.13' 2016-10-18 10:16:58 -07:00
Tom Eastep
31b6e9e299 Fix another DEST bug in mangle inline action handling :-(
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-18 10:15:43 -07:00
Tom Eastep
d52a4b1c9d Implement SNAT actions and inlines
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-18 10:09:07 -07:00
Tom Eastep
9796af5d80 Merge branch '5.0.13' 2016-10-17 10:16:30 -07:00
Tom Eastep
f3dd77a3f1 Merge branch '5.0.13' 2016-10-16 16:36:08 -07:00
Tom Eastep
05dbfbb988 Restrict hypen as range separator to use with integers
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-16 13:26:44 -07:00
Tom Eastep
69a7c78179 Merge branch '5.0.13' 2016-10-16 12:28:01 -07:00
Tom Eastep
2ca86d9abd Merge branch '5.0.13' 2016-10-16 10:22:12 -07:00
Tom Eastep
1ca91d7ddc Correct handling of ECN file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-16 08:41:19 -07:00
Tom Eastep
047b5ca6d5 Add the --exits option to ADD with timeout
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-15 16:43:04 -07:00
Tom Eastep
ef0253905a More document updates for the snat file.
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-15 16:16:30 -07:00
Tom Eastep
86c4333f8f Correct the shorewall-snat(5) examples
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-15 14:58:49 -07:00
Tom Eastep
026c30cfff Update the documentation for /etc/shorewall/snat
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-15 13:52:28 -07:00
Tom Eastep
e1de1f0527 Convert Sample masq files to equivalent snat files
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-15 12:43:42 -07:00
Tom Eastep
43fdddb438 Add 'snat' config file
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-15 11:38:52 -07:00
Tom Eastep
44477d97ac Move Masq file processing to the Rules module
- This will enable supporting actions in the new snat file

Signed-off-by: Tom Eastep <teastep@shorewall.net>
2016-10-14 12:42:58 -07:00
320 changed files with 14230 additions and 28376 deletions

View File

@@ -190,7 +190,7 @@ for p in ${!params[@]}; do
done done
echo '#' > shorewallrc echo '#' > shorewallrc
echo "# Created by Shorewall Core version $VERSION configure - " `date` >> shorewallrc echo "# Created by Shorewall Core version $VERSION configure - " `date --utc --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}"` >> shorewallrc
echo "# rc file: $rcfile" >> shorewallrc echo "# rc file: $rcfile" >> shorewallrc
echo '#' >> shorewallrc echo '#' >> shorewallrc

View File

@@ -173,7 +173,12 @@ 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", VERSION, $abbr[$localtime[4]], $localtime[3], 1900 + $localtime[5] , @localtime[2,1,0]; if ( $ENV{SOURCE_DATE_EPOCH} ) {
printf $outfile "#\n# Created by Shorewall Core version %s configure.pl - %s\n", VERSION, `date --utc --date=\"\@$ENV{SOURCE_DATE_EPOCH}\"`;
} else {
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 "# rc file: $rcfilename\n#\n";
print $outfile "# Input: @ARGV\n#\n" if @ARGV; print $outfile "# Input: @ARGV\n#\n" if @ARGV;

View File

@@ -22,64 +22,20 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>. # along with this program; if not, see <http://www.gnu.org/licenses/>.
# #
VERSION=xxx #The Build script inserts the actual version VERSION=xxx # The Build script inserts the actual version
PRODUCT=shorewall-core PRODUCT=shorewall-core
Product="Shorewall Core" Product="Shorewall Core"
usage() # $1 = exit status usage() # $1 = exit status
{ {
ME=$(basename $0) ME=$(basename $0)
echo "usage: $ME [ <configuration-file> ] " echo "usage: $ME [ <option> ] [ <shorewallrc file> ]"
echo " $ME -v" echo "where <option> is one of"
echo " $ME -h" echo " -h"
echo " -v"
exit $1 exit $1
} }
fatal_error()
{
echo " ERROR: $@" >&2
exit 1
}
split() {
local ifs
ifs=$IFS
IFS=:
set -- $1
echo $*
IFS=$ifs
}
qt()
{
"$@" >/dev/null 2>&1
}
mywhich() {
local dir
for dir in $(split $PATH); do
if [ -x $dir/$1 ]; then
echo $dir/$1
return 0
fi
done
return 2
}
cant_autostart()
{
echo
echo "WARNING: Unable to configure shorewall to start automatically at boot" >&2
}
delete_file() # $1 = file to delete
{
rm -f $1
}
install_file() # $1 = source $2 = target $3 = mode install_file() # $1 = source $2 = target $3 = mode
{ {
if cp -f $1 $2; then if cp -f $1 $2; then
@@ -98,16 +54,16 @@ install_file() # $1 = source $2 = target $3 = mode
exit 1 exit 1
} }
require()
{
eval [ -n "\$$1" ] || fatal_error "Required option $1 not set"
}
# #
# Change to the directory containing this script # Change to the directory containing this script
# #
cd "$(dirname $0)" cd "$(dirname $0)"
#
# Source common functions
#
. ./lib.installer || { echo "ERROR: Can not load common functions." >&2; exit 1; }
# #
# Parse the run line # Parse the run line
# #
@@ -126,7 +82,7 @@ while [ $finished -eq 0 ]; do
usage 0 usage 0
;; ;;
v) v)
echo "Shorewall Firewall Installer Version $VERSION" echo "$Product Firewall Installer Version $VERSION"
exit 0 exit 0
;; ;;
*) *)
@@ -148,14 +104,14 @@ done
# #
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
if [ -f ./shorewallrc ]; then if [ -f ./shorewallrc ]; then
. ./shorewallrc
file=./shorewallrc file=./shorewallrc
. $file || fatal_error "Can not load the RC file: $file"
elif [ -f ~/.shorewallrc ]; then elif [ -f ~/.shorewallrc ]; then
. ~/.shorewallrc || exit 1
file=~/.shorewallrc file=~/.shorewallrc
. $file || fatal_error "Can not load the RC file: $file"
elif [ -f /usr/share/shorewall/shorewallrc ]; then elif [ -f /usr/share/shorewall/shorewallrc ]; then
. /usr/share/shorewall/shorewallrc
file=/usr/share/shorewall/shorewallrc file=/usr/share/shorewall/shorewallrc
. $file || fatal_error "Can not load the RC file: $file"
else else
fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found"
fi fi
@@ -169,7 +125,7 @@ elif [ $# -eq 1 ]; then
;; ;;
esac esac
. $file . $file || fatal_error "Can not load the RC file: $file"
else else
usage 1 usage 1
fi fi
@@ -285,13 +241,12 @@ case "$HOST" in
debian|gentoo|redhat|slackware|archlinux|linux|suse|openwrt) debian|gentoo|redhat|slackware|archlinux|linux|suse|openwrt)
;; ;;
*) *)
echo "ERROR: Unknown HOST \"$HOST\"" >&2 fatal_error "Unknown HOST \"$HOST\""
exit 1;
;; ;;
esac esac
if [ -z "$file" ]; then if [ -z "$file" ]; then
if $HOST = linux; then if [ $HOST = linux ]; then
file=shorewallrc.default file=shorewallrc.default
else else
file=shorewallrc.${HOST} file=shorewallrc.${HOST}
@@ -304,7 +259,8 @@ if [ -z "$file" ]; then
echo "" >&2 echo "" >&2
echo "Example:" >&2 echo "Example:" >&2
echo "" >&2 echo "" >&2
echo " ./install.sh $file" &>2 echo " ./install.sh $file" >&2
exit 1
fi fi
if [ -n "$DESTDIR" ]; then if [ -n "$DESTDIR" ]; then
@@ -315,45 +271,31 @@ if [ -n "$DESTDIR" ]; then
fi fi
fi fi
echo "Installing Shorewall Core Version $VERSION" echo "Installing $Product Version $VERSION"
# #
# Create directories # Create directories
# #
mkdir -p ${DESTDIR}${LIBEXECDIR}/shorewall make_parent_directory ${DESTDIR}${LIBEXECDIR}/shorewall 0755
chmod 755 ${DESTDIR}${LIBEXECDIR}/shorewall
mkdir -p ${DESTDIR}${SHAREDIR}/shorewall make_parent_directory ${DESTDIR}${SHAREDIR}/shorewall 0755
chmod 755 ${DESTDIR}${SHAREDIR}/shorewall
mkdir -p ${DESTDIR}${CONFDIR} make_parent_directory ${DESTDIR}${CONFDIR} 0755
chmod 755 ${DESTDIR}${CONFDIR}
if [ -n "${SYSCONFDIR}" ]; then [ -n "${SYSCONFDIR}" ] && make_parent_directory ${DESTDIR}${SYSCONFDIR} 0755
mkdir -p ${DESTDIR}${SYSCONFDIR}
chmod 755 ${DESTDIR}${SYSCONFDIR}
fi
if [ -z "${SERVICEDIR}" ]; then if [ -z "${SERVICEDIR}" ]; then
SERVICEDIR="$SYSTEMD" SERVICEDIR="$SYSTEMD"
fi fi
if [ -n "${SERVICEDIR}" ]; then [ -n "${SERVICEDIR}" ] && make_parent_directory ${DESTDIR}${SERVICEDIR} 0755
mkdir -p ${DESTDIR}${SERVICEDIR}
chmod 755 ${DESTDIR}${SERVICEDIR}
fi
mkdir -p ${DESTDIR}${SBINDIR} make_parent_directory ${DESTDIR}${SBINDIR} 0755
chmod 755 ${DESTDIR}${SBINDIR}
if [ -n "${MANDIR}" ]; then [ -n "${MANDIR}" ] && make_parent_directory ${DESTDIR}${MANDIR} 0755
mkdir -p ${DESTDIR}${MANDIR}
chmod 755 ${DESTDIR}${MANDIR}
fi
if [ -n "${INITFILE}" ]; then if [ -n "${INITFILE}" ]; then
mkdir -p ${DESTDIR}${INITDIR} make_parent_directory ${DESTDIR}${INITDIR} 0755
chmod 755 ${DESTDIR}${INITDIR}
if [ -n "$AUXINITSOURCE" -a -f "$AUXINITSOURCE" ]; then if [ -n "$AUXINITSOURCE" -a -f "$AUXINITSOURCE" ]; then
install_file $AUXINITSOURCE ${DESTDIR}${INITDIR}/$AUXINITFILE 0544 install_file $AUXINITSOURCE ${DESTDIR}${INITDIR}/$AUXINITFILE 0544
@@ -365,6 +307,12 @@ fi
# Note: ${VARDIR} is created at run-time since it has always been # Note: ${VARDIR} is created at run-time since it has always been
# a relocatable directory on a per-product basis # a relocatable directory on a per-product basis
# #
# Install the CLI
#
install_file shorewall ${DESTDIR}${SBINDIR}/shorewall 0755
[ $SHAREDIR = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SBINDIR}/shorewall
echo "Shorewall CLI program installed in ${DESTDIR}${SBINDIR}/shorewall"
#
# Install wait4ifup # Install wait4ifup
# #
install_file wait4ifup ${DESTDIR}${LIBEXECDIR}/shorewall/wait4ifup 0755 install_file wait4ifup ${DESTDIR}${LIBEXECDIR}/shorewall/wait4ifup 0755
@@ -376,10 +324,40 @@ echo "wait4ifup installed in ${DESTDIR}${LIBEXECDIR}/shorewall/wait4ifup"
# Install the libraries # Install the libraries
# #
for f in lib.* ; do for f in lib.* ; do
install_file $f ${DESTDIR}${SHAREDIR}/shorewall/$f 0644 case $f in
echo "Library ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/shorewall/$f" *installer)
;;
*)
install_file $f ${DESTDIR}${SHAREDIR}/shorewall/$f 0644
echo "Library ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/shorewall/$f"
;;
esac
done done
if [ $SHAREDIR != /usr/share ]; then
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/shorewall/lib.base
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/shorewall/lib.cli
fi
#
# Install the Man Pages
#
if [ -n "$MANDIR" ]; then
cd manpages
[ -n "$INSTALLD" ] || make_parent_directory ${DESTDIR}${MANDIR}/man8 0755
for f in *.8; do
gzip -9c $f > $f.gz
install_file $f.gz ${DESTDIR}${MANDIR}/man8/$f.gz 0644
echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man8/$f.gz"
done
cd ..
echo "Man Pages Installed"
fi
# #
# Symbolically link 'functions' to lib.base # Symbolically link 'functions' to lib.base
# #
@@ -388,7 +366,7 @@ ln -sf lib.base ${DESTDIR}${SHAREDIR}/shorewall/functions
# Create the version file # Create the version file
# #
echo "$VERSION" > ${DESTDIR}${SHAREDIR}/shorewall/coreversion echo "$VERSION" > ${DESTDIR}${SHAREDIR}/shorewall/coreversion
chmod 644 ${DESTDIR}${SHAREDIR}/shorewall/coreversion chmod 0644 ${DESTDIR}${SHAREDIR}/shorewall/coreversion
if [ -z "${DESTDIR}" ]; then if [ -z "${DESTDIR}" ]; then
if [ $update -ne 0 ]; then if [ $update -ne 0 ]; then
@@ -413,14 +391,20 @@ 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 case $f in
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/shorewall/$f *installer)
else ;;
eval sed -i \'\' -e \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/shorewall/$f *)
fi if [ $BUILD != apple ]; then
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/shorewall/$f
else
eval sed -i \'\' -e \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/shorewall/$f
fi
;;
esac
done done
fi fi
# #
# Report Success # Report Success
# #
echo "Shorewall Core Version $VERSION Installed" echo "$Product Version $VERSION Installed"

View File

@@ -1,7 +1,7 @@
# #
# Shorewall 5.0 -- /usr/share/shorewall/lib.base # Shorewall 5.1 -- /usr/share/shorewall/lib.base
# #
# (c) 1999-2015 - Tom Eastep (teastep@shorewall.net) # (c) 1999-2017 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.net # Complete documentation is available at http://shorewall.net
# #
@@ -20,412 +20,22 @@
# 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 library contains the code common to all Shorewall components except the # This library is a compatibility wrapper around lib.core.
# generated scripts.
# #
SHOREWALL_LIBVERSION=40509 if [ -z "$PRODUCT" ]; then
[ -n "${g_program:=shorewall}" ]
if [ -z "$g_readrc" ]; then
# #
# This is modified by the installer when ${SHAREDIR} != /usr/share # This is modified by the installer when ${SHAREDIR} != /usr/share
# #
. /usr/share/shorewall/shorewallrc . /usr/share/shorewall/shorewallrc
g_sharedir="$SHAREDIR"/$g_program g_basedir=${SHAREDIR}/shorewall
g_confdir="$CONFDIR"/$g_program
g_readrc=1 if [ -z "$SHOREWALL_LIBVERSION" ]; then
. ${g_basedir}/lib.core
fi
set_default_product
setup_product_environment
fi fi
g_basedir=${SHAREDIR}/shorewall
case $g_program in
shorewall)
g_product="Shorewall"
g_family=4
g_tool=iptables
g_lite=
;;
shorewall6)
g_product="Shorewall6"
g_family=6
g_tool=ip6tables
g_lite=
;;
shorewall-lite)
g_product="Shorewall Lite"
g_family=4
g_tool=iptables
g_lite=Yes
;;
shorewall6-lite)
g_product="Shorewall6 Lite"
g_family=6
g_tool=ip6tables
g_lite=Yes
;;
esac
if [ -z "${VARLIB}" ]; then
VARLIB=${VARDIR}
VARDIR=${VARLIB}/$g_program
elif [ -z "${VARDIR}" ]; then
VARDIR="${VARLIB}/${PRODUCT}"
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
#
progress_message() # $* = Message
{
local timestamp
timestamp=
if [ $VERBOSITY -gt 1 ]; then
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
echo "${timestamp}$@"
fi
}
progress_message2() # $* = Message
{
local timestamp
timestamp=
if [ $VERBOSITY -gt 0 ]; then
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
echo "${timestamp}$@"
fi
}
progress_message3() # $* = Message
{
local timestamp
timestamp=
if [ $VERBOSITY -ge 0 ]; then
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
echo "${timestamp}$@"
fi
}
#
# Undo the effect of 'separate_list()'
#
combine_list()
{
local f
local o
o=
for f in $* ; do
o="${o:+$o,}$f"
done
echo $o
}
#
# Validate an IP address
#
valid_address() {
local x
local y
local ifs
ifs=$IFS
IFS=.
for x in $1; do
case $x in
[0-9]|[0-9][0-9]|[1-2][0-9][0-9])
[ $x -lt 256 ] || { IFS=$ifs; return 2; }
;;
*)
IFS=$ifs
return 2
;;
esac
done
IFS=$ifs
return 0
}
#
# Miserable Hack to work around broken BusyBox ash in OpenWRT
#
addr_comp() {
test $(bc <<EOF
$1 > $2
EOF
) -eq 1
}
#
# Enumerate the members of an IP range -- When using a shell supporting only
# 32-bit signed arithmetic, the range cannot span 128.0.0.0.
#
# Comes in two flavors:
#
# ip_range() - produces a mimimal list of network/host addresses that spans
# the range.
#
# ip_range_explicit() - explicitly enumerates the range.
#
ip_range() {
local first
local last
local l
local x
local y
local z
local vlsm
case $1 in
!*)
#
# Let iptables complain if it's a range
#
echo $1
return
;;
[0-9]*.*.*.*-*.*.*.*)
;;
*)
echo $1
return
;;
esac
first=$(decodeaddr ${1%-*})
last=$(decodeaddr ${1#*-})
if addr_comp $first $last; then
fatal_error "Invalid IP address range: $1"
fi
l=$(( $last + 1 ))
while addr_comp $l $first; do
vlsm=
x=31
y=2
z=1
while [ $(( $first % $y )) -eq 0 ] && ! addr_comp $(( $first + $y )) $l; do
vlsm=/$x
x=$(( $x - 1 ))
z=$y
y=$(( $y * 2 ))
done
echo $(encodeaddr $first)$vlsm
first=$(($first + $z))
done
}
ip_range_explicit() {
local first
local last
case $1 in
[0-9]*.*.*.*-*.*.*.*)
;;
*)
echo $1
return
;;
esac
first=$(decodeaddr ${1%-*})
last=$(decodeaddr ${1#*-})
if addr_comp $first $last; then
fatal_error "Invalid IP address range: $1"
fi
while ! addr_comp $first $last; do
echo $(encodeaddr $first)
first=$(($first + 1))
done
}
[ -z "$LEFTSHIFT" ] && . ${g_basedir}/lib.common
#
# Netmask to VLSM
#
ip_vlsm() {
local mask
mask=$(decodeaddr $1)
local vlsm
vlsm=0
local x
x=$(( 128 << 24 )) # 0x80000000
while [ $(( $x & $mask )) -ne 0 ]; do
[ $mask -eq $x ] && mask=0 || mask=$(( $mask $LEFTSHIFT 1 )) # Not all shells shift 0x80000000 left properly.
vlsm=$(($vlsm + 1))
done
if [ $(( $mask & 2147483647 )) -ne 0 ]; then # 2147483647 = 0x7fffffff
echo "Invalid net mask: $1" >&2
else
echo $vlsm
fi
}
#
# Set default config path
#
ensure_config_path() {
local F
F=${g_sharedir}/configpath
if [ -z "$CONFIG_PATH" ]; then
[ -f $F ] || { echo " ERROR: $F does not exist"; exit 2; }
. $F
fi
if [ -n "$g_shorewalldir" ]; then
[ "${CONFIG_PATH%%:*}" = "$g_shorewalldir" ] || CONFIG_PATH=$g_shorewalldir:$CONFIG_PATH
fi
}
#
# Get fully-qualified name of file
#
resolve_file() # $1 = file name
{
local pwd
pwd=$PWD
case $1 in
/*)
echo $1
;;
.)
echo $pwd
;;
./*)
echo ${pwd}${1#.}
;;
..)
cd ..
echo $PWD
cd $pwd
;;
../*)
cd ..
resolve_file ${1#../}
cd $pwd
;;
*)
echo $pwd/$1
;;
esac
}
#
# Determine how to do "echo -e"
#
find_echo() {
local result
result=$(echo "a\tb")
[ ${#result} -eq 3 ] && { echo echo; return; }
result=$(echo -e "a\tb")
[ ${#result} -eq 3 ] && { echo "echo -e"; return; }
result=$(which echo)
[ -n "$result" ] && { echo "$result -e"; return; }
echo echo
}
# Determine which version of mktemp is present (if any) and set MKTEMP accortingly:
#
# None - No mktemp
# BSD - BSD mktemp (Mandrake)
# STD - mktemp.org mktemp
#
find_mktemp() {
local mktemp
mktemp=`mywhich mktemp 2> /dev/null`
if [ -n "$mktemp" ]; then
if qt mktemp -V ; then
MKTEMP=STD
else
MKTEMP=BSD
fi
else
MKTEMP=None
fi
}
#
# create a temporary file. If a directory name is passed, the file will be created in
# that directory. Otherwise, it will be created in a temporary directory.
#
mktempfile() {
[ -z "$MKTEMP" ] && find_mktemp
if [ $# -gt 0 ]; then
case "$MKTEMP" in
BSD)
mktemp $1/shorewall.XXXXXX
;;
STD)
mktemp -p $1 shorewall.XXXXXX
;;
None)
> $1/shorewall-$$ && echo $1/shorewall-$$
;;
*)
error_message "ERROR:Internal error in mktempfile"
;;
esac
else
case "$MKTEMP" in
BSD)
mktemp ${TMPDIR:-/tmp}/shorewall.XXXXXX
;;
STD)
mktemp -t shorewall.XXXXXX
;;
None)
rm -f ${TMPDIR:-/tmp}/shorewall-$$
> ${TMPDIR:-}/shorewall-$$ && echo ${TMPDIR:-/tmp}/shorewall-$$
;;
*)
error_message "ERROR:Internal error in mktempfile"
;;
esac
fi
}

View File

@@ -25,22 +25,18 @@
# loaded after this one and replaces some of the functions declared here. # loaded after this one and replaces some of the functions declared here.
# #
SHOREWALL_CAPVERSION=50004 SHOREWALL_CAPVERSION=50106
[ -n "${g_program:=shorewall}" ] if [ -z "$g_basedir" ]; then
if [ -z "$g_readrc" ]; then
# #
# This is modified by the installer when ${SHAREDIR} <> /usr/share # This is modified by the installer when ${SHAREDIR} <> /usr/share
# #
. /usr/share/shorewall/shorewallrc . /usr/share/shorewall/shorewallrc
g_sharedir="$SHAREDIR"/$g_program g_basedir=${SHAREDIR}/shorewall
g_confdir="$CONFDIR"/$g_program
g_readrc=1
fi fi
. ${SHAREDIR}/shorewall/lib.base . ${g_basedir}/lib.core
# #
# Issue an error message and die # Issue an error message and die
@@ -82,29 +78,6 @@ showchain() # $1 = name of chain
fi fi
} }
#
# The 'awk' hack that compensates for bugs in iptables-save (or rather in the extension modules).
#
iptablesbug()
{
if [ $g_family -eq 4 ]; then
if qt mywhich awk ; then
awk 'BEGIN { sline=""; };\
/^-[jg]/ { print sline $0; next };\
/-m policy.*-[jg] / { print $0; next };\
/-m policy/ { sline=$0; next };\
/--mask ff/ { sub( /--mask ff/, "--mask 0xff" ) };\
{ print ; sline="" }'
else
echo " WARNING: You don't have 'awk' on this system so the output of the save command may be unusable" >&2
cat
fi
else
cat
fi
}
# #
# Validate the value of RESTOREFILE # Validate the value of RESTOREFILE
# #
@@ -395,13 +368,13 @@ logwatch() # $1 = timeout -- if negative, prompt each time that
if [ "$rejects" != "$oldrejects" ]; then if [ "$rejects" != "$oldrejects" ]; then
oldrejects="$rejects" oldrejects="$rejects"
$g_ring_bell printf '\a'
packet_log 40 packet_log 40
if [ "$pause" = "Yes" ]; then if [ "$pause" = "Yes" ]; then
echo echo
echo $g_echo_n 'Enter any character to continue: ' printf 'Enter any character to continue: '
read foo read foo
else else
timed_read timed_read
@@ -949,7 +922,7 @@ show_events() {
for file in /proc/net/xt_recent/*; do for file in /proc/net/xt_recent/*; do
base=$(basename $file) base=$(basename $file)
if [ $base != %CURRENTTIME ]; then if [ "$base" != %CURRENTTIME -a "$base" != "*" ]; then
echo $base echo $base
show_event $base show_event $base
echo echo
@@ -1011,13 +984,6 @@ show_raw() {
$g_tool -t raw -L $g_ipt_options | $output_filter $g_tool -t raw -L $g_ipt_options | $output_filter
} }
show_rawpost() {
echo "$g_product $SHOREWALL_VERSION RAWPOST Table at $g_hostname - $(date)"
echo
show_reset
$g_tool -t rawpost -L $g_ipt_options | $output_filter
}
show_mangle() { show_mangle() {
echo "$g_product $SHOREWALL_VERSION Mangle Table at $g_hostname - $(date)" echo "$g_product $SHOREWALL_VERSION Mangle Table at $g_hostname - $(date)"
echo echo
@@ -1161,6 +1127,64 @@ show_macros() {
done done
} }
show_an_action() {
echo "Shorewall $SHOREWALL_VERSION Action $1 at $g_hostname - $(date)"
cat ${directory}/action.$1
}
show_a_macro() {
echo "Shorewall $SHOREWALL_VERSION Macro $1 at $g_hostname - $(date)"
cat ${directory}/macro.$1
}
#
# Don't dump empty SPD entries or entries from the other address family
#
spd_filter() {
#
# af = Address Family (4 or 6)
# afok = Address Family of entry matches af
# p = print the contents of A (entry is not empty)
# i = Number of lines stored in A
#
awk -v af=$g_family \
'function prnt(A,i, j) { while ( j < i ) print A[j++]; };\
\
/^src / { if (p) prnt( A, i );\
afok = 1;\
p = 0;\
i = 0;\
if ( af == 4 )\
{ if ( /:/ ) afok = 0; }\
else\
{ if ( /\./ ) afok = 0; }\
};\
{ if ( afok ) A[i++] = $0; };\
/tmpl/ { p = afok; };\
\
END { if (p) prnt( A, i ); }'
}
#
# Print a heading with leading and trailing black lines
#
heading() {
echo
echo "$@"
echo
}
show_ipsec() {
heading "PFKEY SPD"
$IP -s -$g_family xfrm policy | spd_filter
heading "PFKEY SAD"
$IP -s -$g_family xfrm state | egrep -v '[[:space:]]+(auth-trunc|enc )' # Don't divulge the keys
}
show_ipsec_command() {
echo "$g_product $SHOREWALL_VERSION IPSEC at $g_hostname - $(date)"
show_ipsec
}
# #
# Show Command Executor # Show Command Executor
# #
@@ -1181,10 +1205,10 @@ show_command() {
if [ -n "$foo" ]; then if [ -n "$foo" ]; then
macro=${macro#*.} macro=${macro#*.}
foo=${foo%.*} foo=${foo%.*}
if [ ${#macro} -gt 10 ]; then if [ ${#macro} -gt 5 ]; then
echo " $macro ${foo#\#}" printf " $macro\t${foo#\#}\n"
else else
$g_echo_e " $macro \t${foo#\#}" printf " $macro\t\t${foo#\#}\n"
fi fi
fi fi
} }
@@ -1231,7 +1255,7 @@ show_command() {
[ $# -eq 1 ] && missing_option_value -t [ $# -eq 1 ] && missing_option_value -t
case $2 in case $2 in
mangle|nat|filter|raw|rawpost) mangle|nat|filter|raw)
table=$2 table=$2
table_given=Yes table_given=Yes
;; ;;
@@ -1285,10 +1309,6 @@ show_command() {
[ $# -gt 1 ] && too_many_arguments $2 [ $# -gt 1 ] && too_many_arguments $2
eval show_raw $g_pager eval show_raw $g_pager
;; ;;
rawpost)
[ $# -gt 1 ] && too_many_arguments $2
eval show_rawpost $g_pager
;;
tos|mangle) tos|mangle)
[ $# -gt 1 ] && too_many_arguments $2 [ $# -gt 1 ] && too_many_arguments $2
eval show_mangle $g_pager eval show_mangle $g_pager
@@ -1356,14 +1376,14 @@ show_command() {
echo "LIBEXEC=${LIBEXECDIR}" echo "LIBEXEC=${LIBEXECDIR}"
echo "SBINDIR=${SBINDIR}" echo "SBINDIR=${SBINDIR}"
echo "CONFDIR=${CONFDIR}" echo "CONFDIR=${CONFDIR}"
[ -n "$g_lite" ] && [ ${VARDIR} != /var/lib/$g_program ] && echo "LITEDIR=${VARDIR}" [ -n "$g_lite" ] && [ ${VARDIR} != /var/lib/$PRODUCT ] && echo "LITEDIR=${VARDIR}"
else else
echo "Default CONFIG_PATH is $CONFIG_PATH" echo "Default CONFIG_PATH is $CONFIG_PATH"
echo "Default VARDIR is /var/lib/$g_program" echo "Default VARDIR is /var/lib/$PRODUCT"
echo "LIBEXEC is ${LIBEXECDIR}" echo "LIBEXEC is ${LIBEXECDIR}"
echo "SBINDIR is ${SBINDIR}" echo "SBINDIR is ${SBINDIR}"
echo "CONFDIR is ${CONFDIR}" echo "CONFDIR is ${CONFDIR}"
[ -n "$g_lite" ] && [ ${VARDIR} != /var/lib/$g_program ] && echo "LITEDIR is ${VARDIR}" [ -n "$g_lite" ] && [ ${VARDIR} != /var/lib/$PRODUCT ] && echo "LITEDIR is ${VARDIR}"
fi fi
;; ;;
chain) chain)
@@ -1426,23 +1446,41 @@ show_command() {
$g_tool -t filter -L dynamic $g_ipt_options | fgrep ACCEPT | $output_filter $g_tool -t filter -L dynamic $g_ipt_options | fgrep ACCEPT | $output_filter
fi fi
;; ;;
ipsec)
[ $# -gt 1 ] && too_many_arguments $2
eval show_ipsec_command $g_pager
;;
*) *)
case "$g_program" in case "$PRODUCT" in
*-lite) *-lite)
;; ;;
*) *)
case $1 in case $1 in
action)
[ $# -lt 2 ] && fatal_error 'Missing <action>'
[ $# -gt 2 ] && too_many_arguments $2
for directory in $(split $CONFIG_PATH); do
if [ -f ${directory}/action.$2 ]; then
eval show_an_action $2 $g_pager
return
fi
done
echo " WARNING: Action $2 not found" >&2
return
;;
actions) actions)
[ $# -gt 1 ] && too_many_arguments $2 [ $# -gt 1 ] && too_many_arguments $2
eval show_actions_sorted $g_pager eval show_actions_sorted $g_pager
return return
;; ;;
macro) macro)
[ $# -lt 2 ] && fatal_error 'Missing <macro>'
[ $# -ne 2 ] && too_many_arguments $2 [ $# -ne 2 ] && too_many_arguments $2
for directory in $(split $CONFIG_PATH); do for directory in $(split $CONFIG_PATH); do
if [ -f ${directory}/macro.$2 ]; then if [ -f ${directory}/macro.$2 ]; then
echo "Shorewall $SHOREWALL_VERSION Macro $2 at $g_hostname - $(date)" eval show_a_macro $2 $g_pager
cat ${directory}/macro.$2
return return
fi fi
done done
@@ -1674,11 +1712,6 @@ do_dump_command() {
$g_tool -t raw -L $g_ipt_options $g_tool -t raw -L $g_ipt_options
fi fi
if qt $g_tool -t rawpost -L -n; then
heading "Rawpost Table"
$g_tool -t rawpost -L $g_ipt_options
fi
local count local count
local max local max
@@ -1729,12 +1762,7 @@ do_dump_command() {
heading "Events" heading "Events"
show_events show_events
if qt mywhich setkey; then show_ipsec
heading "PFKEY SPD"
setkey -DP
heading "PFKEY SAD"
setkey -D | grep -Ev '^[[:space:]](A:|E:)' # Don't divulge the keys
fi
heading "/proc" heading "/proc"
show_proc /proc/version show_proc /proc/version
@@ -1785,7 +1813,7 @@ do_dump_command() {
echo echo
qt mywhich ss && ss -${g_family}tunap || { qt mywhich netstat && netatat -tunap; } qt mywhich ss && ss -${g_family}tunap || { qt mywhich netstat && netstat -tunap; }
if [ -n "$TC_ENABLED" ]; then if [ -n "$TC_ENABLED" ]; then
heading "Traffic Control" heading "Traffic Control"
@@ -1805,6 +1833,7 @@ dump_command() {
restore_command() { restore_command() {
local finished local finished
finished=0 finished=0
local result
while [ $finished -eq 0 -a $# -gt 0 ]; do while [ $finished -eq 0 -a $# -gt 0 ]; do
option=$1 option=$1
@@ -1869,8 +1898,11 @@ restore_command() {
progress_message3 "Restoring $g_product..." progress_message3 "Restoring $g_product..."
run_it $g_restorepath restore && progress_message3 "$g_product restored from ${VARDIR}/$RESTOREFILE" run_it $g_restorepath restore && progress_message3 "$g_product restored from ${VARDIR}/$RESTOREFILE"
result=$?
[ -n "$g_nolock" ] || mutex_off [ -n "$g_nolock" ] || mutex_off
exit $result
else else
echo "File $g_restorepath: file not found" echo "File $g_restorepath: file not found"
[ -n "$g_nolock" ] || mutex_off [ -n "$g_nolock" ] || mutex_off
@@ -1930,15 +1962,6 @@ read_yesno_with_timeout() {
fi fi
} }
#
# Print a heading with leading and trailing black lines
#
heading() {
echo
echo "$@"
echo
}
# #
# Create the appropriate -q option to pass onward # Create the appropriate -q option to pass onward
# #
@@ -2739,7 +2762,6 @@ determine_capabilities() {
CONNMARK_MATCH= CONNMARK_MATCH=
XCONNMARK_MATCH= XCONNMARK_MATCH=
RAW_TABLE= RAW_TABLE=
RAWPOST_TABLE=
IPP2P_MATCH= IPP2P_MATCH=
OLD_IPP2P_MATCH= OLD_IPP2P_MATCH=
LENGTH_MATCH= LENGTH_MATCH=
@@ -2764,7 +2786,7 @@ determine_capabilities() {
GOTO_TARGET= GOTO_TARGET=
LOGMARK_TARGET= LOGMARK_TARGET=
IPMARK_TARGET= IPMARK_TARGET=
LOG_TARGET=Yes LOG_TARGET=
ULOG_TARGET= ULOG_TARGET=
NFLOG_TARGET= NFLOG_TARGET=
PERSISTENT_SNAT= PERSISTENT_SNAT=
@@ -2795,6 +2817,10 @@ determine_capabilities() {
IFACE_MATCH= IFACE_MATCH=
TCPMSS_TARGET= TCPMSS_TARGET=
WAIT_OPTION= WAIT_OPTION=
CPU_FANOUT=
NETMAP_TARGET=
NFLOG_SIZE=
RESTORE_WAIT_OPTION=
AMANDA_HELPER= AMANDA_HELPER=
FTP_HELPER= FTP_HELPER=
@@ -2818,9 +2844,11 @@ determine_capabilities() {
qt $arptables -L OUT && ARPTABLESJF=Yes qt $arptables -L OUT && ARPTABLESJF=Yes
fi fi
[ -z "$(${g_tool}-restore --wait < /dev/null 2>&1)" ] && RESTORE_WAIT_OPTION=Yes
if qt $g_tool --wait -t filter -L INPUT -n -v; then if qt $g_tool --wait -t filter -L INPUT -n -v; then
WAIT_OPTION=Yes WAIT_OPTION=Yes
tool="$tool --wait" g_tool="$g_tool --wait"
fi fi
chain=fooX$$ chain=fooX$$
@@ -2829,8 +2857,10 @@ determine_capabilities() {
if qt $g_tool -t nat -N $chain; then if qt $g_tool -t nat -N $chain; then
if [ $g_family -eq 4 ]; then if [ $g_family -eq 4 ]; then
qt $g_tool -t nat -A $chain -j SNAT --to-source 1.2.3.4 --persistent && PERSISTENT_SNAT=Yes qt $g_tool -t nat -A $chain -j SNAT --to-source 1.2.3.4 --persistent && PERSISTENT_SNAT=Yes
qt $g_tool -t nat -A $chain -j NETMAP --to 1.2.3.0/24 && NETMAP_TARGET=Yes
else else
qt $g_tool -t nat -A $chain -j SNAT --to-source 2001::1 --persistent && PERSISTENT_SNAT=Yes qt $g_tool -t nat -A $chain -j SNAT --to-source 2001::1 --persistent && PERSISTENT_SNAT=Yes
qt $g_tool -t nat -A $chain -j NETMAP --to 2001:470:B:227::/64 && NETMAP_TARGET=Yes
fi fi
qt $g_tool -t nat -A $chain -j MASQUERADE && MASQUERADE_TGT=Yes qt $g_tool -t nat -A $chain -j MASQUERADE && MASQUERADE_TGT=Yes
qt $g_tool -t nat -A $chain -p udplite -m multiport --dport 33 -j REDIRECT --to-port 22 && UDPREDIRECT=Yes qt $g_tool -t nat -A $chain -p udplite -m multiport --dport 33 -j REDIRECT --to-port 22 && UDPREDIRECT=Yes
@@ -2990,7 +3020,6 @@ determine_capabilities() {
fi fi
qt $g_tool -t raw -L -n && RAW_TABLE=Yes qt $g_tool -t raw -L -n && RAW_TABLE=Yes
qt $g_tool -t rawpost -L -n && RAWPOST_TABLE=Yes
if [ -n "$RAW_TABLE" ]; then if [ -n "$RAW_TABLE" ]; then
qt $g_tool -t raw -F $chain qt $g_tool -t raw -F $chain
@@ -3092,7 +3121,12 @@ determine_capabilities() {
qt $g_tool -A $chain -m hashlimit --hashlimit 4 --hashlimit-burst 5 --hashlimit-name $chain --hashlimit-mode dstip -j ACCEPT && OLD_HL_MATCH=Yes qt $g_tool -A $chain -m hashlimit --hashlimit 4 --hashlimit-burst 5 --hashlimit-name $chain --hashlimit-mode dstip -j ACCEPT && OLD_HL_MATCH=Yes
HASHLIMIT_MATCH=$OLD_HL_MATCH HASHLIMIT_MATCH=$OLD_HL_MATCH
fi fi
qt $g_tool -A $chain -j NFQUEUE --queue-num 4 && NFQUEUE_TARGET=Yes
if qt $g_tool -A $chain -j NFQUEUE --queue-num 4; then
NFQUEUE_TARGET=Yes
qt $g_tool -A $chain -j NFQUEUE --queue-balance 0:3 --queue-cpu-fanout && CPU_FANOUT=Yes
fi
qt $g_tool -A $chain -m realm --realm 4 && REALM_MATCH=Yes qt $g_tool -A $chain -m realm --realm 4 && REALM_MATCH=Yes
# #
@@ -3120,12 +3154,15 @@ determine_capabilities() {
qt $g_tool -A $chain -m time --timestart 23:00 -j DROP && TIME_MATCH=Yes qt $g_tool -A $chain -m time --timestart 23:00 -j DROP && TIME_MATCH=Yes
qt $g_tool -A $chain -g $chain1 && GOTO_TARGET=Yes qt $g_tool -A $chain -g $chain1 && GOTO_TARGET=Yes
qt $g_tool -A $chain -j LOGMARK && LOGMARK_TARGET=Yes qt $g_tool -A $chain -j LOGMARK && LOGMARK_TARGET=Yes
qt $g_tool -A $chain -j LOG || LOG_TARGET= qt $g_tool -A $chain -j LOG && LOG_TARGET=Yes
qt $g_tool -A $chain -j ULOG && ULOG_TARGET=Yes qt $g_tool -A $chain -j ULOG && ULOG_TARGET=Yes
qt $g_tool -A $chain -j NFLOG && NFLOG_TARGET=Yes
qt $g_tool -A $chain -j MARK --set-mark 5 && MARK_ANYWHERE=Yes qt $g_tool -A $chain -j MARK --set-mark 5 && MARK_ANYWHERE=Yes
qt $g_tool -A $chain -m statistic --mode nth --every 2 --packet 1 && STATISTIC_MATCH=Yes qt $g_tool -A $chain -m statistic --mode nth --every 2 --packet 1 && STATISTIC_MATCH=Yes
qt $g_tool -A $chain -m geoip --src-cc US && GEOIP_MATCH=Yes qt $g_tool -A $chain -m geoip --src-cc US && GEOIP_MATCH=Yes
if qt $g_tool -A $chain -j NFLOG; then
NFLOG_TARGET=Yes
qt $g_tool -A $chain -j NFLOG --nflog-size 64 && NFLOG_SIZE=Yes
fi
if [ $g_family -eq 4 ]; then if [ $g_family -eq 4 ]; then
qt $g_tool -A $chain -j ACCOUNT --addr 192.168.1.0/29 --tname $chain && ACCOUNT_TARGET=Yes qt $g_tool -A $chain -j ACCOUNT --addr 192.168.1.0/29 --tname $chain && ACCOUNT_TARGET=Yes
@@ -3211,7 +3248,6 @@ report_capabilities_unsorted() {
report_capability "Connmark Match (CONNMARK_MATCH)" $CONNMARK_MATCH report_capability "Connmark Match (CONNMARK_MATCH)" $CONNMARK_MATCH
[ -n "$CONNMARK_MATCH" ] && report_capability "Extended Connmark Match (XCONNMARK_MATCH)" $XCONNMARK_MATCH [ -n "$CONNMARK_MATCH" ] && report_capability "Extended Connmark Match (XCONNMARK_MATCH)" $XCONNMARK_MATCH
report_capability "Raw Table (RAW_TABLE)" $RAW_TABLE report_capability "Raw Table (RAW_TABLE)" $RAW_TABLE
report_capability "Rawpost Table (RAWPOST_TABLE)" $RAWPOST_TABLE
report_capability "IPP2P Match (IPP2P_MATCH)" $IPP2P_MATCH report_capability "IPP2P Match (IPP2P_MATCH)" $IPP2P_MATCH
[ -n "$OLD_IPP2P_MATCH" ] && report_capability "Old IPP2P Match Syntax (OLD_IPP2P_MATCH)" $OLD_IPP2P_MATCH [ -n "$OLD_IPP2P_MATCH" ] && report_capability "Old IPP2P Match Syntax (OLD_IPP2P_MATCH)" $OLD_IPP2P_MATCH
report_capability "CLASSIFY Target (CLASSIFY_TARGET)" $CLASSIFY_TARGET report_capability "CLASSIFY Target (CLASSIFY_TARGET)" $CLASSIFY_TARGET
@@ -3282,14 +3318,19 @@ report_capabilities_unsorted() {
if [ $g_family -eq 4 ]; then if [ $g_family -eq 4 ]; then
report_capability "iptables -S (IPTABLES_S)" $IPTABLES_S report_capability "iptables -S (IPTABLES_S)" $IPTABLES_S
report_capability "iptables --wait option (WAIT_OPTION)" $WAIT_OPTION report_capability "iptables --wait option (WAIT_OPTION)" $WAIT_OPTION
report_capability "iptables-restore --wait option (RESTORE_WAIT_OPTION)" $RESTORE_WAIT_OPTION
else else
report_capability "ip6tables -S (IPTABLES_S)" $IPTABLES_S report_capability "ip6tables -S (IPTABLES_S)" $IPTABLES_S
report_capability "ip6tables --wait option (WAIT_OPTION)" $WAIT_OPTION report_capability "ip6tables --wait option (WAIT_OPTION)" $WAIT_OPTION
report_capability "ip6tables-restore --wait option (RESTORE_WAIT_OPTION)" $RESTORE_WAIT_OPTION
fi fi
report_capability "Basic Filter (BASIC_FILTER)" $BASIC_FILTER report_capability "Basic Filter (BASIC_FILTER)" $BASIC_FILTER
report_capability "Basic Ematch (BASIC_EMATCH)" $BASIC_EMATCH report_capability "Basic Ematch (BASIC_EMATCH)" $BASIC_EMATCH
report_capability "CT Target (CT_TARGET)" $CT_TARGET report_capability "CT Target (CT_TARGET)" $CT_TARGET
report_capability "NFQUEUE CPU Fanout (CPU_FANOUT)" $CPU_FANOUT
report_capability "NETMAP Target (NETMAP_TARGET)" $NETMAP_TARGET
report_capability "--nflog-size support (NFLOG_SIZE)" $NFLOG_SIZE
echo " Kernel Version (KERNELVERSION): $KERNELVERSION" echo " Kernel Version (KERNELVERSION): $KERNELVERSION"
echo " Capabilities Version (CAPVERSION): $CAPVERSION" echo " Capabilities Version (CAPVERSION): $CAPVERSION"
@@ -3339,7 +3380,6 @@ report_capabilities_unsorted1() {
report_capability1 CONNMARK_MATCH report_capability1 CONNMARK_MATCH
report_capability1 XCONNMARK_MATCH report_capability1 XCONNMARK_MATCH
report_capability1 RAW_TABLE report_capability1 RAW_TABLE
report_capability1 RAWPOST_TABLE
report_capability1 IPP2P_MATCH report_capability1 IPP2P_MATCH
report_capability1 OLD_IPP2P_MATCH report_capability1 OLD_IPP2P_MATCH
report_capability1 CLASSIFY_TARGET report_capability1 CLASSIFY_TARGET
@@ -3395,6 +3435,10 @@ report_capabilities_unsorted1() {
report_capability1 IFACE_MATCH report_capability1 IFACE_MATCH
report_capability1 TCPMSS_TARGET report_capability1 TCPMSS_TARGET
report_capability1 WAIT_OPTION report_capability1 WAIT_OPTION
report_capability1 CPU_FANOUT
report_capability1 NETMAP_TARGET
report_capability1 NFLOG_SIZE
report_capability1 RESTORE_WAIT_OPTION
report_capability1 AMANDA_HELPER report_capability1 AMANDA_HELPER
report_capability1 FTP_HELPER report_capability1 FTP_HELPER
@@ -3566,7 +3610,7 @@ blacklist_command() {
if [ $VERBOSITY -gt 1 ]; then if [ $VERBOSITY -gt 1 ]; then
echo "$message" | awk '/have been deleted/ { sub( /^.*: /, "" ); sub( / /, " src " ); }; { print; }' echo "$message" | awk '/have been deleted/ { sub( /^.*: /, "" ); sub( / /, " src " ); }; { print; }'
else else
echo "$message" | head -n1 | sed '/^.*: //; s/ / src /' echo "$message" | head -n1 | sed 's/^.*: //; s/ / src /'
fi fi
fi fi
@@ -3576,7 +3620,7 @@ blacklist_command() {
if [ $VERBOSITY -gt 1 ]; then if [ $VERBOSITY -gt 1 ]; then
echo "$message" | awk '/have been deleted/ { sub( /^.*: /, "" ); sub( / /, " dst " ); }; { print; }' echo "$message" | awk '/have been deleted/ { sub( /^.*: /, "" ); sub( / /, " dst " ); }; { print; }'
else else
echo "$message" | head -n1 | sed '/^.*: //; s/ / dst /' echo "$message" | head -n1 | sed 's/^.*: //; s/ / dst /'
fi fi
fi fi
fi fi
@@ -3699,7 +3743,7 @@ ipcalc_command() {
valid_address $address || fatal_error "Invalid IP address: $address" valid_address $address || fatal_error "Invalid IP address: $address"
[ -z "$vlsm" ] && fatal_error "Missing VLSM" [ -z "$vlsm" ] && fatal_error "Missing VLSM"
[ "x$address" = "x$vlsm" ] && "Invalid VLSM" [ "x$address" = "x$vlsm" ] && fatal_error "Invalid VLSM"
[ $vlsm -gt 32 ] && fatal_error "Invalid VLSM: /$vlsm" [ $vlsm -gt 32 ] && fatal_error "Invalid VLSM: /$vlsm"
address=$address/$vlsm address=$address/$vlsm
@@ -3866,7 +3910,7 @@ get_config() {
ensure_config_path ensure_config_path
config=$(find_file ${g_program}.conf) config=$(find_file ${PRODUCT}.conf)
if [ -f $config ]; then if [ -f $config ]; then
if [ -r $config ]; then if [ -r $config ]; then
@@ -3992,24 +4036,26 @@ get_config() {
g_loopback=$(find_loopback_interfaces) g_loopback=$(find_loopback_interfaces)
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER if [ -z "$g_nopager" ]; then
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
if [ -n "$PAGER" -a -t 1 ]; then if [ -n "$PAGER" -a -t 1 ]; then
case $PAGER in case $PAGER in
/*) /*)
g_pager="$PAGER" g_pager="$PAGER"
[ -f "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist" [ -f "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist"
;; ;;
*) *)
g_pager=$(mywhich $PAGER 2> /dev/null) g_pager=$(mywhich $PAGER 2> /dev/null)
[ -n "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist" [ -n "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist"
;; ;;
esac esac
[ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable" [ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable"
g_pager="| $g_pager" g_pager="| $g_pager"
fi fi
fi
if [ -n "$DYNAMIC_BLACKLIST" ]; then if [ -n "$DYNAMIC_BLACKLIST" ]; then
setup_dbl setup_dbl
@@ -4246,12 +4292,17 @@ usage() # $1 = exit status
echo " reenable <interface>" echo " reenable <interface>"
ecko " refresh [ -d ] [ -n ] [ -T ] [ -D <directory> ] [ <chain>... ]" ecko " refresh [ -d ] [ -n ] [ -T ] [ -D <directory> ] [ <chain>... ]"
echo " reject <address> ..." echo " reject <address> ..."
ecko " reload [ -s ] [ -c ] [ -r <root user> ] [ -T ] [ -i ] [ <directory> ] <system>"
if [ -n "$g_lite" ]; then
echo " reload [ -n ] [ -p ] [ -f ] [ -C ] [ <directory> ]"
else
echo " reload [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ -C ] [ <directory> ]"
fi
if [ -z "$g_lite" ]; then if [ -z "$g_lite" ]; then
echo " remote-reload [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>" echo " remote-reload [ -n ] [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>"
echo " remote-restart [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>" echo " remote-restart [ -n ] [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>"
echo " remote-start [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>" echo " remote-start [ -n ] [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>"
fi fi
echo " reset [ <chain> ... ]" echo " reset [ <chain> ... ]"
@@ -4270,6 +4321,7 @@ usage() # $1 = exit status
echo " savesets" echo " savesets"
echo " [ show | list | ls ] [ -b ] [ -x ] [ -t {filter|mangle|nat} ] [ {chain [<chain> [ <chain> ... ]" echo " [ show | list | ls ] [ -b ] [ -x ] [ -t {filter|mangle|nat} ] [ {chain [<chain> [ <chain> ... ]"
ecko " [ show | list | ls ] actions" ecko " [ show | list | ls ] actions"
ecko " [ show | list | ls ] action <action>"
echo " [ show | list | ls ] arptables" echo " [ show | list | ls ] arptables"
echo " [ show | list | ls ] [ -f ] capabilities" echo " [ show | list | ls ] [ -f ] capabilities"
echo " [ show | list | ls ] [ -x ] {bl|blacklists}" echo " [ show | list | ls ] [ -x ] {bl|blacklists}"
@@ -4285,8 +4337,9 @@ usage() # $1 = exit status
echo " [ show | list | ls ] ipa" echo " [ show | list | ls ] ipa"
fi fi
echo " [ show | list | ls ] ipsec"
echo " [ show | list | ls ] [ -m ] log [<regex>]" echo " [ show | list | ls ] [ -m ] log [<regex>]"
echo " [ show | list | ls ] [ -x ] mangle|nat|raw|rawpost" echo " [ show | list | ls ] [ -x ] mangle|nat|raw"
ecko " [ show | list | ls ] macro <macro>" ecko " [ show | list | ls ] macro <macro>"
ecko " [ show | list | ls ] macros" ecko " [ show | list | ls ] macros"
echo " [ show | list | ls ] nfacct" echo " [ show | list | ls ] nfacct"
@@ -4315,7 +4368,7 @@ usage() # $1 = exit status
# #
# This is the main entry point into the CLI. It directly handles all commands supported # This is the main entry point into the CLI. It directly handles all commands supported
# by both the full and lite versions. Note, however, that functions such as start_command() # by both the full and lite versions. Note, however, that functions such as start_command()
# appear in both this library and it lib.cli-std. The ones in cli-std overload the ones # appear in both this library and in lib.cli-std. The ones in cli-std overload the ones
# here if that lib is loaded below. # here if that lib is loaded below.
# #
shorewall_cli() { shorewall_cli() {
@@ -4357,18 +4410,24 @@ shorewall_cli() {
g_loopback= g_loopback=
g_compiled= g_compiled=
g_pager= g_pager=
g_nopager=
g_blacklistipset= g_blacklistipset=
g_disconnect= g_disconnect=
VERBOSE= VERBOSE=
VERBOSITY=1 VERBOSITY=1
#
[ -n "$g_lite" ] || . ${g_basedir}/lib.cli-std # Set the default product based on the Shorewall packages installed
#
set_default_product
finished=0 finished=0
while [ $finished -eq 0 ]; do while [ $finished -eq 0 ]; do
[ $# -eq 0 ] && usage 1 if [ $# -eq 0 ]; then
setup_product_environment 1
usage 1
fi
option=$1 option=$1
case $option in case $option in
-) -)
@@ -4453,6 +4512,34 @@ shorewall_cli() {
g_timestamp=Yes g_timestamp=Yes
option=${option#t} option=${option#t}
;; ;;
p*)
g_nopager=Yes
option=${option#p}
;;
6*)
if [ "$PRODUCT" = shorewall ]; then
PRODUCT=shorewall6
elif [ "$PRODUCT" = shorewall-lite ]; then
PRODUCT=shorewall6-lite
fi
option=${option#6}
;;
4*)
if [ "$PRODUCT" = shorewall6 ]; then
PRODUCT=shorewall
elif [ "$PRODUCT" = shorewall6-lite ]; then
PRODUCT=shorewall-lite
fi
option=${option#4}
;;
l*)
if [ "$PRODUCT" = shorewall ]; then
PRODUCT=shorewall-lite
elif [ "$PRODUCT" = shorewall6 ]; then
PRODUCT=shorewall6-lite
fi
option=${option#l}
;;
-) -)
finished=1 finished=1
option= option=
@@ -4470,16 +4557,16 @@ shorewall_cli() {
esac esac
done done
if [ $# -eq 0 ]; then setup_product_environment 1
usage 1
fi [ -n "$g_lite" ] || . ${SHAREDIR}/shorewall/lib.cli-std
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
MUTEX_TIMEOUT= MUTEX_TIMEOUT=
[ -f ${g_confdir}/vardir ] && . ${g_confdir}/vardir [ -f ${g_confdir}/vardir ] && . ${g_confdir}/vardir
[ -n "${VARDIR:=/var/lib/$g_program}" ] [ -n "${VARDIR:=/var/lib/$PRODUCT}" ]
g_firewall=${VARDIR}/firewall g_firewall=${VARDIR}/firewall
@@ -4494,26 +4581,6 @@ shorewall_cli() {
banner="${g_product}-${SHOREWALL_VERSION} Status at $g_hostname -" banner="${g_product}-${SHOREWALL_VERSION} Status at $g_hostname -"
case $(echo -e) in
-e*)
g_ring_bell="echo \a"
g_echo_e="echo"
;;
*)
g_ring_bell="echo -e \a"
g_echo_e="echo -e"
;;
esac
case $(echo -n "Testing") in
-n*)
g_echo_n=
;;
*)
g_echo_n=-n
;;
esac
COMMAND=$1 COMMAND=$1
case "$COMMAND" in case "$COMMAND" in

View File

@@ -1,7 +1,7 @@
# #
# Shorewall 5.0 -- /usr/share/shorewall/lib.common. # Shorewall 5.1 -- /usr/share/shorewall/lib.common.
# #
# (c) 2010-2015 - Tom Eastep (teastep@shorewall.net) # (c) 2010-2017 - Tom Eastep (teastep@shorewall.net)
# #
# Complete documentation is available at http://shorewall.net # Complete documentation is available at http://shorewall.net
# #
@@ -269,53 +269,48 @@ loadmodule() # $1 = module name, $2 - * arguments
{ {
local modulename local modulename
modulename=$1 modulename=$1
shift
local moduleoptions
moduleoptions=$*
local modulefile local modulefile
local suffix local suffix
if [ -d /sys/module/ ]; then if [ -d /sys/module/ ]; then
if ! list_search $modulename $DONT_LOAD; then if ! list_search $modulename $DONT_LOAD; then
if [ ! -d /sys/module/$modulename ]; then if [ ! -d /sys/module/$modulename ]; then
shift case $moduleloader in
insmod)
for suffix in $MODULE_SUFFIX ; do for directory in $moduledirectories; do
for directory in $moduledirectories; do for modulefile in $directory/${modulename}.*; do
modulefile=$directory/${modulename}.${suffix} if [ -f $modulefile ]; then
insmod $modulefile $moduleoptions
if [ -f $modulefile ]; then return
case $moduleloader in fi
insmod) done
insmod $modulefile $* done
;; ;;
*) *)
modprobe $modulename $* modprobe -q $modulename $moduleoptions
;; ;;
esac esac
break 2
fi
done
done
fi fi
fi fi
elif ! list_search $modulename $DONT_LOAD $MODULES; then elif ! list_search $modulename $DONT_LOAD $MODULES; then
shift case $moduleloader in
insmod)
for suffix in $MODULE_SUFFIX ; do for directory in $moduledirectories; do
for directory in $moduledirectories; do for modulefile in $directory/${modulename}.*; do
modulefile=$directory/${modulename}.${suffix} if [ -f $modulefile ]; then
insmod $modulefile $moduleoptions
if [ -f $modulefile ]; then return
case $moduleloader in fi
insmod) done
insmod $modulefile $* done
;; ;;
*) *)
modprobe $modulename $* modprobe -q $modulename $moduleoptions
;; ;;
esac esac
break 2
fi
done
done
fi fi
} }
@@ -338,8 +333,6 @@ reload_kernel_modules() {
moduleloader=insmod moduleloader=insmod
fi fi
[ -n "${MODULE_SUFFIX:=ko ko.gz ko.xz o o.gz o.xz gz xz}" ]
if [ -n "$MODULESDIR" ]; then if [ -n "$MODULESDIR" ]; then
case "$MODULESDIR" in case "$MODULESDIR" in
+*) +*)
@@ -394,8 +387,6 @@ load_kernel_modules() # $1 = Yes, if we are to save moduleinfo in $VARDIR
moduleloader=insmod moduleloader=insmod
fi fi
[ -n "${MODULE_SUFFIX:=o gz xz ko o.gz o.xz ko.gz ko.xz}" ]
if [ -n "$MODULESDIR" ]; then if [ -n "$MODULESDIR" ]; then
case "$MODULESDIR" in case "$MODULESDIR" in
+*) +*)

440
Shorewall-core/lib.core Normal file
View File

@@ -0,0 +1,440 @@
#
# Shorewall 5.1 -- /usr/share/shorewall/lib.core
#
# (c) 1999-2017 - Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is part of Shorewall.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 2 of the license or, at your
# option, any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# This library contains the code common to all Shorewall components except the
# generated scripts.
#
SHOREWALL_LIBVERSION=50108
#
# Fatal Error
#
fatal_error() # $@ = Message
{
echo " ERROR: $@" >&2
exit 2
}
setup_product_environment() { # $1 = if non-empty, source shorewallrc again now that we have the correct product
g_basedir=${SHAREDIR}/shorewall
g_sharedir="$SHAREDIR"/$PRODUCT
g_confdir="$CONFDIR"/$PRODUCT
case $PRODUCT in
shorewall)
g_product="Shorewall"
g_family=4
g_tool=iptables
g_lite=
;;
shorewall6)
g_product="Shorewall6"
g_family=6
g_tool=ip6tables
g_lite=
;;
shorewall-lite)
g_product="Shorewall Lite"
g_family=4
g_tool=iptables
g_lite=Yes
;;
shorewall6-lite)
g_product="Shorewall6 Lite"
g_family=6
g_tool=ip6tables
g_lite=Yes
;;
*)
fatal_error "Unknown PRODUCT ($PRODUCT)"
;;
esac
[ -f ${SHAREDIR}/${PRODUCT}/version ] || fatal_error "$g_product does not appear to be installed on this system"
#
# We need to do this again, now that we have the correct product
#
[ -n "$1" ] && . ${g_basedir}/shorewallrc
if [ -z "${VARLIB}" ]; then
VARLIB=${VARDIR}
VARDIR=${VARLIB}/${PRODUCT}
elif [ -z "${VARDIR}" ]; then
VARDIR="${VARLIB}/${PRODUCT}"
fi
}
set_default_product() {
case $(basename $0) in
shorewall6)
PRODUCT=shorewall6
;;
shorewall4)
PRODUCT=shorewall
;;
shorewall-lite)
PRODUCT=shorewall-lite
;;
shorewall6-lite)
PRODUCT=shorewall6-lite
;;
*)
if [ -f ${g_basedir}/version ]; then
PRODUCT=shorewall
elif [ -f ${SHAREDIR}/shorewall-lite/version ]; then
PRODUCT=shorewall-lite
elif [ -f ${SHAREDIR}/shorewall6-lite/version ]; then
PRODUCT=shorewall6-lite
else
fatal_error "No Shorewall firewall product is installed"
fi
;;
esac
}
# Not configured Error
#
not_configured_error() # $@ = Message
{
echo " ERROR: $@" >&2
exit 6
}
#
# Conditionally produce message
#
progress_message() # $* = Message
{
local timestamp
timestamp=
if [ $VERBOSITY -gt 1 ]; then
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
echo "${timestamp}$@"
fi
}
progress_message2() # $* = Message
{
local timestamp
timestamp=
if [ $VERBOSITY -gt 0 ]; then
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
echo "${timestamp}$@"
fi
}
progress_message3() # $* = Message
{
local timestamp
timestamp=
if [ $VERBOSITY -ge 0 ]; then
[ -n "$g_timestamp" ] && timestamp="$(date +%H:%M:%S) "
echo "${timestamp}$@"
fi
}
#
# Undo the effect of 'separate_list()'
#
combine_list()
{
local f
local o
o=
for f in $* ; do
o="${o:+$o,}$f"
done
echo $o
}
#
# Validate an IP address
#
valid_address() {
local x
local y
local ifs
ifs=$IFS
IFS=.
for x in $1; do
case $x in
[0-9]|[0-9][0-9]|[1-2][0-9][0-9])
[ $x -lt 256 ] || { IFS=$ifs; return 2; }
;;
*)
IFS=$ifs
return 2
;;
esac
done
IFS=$ifs
return 0
}
#
# Miserable Hack to work around broken BusyBox ash in OpenWRT
#
addr_comp() {
test $(bc <<EOF
$1 > $2
EOF
) -eq 1
}
#
# Enumerate the members of an IP range -- When using a shell supporting only
# 32-bit signed arithmetic, the range cannot span 128.0.0.0.
#
# Comes in two flavors:
#
# ip_range() - produces a mimimal list of network/host addresses that spans
# the range.
#
# ip_range_explicit() - explicitly enumerates the range.
#
ip_range() {
local first
local last
local l
local x
local y
local z
local vlsm
case $1 in
!*)
#
# Let iptables complain if it's a range
#
echo $1
return
;;
[0-9]*.*.*.*-*.*.*.*)
;;
*)
echo $1
return
;;
esac
first=$(decodeaddr ${1%-*})
last=$(decodeaddr ${1#*-})
if addr_comp $first $last; then
fatal_error "Invalid IP address range: $1"
fi
l=$(( $last + 1 ))
while addr_comp $l $first; do
vlsm=
x=31
y=2
z=1
while [ $(( $first % $y )) -eq 0 ] && ! addr_comp $(( $first + $y )) $l; do
vlsm=/$x
x=$(( $x - 1 ))
z=$y
y=$(( $y * 2 ))
done
echo $(encodeaddr $first)$vlsm
first=$(($first + $z))
done
}
ip_range_explicit() {
local first
local last
case $1 in
[0-9]*.*.*.*-*.*.*.*)
;;
*)
echo $1
return
;;
esac
first=$(decodeaddr ${1%-*})
last=$(decodeaddr ${1#*-})
if addr_comp $first $last; then
fatal_error "Invalid IP address range: $1"
fi
while ! addr_comp $first $last; do
echo $(encodeaddr $first)
first=$(($first + 1))
done
}
[ -z "$LEFTSHIFT" ] && . ${g_basedir}/lib.common
#
# Netmask to VLSM
#
ip_vlsm() {
local mask
mask=$(decodeaddr $1)
local vlsm
vlsm=0
local x
x=$(( 128 << 24 )) # 0x80000000
while [ $(( $x & $mask )) -ne 0 ]; do
[ $mask -eq $x ] && mask=0 || mask=$(( $mask $LEFTSHIFT 1 )) # Not all shells shift 0x80000000 left properly.
vlsm=$(($vlsm + 1))
done
if [ $(( $mask & 2147483647 )) -ne 0 ]; then # 2147483647 = 0x7fffffff
echo "Invalid net mask: $1" >&2
else
echo $vlsm
fi
}
#
# Set default config path
#
ensure_config_path() {
local F
F=${g_sharedir}/configpath
if [ -z "$CONFIG_PATH" ]; then
[ -f $F ] || { echo " ERROR: $F does not exist"; exit 2; }
. $F
fi
if [ -n "$g_shorewalldir" ]; then
[ "${CONFIG_PATH%%:*}" = "$g_shorewalldir" ] || CONFIG_PATH=$g_shorewalldir:$CONFIG_PATH
fi
}
#
# Get fully-qualified name of file
#
resolve_file() # $1 = file name
{
local pwd
pwd=$PWD
case $1 in
/*)
echo $1
;;
.)
echo $pwd
;;
./*)
echo ${pwd}${1#.}
;;
..)
cd ..
echo $PWD
cd $pwd
;;
../*)
cd ..
resolve_file ${1#../}
cd $pwd
;;
*)
echo $pwd/$1
;;
esac
}
# Determine which version of mktemp is present (if any) and set MKTEMP accortingly:
#
# None - No mktemp
# BSD - BSD mktemp (Mandrake)
# STD - mktemp.org mktemp
#
find_mktemp() {
local mktemp
mktemp=`mywhich mktemp 2> /dev/null`
if [ -n "$mktemp" ]; then
if qt mktemp -V ; then
MKTEMP=STD
else
MKTEMP=BSD
fi
else
MKTEMP=None
fi
}
#
# create a temporary file. If a directory name is passed, the file will be created in
# that directory. Otherwise, it will be created in a temporary directory.
#
mktempfile() {
[ -z "$MKTEMP" ] && find_mktemp
if [ $# -gt 0 ]; then
case "$MKTEMP" in
BSD)
mktemp $1/shorewall.XXXXXX
;;
STD)
mktemp -p $1 shorewall.XXXXXX
;;
None)
> $1/shorewall-$$ && echo $1/shorewall-$$
;;
*)
error_message "ERROR:Internal error in mktempfile"
;;
esac
else
case "$MKTEMP" in
BSD)
mktemp ${TMPDIR:-/tmp}/shorewall.XXXXXX
;;
STD)
mktemp -t shorewall.XXXXXX
;;
None)
rm -f ${TMPDIR:-/tmp}/shorewall-$$
> ${TMPDIR:-}/shorewall-$$ && echo ${TMPDIR:-/tmp}/shorewall-$$
;;
*)
error_message "ERROR:Internal error in mktempfile"
;;
esac
fi
}

View File

@@ -0,0 +1,89 @@
#
#
# Shorewall 5.1 -- /usr/share/shorewall/lib.installer.
#
# (c) 2017 - Tom Eastep (teastep@shorewall.net)
# (c) 2017 - Matt Darfeuille (matdarf@gmail.com)
#
# Complete documentation is available at http://shorewall.net
#
# This program is part of Shorewall.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 2 of the license or, at your
# option, any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# The purpose of this library is to hold those functions used by the products installer.
#
#########################################################################################
fatal_error()
{
echo " ERROR: $@" >&2
exit 1
}
split() {
local ifs
ifs=$IFS
IFS=:
set -- $1
echo $*
IFS=$ifs
}
qt()
{
"$@" >/dev/null 2>&1
}
mywhich() {
local dir
for dir in $(split $PATH); do
if [ -x $dir/$1 ]; then
return 0
fi
done
return 2
}
delete_file() # $1 = file to delete
{
rm -f $1
}
require()
{
eval [ -n "\$$1" ] || fatal_error "Required option $1 not set"
}
make_directory() # $1 = directory , $2 = mode
{
mkdir $1
chmod $2 $1
[ -n "$OWNERSHIP" ] && chown $OWNERSHIP $1
}
make_parent_directory() # $1 = directory , $2 = mode
{
mkdir -p $1
chmod $2 $1
[ -n "$OWNERSHIP" ] && chown $OWNER:$GROUP $1
}
cant_autostart()
{
echo
echo "WARNING: Unable to configure $Product to start automatically at boot" >&2
}

View File

@@ -0,0 +1,106 @@
#
#
# Shorewall 5.1 -- /usr/share/shorewall/lib.installer.
#
# (c) 2017 - Tom Eastep (teastep@shorewall.net)
# (c) 2017 - Matt Darfeuille (matdarf@gmail.com)
#
# Complete documentation is available at http://shorewall.net
#
# This program is part of Shorewall.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 2 of the license or, at your
# option, any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# The purpose of this library is to hold those functions used by the products uninstaller.
#
#########################################################################################
fatal_error()
{
echo " ERROR: $@" >&2
exit 1
}
split() {
local ifs
ifs=$IFS
IFS=:
set -- $1
echo $*
IFS=$ifs
}
qt()
{
"$@" >/dev/null 2>&1
}
mywhich() {
local dir
for dir in $(split $PATH); do
if [ -x $dir/$1 ]; then
return 0
fi
done
return 2
}
remove_file() # $1 = file to remove
{
if [ -n "$1" ] ; then
if [ -f $1 -o -L $1 ] ; then
rm -f $1
echo "$1 Removed"
fi
fi
}
remove_directory() # $1 = directory to remove
{
if [ -n "$1" ] ; then
if [ -d $1 ] ; then
rm -rf $1
echo "$1 Removed"
fi
fi
}
remove_file_with_wildcard() # $1 = file with wildcard to remove
{
if [ -n "$1" ] ; then
for f in $1; do
if [ -d $f ] ; then
rm -rf $f
echo "$f Removed"
elif [ -f $f -o -L $f ] ; then
rm -f $f
echo "$f Removed"
fi
done
fi
}
restore_file() # $1 = file to restore
{
if [ -f ${1}-shorewall.bkout ]; then
if (mv -f ${1}-shorewall.bkout $1); then
echo
echo "$1 restored"
else
exit 1
fi
fi
}

View File

@@ -1,8 +1,8 @@
#!/bin/sh #!/bin/sh
# #
# Shorewall Packet Filtering Firewall Control Program - V5.0 # Shorewall Packet Filtering Firewall Control Program - V5.1
# #
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2014,2015 - # (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2014,2015-2017
# Tom Eastep (teastep@shorewall.net) # Tom Eastep (teastep@shorewall.net)
# #
# Shorewall documentation is available at http://www.shorewall.net # Shorewall documentation is available at http://www.shorewall.net
@@ -25,6 +25,10 @@
# For a list of supported commands, type 'shorewall help' or 'shorewall6 help' # For a list of supported commands, type 'shorewall help' or 'shorewall6 help'
# #
################################################################################################ ################################################################################################
#
# Default product is Shorewall. PRODUCT will be set based on $0 and on passed -[46] and -l
# options
#
PRODUCT=shorewall PRODUCT=shorewall
# #
@@ -32,11 +36,8 @@ PRODUCT=shorewall
# #
. /usr/share/shorewall/shorewallrc . /usr/share/shorewall/shorewallrc
g_program=$PRODUCT g_basedir=${SHAREDIR}/shorewall
g_sharedir="$SHAREDIR"/shorewall
g_confdir="$CONFDIR"/shorewall
g_readrc=1
. $g_sharedir/lib.cli . ${g_basedir}/lib.cli
shorewall_cli $@ shorewall_cli $@

View File

@@ -1,5 +1,5 @@
# #
# Debian Shorewall 4.5 rc file # Debian Shorewall 5.0 rc file
# #
BUILD= #Default is to detect the build system BUILD= #Default is to detect the build system
HOST=debian HOST=debian
@@ -14,7 +14,7 @@ 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=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.systemd #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 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 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) SERVICEDIR=/lib/systemd/system #Directory where .service files are installed (systems running systemd only)

View File

@@ -1,5 +1,5 @@
# #
# Debian Shorewall 4.5 rc file # Debian Shorewall 5.0 rc file
# #
BUILD= #Default is to detect the build system BUILD= #Default is to detect the build system
HOST=debian HOST=debian
@@ -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.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.sysvinit #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
SERVICEDIR= #Directory where .service files are installed (systems running systemd only) SERVICEDIR= #Directory where .service files are installed (systems running systemd only)

View File

@@ -1,8 +1,8 @@
# #
# Default Shorewall 5.0 rc file # Default Shorewall 5.0 rc file
# #
HOST=linux #Generic Linux
BUILD= #Default is to detect the build system BUILD= #Default is to detect the build system
HOST=linux #Generic Linux
PREFIX=/usr #Top-level directory for shared files, libraries, etc. PREFIX=/usr #Top-level directory for shared files, libraries, etc.
SHAREDIR=${PREFIX}/share #Directory for arch-neutral files. SHAREDIR=${PREFIX}/share #Directory for arch-neutral files.
LIBEXECDIR=${PREFIX}/share #Directory for executable scripts. LIBEXECDIR=${PREFIX}/share #Directory for executable scripts.

View File

@@ -1,8 +1,8 @@
# #
# Created by Shorewall Core version 5.0.2-RC1 configure - Fri, Nov 06, 2015 10:02:03 AM # OpenWRT Shorewall 5.0 rc file
#
# Input: host=openwrt
# #
BUILD= #Default is to detect the build system
HOST=openwrt
PREFIX=/usr #Top-level directory for shared files, libraries, etc. PREFIX=/usr #Top-level directory for shared files, libraries, etc.
SHAREDIR=${PREFIX}/share #Directory for arch-neutral files. SHAREDIR=${PREFIX}/share #Directory for arch-neutral files.
LIBEXECDIR=${PREFIX}/share #Directory for executable scripts. LIBEXECDIR=${PREFIX}/share #Directory for executable scripts.

View File

@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Script to back uninstall Shoreline Firewall # Script to back uninstall Shoreline Firewall Core Modules
# #
# (c) 2000-2016 - Tom Eastep (teastep@shorewall.net) # (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
# #
@@ -26,64 +26,75 @@
# You may only use this script to uninstall the version # You may only use this script to uninstall the version
# 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-core" PRODUCT=shorewall-core
Product="Shorewall Core" Product="Shorewall Core"
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"
exit $1 exit $1
} }
fatal_error()
{
echo " ERROR: $@" >&2
exit 1
}
qt()
{
"$@" >/dev/null 2>&1
}
restore_file() # $1 = file to restore
{
if [ -f ${1}-shorewall.bkout ]; then
if (mv -f ${1}-shorewall.bkout $1); then
echo
echo "$1 restored"
else
exit 1
fi
fi
}
remove_file() # $1 = file to restore
{
if [ -f $1 -o -L $1 ] ; then
rm -f $1
echo "$1 Removed"
fi
}
# #
# Change to the directory containing this script # Change to the directory containing this script
# #
cd "$(dirname $0)" cd "$(dirname $0)"
#
# Source common functions
#
. ./lib.uninstaller || { echo "ERROR: Can not load common functions." >&2; exit 1; }
#
# Parse the run line
#
finished=0
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 Uninstaller Version $VERSION"
exit 0
;;
*)
usage 1
;;
esac
done
shift
;;
*)
finished=1
;;
esac
done
# #
# Read the RC file # Read the RC file
# #
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
if [ -f ./shorewallrc ]; then if [ -f ./shorewallrc ]; then
. ./shorewallrc . ./shorewallrc || fatal_error "Can not load the RC file: ./shorewallrc"
elif [ -f ~/.shorewallrc ]; then elif [ -f ~/.shorewallrc ]; then
. ~/.shorewallrc || exit 1 . ~/.shorewallrc || fatal_error "Can not load the RC file: ~/.shorewallrc"
file=./.shorewallrc
elif [ -f /usr/share/shorewall/shorewallrc ]; then elif [ -f /usr/share/shorewall/shorewallrc ]; then
. /usr/share/shorewall/shorewallrc . /usr/share/shorewall/shorewallrc || fatal_error "Can not load the RC file: /usr/share/shorewall/shorewallrc"
else else
fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found"
fi fi
@@ -93,11 +104,11 @@ elif [ $# -eq 1 ]; then
/*|.*) /*|.*)
;; ;;
*) *)
file=./$file file=./$file || exit 1
;; ;;
esac esac
. $file . $file || fatal_error "Can not load the RC file: $file"
else else
usage 1 usage 1
fi fi
@@ -105,20 +116,26 @@ fi
if [ -f ${SHAREDIR}/shorewall/coreversion ]; then if [ -f ${SHAREDIR}/shorewall/coreversion ]; then
INSTALLED_VERSION="$(cat ${SHAREDIR}/shorewall/coreversion)" INSTALLED_VERSION="$(cat ${SHAREDIR}/shorewall/coreversion)"
if [ "$INSTALLED_VERSION" != "$VERSION" ]; then if [ "$INSTALLED_VERSION" != "$VERSION" ]; then
echo "WARNING: Shorewall Core Version $INSTALLED_VERSION is installed" echo "WARNING: $Product Version $INSTALLED_VERSION is installed"
echo " and this is the $VERSION uninstaller." echo " and this is the $VERSION uninstaller."
VERSION="$INSTALLED_VERSION" VERSION="$INSTALLED_VERSION"
fi fi
else else
echo "WARNING: Shorewall Core Version $VERSION is not installed" echo "WARNING: $Product Version $VERSION is not installed"
VERSION="" VERSION=""
fi fi
echo "Uninstalling Shorewall Core $VERSION" echo "Uninstalling $Product $VERSION"
rm -rf ${SHAREDIR}/shorewall if [ -n "${MANDIR}" ]; then
rm -f ~/.shorewallrc remove_file_with_wildcard ${MANDIR}/man5/shorewall\*
remove_file_with_wildcard ${MANDIR}/man8/shorewall\*
echo "Shorewall Core Uninstalled" fi
remove_directory ${SHAREDIR}/shorewall
remove_file ~/.shorewallrc
#
# Report Success
#
echo "$Product $VERSION Uninstalled"

View File

@@ -0,0 +1,21 @@
# List the Shorewall products that Shorewall-init is to
# initialize (space-separated list).
#
# Sample: PRODUCTS="shorewall shorewall6"
#
PRODUCTS=""
#
# Set this to 1 if you want Shorewall-init to react to
# ifup/ifdown and NetworkManager events
#
IFUPDOWN=0
#
# Where Up/Down events get logged
#
LOGFILE=/var/log/shorewall-ifupdown.log
# Startup options - set verbosity to 0 (minimal reporting)
OPTIONS="-V0"
# IOF

View File

@@ -0,0 +1,27 @@
# List the Shorewall products that Shorewall-init is to
# initialize (space-separated list).
#
# Sample: PRODUCTS="shorewall shorewall6"
#
PRODUCTS=""
#
# Set this to 1 if you want Shorewall-init to react to
# ifup/ifdown and NetworkManager events
#
IFUPDOWN=0
#
# Set this to the name of the file that is to hold
# ipset contents. Shorewall-init will load those ipsets
# during 'start' and will save them there during 'stop'.
#
SAVE_IPSETS=""
#
# Where Up/Down events get logged
#
LOGFILE=/var/log/shorewall-ifupdown.log
# Startup options - set verbosity to 0 (minimal reporting)
OPTIONS="-V0"
# IOF

View File

@@ -31,8 +31,10 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${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 ]; then
${SBINDIR}/$PRODUCT compile ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
fi fi
fi fi
} }
@@ -128,7 +130,7 @@ for PRODUCT in $PRODUCTS; do
setstatedir setstatedir
if [ -x $VARLIB/$PRODUCT/firewall ]; then if [ -x $VARLIB/$PRODUCT/firewall ]; then
( ${VARLIB}/$PRODUCT/firewall -V0 $COMMAND $INTERFACE >> $LOGFILE 2>&1 ) || true ( ${VARLIB}/$PRODUCT/firewall -V0 $COMMAND $INTERFACE >> $LOGFILE 2>&1 ) || true
fi fi
done done

View File

@@ -33,9 +33,11 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${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 ]; then
${SBINDIR}/$PRODUCT $OPTIONS compile ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
fi fi
fi fi
} }

View File

@@ -31,8 +31,10 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${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 ]; then
${SBINDIR}/$PRODUCT compile ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
fi fi
fi fi
} }

View File

@@ -73,10 +73,16 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ -x ${STATEDIR}/firewall ]; then
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c return 0
else else
return 0 if [ $PRODUCT = shorewall ]; then
${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
else
return 1
fi
fi fi
} }
@@ -102,20 +108,18 @@ shorewall_start () {
local PRODUCT local PRODUCT
local STATEDIR local STATEDIR
echo -n "Initializing \"Shorewall-based firewalls\": " printf "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; 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 fi
fi )
)
fi
fi fi
done done
@@ -123,7 +127,7 @@ shorewall_start () {
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
echo -n "Restoring ipsets: " printf "Restoring ipsets: "
if ! ipset -R < "$SAVE_IPSETS"; then if ! ipset -R < "$SAVE_IPSETS"; then
echo_notdone echo_notdone
@@ -140,12 +144,10 @@ shorewall_stop () {
local PRODUCT local PRODUCT
local STATEDIR local STATEDIR
echo -n "Clearing \"Shorewall-based firewalls\": " printf "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then ${STATEDIR}/firewall ${OPTIONS} clear
${STATEDIR}/firewall ${OPTIONS} clear
fi
fi fi
done done
@@ -157,8 +159,9 @@ shorewall_stop () {
mkdir -p $(dirname "$SAVE_IPSETS") mkdir -p $(dirname "$SAVE_IPSETS")
if ipset -S > "${SAVE_IPSETS}.tmp"; then if ipset -S > "${SAVE_IPSETS}.tmp"; then
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
else else
rm -f "${SAVE_IPSETS}.tmp"
echo_notdone echo_notdone
fi fi

View File

@@ -44,10 +44,14 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT == shorewall -o $PRODUCT == shorewall6 ]; then if [ -x ${STATEDIR}/firewall ]; then
${SBINDIR}/$PRODUCT $OPTIONS compile -c
else
return 0 return 0
elif [ $PRODUCT = shorewall ]; then
${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
else
return 1
fi fi
} }
@@ -62,22 +66,22 @@ start () {
return 6 #Not configured return 6 #Not configured
fi fi
echo -n "Initializing \"Shorewall-based firewalls\": " printf "Initializing \"Shorewall-based firewalls\": "
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
ipset -R < "$SAVE_IPSETS"
fi
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
setstatedir setstatedir
retval=$? retval=$?
if [ $retval -eq 0 ]; then if [ $retval -eq 0 ]; then
if [ -x "${STATEDIR}/firewall" ]; then ${STATEDIR}/firewall ${OPTIONS} stop 2>&1 | $logger
${STATEDIR}/firewall ${OPTIONS} stop 2>&1 | $logger retval=${PIPESTATUS[0]}
retval=${PIPESTATUS[0]} [ $retval -ne 0 ] && break
[ $retval -ne 0 ] && break
else
retval=6 #Product not configured
break
fi
else else
retval=6 #Product not configured
break break
fi fi
done done
@@ -97,27 +101,32 @@ stop () {
local PRODUCT local PRODUCT
local STATEDIR local STATEDIR
echo -n "Clearing \"Shorewall-based firewalls\": " printf "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
setstatedir setstatedir
retval=$? retval=$?
if [ $retval -eq 0 ]; then if [ $retval -eq 0 ]; then
if [ -x "${STATEDIR}/firewall" ]; then ${STATEDIR}/firewall ${OPTIONS} clear 2>&1 | $logger
${STATEDIR}/firewall ${OPTIONS} clear 2>&1 | $logger retval=${PIPESTATUS[0]}
retval=${PIPESTATUS[0]} [ $retval -ne 0 ] && break
[ $retval -ne 0 ] && break
else
retval=6 #Product not configured
break
fi
else else
retval=6 #Product not configured
break break
fi fi
done done
if [ $retval -eq 0 ]; then if [ $retval -eq 0 ]; then
if [ -n "$SAVE_IPSETS" ]; then
mkdir -p $(dirname "$SAVE_IPSETS")
if ipset -S > "${SAVE_IPSETS}.tmp"; then
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
else
rm -f "${SAVE_IPSETS}.tmp"
fi
fi
rm -f $lockfile rm -f $lockfile
success success
else else

32
Shorewall-init/init.openwrt.sh Normal file → Executable file
View File

@@ -75,10 +75,14 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ -x ${STATEDIR}/firewall ]; then
${SBINDIR}/$PRODUCT ${OPTIONS} compile $STATEDIR/firewall
else
return 0 return 0
elif [ $PRODUCT = shorewall ]; then
${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
else
return 1
fi fi
} }
@@ -87,13 +91,11 @@ start () {
local PRODUCT local PRODUCT
local STATEDIR local STATEDIR
echo -n "Initializing \"Shorewall-based firewalls\": " printf "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; 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
fi
fi fi
fi fi
done done
@@ -101,6 +103,8 @@ start () {
if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then if [ -n "$SAVE_IPSETS" -a -f "$SAVE_IPSETS" ]; then
ipset -R < "$SAVE_IPSETS" ipset -R < "$SAVE_IPSETS"
fi fi
return 0
} }
boot () { boot () {
@@ -112,20 +116,22 @@ stop () {
local PRODUCT local PRODUCT
local STATEDIR local STATEDIR
echo -n "Clearing \"Shorewall-based firewalls\": " printf "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then ${STATEDIR}/firewall ${OPTIONS} clear
${STATEDIR}/firewall ${OPTIONS} clear
fi
fi fi
done done
if [ -n "$SAVE_IPSETS" ]; then if [ -n "$SAVE_IPSETS" ]; then
mkdir -p $(dirname "$SAVE_IPSETS") mkdir -p $(dirname "$SAVE_IPSETS")
if ipset -S > "${SAVE_IPSETS}.tmp"; then if ipset -S > "${SAVE_IPSETS}.tmp"; then
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
else
rm -f "${SAVE_IPSETS}.tmp"
fi fi
fi fi
return 0
} }

View File

@@ -69,10 +69,12 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ -x ${STATEDIR}/firewall ]; then
return 0
elif [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then
${SBINDIR}/$PRODUCT ${OPTIONS} compile $STATEDIR/firewall ${SBINDIR}/$PRODUCT ${OPTIONS} compile $STATEDIR/firewall
else else
return 0 return 1
fi fi
} }
@@ -81,13 +83,11 @@ shorewall_start () {
local PRODUCT local PRODUCT
local STATEDIR local STATEDIR
echo -n "Initializing \"Shorewall-based firewalls\": " printf "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; 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
fi
fi fi
fi fi
done done
@@ -104,19 +104,19 @@ shorewall_stop () {
local PRODUCT local PRODUCT
local STATEDIR local STATEDIR
echo -n "Clearing \"Shorewall-based firewalls\": " printf "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then ${STATEDIR}/firewall ${OPTIONS} clear
${STATEDIR}/firewall ${OPTIONS} clear
fi
fi fi
done done
if [ -n "$SAVE_IPSETS" ]; then if [ -n "$SAVE_IPSETS" ]; then
mkdir -p $(dirname "$SAVE_IPSETS") mkdir -p $(dirname "$SAVE_IPSETS")
if ipset -S > "${SAVE_IPSETS}.tmp"; then if ipset -S > "${SAVE_IPSETS}.tmp"; then
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
else
rm -f "${SAVE_IPSETS}.tmp"
fi fi
fi fi

View File

@@ -79,10 +79,14 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ -x ${STATEDIR}/firewall ]; then
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c
else
return 0 return 0
elif [ $PRODUCT = shorewall ]; then
${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
else
return 6
fi fi
} }
@@ -91,13 +95,11 @@ shorewall_start () {
local PRODUCT local PRODUCT
local STATEDIR local STATEDIR
echo -n "Initializing \"Shorewall-based firewalls\": " printf "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; 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
fi
fi fi
fi fi
done done
@@ -112,19 +114,19 @@ shorewall_stop () {
local PRODUCT local PRODUCT
local STATEDIR local STATEDIR
echo -n "Clearing \"Shorewall-based firewalls\": " printf "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then ${STATEDIR}/firewall ${OPTIONS} clear
${STATEDIR}/firewall ${OPTIONS} clear
fi
fi fi
done done
if [ -n "$SAVE_IPSETS" ]; then if [ -n "$SAVE_IPSETS" ]; then
mkdir -p $(dirname "$SAVE_IPSETS") mkdir -p $(dirname "$SAVE_IPSETS")
if ipset -S > "${SAVE_IPSETS}.tmp"; then if ipset -S > "${SAVE_IPSETS}.tmp"; then
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
else
rm -f "${SAVE_IPSETS}.tmp"
fi fi
fi fi
} }

View File

@@ -27,58 +27,21 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
VERSION=xxx #The Build script inserts the actual version. VERSION=xxx # The Build script inserts the actual version
PRODUCT=shorewall-init PRODUCT=shorewall-init
Product="Shorewall Init" Product="Shorewall Init"
usage() # $1 = exit status usage() # $1 = exit status
{ {
ME=$(basename $0) ME=$(basename $0)
echo "usage: $ME [ <configuration-file> ]" echo "usage: $ME [ <option> ] [ <shorewallrc file> ]"
echo " $ME -v" echo "where <option> is one of"
echo " $ME -h" echo " -h"
echo " $ME -n" echo " -v"
echo " -n"
exit $1 exit $1
} }
fatal_error()
{
echo " ERROR: $@" >&2
exit 1
}
split() {
local ifs
ifs=$IFS
IFS=:
set -- $1
echo $*
IFS=$ifs
}
qt()
{
"$@" >/dev/null 2>&1
}
mywhich() {
local dir
for dir in $(split $PATH); do
if [ -x $dir/$1 ]; then
return 0
fi
done
return 2
}
cant_autostart()
{
echo
echo "WARNING: Unable to configure shorewall init to start automatically at boot" >&2
}
install_file() # $1 = source $2 = target $3 = mode install_file() # $1 = source $2 = target $3 = mode
{ {
if cp -f $1 $2; then if cp -f $1 $2; then
@@ -97,23 +60,16 @@ install_file() # $1 = source $2 = target $3 = mode
exit 1 exit 1
} }
make_directory() # $1 = directory , $2 = mode
{
mkdir -p $1
chmod 0755 $1
[ -n "$OWNERSHIP" ] && chown $OWNERSHIP $1
}
require()
{
eval [ -n "\$$1" ] || fatal_error "Required option $1 not set"
}
# #
# Change to the directory containing this script # Change to the directory containing this script
# #
cd "$(dirname $0)" cd "$(dirname $0)"
#
# Source common functions
#
. ./lib.installer || { echo "ERROR: Can not load common functions." >&2; exit 1; }
# #
# Parse the run line # Parse the run line
# #
@@ -134,7 +90,7 @@ while [ $finished -eq 0 ] ; do
usage 0 usage 0
;; ;;
v) v)
echo "Shorewall-init Firewall Installer Version $VERSION" echo "$Product Firewall Installer Version $VERSION"
exit 0 exit 0
;; ;;
n*) n*)
@@ -159,17 +115,17 @@ done
# Read the RC file # Read the RC file
# #
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
#
# Load packager's settings if any
#
if [ -f ./shorewallrc ]; then if [ -f ./shorewallrc ]; then
. ./shorewallrc || exit 1 file=./shorewallrc
file=~/.shorewallrc . $file || fatal_error "Can not load the RC file: $file"
elif [ -f ~/.shorewallrc ]; then elif [ -f ~/.shorewallrc ]; then
. ~/.shorewallrc || exit 1 file=~/.shorewallrc
file=./.shorewallrc . $file || fatal_error "Can not load the RC file: $file"
else elif [ -f /usr/share/shorewall/shorewallrc ]; then
fatal_error "No configuration file specified and ~/.shorewallrc not found" file=/usr/share/shorewall/shorewallrc
. $file || fatal_error "Can not load the RC file: $file"
else
fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found"
fi fi
elif [ $# -eq 1 ]; then elif [ $# -eq 1 ]; then
file=$1 file=$1
@@ -177,11 +133,11 @@ elif [ $# -eq 1 ]; then
/*|.*) /*|.*)
;; ;;
*) *)
file=./$file file=./$file || exit 1
;; ;;
esac esac
. $file . $file || fatal_error "Can not load the RC file: $file"
else else
usage 1 usage 1
fi fi
@@ -298,12 +254,10 @@ case "$HOST" in
echo "Installing Openwrt-specific configuration..." echo "Installing Openwrt-specific configuration..."
;; ;;
linux) linux)
echo "ERROR: Shorewall-init is not supported on this system" >&2 fatal_error "Shorewall-init is not supported on this system"
exit 1
;; ;;
*) *)
echo "ERROR: Unsupported HOST distribution: \"$HOST\"" >&2 fatal_error "Unsupported HOST distribution: \"$HOST\""
exit 1;
;; ;;
esac esac
@@ -315,30 +269,27 @@ if [ -n "$DESTDIR" ]; then
OWNERSHIP="" OWNERSHIP=""
fi fi
make_directory ${DESTDIR}${INITDIR} 0755 make_parent_directory ${DESTDIR}${INITDIR} 0755
fi fi
echo "Installing Shorewall Init Version $VERSION" echo "Installing $Product Version $VERSION"
# #
# Check for /usr/share/shorewall-init/version # Check for /usr/share/shorewall-init/version
# #
if [ -f ${DESTDIR}${SHAREDIR}/shorewall-init/version ]; then if [ -f ${DESTDIR}${SHAREDIR}/$PRODUCT/version ]; then
first_install="" first_install=""
else else
first_install="Yes" first_install="Yes"
fi fi
if [ -n "$DESTDIR" ]; then [ -n "$DESTDIR" ] && make_parent_directory ${DESTDIR}${CONFDIR}/logrotate.d 0755
mkdir -p ${DESTDIR}${CONFDIR}/logrotate.d
chmod 0755 ${DESTDIR}${CONFDIR}/logrotate.d
fi
# #
# Install the Firewall Script # Install the Firewall Script
# #
if [ -n "$INITFILE" ]; then if [ -n "$INITFILE" ]; then
mkdir -p ${DESTDIR}${INITDIR} make_parent_directory ${DESTDIR}${INITDIR} 0755
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
@@ -357,25 +308,21 @@ if [ -z "${SERVICEDIR}" ]; then
fi fi
if [ -n "$SERVICEDIR" ]; then if [ -n "$SERVICEDIR" ]; then
mkdir -p ${DESTDIR}${SERVICEDIR} make_parent_directory ${DESTDIR}${SERVICEDIR} 0755
[ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service [ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service
install_file $SERVICEFILE ${DESTDIR}${SERVICEDIR}/$PRODUCT.service 0644 install_file $SERVICEFILE ${DESTDIR}${SERVICEDIR}/$PRODUCT.service 0644
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SERVICEDIR}/$PRODUCT.service [ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SERVICEDIR}/$PRODUCT.service" echo "Service file $SERVICEFILE installed as ${DESTDIR}${SERVICEDIR}/$PRODUCT.service"
if [ -n "$DESTDIR" -o $configure -eq 0 ]; then [ -n "$DESTDIR" -o $configure -eq 0 ] && make_parent_directory ${DESTDIR}${SBINDIR} 0755
mkdir -p ${DESTDIR}${SBINDIR} install_file $PRODUCT ${DESTDIR}${SBINDIR}/$PRODUCT 0700
chmod 0755 ${DESTDIR}${SBINDIR} [ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SBINDIR}/$PRODUCT
fi echo "CLI installed as ${DESTDIR}${SBINDIR}/$PRODUCT"
install_file shorewall-init ${DESTDIR}${SBINDIR}/shorewall-init 0700
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SBINDIR}/shorewall-init
echo "CLI installed as ${DESTDIR}${SBINDIR}/shorewall-init"
fi fi
# #
# Create /usr/share/shorewall-init if needed # Create /usr/share/shorewall-init if needed
# #
mkdir -p ${DESTDIR}${SHAREDIR}/shorewall-init make_parent_directory ${DESTDIR}${SHAREDIR}/$PRODUCT 0755
chmod 0755 ${DESTDIR}${SHAREDIR}/shorewall-init
# #
# Install logrotate file # Install logrotate file
@@ -388,55 +335,53 @@ fi
# #
# Create the version file # Create the version file
# #
echo "$VERSION" > ${DESTDIR}/${SHAREDIR}/shorewall-init/version echo "$VERSION" > ${DESTDIR}/${SHAREDIR}/$PRODUCT/version
chmod 0644 ${DESTDIR}${SHAREDIR}/shorewall-init/version chmod 0644 ${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" ]; then
rm -f ${SHAREDIR}/shorewall-init/init rm -f ${SHAREDIR}/$PRODUCT/init
ln -s ${INITDIR}/${INITFILE} ${SHAREDIR}/shorewall-init/init ln -s ${INITDIR}/${INITFILE} ${SHAREDIR}/$PRODUCT/init
fi 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/ make_parent_directory ${DESTDIR}${ETC}/network/if-up.d 0755
mkdir -p ${DESTDIR}${ETC}/network/if-down.d/ make_parent_directory ${DESTDIR}${ETC}/network/if-down.d 0755
mkdir -p ${DESTDIR}${ETC}/network/if-post-down.d/ make_parent_directory ${DESTDIR}${ETC}/network/if-post-down.d 0755
elif [ $configure -eq 0 ]; then elif [ $configure -eq 0 ]; then
mkdir -p ${DESTDIR}${CONFDIR}/network/if-up.d/ make_parent_directory ${DESTDIR}${CONFDIR}/network/if-up.d 0755
mkdir -p ${DESTDIR}${CONFDIR}/network/if-down.d/ make_parent_directory ${DESTDIR}${CONFDIR}/network/if-down.d 0755
mkdir -p ${DESTDIR}${CONFDIR}/network/if-post-down.d/ make_parent_directory ${DESTDIR}${CONFDIR}/network/if-post-down.d 0755
fi fi
if [ ! -f ${DESTDIR}${CONFDIR}/default/shorewall-init ]; then if [ ! -f ${DESTDIR}${CONFDIR}/default/$PRODUCT ]; then
if [ -n "${DESTDIR}" ]; then [ -n "${DESTDIR}" ] && make_parent_directory ${DESTDIR}${ETC}/default 0755
mkdir -p ${DESTDIR}${ETC}/default
fi
[ $configure -eq 1 ] || mkdir -p ${DESTDIR}${CONFDIR}/default [ $configure -eq 1 ] || make_parent_directory ${DESTDIR}${CONFDIR}/default 0755
install_file sysconfig ${DESTDIR}${ETC}/default/shorewall-init 0644 install_file ${SYSCONFFILE} ${DESTDIR}${ETC}/default/$PRODUCT 0644
echo "sysconfig file installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}" echo "${SYSCONFFILE} file installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}"
fi fi
IFUPDOWN=ifupdown.debian.sh IFUPDOWN=ifupdown.debian.sh
else else
if [ -n "$DESTDIR" ]; then if [ -n "$DESTDIR" ]; then
mkdir -p ${DESTDIR}${SYSCONFDIR} make_parent_directory ${DESTDIR}${SYSCONFDIR} 0755
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 make_parent_directory ${DESTDIR}${ETC}/sysconfig/network/if-up.d 0755
mkdir -p ${DESTDIR}${ETC}/sysconfig/network/if-down.d make_parent_directory ${DESTDIR}${ETC}/sysconfig/network/if-down.d 0755
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
elif [ $HOST = openwrt ]; then elif [ $HOST = openwrt ]; then
# Not implemented on openwrt # Not implemented on OpenWRT
/bin/true /bin/true
else else
mkdir -p ${DESTDIR}/${ETC}/NetworkManager/dispatcher.d make_parent_directory ${DESTDIR}/${ETC}/NetworkManager/dispatcher.d 0755
fi fi
fi fi
fi fi
@@ -458,13 +403,13 @@ if [ $HOST != openwrt ]; then
[ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ifupdown [ "${SHAREDIR}" = /usr/share ] || eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ifupdown
mkdir -p ${DESTDIR}${LIBEXECDIR}/shorewall-init make_parent_directory ${DESTDIR}${LIBEXECDIR}/$PRODUCT 0755
install_file ifupdown ${DESTDIR}${LIBEXECDIR}/shorewall-init/ifupdown 0544 install_file ifupdown ${DESTDIR}${LIBEXECDIR}/$PRODUCT/ifupdown 0544
fi fi
if [ -d ${DESTDIR}/etc/NetworkManager ]; then if [ -d ${DESTDIR}/etc/NetworkManager ]; then
[ $configure -eq 1 ] || mkdir -p ${DESTDIR}${CONFDIR}/NetworkManager/dispatcher.d/ [ $configure -eq 1 ] || make_parent_directory ${DESTDIR}${CONFDIR}/NetworkManager/dispatcher.d 0755
install_file ifupdown ${DESTDIR}${ETC}/NetworkManager/dispatcher.d/01-shorewall 0544 install_file ifupdown ${DESTDIR}${ETC}/NetworkManager/dispatcher.d/01-shorewall 0544
fi fi
@@ -483,8 +428,8 @@ case $HOST in
suse) suse)
if [ -z "$RPM" ]; then if [ -z "$RPM" ]; then
if [ $configure -eq 0 ]; then if [ $configure -eq 0 ]; then
mkdir -p ${DESTDIR}${SYSCONFDIR}/network/if-up.d/ make_parent_directory ${DESTDIR}${SYSCONFDIR}/network/if-up.d 0755
mkdir -p ${DESTDIR}${SYSCONFDIR}/network/if-down.d/ make_parent_directory ${DESTDIR}${SYSCONFDIR}/network/if-down.d 0755
fi fi
install_file ifupdown ${DESTDIR}${SYSCONFDIR}/network/if-up.d/shorewall 0544 install_file ifupdown ${DESTDIR}${SYSCONFDIR}/network/if-up.d/shorewall 0544
@@ -518,17 +463,17 @@ if [ -z "$DESTDIR" ]; then
if [ $HOST = debian ]; then if [ $HOST = debian ]; then
if [ -n "$SERVICEDIR" ]; then if [ -n "$SERVICEDIR" ]; then
if systemctl enable ${PRODUCT}.service; then if systemctl enable ${PRODUCT}.service; then
echo "Shorewall Init will start automatically at boot" echo "$Product will start automatically at boot"
fi fi
elif mywhich insserv; then elif mywhich insserv; then
if insserv ${INITDIR}/shorewall-init; then if insserv ${INITDIR}/$PRODUCT; then
echo "Shorewall Init will start automatically at boot" echo "$Product will start automatically at boot"
else else
cant_autostart cant_autostart
fi fi
elif mywhich update-rc.d ; then elif mywhich update-rc.d ; then
if update-rc.d $PRODUCT enable; then if update-rc.d $PRODUCT enable; then
echo "$PRODUCT will start automatically at boot" echo "$Product will start automatically at boot"
echo "Set startup=1 in ${CONFDIR}/default/$PRODUCT to enable" echo "Set startup=1 in ${CONFDIR}/default/$PRODUCT to enable"
else else
cant_autostart cant_autostart
@@ -549,31 +494,31 @@ if [ -z "$DESTDIR" ]; then
/bin/true /bin/true
else else
if [ -n "$SERVICEDIR" ]; then if [ -n "$SERVICEDIR" ]; then
if systemctl enable shorewall-init.service; then if systemctl enable ${PRODUCT}.service; then
echo "Shorewall Init will start automatically at boot" echo "$Product will start automatically at boot"
fi fi
elif [ -x ${SBINDIR}/insserv -o -x /usr${SBINDIR}/insserv ]; then elif [ -x ${SBINDIR}/insserv -o -x /usr${SBINDIR}/insserv ]; then
if insserv ${INITDIR}/shorewall-init ; then if insserv ${INITDIR}/$PRODUCT ; then
echo "Shorewall Init will start automatically at boot" echo "$Product will start automatically at boot"
else else
cant_autostart cant_autostart
fi fi
elif [ -x ${SBINDIR}/chkconfig -o -x /usr${SBINDIR}/chkconfig ]; then elif [ -x ${SBINDIR}/chkconfig -o -x /usr${SBINDIR}/chkconfig ]; then
if chkconfig --add shorewall-init ; then if chkconfig --add $PRODUCT ; then
echo "Shorewall Init will start automatically in run levels as follows:" echo "$Product will start automatically at boot"
chkconfig --list shorewall-init chkconfig --list $PRODUCT
else else
cant_autostart cant_autostart
fi fi
elif [ -x ${SBINDIR}/rc-update ]; then elif [ -x ${SBINDIR}/rc-update ]; then
if rc-update add shorewall-init default; then if rc-update add $PRODUCT default; then
echo "Shorewall Init will start automatically at boot" echo "$Product will start automatically at boot"
else else
cant_autostart cant_autostart
fi fi
elif [ $HOST = openwrt -a -f ${CONFDIR}/rc.common ]; then elif [ $HOST = openwrt -a -f ${CONFDIR}/rc.common ]; then
/etc/init.d/$PRODUCT enable /etc/init.d/$PRODUCT enable
if /etc/init.d/shorewall-init enabled; then if /etc/init.d/$PRODUCT enabled; then
echo "$Product will start automatically at boot" echo "$Product will start automatically at boot"
else else
cant_autostart cant_autostart
@@ -587,11 +532,11 @@ else
if [ $configure -eq 1 -a -n "$first_install" ]; then if [ $configure -eq 1 -a -n "$first_install" ]; then
if [ $HOST = debian -a -z "$SERVICEDIR" ]; then if [ $HOST = debian -a -z "$SERVICEDIR" ]; then
if [ -n "${DESTDIR}" ]; then if [ -n "${DESTDIR}" ]; then
mkdir -p ${DESTDIR}/etc/rcS.d make_parent_directory ${DESTDIR}/etc/rcS.d 0755
fi fi
ln -sf ../init.d/shorewall-init ${DESTDIR}${CONFDIR}/rcS.d/S38shorewall-init ln -sf ../init.d/$PRODUCT ${DESTDIR}${CONFDIR}/rcS.d/S38${PRODUCT}
echo "Shorewall Init will start automatically at boot" echo "$Product will start automatically at boot"
fi fi
fi fi
fi fi
@@ -602,8 +547,8 @@ 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
mkdir -p ${DESTDIR}/etc/ppp/$directory #SuSE doesn't create the IPv6 directories make_parent_directory ${DESTDIR}/etc/ppp/$directory 0755 #SuSE doesn't create the IPv6 directories
cp -fp ${DESTDIR}${LIBEXECDIR}/shorewall-init/ifupdown ${DESTDIR}${CONFDIR}/ppp/$directory/shorewall cp -fp ${DESTDIR}${LIBEXECDIR}/$PRODUCT/ifupdown ${DESTDIR}${CONFDIR}/ppp/$directory/shorewall
done done
;; ;;
redhat) redhat)
@@ -614,19 +559,19 @@ if [ -d ${DESTDIR}/etc/ppp ]; then
FILE=${DESTDIR}/etc/ppp/$file FILE=${DESTDIR}/etc/ppp/$file
if [ -f $FILE ]; then if [ -f $FILE ]; then
if grep -qF Shorewall-based $FILE ; then if grep -qF Shorewall-based $FILE ; then
cp -fp ${DESTDIR}${LIBEXECDIR}/shorewall-init/ifupdown $FILE cp -fp ${DESTDIR}${LIBEXECDIR}/$PRODUCT/ifupdown $FILE
else else
echo "$FILE already exists -- ppp devices will not be handled" echo "$FILE already exists -- ppp devices will not be handled"
break break
fi fi
else else
cp -fp ${DESTDIR}${LIBEXECDIR}/shorewall-init/ifupdown $FILE cp -fp ${DESTDIR}${LIBEXECDIR}/$PRODUCT/ifupdown $FILE
fi fi
done done
;; ;;
esac esac
fi fi
# #
# Report Success # Report Success
# #
echo "shorewall Init Version $VERSION Installed" echo "shorewall Init Version $VERSION Installed"

View File

@@ -33,10 +33,12 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ -x ${STATEDIR}/firewall ]; then
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c return 0
else elif [ $PRODUCT = shorewall ]; then
return 0 ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
fi fi
} }
@@ -62,19 +64,17 @@ shorewall_start () {
local PRODUCT local PRODUCT
local STATEDIR local STATEDIR
echo -n "Initializing \"Shorewall-based firewalls\": " printf "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; 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 fi
fi )
)
fi
fi fi
done done
@@ -90,19 +90,19 @@ shorewall_stop () {
local PRODUCT local PRODUCT
local STATEDIR local STATEDIR
echo -n "Clearing \"Shorewall-based firewalls\": " printf "Clearing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
if setstatedir; then if setstatedir; then
if [ -x ${STATEDIR}/firewall ]; then ${STATEDIR}/firewall ${OPTIONS} clear
${STATEDIR}/firewall ${OPTIONS} clear
fi
fi fi
done done
if [ -n "$SAVE_IPSETS" ]; then if [ -n "$SAVE_IPSETS" ]; then
mkdir -p $(dirname "$SAVE_IPSETS") mkdir -p $(dirname "$SAVE_IPSETS")
if ipset -S > "${SAVE_IPSETS}.tmp"; then if ipset -S > "${SAVE_IPSETS}.tmp"; then
grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" grep -qE -- '^(-N|create )' "${SAVE_IPSETS}.tmp" && mv -f "${SAVE_IPSETS}.tmp" "$SAVE_IPSETS" || rm -f "${SAVE_IPSETS}.tmp"
else
rm -f "${SAVE_IPSETS}.tmp"
fi fi
fi fi

View File

@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Script to back uninstall Shoreline Firewall # Script to back uninstall Shoreline Firewall Init
# #
# (c) 2000-2016 - Tom Eastep (teastep@shorewall.net) # (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
# #
@@ -26,62 +26,34 @@
# You may only use this script to uninstall the version # You may only use this script to uninstall the version
# 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-init PRODUCT=shorewall-init
Product="Shorewall Init" Product="Shorewall Init"
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()
{
"$@" >/dev/null 2>&1
}
split() {
local ifs
ifs=$IFS
IFS=:
set -- $1
echo $*
IFS=$ifs
}
mywhich() {
local dir
for dir in $(split $PATH); do
if [ -x $dir/$1 ]; then
return 0
fi
done
return 2
}
remove_file() # $1 = file to restore
{
if [ -f $1 -o -L $1 ] ; then
rm -f $1
echo "$1 Removed"
fi
}
# #
# Change to the directory containing this script # Change to the directory containing this script
# #
cd "$(dirname $0)" cd "$(dirname $0)"
#
# Source common functions
#
. ./lib.uninstaller || { echo "ERROR: Can not load common functions." >&2; exit 1; }
#
# Parse the run line
#
finished=0 finished=0
configure=1 configure=1
@@ -118,17 +90,17 @@ while [ $finished -eq 0 ]; do
;; ;;
esac esac
done done
# #
# Read the RC file # Read the RC file
# #
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
if [ -f ./shorewallrc ]; then if [ -f ./shorewallrc ]; then
. ./shorewallrc . ./shorewallrc || fatal_error "Can not load the RC file: ./shorewallrc"
elif [ -f ~/.shorewallrc ]; then elif [ -f ~/.shorewallrc ]; then
. ~/.shorewallrc || exit 1 . ~/.shorewallrc || fatal_error "Can not load the RC file: ~/.shorewallrc"
file=./.shorewallrc
elif [ -f /usr/share/shorewall/shorewallrc ]; then elif [ -f /usr/share/shorewall/shorewallrc ]; then
. /usr/share/shorewall/shorewallrc . /usr/share/shorewall/shorewallrc || fatal_error "Can not load the RC file: /usr/share/shorewall/shorewallrc"
else else
fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found"
fi fi
@@ -138,72 +110,72 @@ elif [ $# -eq 1 ]; then
/*|.*) /*|.*)
;; ;;
*) *)
file=./$file file=./$file || exit 1
;; ;;
esac esac
. $file || exit 1 . $file || fatal_error "Can not load the RC file: $file"
else else
usage 1 usage 1
fi fi
if [ -f ${SHAREDIR}/shorewall-init/version ]; then if [ -f ${SHAREDIR}/$PRODUCT/version ]; then
INSTALLED_VERSION="$(cat ${SHAREDIR}/shorewall-init/version)" INSTALLED_VERSION="$(cat ${SHAREDIR}/$PRODUCT/version)"
if [ "$INSTALLED_VERSION" != "$VERSION" ]; then if [ "$INSTALLED_VERSION" != "$VERSION" ]; then
echo "WARNING: Shorewall Init Version $INSTALLED_VERSION is installed" echo "WARNING: $Product Version $INSTALLED_VERSION is installed"
echo " and this is the $VERSION uninstaller." echo " and this is the $VERSION uninstaller."
VERSION="$INSTALLED_VERSION" VERSION="$INSTALLED_VERSION"
fi fi
else else
echo "WARNING: Shorewall Init Version $VERSION is not installed" echo "WARNING: $Product Version $VERSION is not installed"
VERSION="" VERSION=""
fi fi
[ -n "${LIBEXEC:=${SHAREDIR}}" ] echo "Uninstalling $Product $VERSION"
echo "Uninstalling Shorewall Init $VERSION"
[ -n "$SANDBOX" ] && configure=0 [ -n "$SANDBOX" ] && configure=0
INITSCRIPT=${CONFDIR}/init.d/shorewall-init [ -n "${LIBEXEC:=${SHAREDIR}}" ]
if [ -f "$INITSCRIPT" ]; then remove_file ${SBINDIR}/$PRODUCT
FIREWALL=${CONFDIR}/init.d/$PRODUCT
if [ -f "$FIREWALL" ]; then
if [ $configure -eq 1 ]; then if [ $configure -eq 1 ]; then
if [ $HOST = openwrt ]; then if [ $HOST = openwrt ] ; then
if /etc/init.d/shorewall-init enabled; then if /etc/init.d/$PRODUCT enabled; then
/etc/init.d/shorewall-init disable /etc/init.d/$PRODUCT disable
fi fi
elif mywhich updaterc.d ; then
updaterc.d shorewall-init remove
elif mywhich insserv ; then elif mywhich insserv ; then
insserv -r $INITSCRIPT insserv -r $FIREWALL
elif mywhich update-rc.d ; then
update-rc.d ${PRODUCT} remove
elif mywhich chkconfig ; then elif mywhich chkconfig ; then
chkconfig --del $(basename $INITSCRIPT) chkconfig --del $(basename $FIREWALL)
fi fi
fi fi
remove_file $INITSCRIPT remove_file $FIREWALL
fi fi
if [ -z "${SERVICEDIR}" ]; then [ -z "${SERVICEDIR}" ] && SERVICEDIR="$SYSTEMD"
SERVICEDIR="$SYSTEMD"
fi
if [ -n "$SERVICEDIR" ]; then if [ -n "$SERVICEDIR" ]; then
[ $configure -eq 1 ] && systemctl disable shorewall-init.service [ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service
rm -f $SERVICEDIR/shorewall-init.service remove_file $SERVICEDIR/${PRODUCT}.service
fi fi
if [ $HOST = openwrt ]; then if [ $HOST = openwrt ]; then
[ "$(readlink -q ${SBINDIR}/ifup-local)" = ${SHAREDIR}/shorewall-init ] && remove_file ${SBINDIR}/ifup-local [ "$(readlink -q ${SBINDIR}/ifup-local)" = ${SHAREDIR}/$PRODUCT ] && remove_file ${SBINDIR}/ifup-local
[ "$(readlink -q ${SBINDIR}/ifdown-local)" = ${SHAREDIR}/shorewall-init ] && remove_file ${SBINDIR}/ifdown-local [ "$(readlink -q ${SBINDIR}/ifdown-local)" = ${SHAREDIR}/$PRODUCT ] && remove_file ${SBINDIR}/ifdown-local
else else
[ "$(readlink -m -q ${SBINDIR}/ifup-local)" = ${SHAREDIR}/shorewall-init ] && remove_file ${SBINDIR}/ifup-local [ "$(readlink -m -q ${SBINDIR}/ifup-local)" = ${SHAREDIR}/$PRODUCT ] && 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}/$PRODUCT ] && remove_file ${SBINDIR}/ifdown-local
fi fi
remove_file ${CONFDIR}/default/shorewall-init remove_file ${CONFDIR}/default/$PRODUCT
remove_file ${CONFDIR}/sysconfig/shorewall-init remove_file ${CONFDIR}/sysconfig/$PRODUCT
remove_file ${CONFDIR}/NetworkManager/dispatcher.d/01-shorewall remove_file ${CONFDIR}/NetworkManager/dispatcher.d/01-shorewall
@@ -228,10 +200,11 @@ if [ -d ${CONFDIR}/ppp ]; then
done done
fi fi
rm -f ${SBINDIR}/shorewall-init remove_directory ${SHAREDIR}/$PRODUCT
rm -rf ${SHAREDIR}/shorewall-init remove_directory ${LIBEXECDIR}/$PRODUCT
rm -rf ${LIBEXECDIR}/shorewall-init remove_file ${CONFDIR}/logrotate.d/$PRODUCT
echo "Shorewall Init Uninstalled"
#
# Report Success
#
echo "$Product $VERSION Uninstalled"

View File

@@ -1,18 +0,0 @@
# Shorewall Lite Makefile to restart if firewall script is newer than last restart
VARDIR=$(shell /sbin/shorewall-lite show vardir)
SHAREDIR=/usr/share/shorewall-lite
RESTOREFILE?=.restore
all: $(VARDIR)/$(RESTOREFILE)
$(VARDIR)/$(RESTOREFILE): $(VARDIR)/firewall
@/sbin/shorewall-lite -q save >/dev/null; \
if \
/sbin/shorewall-lite -q restart >/dev/null 2>&1; \
then \
/sbin/shorewall-lite -q save >/dev/null; \
else \
/sbin/shorewall-lite -q restart 2>&1 | tail >&2; exit 1; \
fi
# EOF

View File

@@ -0,0 +1,26 @@
#
# Global start/restart/reload/stop options
#
OPTIONS=""
#
# Start options
#
STARTOPTIONS=""
#
# Restart options
#
RESTARTOPTIONS=""
#
# Reload options
#
RELOADOPTIONS=""
#
# Stop options
#
STOPOPTIONS=""
# EOF

View File

@@ -1,5 +1,5 @@
# prevent startup with default configuration # prevent startup with default configuration
# set the following varible to 1 in order to allow Shorewall-lite to start # set the following variable to 1 in order to allow Shorewall-lite to start
startup=0 startup=0
@@ -16,7 +16,7 @@ startup=0
# wait_interface= # wait_interface=
# #
# Startup options # Global start/restart/reload/stop options
# #
OPTIONS="" OPTIONS=""
@@ -30,6 +30,16 @@ STARTOPTIONS=""
# #
RESTARTOPTIONS="" RESTARTOPTIONS=""
#
# Reload options
#
RELOADOPTIONS=""
#
# Stop options
#
STOPOPTIONS=""
# #
# Init Log -- if /dev/null, use the STARTUP_LOG defined in shorewall.conf # Init Log -- if /dev/null, use the STARTUP_LOG defined in shorewall.conf
# #

View File

@@ -13,7 +13,7 @@
. /lib/lsb/init-functions . /lib/lsb/init-functions
SRWL=/sbin/shorewall-lite SRWL='/sbin/shorewall -l'
SRWL_OPTS="-tvv" SRWL_OPTS="-tvv"
test -n ${INITLOG:=/var/log/shorewall-lite-init.log} test -n ${INITLOG:=/var/log/shorewall-lite-init.log}
@@ -85,7 +85,7 @@ fi
# start the firewall # start the firewall
shorewall_start () { shorewall_start () {
echo -n "Starting \"Shorewall firewall\": " printf "Starting \"Shorewall firewall\": "
$SRWL $SRWL_OPTS start $STARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone $SRWL $SRWL_OPTS start $STARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
return 0 return 0
} }
@@ -93,10 +93,10 @@ shorewall_start () {
# stop the firewall # stop the firewall
shorewall_stop () { shorewall_stop () {
if [ "$SAFESTOP" = 1 ]; then if [ "$SAFESTOP" = 1 ]; then
echo -n "Stopping \"Shorewall Lite firewall\": " printf "Stopping \"Shorewall Lite firewall\": "
$SRWL $SRWL_OPTS stop >> $INITLOG 2>&1 && echo "done." || echo_notdone $SRWL $SRWL_OPTS stop >> $INITLOG 2>&1 && echo "done." || echo_notdone
else else
echo -n "Clearing all \"Shorewall Lite firewall\" rules: " printf "Clearing all \"Shorewall Lite firewall\" rules: "
$SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone $SRWL $SRWL_OPTS clear >> $INITLOG 2>&1 && echo "done." || echo_notdone
fi fi
return 0 return 0
@@ -104,14 +104,14 @@ shorewall_stop () {
# restart the firewall # restart the firewall
shorewall_restart () { shorewall_restart () {
echo -n "Restarting \"Shorewall firewall\": " printf "Restarting \"Shorewall firewall\": "
$SRWL $SRWL_OPTS restart $RESTARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone $SRWL $SRWL_OPTS restart $RESTARTOPTIONS >> $INITLOG 2>&1 && echo "done." || echo_notdone
return 0 return 0
} }
# refresh the firewall # refresh the firewall
shorewall_refresh () { shorewall_refresh () {
echo -n "Refreshing \"Shorewall firewall\": " printf "Refreshing \"Shorewall firewall\": "
$SRWL $SRWL_OPTS refresh >> $INITLOG 2>&1 && echo "done." || echo_notdone $SRWL $SRWL_OPTS refresh >> $INITLOG 2>&1 && echo "done." || echo_notdone
return 0 return 0
} }

View File

@@ -25,7 +25,7 @@
# #
. /usr/share/shorewall/shorewallrc . /usr/share/shorewall/shorewallrc
prog="shorewall-lite" prog="shorewall -l"
shorewall="${SBINDIR}/$prog" shorewall="${SBINDIR}/$prog"
logger="logger -i -t $prog" logger="logger -i -t $prog"
lockfile="/var/lock/subsys/$prog" lockfile="/var/lock/subsys/$prog"
@@ -38,7 +38,7 @@ if [ -f ${SYSCONFDIR}/$prog ]; then
fi fi
start() { start() {
echo -n $"Starting Shorewall: " printf $"Starting Shorewall: "
$shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger $shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
retval=${PIPESTATUS[0]} retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then if [[ $retval == 0 ]]; then
@@ -52,7 +52,7 @@ start() {
} }
stop() { stop() {
echo -n $"Stopping Shorewall: " printf $"Stopping Shorewall: "
$shorewall $OPTIONS stop 2>&1 | $logger $shorewall $OPTIONS stop 2>&1 | $logger
retval=${PIPESTATUS[0]} retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then if [[ $retval == 0 ]]; then
@@ -68,7 +68,7 @@ stop() {
restart() { 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: " printf $"Restarting Shorewall: "
$shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger $shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
retval=${PIPESTATUS[0]} retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then if [[ $retval == 0 ]]; then

View File

@@ -69,7 +69,7 @@ SHOREWALL_INIT_SCRIPT=1
command="$action" command="$action"
start() { start() {
exec ${SBINDIR}/shorewall-lite $OPTIONS $command $STARTOPTIONS exec ${SBINDIR}/shorewall -l $OPTIONS $command $STARTOPTIONS
} }
boot() { boot() {
@@ -78,17 +78,17 @@ boot() {
} }
restart() { restart() {
exec ${SBINDIR}/shorewall-lite $OPTIONS $command $RESTARTOPTIONS exec ${SBINDIR}/shorewall -l $OPTIONS $command $RESTARTOPTIONS
} }
reload() { reload() {
exec ${SBINDIR}/shorewall-lite $OPTIONS $command $RELOADOPTION exec ${SBINDIR}/shorewall -l $OPTIONS $command $RELOADOPTION
} }
stop() { stop() {
exec ${SBINDIR}/shorewall-lite $OPTIONS $command $STOPOPTIONS exec ${SBINDIR}/shorewall -l $OPTIONS $command $STOPOPTIONS
} }
status() { status() {
exec ${SBINDIR}/shorewall-lite $OPTIONS $command $@ exec ${SBINDIR}/shorewall -l $OPTIONS $command $@
} }

View File

@@ -22,62 +22,19 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>. # along with this program; if not, see <http://www.gnu.org/licenses/>.
# #
VERSION=xxx #The Build script inserts the actual version VERSION=xxx # The Build script inserts the actual version
usage() # $1 = exit status usage() # $1 = exit status
{ {
ME=$(basename $0) ME=$(basename $0)
echo "usage: $ME [ <configuration-file> ]" echo "usage: $ME [ <option> ] [ <shorewallrc file> ]"
echo " $ME -v" echo "where <option> is one of"
echo " $ME -h" echo " -h"
echo " $ME -n" echo " -v"
echo " -n"
exit $1 exit $1
} }
fatal_error()
{
echo " ERROR: $@" >&2
exit 1
}
split() {
local ifs
ifs=$IFS
IFS=:
set -- $1
echo $*
IFS=$ifs
}
qt()
{
"$@" >/dev/null 2>&1
}
mywhich() {
local dir
for dir in $(split $PATH); do
if [ -x $dir/$1 ]; then
echo $dir/$1
return 0
fi
done
return 2
}
cant_autostart()
{
echo
echo "WARNING: Unable to configure $Product to start automatically at boot" >&2
}
delete_file() # $1 = file to delete
{
rm -f $1
}
install_file() # $1 = source $2 = target $3 = mode install_file() # $1 = source $2 = target $3 = mode
{ {
if cp -f $1 $2; then if cp -f $1 $2; then
@@ -96,25 +53,12 @@ install_file() # $1 = source $2 = target $3 = mode
exit 1 exit 1
} }
make_directory() # $1 = directory , $2 = mode
{
mkdir -p $1
chmod 755 $1
[ -n "$OWNERSHIP" ] && chown $OWNERSHIP $1
}
require()
{
eval [ -n "\$$1" ] || fatal_error "Required option $1 not set"
}
# #
# Change to the directory containing this script # Change to the directory containing this script
# #
cd "$(dirname $0)" cd "$(dirname $0)"
if [ -f shorewall-lite ]; then if [ -f shorewall-lite.service ]; then
PRODUCT=shorewall-lite PRODUCT=shorewall-lite
Product="Shorewall Lite" Product="Shorewall Lite"
else else
@@ -122,6 +66,11 @@ else
Product="Shorewall6 Lite" Product="Shorewall6 Lite"
fi fi
#
# Source common functions
#
. ./lib.installer || { echo "ERROR: Can not load common functions." >&2; exit 1; }
# #
# Parse the run line # Parse the run line
# #
@@ -168,12 +117,14 @@ done
# #
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
if [ -f ./shorewallrc ]; then if [ -f ./shorewallrc ]; then
. ./shorewallrc || exit 1
file=./shorewallrc file=./shorewallrc
. $file || fatal_error "Can not load the RC file: $file"
elif [ -f ~/.shorewallrc ]; then elif [ -f ~/.shorewallrc ]; then
. ~/.shorewallrc file=~/.shorewallrc
. $file || fatal_error "Can not load the RC file: $file"
elif [ -f /usr/share/shorewall/shorewallrc ]; then elif [ -f /usr/share/shorewall/shorewallrc ]; then
. /usr/share/shorewall/shorewallrc file=/usr/share/shorewall/shorewallrc
. $file || fatal_error "Can not load the RC file: $file"
else else
fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found"
fi fi
@@ -183,11 +134,11 @@ elif [ $# -eq 1 ]; then
/*|.*) /*|.*)
;; ;;
*) *)
file=./$file file=./$file || exit 1
;; ;;
esac esac
. $file . $file || fatal_error "Can not load the RC file: $file"
else else
usage 1 usage 1
fi fi
@@ -318,8 +269,7 @@ case "$HOST" in
linux) linux)
;; ;;
*) *)
echo "ERROR: Unknown HOST \"$HOST\"" >&2 fatal_error "ERROR: Unknown HOST \"$HOST\""
exit 1;
;; ;;
esac esac
@@ -331,8 +281,7 @@ if [ -n "$DESTDIR" ]; then
OWNERSHIP="" OWNERSHIP=""
fi fi
make_directory ${DESTDIR}${SBINDIR} 755 make_parent_directory ${DESTDIR}${INITDIR} 0755
make_directory ${DESTDIR}${INITDIR} 755
else else
if [ ! -f ${SHAREDIR}/shorewall/coreversion ]; then if [ ! -f ${SHAREDIR}/shorewall/coreversion ]; then
@@ -362,9 +311,9 @@ else
fi fi
# #
# Check for ${SBINDIR}/$PRODUCT # Check for ${SHAREDIR}/$PRODUCT/version
# #
if [ -f ${DESTDIR}${SBINDIR}/$PRODUCT ]; then if [ -f ${DESTDIR}${SHAREDIR}/$PRODUCT/version ]; then
first_install="" first_install=""
else else
first_install="Yes" first_install="Yes"
@@ -372,27 +321,20 @@ fi
delete_file ${DESTDIR}/usr/share/$PRODUCT/xmodules delete_file ${DESTDIR}/usr/share/$PRODUCT/xmodules
install_file $PRODUCT ${DESTDIR}${SBINDIR}/$PRODUCT 0544 [ -n "${INITFILE}" ] && make_parent_directory ${DESTDIR}${INITDIR} 0755
[ -n "${INITFILE}" ] && make_directory ${DESTDIR}${INITDIR} 755
echo "$Product control program installed in ${DESTDIR}${SBINDIR}/$PRODUCT"
# #
# Create ${CONFDIR}/$PRODUCT, /usr/share/$PRODUCT and /var/lib/$PRODUCT if needed # Create ${CONFDIR}/$PRODUCT, /usr/share/$PRODUCT and /var/lib/$PRODUCT if needed
# #
mkdir -p ${DESTDIR}${CONFDIR}/$PRODUCT make_parent_directory ${DESTDIR}${CONFDIR}/$PRODUCT 0755
mkdir -p ${DESTDIR}${SHAREDIR}/$PRODUCT make_parent_directory ${DESTDIR}${SHAREDIR}/$PRODUCT 0755
mkdir -p ${DESTDIR}${LIBEXECDIR}/$PRODUCT make_parent_directory ${DESTDIR}${LIBEXECDIR}/$PRODUCT 0755
mkdir -p ${DESTDIR}${VARDIR} make_parent_directory ${DESTDIR}${SBINDIR} 0755
make_parent_directory ${DESTDIR}${VARDIR} 0755
chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT
chmod 755 ${DESTDIR}${SHAREDIR}/$PRODUCT
if [ -n "$DESTDIR" ]; then if [ -n "$DESTDIR" ]; then
mkdir -p ${DESTDIR}${CONFDIR}/logrotate.d make_parent_directory ${DESTDIR}${CONFDIR}/logrotate.d 0755
chmod 755 ${DESTDIR}${CONFDIR}/logrotate.d make_parent_directory ${DESTDIR}${INITDIR} 0755
mkdir -p ${DESTDIR}${INITDIR}
chmod 755 ${DESTDIR}${INITDIR}
fi fi
if [ -n "$INITFILE" ]; then if [ -n "$INITFILE" ]; then
@@ -413,9 +355,9 @@ if [ -z "${SERVICEDIR}" ]; then
fi fi
if [ -n "$SERVICEDIR" ]; then if [ -n "$SERVICEDIR" ]; then
mkdir -p ${DESTDIR}${SERVICEDIR} make_parent_directory ${DESTDIR}${SERVICEDIR} 0755
[ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service [ -z "$SERVICEFILE" ] && SERVICEFILE=$PRODUCT.service
install_file $SERVICEFILE ${DESTDIR}${SERVICEDIR}/$PRODUCT.service 644 install_file $SERVICEFILE ${DESTDIR}${SERVICEDIR}/$PRODUCT.service 0644
[ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SERVICEDIR}/$PRODUCT.service [ ${SBINDIR} != /sbin ] && eval sed -i \'s\|/sbin/\|${SBINDIR}/\|\' ${DESTDIR}${SERVICEDIR}/$PRODUCT.service
echo "Service file $SERVICEFILE installed as ${DESTDIR}${SERVICEDIR}/$PRODUCT.service" echo "Service file $SERVICEFILE installed as ${DESTDIR}${SERVICEDIR}/$PRODUCT.service"
fi fi
@@ -433,15 +375,6 @@ elif [ $HOST = gentoo ]; then
# Adjust SUBSYSLOCK path (see https://bugs.gentoo.org/show_bug.cgi?id=459316) # Adjust SUBSYSLOCK path (see https://bugs.gentoo.org/show_bug.cgi?id=459316)
perl -p -w -i -e "s|^SUBSYSLOCK=.*|SUBSYSLOCK=/run/lock/$PRODUCT|;" ${DESTDIR}${CONFDIR}/$PRODUCT/$PRODUCT.conf perl -p -w -i -e "s|^SUBSYSLOCK=.*|SUBSYSLOCK=/run/lock/$PRODUCT|;" ${DESTDIR}${CONFDIR}/$PRODUCT/$PRODUCT.conf
fi fi
#
# Install the Makefile
#
install_file Makefile ${DESTDIR}${CONFDIR}/$PRODUCT/Makefile 0600
[ $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
echo "Makefile installed as ${DESTDIR}${CONFDIR}/$PRODUCT/Makefile"
# #
# Install the default config path file # Install the default config path file
# #
@@ -453,8 +386,14 @@ 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 case $f in
echo "Library ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f" *installer)
;;
*)
install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 0644
echo "Library ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f"
;;
esac
fi fi
done done
@@ -482,12 +421,12 @@ if [ -f modules ]; then
fi fi
if [ -f helpers ]; then if [ -f helpers ]; then
install_file helpers ${DESTDIR}${SHAREDIR}/$PRODUCT/helpers 600 install_file helpers ${DESTDIR}${SHAREDIR}/$PRODUCT/helpers 0600
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
install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 644 install_file $f ${DESTDIR}${SHAREDIR}/$PRODUCT/$f 0644
echo "Module file $f installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f" echo "Module file $f installed as ${DESTDIR}${SHAREDIR}/$PRODUCT/$f"
done done
@@ -498,17 +437,19 @@ done
if [ -d manpages -a -n "$MANDIR" ]; then if [ -d manpages -a -n "$MANDIR" ]; then
cd manpages cd manpages
mkdir -p ${DESTDIR}${MANDIR}/man5/ ${DESTDIR}${MANDIR}/man8/ make_parent_directory ${DESTDIR}${MANDIR}/man5 0755
for f in *.5; do for f in *.5; do
gzip -c $f > $f.gz gzip -c $f > $f.gz
install_file $f.gz ${DESTDIR}${MANDIR}/man5/$f.gz 644 install_file $f.gz ${DESTDIR}${MANDIR}/man5/$f.gz 0644
echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man5/$f.gz" echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man5/$f.gz"
done done
make_parent_directory ${DESTDIR}${MANDIR}/man8 0755
for f in *.8; do for f in *.8; do
gzip -c $f > $f.gz gzip -c $f > $f.gz
install_file $f.gz ${DESTDIR}${MANDIR}/man8/$f.gz 644 install_file $f.gz ${DESTDIR}${MANDIR}/man8/$f.gz 0644
echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man8/$f.gz" echo "Man page $f.gz installed to ${DESTDIR}${MANDIR}/man8/$f.gz"
done done
@@ -518,7 +459,7 @@ if [ -d manpages -a -n "$MANDIR" ]; then
fi fi
if [ -d ${DESTDIR}${CONFDIR}/logrotate.d ]; then if [ -d ${DESTDIR}${CONFDIR}/logrotate.d ]; then
install_file logrotate ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT 644 install_file logrotate ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT 0644
echo "Logrotate file installed as ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT" echo "Logrotate file installed as ${DESTDIR}${CONFDIR}/logrotate.d/$PRODUCT"
fi fi
@@ -526,7 +467,7 @@ fi
# Create the version file # Create the version file
# #
echo "$VERSION" > ${DESTDIR}${SHAREDIR}/$PRODUCT/version echo "$VERSION" > ${DESTDIR}${SHAREDIR}/$PRODUCT/version
chmod 644 ${DESTDIR}${SHAREDIR}/$PRODUCT/version chmod 0644 ${DESTDIR}${SHAREDIR}/$PRODUCT/version
# #
# Remove and create the symbolic link to the init script # Remove and create the symbolic link to the init script
# #
@@ -540,14 +481,16 @@ delete_file ${DESTDIR}${SHAREDIR}/$PRODUCT/lib.common
delete_file ${DESTDIR}${SHAREDIR}/$PRODUCT/lib.cli delete_file ${DESTDIR}${SHAREDIR}/$PRODUCT/lib.cli
delete_file ${DESTDIR}${SHAREDIR}/$PRODUCT/wait4ifup delete_file ${DESTDIR}${SHAREDIR}/$PRODUCT/wait4ifup
#
# Creatae the symbolic link for the CLI
#
ln -sf shorewall ${DESTDIR}${SBINDIR}/${PRODUCT}
# #
# Note -- not all packages will have the SYSCONFFILE so we need to check for its existance here # Note -- not all packages will have the SYSCONFFILE so we need to check for its existance here
# #
if [ -n "$SYSCONFFILE" -a -f "$SYSCONFFILE" -a ! -f ${DESTDIR}${SYSCONFDIR}/${PRODUCT} ]; then if [ -n "$SYSCONFFILE" -a -f "$SYSCONFFILE" -a ! -f ${DESTDIR}${SYSCONFDIR}/${PRODUCT} ]; then
if [ ${DESTDIR} ]; then [ ${DESTDIR} ] && make_parent_directory ${DESTDIR}${SYSCONFDIR} 0755
mkdir -p ${DESTDIR}${SYSCONFDIR}
chmod 755 ${DESTDIR}${SYSCONFDIR}
fi
install_file ${SYSCONFFILE} ${DESTDIR}${SYSCONFDIR}/${PRODUCT} 0640 install_file ${SYSCONFFILE} ${DESTDIR}${SYSCONFDIR}/${PRODUCT} 0640
echo "$SYSCONFFILE file installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}" echo "$SYSCONFFILE file installed in ${DESTDIR}${SYSCONFDIR}/${PRODUCT}"
@@ -555,7 +498,6 @@ 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
fi fi
if [ $configure -eq 1 -a -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
@@ -616,6 +558,6 @@ if [ $configure -eq 1 -a -z "$DESTDIR" -a -n "$first_install" -a -z "${cygwin}${
fi fi
# #
# Report Success # Report Success
# #
echo "$Product Version $VERSION Installed" echo "$Product Version $VERSION Installed"

File diff suppressed because it is too large Load Diff

View File

@@ -28,7 +28,7 @@
# #
# On the target system (the system where the firewall program is to run): # On the target system (the system where the firewall program is to run):
# #
# [ IPTABLES=<iptables binary> ] [ MODULESDIR=<kernel modules directory> ] [ MODULE_SUFFIX="<module suffix list>" ] shorecap > capabilities # [ IPTABLES=<iptables binary> ] [ MODULESDIR=<kernel modules directory> ] shorecap > capabilities
# #
# Now move the capabilities file to the compilation system. The file must # Now move the capabilities file to the compilation system. The file must
# be placed in a directory on the CONFIG_PATH to be used when compiling firewalls # be placed in a directory on the CONFIG_PATH to be used when compiling firewalls
@@ -38,26 +38,26 @@
# #
# 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 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
# require Shorewall to be installed. # require Shorewall to be installed.
g_program=shorewall-lite PRODUCT=shorewall-lite
# #
# This is modified by the installer when ${SHAREDIR} != /usr/share # This is modified by the installer when ${SHAREDIR} != /usr/share
# #
. /usr/share/shorewall/shorewallrc . /usr/share/shorewall/shorewallrc
g_sharedir="$SHAREDIR"/shorewall-lite g_basedir=${SHAREDIR}/shorewall
g_confdir="$CONFDIR"/shorewall-lite
g_readrc=1
. ${SHAREDIR}/shorewall/lib.cli . ${SHAREDIR}/shorewall/lib.cli
. /usr/share/shorewall-lite/configpath
setup_product_environment
. ${SHAREDIR}/shorewall-lite/configpath
[ -n "$PATH" ] || PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin [ -n "$PATH" ] || PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin

View File

@@ -1,42 +0,0 @@
#!/bin/sh
#
# Shorewall Lite Packet Filtering Firewall Control Program - V4.5
#
# (c) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2014 -
# Tom Eastep (teastep@shorewall.net)
#
# Shorewall documentation is available at http://www.shorewall.net
#
# This program is part of Shorewall.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 2 of the license or, at your
# option, any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# For a list of supported commands, type 'shorewall help' or 'shorewall6 help'
#
################################################################################################
PRODUCT=shorewall-lite
#
# This is modified by the installer when ${SHAREDIR} != /usr/share
#
. /usr/share/shorewall/shorewallrc
g_program=$PRODUCT
g_sharedir="$SHAREDIR"/shorewall-lite
g_confdir="$CONFDIR"/shorewall-lite
g_readrc=1
. ${SHAREDIR}/shorewall/lib.cli
shorewall_cli $@

View File

@@ -16,7 +16,7 @@ RemainAfterExit=yes
EnvironmentFile=-/etc/default/shorewall-lite EnvironmentFile=-/etc/default/shorewall-lite
StandardOutput=syslog StandardOutput=syslog
ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS ExecStart=/sbin/shorewall-lite $OPTIONS start $STARTOPTIONS
ExecStop=/sbin/shorewall-lite $OPTIONS stop ExecStop=/sbin/shorewall-lite $OPTIONS clear
ExecReload=/sbin/shorewall-lite $OPTIONS reload $RELOADOPTIONS ExecReload=/sbin/shorewall-lite $OPTIONS reload $RELOADOPTIONS
[Install] [Install]

View File

@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Script to back uninstall Shoreline Firewall # Script to back uninstall Shoreline Firewall Lite
# #
# (c) 2000-2016 - Tom Eastep (teastep@shorewall.net) # (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
# #
@@ -26,9 +26,7 @@
# You may only use this script to uninstall the version # You may only use this script to uninstall the version
# 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
Product="Shorewall Lite"
usage() # $1 = exit status usage() # $1 = exit status
{ {
@@ -41,46 +39,27 @@ usage() # $1 = exit status
exit $1 exit $1
} }
fatal_error() #
{ # Change to the directory containing this script
echo " ERROR: $@" >&2 #
exit 1 cd "$(dirname $0)"
}
qt() if [ -f shorewall-lite.service ]; then
{ PRODUCT=shorewall-lite
"$@" >/dev/null 2>&1 Product="Shorewall Lite"
} else
PRODUCT=shorewall6-lite
Product="Shorewall6 Lite"
fi
split() { #
local ifs # Source common functions
ifs=$IFS #
IFS=: . ./lib.uninstaller || { echo "ERROR: Can not load common functions." >&2; exit 1; }
set -- $1
echo $*
IFS=$ifs
}
mywhich() {
local dir
for dir in $(split $PATH); do
if [ -x $dir/$1 ]; then
return 0
fi
done
return 2
}
remove_file() # $1 = file to restore
{
if [ -f $1 -o -L $1 ] ; then
rm -f $1
echo "$1 Removed"
fi
}
#
# Parse the run line
#
finished=0 finished=0
configure=1 configure=1
@@ -97,7 +76,7 @@ while [ $finished -eq 0 ]; do
usage 0 usage 0
;; ;;
v) v)
echo "$Product Firewall Installer Version $VERSION" echo "$Product Firewall Uninstaller Version $VERSION"
exit 0 exit 0
;; ;;
n*) n*)
@@ -117,17 +96,17 @@ while [ $finished -eq 0 ]; do
;; ;;
esac esac
done done
# #
# Read the RC file # Read the RC file
# #
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
if [ -f ./shorewallrc ]; then if [ -f ./shorewallrc ]; then
. ./shorewallrc . ./shorewallrc || fatal_error "Can not load the RC file: ./shorewallrc"
elif [ -f ~/.shorewallrc ]; then elif [ -f ~/.shorewallrc ]; then
. ~/.shorewallrc || exit 1 . ~/.shorewallrc || fatal_error "Can not load the RC file: ~/.shorewallrc"
file=./.shorewallrc
elif [ -f /usr/share/shorewall/shorewallrc ]; then elif [ -f /usr/share/shorewall/shorewallrc ]; then
. /usr/share/shorewall/shorewallrc . /usr/share/shorewall/shorewallrc || fatal_error "Can not load the RC file: /usr/share/shorewall/shorewallrc"
else else
fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found" fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found"
fi fi
@@ -137,46 +116,50 @@ elif [ $# -eq 1 ]; then
/*|.*) /*|.*)
;; ;;
*) *)
file=./$file file=./$file || exit 1
;; ;;
esac esac
. $file . $file || fatal_error "Can not load the RC file: $file"
else else
usage 1 usage 1
fi fi
if [ -f ${SHAREDIR}/shorewall-lite/version ]; then if [ -f ${SHAREDIR}/$PRODUCT/version ]; then
INSTALLED_VERSION="$(cat ${SHAREDIR}/shorewall-lite/version)" INSTALLED_VERSION="$(cat ${SHAREDIR}/$PRODUCT/version)"
if [ "$INSTALLED_VERSION" != "$VERSION" ]; then if [ "$INSTALLED_VERSION" != "$VERSION" ]; then
echo "WARNING: Shorewall Lite Version $INSTALLED_VERSION is installed" echo "WARNING: $Product Version $INSTALLED_VERSION is installed"
echo " and this is the $VERSION uninstaller." echo " and this is the $VERSION uninstaller."
VERSION="$INSTALLED_VERSION" VERSION="$INSTALLED_VERSION"
fi fi
else else
echo "WARNING: Shorewall Lite Version $VERSION is not installed" echo "WARNING: $Product Version $VERSION is not installed"
VERSION="" VERSION=""
fi fi
echo "Uninstalling Shorewall Lite $VERSION" echo "Uninstalling $Product $VERSION"
[ -n "$SANDBOX" ] && configure=0 [ -n "$SANDBOX" ] && configure=0
if [ $configure -eq 1 ]; then if [ $configure -eq 1 ]; then
if qt iptables -L shorewall -n && [ ! -f ${SBINDIR}/shorewall ]; then if qt iptables -L shorewall -n && [ ! -f ${SBINDIR}/shorewall ]; then
shorewall-lite clear ${SBINDIR}/$PRODUCT clear
elif qt ip6tables -L shorewall -n && [ ! -f ${SBINDIR}/shorewall6 ]; then
${SBINDIR}/$PRODUCT clear
fi fi
fi fi
if [ -L ${SHAREDIR}/shorewall-lite/init ]; then remove_file ${SBINDIR}/$PRODUCT
if [ -L ${SHAREDIR}/$PRODUCT/init ]; then
if [ $HOST = openwrt ]; then if [ $HOST = openwrt ]; then
if [ $configure -eq 1 ] && /etc/init.d/shorewall-lite enabled; then if [ $configure -eq 1 ] && /etc/init.d/$PRODUCT enabled; then
/etc/init.d/shorewall-lite disable /etc/init.d/$PRODUCT disable
fi fi
FIREWALL=$(readlink ${SHAREDIR}/shorewall-lite/init) FIREWALL=$(readlink ${SHAREDIR}/$PRODUCT/init)
else else
FIREWALL=$(readlink -m -q ${SHAREDIR}/shorewall-lite/init) FIREWALL=$(readlink -m -q ${SHAREDIR}/$PRODUCT/init)
fi fi
elif [ -n "$INITFILE" ]; then elif [ -n "$INITFILE" ]; then
FIREWALL=${INITDIR}/${INITFILE} FIREWALL=${INITDIR}/${INITFILE}
@@ -184,10 +167,10 @@ fi
if [ -f "$FIREWALL" ]; then if [ -f "$FIREWALL" ]; then
if [ $configure -eq 1 ]; then if [ $configure -eq 1 ]; then
if mywhich updaterc.d ; then if mywhich insserv ; then
updaterc.d shorewall-lite remove
elif mywhich insserv ; then
insserv -r $FIREWALL insserv -r $FIREWALL
elif mywhich update-rc.d ; then
update-rc.d ${PRODUCT} remove
elif mywhich chkconfig ; then elif mywhich chkconfig ; then
chkconfig --del $(basename $FIREWALL) chkconfig --del $(basename $FIREWALL)
fi fi
@@ -196,26 +179,29 @@ if [ -f "$FIREWALL" ]; then
remove_file $FIREWALL remove_file $FIREWALL
fi fi
[ -z "$SERVICEDIR" ] && SERVICEDIR="$SYSTEMD" [ -z "${SERVICEDIR}" ] && SERVICEDIR="$SYSTEMD"
if [ -n "$SERVICEDIR" ]; then if [ -n "$SERVICEDIR" ]; then
[ $configure -eq 1 ] && systemctl disable ${PRODUCT} [ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service
rm -f $SERVICEDIR/shorewall-lite.service remove_file $SERVICEDIR/${PRODUCT}.service
fi fi
rm -f ${SBINDIR}/shorewall-lite remove_directory ${CONFDIR}/$PRODUCT
remove_directory ${VARDIR}
remove_directory ${SHAREDIR}/$PRODUCT
remove_directory ${LIBEXECDIR}/$PRODUCT
remove_file ${CONFDIR}/logrotate.d/$PRODUCT
rm -rf ${CONFDIR}/shorewall-lite if [ -n "$SYSCONFDIR" ]; then
rm -rf ${VARDIR} [ -n "$SYSCONFFILE" ] && remove_file ${SYSCONFDIR}/${PRODUCT}
rm -rf ${SHAREDIR}/shorewall-lite fi
rm -rf ${LIBEXECDIR}/shorewall-lite
rm -f ${CONFDIR}/logrotate.d/shorewall-lite
rm -f ${SYSCONFDIR}/shorewall-lite
if [ -n "${MANDIR}" ]; then if [ -n "${MANDIR}" ]; then
rm -f ${MANDIR}/man5/shorewall-lite* remove_file_with_wildcard ${MANDIR}/man5/${PRODUCT}\*
rm -f ${MANDIR}/man8/shorewall-lite* remove_file_with_wildcard ${MANDIR}/man8/${PRODUCT}\*
fi fi
echo "Shorewall Lite Uninstalled" #
# Report Success
#
echo "$Product $VERSION Uninstalled"

View File

@@ -0,0 +1,9 @@
#
# Shorewall6 -- /usr/share/shorewall/action.A_AllowICMPs
#
# This action A_ACCEPTs needed ICMP types
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT
AllowICMPs(A_ACCEPT)

View File

@@ -12,6 +12,8 @@
# #
# IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!! # IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!!
# #
?require AUDIT_TARGET
?warning "You are using the deprecated A_Drop default action. Please see http://www.shorewall.net/Actions.html
############################################################################### ###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT #ACTION SOURCE DEST PROTO DPORT SPORT
# #
@@ -30,9 +32,10 @@ Auth(A_DROP)
# #
A_AllowICMPs - - icmp A_AllowICMPs - - icmp
# #
# Don't log broadcasts # Don't log broadcasts and multicasts
# #
dropBcast(audit) dropBcast(audit)
dropMcast(audit)
# #
# Drop packets that are in the INVALID state -- these are usually ICMP packets # Drop packets that are in the INVALID state -- these are usually ICMP packets
# and just confuse people when they appear in the log. # and just confuse people when they appear in the log.

View File

@@ -22,8 +22,9 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
# A_REJECTWITH[([<option>])] where <option> is a valid REJECT option.# # A_REJECT[([<option>])] where <option> is a valid REJECT option.#
############################################################################### ###############################################################################
?require AUDIT_TARGET
DEFAULTS - DEFAULTS -

View File

@@ -22,8 +22,9 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
# A_REJECTWITH[([<option>])] where <option> is a valid REJECT option.# # A_REJECT[([<option>])] where <option> is a valid REJECT option.#
############################################################################### ###############################################################################
?require AUDIT_TARGET
DEFAULTS - DEFAULTS -

View File

@@ -11,6 +11,8 @@
# internet operation are always ACCEPTed. # internet operation are always ACCEPTed.
# #
# IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!! # IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!!
?require AUDIT_TARGET
?warning "You are using the deprecated A_REJECT default action. Please see http://www.shorewall.net/Actions.html
############################################################################### ###############################################################################
#ACTION SOURCE DEST PROTO #ACTION SOURCE DEST PROTO
# #
@@ -25,10 +27,11 @@ COUNT
# #
A_AllowICMPs - - icmp A_AllowICMPs - - icmp
# #
# Drop Broadcasts so they don't clutter up the log # Drop Broadcasts and multicasts so they don't clutter up the log
# (broadcasts must *not* be rejected). # (these must *not* be rejected).
# #
dropBcast(audit) dropBcast(audit)
dropMcast(audit)
# #
# Drop packets that are in the INVALID state -- these are usually ICMP packets # Drop packets that are in the INVALID state -- these are usually ICMP packets
# and just confuse people when they appear in the log (these ICMPs cannot be # and just confuse people when they appear in the log (these ICMPs cannot be

View File

@@ -0,0 +1,44 @@
#
# Shorewall -- /usr/share/shorewall/action.AllowICMPs
#
# This action ACCEPTs needed ICMP types.
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
DEFAULTS ACCEPT
?if __IPV4
@1 - - icmp fragmentation-needed {comment="Needed ICMP types"}
@1 - - icmp time-exceeded {comment="Needed ICMP types"}
?else
?COMMENT Needed ICMP types (RFC4890)
@1 - - ipv6-icmp destination-unreachable
@1 - - ipv6-icmp packet-too-big
@1 - - ipv6-icmp time-exceeded
@1 - - ipv6-icmp parameter-problem
# The following should have a ttl of 255 and must be allowed to transit a bridge
@1 - - ipv6-icmp router-solicitation
@1 - - ipv6-icmp router-advertisement
@1 - - ipv6-icmp neighbour-solicitation
@1 - - ipv6-icmp neighbour-advertisement
@1 - - ipv6-icmp 137 # Redirect
@1 - - ipv6-icmp 141 # Inverse neighbour discovery solicitation
@1 - - ipv6-icmp 142 # Inverse neighbour discovery advertisement
# The following should have a link local source address and must be allowed to transit a bridge
@1 fe80::/10 - ipv6-icmp 130 # Listener query
@1 fe80::/10 - ipv6-icmp 131 # Listener report
@1 fe80::/10 - ipv6-icmp 132 # Listener done
@1 fe80::/10 - ipv6-icmp 143 # Listener report v2
# The following should be received with a ttl of 255 and must be allowed to transit a bridge
@1 - - ipv6-icmp 148 # Certificate path solicitation
@1 - - ipv6-icmp 149 # Certificate path advertisement
# The following should have a link local source address and a ttl of 1 and must be allowed to transit a bridge
@1 fe80::/10 - ipv6-icmp 151 # Multicast router advertisement
@1 fe80::/10 - ipv6-icmp 152 # Multicast router solicitation
@1 fe80::/10 - ipv6-icmp 153 # Multicast router termination
?endif

View File

@@ -0,0 +1,50 @@
#
# Shorewall - /usr/share/shorewall/action.BLACKLIST
#
# This action:
#
# - Adds the sender to the dynamic blacklist ipset
# - Optionally acts on the packet (default is DROP)
#
# Parameters:
#
# 1 - Action to take after adding the packet. Default is DROP.
# Pass -- if you don't want to take any action.
# 2 - Timeout for ipset entry. Default is the timeout specified in
# DYNAMIC_BLACKLIST or the one specified when the ipset was created.
#
###############################################################################
# Note -- This action is defined with the 'section' option, so the first
# parameter is always the section name. That means that in the
# following text, the first parameter passed in the rule is actually
# @2.
###############################################################################
?if $1 eq 'BLACKLIST'
?if $BLACKLIST_LOG_LEVEL
blacklog
?else
$BLACKLIST_DISPOSITION
?endif
?else
?if ! "$SW_DBL_IPSET"
? error The BLACKLIST action may only be used with ipset-based dynamic blacklisting
?endif
DEFAULTS -,DROP,-
#
# Add to the blacklist
#
?if passed(@3)
ADD($SW_DBL_IPSET:src:@3)
?elsif $SW_DBL_TIMEOUT
ADD($SW_DBL_IPSET:src:$SW_DBL_TIMEOUT)
?else
ADD($SW_DBL_IPSET:src)
?endif
#
# Dispose of the packet if asked
#
?if passed(@2)
@2
?endif
?endif

View File

@@ -0,0 +1,65 @@
#
# Shorewall -- /usr/share/shorewall/action.Broadcast
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2011-2016 Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Broadcast[([<action>|[,{audit|-}])]
#
# Default action is DROP
#
###############################################################################
DEFAULTS DROP,-
?if __ADDRTYPE
@1 - - - ;; -m addrtype --dst-type BROADCAST
@1 - - - ;; -m addrtype --dst-type ANYCAST
?else
?begin perl;
use strict;
use Shorewall::IPAddrs;
use Shorewall::Config;
use Shorewall::Chains;
my ( $action, $audit ) = get_action_params( 2 );
my $chainref = get_action_chain;
my ( $level, $tag ) = get_action_logging;
fatal_error "Invalid parameter to action Broadcast" if supplied $audit && $audit ne 'audit';
my $target = require_audit ( $action , $audit );
if ( $family == F_IPV4 ) {
add_commands $chainref, 'for address in $ALL_BCASTS; do';
} elsif ($family == F_IPV6 ) {
add_commands $chainref, 'for address in $ALL_ACASTS; do';
}
incr_cmd_level $chainref;
log_rule_limit $level, $chainref, 'Broadcast' , $action, '', $tag, 'add', ' -d $address ' if $level ne '';
add_jump $chainref, $target, 0, "-d \$address ";
decr_cmd_level $chainref;
add_commands $chainref, 'done';
1;
?end perl;
?endif

View File

@@ -1,7 +1,7 @@
# #
# Shorewall -- /usr/share/shorewall/action.Drop # Shorewall -- /usr/share/shorewall/action.Drop
# #
# The default DROP common rules # The former default DROP common rules. Use of this action is now deprecated
# #
# This action is invoked before a DROP policy is enforced. The purpose # This action is invoked before a DROP policy is enforced. The purpose
# of the action is: # of the action is:
@@ -20,7 +20,7 @@
# depending on the setting of the first parameter. # depending on the setting of the first parameter.
# 4 - Action to take with required ICMP packets. Default is ACCEPT or # 4 - Action to take with required ICMP packets. Default is ACCEPT or
# A_ACCEPT depending on the first parameter. # A_ACCEPT depending on the first parameter.
# 5 - Action to take with late UDP replies (UDP source port 53). Default # 5 - Action to take with late DNS replies (UDP source port 53). Default
# is DROP or A_DROP depending on the first parameter. # is DROP or A_DROP depending on the first parameter.
# 6 - Action to take with UPnP packets. Default is DROP or A_DROP # 6 - Action to take with UPnP packets. Default is DROP or A_DROP
# depending on the first parameter. # depending on the first parameter.
@@ -28,6 +28,7 @@
# IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!! # IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!!
# #
############################################################################### ###############################################################################
?warning "You are using the deprecated Drop default action. Please see http://www.shorewall.net/Actions.html#Default"
?if passed(@1) ?if passed(@1)
?if @1 eq 'audit' ?if @1 eq 'audit'
@@ -58,9 +59,10 @@ Auth(@2)
# #
AllowICMPs(@4) - - icmp AllowICMPs(@4) - - icmp
# #
# Don't log broadcasts # Don't log broadcasts or multicasts
# #
Broadcast(DROP,@1) Broadcast(DROP,@1)
Multicast(DROP,@1)
# #
# Drop packets that are in the INVALID state -- these are usually ICMP packets # Drop packets that are in the INVALID state -- these are usually ICMP packets
# and just confuse people when they appear in the log. # and just confuse people when they appear in the log.

View File

@@ -0,0 +1,10 @@
#
# Shorewall -- /usr/share/shorewall/action.DropDNSrep
#
# This macro silently drops DNS UDP replies that are in the New state
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
DEFAULTS DROP
@1 - - udp - 53 { comment="Late DNS Replies" }

View File

@@ -0,0 +1,33 @@
#
# Shorewall -- /usr/share/shorewall/action.FIN
#
# FIN Action
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2012-2016 Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# FIN[([<action>])]
#
# Default action is ACCEPT
#
###############################################################################
DEFAULTS ACCEPT,-
@1 - - ;;+ -p 6 --tcp-flags ACK,FIN ACK,FIN

View File

@@ -13,9 +13,9 @@
DEFAULTS 2,0 DEFAULTS 2,0
?if @1 !~ /^\d+/ || ! @1 || @1 > 1024 ?if @1 !~ /^\d+/ || ! @1 || @1 > 1024
?error Invalid value for Bricks (@1) ?error Invalid value (@1) for the GlusterFS Bricks argument
?elsif @2 !~ /^[01]$/ ?elsif @2 !~ /^[01]$/
?error Invalid value for IB (@2) ?error Invalid value (@2) for the GlusterFS IB argument
?endif ?endif
#ACTION SOURCE DEST PROTO DPORT #ACTION SOURCE DEST PROTO DPORT

View File

@@ -107,6 +107,11 @@ if ( $command & $REAP_OPT ) {
$duration .= '--rttl ' if $command & $TTL_OPT; $duration .= '--rttl ' if $command & $TTL_OPT;
if ( ( $targets{$action} || 0 ) & NATRULE ) {
perl_action_helper( "${action}-", "-m recent --rcheck ${duration}--hitcount $hitcount" );
$action = 'ACCEPT';
}
if ( $command & $RESET_CMD ) { if ( $command & $RESET_CMD ) {
require_capability 'MARK_ANYWHERE', '"reset"', 's'; require_capability 'MARK_ANYWHERE', '"reset"', 's';

View File

@@ -0,0 +1,70 @@
#
# Shorewall -- /usr/share/shorewall/action.Limit
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2017 Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Limit(<recent-set>,<num-connections>,<timeout>)
#
###############################################################################
DEFAULTS -,-,-
?begin perl
use strict;
use Shorewall::Config;
use Shorewall::Chains;
my $chainref = get_action_chain;
my @param = get_action_params(3);
my ( $level, $tag ) = get_action_logging;
@param = split( ',', $tag ), $tag = $param[0] unless supplied( join '', @param );
fatal_error 'Limit rules must include <set name>,<max connections>,<interval> as the log tag or as parameters' unless @param == 3;
my $set = $param[0];
for ( @param[1,2] ) {
fatal_error 'Max connections and interval in Limit rules must be numeric (' . join( ':', 'Limit', $level eq '' ? 'none' : $level, $tag ) . ')' unless /^\d+$/
}
my $count = $param[1] + 1;
require_capability( 'RECENT_MATCH' , 'Limit rules' , '' );
warning_message "The Limit action is deprecated in favor of per-IP rate limiting using the RATE LIMIT column";
add_irule $chainref, recent => "--name $set --set";
if ( $level ne '' ) {
my $xchainref = new_chain 'filter' , "$chainref->{name}%";
log_irule_limit( $level, $xchainref, '', 'DROP', [], $tag, 'add' , '' );
add_ijump $xchainref, j => 'DROP';
add_ijump $chainref, j => $xchainref, recent => "--name $set --update --seconds $param[2] --hitcount $count";
} else {
add_ijump $chainref, j => 'DROP', recent => "--update --name $set --seconds $param[2] --hitcount $count";
}
add_ijump $chainref, j => 'ACCEPT';
1;
?end perl

View File

@@ -1,5 +1,5 @@
# #
# Shorewall -- /usr/share/shorewall/action.Broadcast # Shorewall -- /usr/share/shorewall/action.Multicast
# #
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt] # This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
# #
@@ -20,7 +20,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
# Broadcast[([<action>|-[,{audit|-}])] # Multicast[([<action>|-[,{audit|-}])]
# #
# Default action is DROP # Default action is DROP
# #
@@ -29,31 +29,28 @@
DEFAULTS DROP,- DEFAULTS DROP,-
?if __ADDRTYPE ?if __ADDRTYPE
@1 - - - ;; -m addrtype --dst-type BROADCAST @1 - - - ;; -m addrtype --dst-type MULTICAST
@1 - - - ;; -m addrtype --dst-type MULTICAST
@1 - - - ;; -m addrtype --dst-type ANYCAST
?else ?else
?begin perl; ?begin perl;
use Shorewall::IPAddrs; use strict;
use Shorewall::Config; use Shorewall::IPAddrs;
use Shorewall::Chains; use Shorewall::Config;
use Shorewall::Chains;
my ( $action ) = get_action_params( 1 ); my ( $action, $audit ) = get_action_params( 2 );
my $chainref = get_action_chain; my $chainref = get_action_chain;
my ( $level, $tag ) = get_action_logging; my ( $level, $tag ) = get_action_logging;
add_commands $chainref, 'for address in $ALL_BCASTS; do'; fatal_error "Invalid parameter to action Multicast" if supplied $audit && $audit ne 'audit';
incr_cmd_level $chainref;
log_rule_limit $level, $chainref, 'Broadcast' , $action, '', $tag, 'add', ' -d $address ' if $level ne '';
add_jump $chainref, $action, 0, "-d \$address ";
decr_cmd_level $chainref;
add_commands $chainref, 'done';
log_rule_limit $level, $chainref, 'Broadcast' , $action, '', $tag, 'add', ' -d 224.0.0.0/4 ' if $level ne ''; my $target = require_audit ( $action , $audit );
add_jump $chainref, $action, 0, '-d 224.0.0.0/4 '; my $dest = ( $family == F_IPV4 ) ? join( ' ', '-d', IPv4_MULTICAST . ' ' ) : join( ' ', '-d', IPv6_MULTICAST . ' ' );
1; log_rule_limit( $level, $chainref, 'Multicast' , $action, '', $tag, 'add', $dest ) if $level ne '';
add_jump $chainref, $target, 0, $dest;
?end perl; 1;
?end perl;
?endif ?endif

View File

@@ -1,7 +1,7 @@
# #
# Shorewall -- /usr/share/shorewall/action.Reject # Shorewall -- /usr/share/shorewall/action.Reject
# #
# The default REJECT action common rules # The former default REJECT action common rules. Use of this action is deprecated.
# #
# This action is invoked before a REJECT policy is enforced. The purpose # This action is invoked before a REJECT policy is enforced. The purpose
# of the action is: # of the action is:
@@ -20,13 +20,14 @@
# depending on the setting of the first parameter. # depending on the setting of the first parameter.
# 4 - Action to take with required ICMP packets. Default is ACCEPT or # 4 - Action to take with required ICMP packets. Default is ACCEPT or
# A_ACCEPT depending on the first parameter. # A_ACCEPT depending on the first parameter.
# 5 - Action to take with late UDP replies (UDP source port 53). Default # 5 - Action to take with late DNS replies (UDP source port 53). Default
# is DROP or A_DROP depending on the first parameter. # is DROP or A_DROP depending on the first parameter.
# 6 - Action to take with UPnP packets. Default is DROP or A_DROP # 6 - Action to take with UPnP packets. Default is DROP or A_DROP
# depending on the first parameter. # depending on the first parameter.
# #
# IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!! # IF YOU ARE HAVING CONNECTION PROBLEMS, CHANGING THIS FILE WON'T HELP!!!!!!!!!
############################################################################### ###############################################################################
?warning "You are using the deprecated Reject default action. Please see http://www.shorewall.net/Actions.html#Default"
?if passed(@1) ?if passed(@1)
?if @1 eq 'audit' ?if @1 eq 'audit'
@@ -61,6 +62,7 @@ AllowICMPs(@4) - - icmp
# (broadcasts must *not* be rejected). # (broadcasts must *not* be rejected).
# #
Broadcast(DROP,@1) Broadcast(DROP,@1)
Multicast(DROP,@1)
# #
# Drop packets that are in the INVALID state -- these are usually ICMP packets # Drop packets that are in the INVALID state -- these are usually ICMP packets
# and just confuse people when they appear in the log (these ICMPs cannot be # and just confuse people when they appear in the log (these ICMPs cannot be

View File

@@ -41,6 +41,11 @@ fatal_error "Invalid Src or Dest ($destination)" unless $destination =~ /^(?:src
set_action_disposition( $disposition) if supplied $disposition; set_action_disposition( $disposition) if supplied $disposition;
set_action_name_to_caller; set_action_name_to_caller;
if ( ( $targets{$action} || 0 ) & NATRULE ) {
perl_action_helper( "${action}-", "" );
$action = 'ACCEPT';
}
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 {

View File

@@ -37,6 +37,11 @@ fatal_error "Invalid Src or Dest ($destination)" unless $destination =~ /^(?:src
set_action_disposition( $disposition) if supplied $disposition; set_action_disposition( $disposition) if supplied $disposition;
set_action_name_to_caller; set_action_name_to_caller;
if ( ( $targets{$action} || 0 ) & NATRULE ) {
perl_action_helper( "${action}-", "" );
$action = 'ACCEPT';
}
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 {

View File

@@ -26,4 +26,4 @@ $tcpflags_action - - ;;+ -p 6 --tcp-flags ALL FIN,URG,PSH
$tcpflags_action - - ;;+ -p 6 --tcp-flags ALL NONE $tcpflags_action - - ;;+ -p 6 --tcp-flags ALL NONE
$tcpflags_action - - ;;+ -p 6 --tcp-flags SYN,RST SYN,RST $tcpflags_action - - ;;+ -p 6 --tcp-flags SYN,RST SYN,RST
$tcpflags_action - - ;;+ -p 6 --tcp-flags SYN,FIN SYN,FIN $tcpflags_action - - ;;+ -p 6 --tcp-flags SYN,FIN SYN,FIN
$tcpflags_action - - ;;+ -p tcp --syn --sport 0 $tcpflags_action - - ;;+ -p 6 --syn --sport 0

View File

@@ -0,0 +1,38 @@
#
# Shorewall -- /usr/share/shorewall/action.allowBcast
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2017 Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# allowBcast[([audit])]
#
###############################################################################
DEFAULTS -
?if passed(@1)
?if @1 eq 'audit'
?require AUDIT_TARGET
Broadcast(A_ACCEPT)
?else
?error "Invalid argument (@1) to allowBcast"
?endif
?else
Broadcast(ACCEPT)
?endif

View File

@@ -0,0 +1,38 @@
#
# Shorewall -- /usr/share/shorewall/action.allowMcast
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2017 Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# allowMcast[([audit])]
#
###############################################################################
DEFAULTS -
?if passed(@1)
?if @1 eq 'audit'
?require AUDIT_TARGET
Multicast(A_ACCEPT)
?else
?error "Invalid argument (@1) to allowMcast"
?endif
?else
Multicast(ACCEPT)
?endif

View File

@@ -0,0 +1,40 @@
#
# Shorewall -- /usr/share/shorewall/action.allowinUPnP
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2017 Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# allowinUPnP[([audit])]
#
###############################################################################
DEFAULTS -
?if passed(@1)
?if @1 eq 'audit'
?require AUDIT_TARGET
A_ACCEPT - - 17 1900
A_ACCEPT - - 6 49152
?else
?error "Invalid argument (@1) to allowinUPnP"
?endif
?else
ACCEPT - - 17 1900
ACCEPT - - 6 49152
?endif

View File

@@ -0,0 +1,39 @@
#
# Shorewall -- /usr/share/shorewall/action.dropBcast
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2017 Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# dropBcast[([audit])]
#
###############################################################################
DEFAULTS -
?if passed(@1)
?if @1 eq 'audit'
?require AUDIT_TARGET
Broadcast(A_DROP)
?else
?error "Invalid argument (@1) to dropBcast"
?endif
?else
Broadcast(DROP)
?endif

View File

@@ -0,0 +1,39 @@
#
# Shorewall -- /usr/share/shorewall/action.dropBcasts
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2017 Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# dropBcasts[([audit])]
#
###############################################################################
DEFAULTS -
?if passed(@1)
?if @1 eq 'audit'
?require AUDIT_TARGET
Broadcast(A_DROP)
?else
?error "Invalid argument (@1) to dropBcasts"
?endif
?else
Broadcast(DROP)
?endif

View File

@@ -0,0 +1,38 @@
#
# Shorewall -- /usr/share/shorewall/action.dropMcast
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2017 Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# dropMcast[([audit])]
#
###############################################################################
DEFAULTS -
?if passed(@1)
?if @1 eq 'audit'
?require AUDIT_TARGET
Multicast(A_DROP)
?else
?error "Invalid argument (@1) to dropMcast"
?endif
?else
Multicast(DROP)
?endif

View File

@@ -0,0 +1,38 @@
#
# Shorewall -- /usr/share/shorewall/action.dropNotSyn
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2017 Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# dropNotSyn[([audit])]
#
###############################################################################
DEFAULTS -
?if passed(@1)
?if @1 eq 'audit'
?require AUDIT_TARGET
A_DROP {proto=6:!syn}
?else
?error "Invalid argument (@1) to dropNotSyn"
?endif
?else
DROP {proto=6:!syn}
?endif

View File

@@ -0,0 +1,43 @@
#
# Shorewall -- /usr/share/shorewall/action.forwardUPnP
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2017 Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# forwardUPnP
#
###############################################################################
DEFAULTS -
?begin perl
use strict;
use Shorewall::Config;
use Shorewall::Chains;
my $chainref = get_action_chain;
set_optflags( $chainref, DONT_OPTIMIZE );
add_commands( $chainref , '[ -f ${VARDIR}/.forwardUPnP ] && cat ${VARDIR}/.forwardUPnP >&3' );
1;
?end perl

View File

@@ -0,0 +1,39 @@
#
# Shorewall -- /usr/share/shorewall/action.rejNotSyn
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2017 Tom Eastep (teastep@shorewall.net)
#
# Complete documentation is available at http://shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# rejNotSyn[([audit])]
#
###############################################################################
DEFAULTS -
?if passed(@1)
?if @1 eq 'audit'
?require AUDIT_TARGET
A_REJECT {proto=6:!syn}
?else
?error "Invalid argument (@1) to rejNotSyn"
?endif
?else
REJECT(tcp-reset) {proto=6:!syn}
?endif

View File

@@ -1,13 +0,0 @@
#
# Shorewall -- /usr/share/shorewall/macro.AllowICMPs
#
# This macro ACCEPTs needed ICMP types.
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
?COMMENT Needed ICMP types
DEFAULT ACCEPT
PARAM - - icmp fragmentation-needed
PARAM - - icmp time-exceeded

View File

@@ -1,13 +0,0 @@
#
# Shorewall -- /usr/share/shorewall/macro.blacklist
#
# This macro handles blacklisting using BLACKLIST_DISPOSITION and BLACKLIST_LOGLEVEL.
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
?if $BLACKLIST_LOGLEVEL
blacklog
?else
$BLACKLIST_DISPOSITION
?endif

View File

@@ -1,49 +0,0 @@
#
# Shorewall -- /usr/share/shorewall/macro.Drop
#
# This macro generates the same rules as the Drop default action
# It is used in place of action.Drop when USE_ACTIONS=No.
#
# Example:
#
# Drop net all
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
#
# Don't log 'auth' DROP
#
DROP - - tcp 113
#
# Drop Broadcasts so they don't clutter up the log
# (broadcasts must *not* be rejected).
#
dropBcast
#
# ACCEPT critical ICMP types
#
ACCEPT - - icmp fragmentation-needed
ACCEPT - - icmp time-exceeded
#
# Drop packets that are in the INVALID state -- these are usually ICMP packets
# and just confuse people when they appear in the log (these ICMPs cannot be
# rejected).
#
dropInvalid
#
# Drop Microsoft noise so that it doesn't clutter up the log.
#
DROP - - udp 135,445
DROP - - udp 137:139
DROP - - udp 1024: 137
DROP - - tcp 135,139,445
DROP - - udp 1900
#
# Drop 'newnotsyn' traffic so that it doesn't get logged.
#
dropNotSyn
#
# Drop late-arriving DNS replies. These are just a nuisance and clutter up
# the log.
#
DROP - - udp - 53

View File

@@ -1,12 +0,0 @@
#
# Shorewall -- /usr/share/shorewall/macro.DropDNSrep
#
# This macro silently drops DNS UDP replies
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
?COMMENT Late DNS Replies
DEFAULT DROP
PARAM - - udp - 53

View File

@@ -15,6 +15,7 @@ PARAM - - tcp 3668,3669 # Virtual Media, Secure (Dell)
PARAM - - tcp 5120,5123 # CD, floppy (Asus, Aten) PARAM - - tcp 5120,5123 # CD, floppy (Asus, Aten)
PARAM - - tcp 5900,5901 # Remote Console (Aten, Dell) PARAM - - tcp 5900,5901 # Remote Console (Aten, Dell)
PARAM - - tcp 7578 # Remote Console (AMI) PARAM - - tcp 7578 # Remote Console (AMI)
PARAM - - tcp 3520 # Remote Console (Redfish)
PARAM - - udp 623 # RMCP PARAM - - udp 623 # RMCP
HTTP HTTP
HTTPS HTTPS

View File

@@ -6,4 +6,5 @@
############################################################################### ###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER #ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
PARAM - - udp 3389
PARAM - - tcp 3389 PARAM - - tcp 3389

View File

@@ -1,49 +0,0 @@
#
# Shorewall -- /usr/share/shorewall/macro.Reject
#
# This macro generates the same rules as the Reject default action
# It is used in place of action.Reject when USE_ACTIONS=No.
#
# Example:
#
# Reject loc fw
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
#
# Don't log 'auth' REJECT
#
REJECT - - tcp 113
#
# Drop Broadcasts so they don't clutter up the log
# (broadcasts must *not* be rejected).
#
dropBcast
#
# ACCEPT critical ICMP types
#
ACCEPT - - icmp fragmentation-needed
ACCEPT - - icmp time-exceeded
#
# Drop packets that are in the INVALID state -- these are usually ICMP packets
# and just confuse people when they appear in the log (these ICMPs cannot be
# rejected).
#
dropInvalid
#
# Reject Microsoft noise so that it doesn't clutter up the log.
#
REJECT - - udp 135,445
REJECT - - udp 137:139
REJECT - - udp 1024: 137
REJECT - - tcp 135,139,445
DROP - - udp 1900
#
# Drop 'newnotsyn' traffic so that it doesn't get logged.
#
dropNotSyn
#
# Drop late-arriving DNS replies. These are just a nuisance and clutter up
# the log.
#
DROP - - udp - 53

View File

@@ -1,23 +0,0 @@
#
# Shorewall -- /etc/shorewall/Makefile
#
# Reload Shorewall if config files are updated.
SWBIN ?= /sbin/shorewall -q
CONFDIR ?= /etc/shorewall
SWSTATE ?= $(shell $(SWBIN) show vardir)/firewall
.PHONY: clean
$(SWSTATE): $(CONFDIR)/*
@$(SWBIN) save >/dev/null; \
RESULT=$$($(SWBIN) reload 2>&1); \
if [ $$? -eq 0 ]; then \
$(SWBIN) save >/dev/null; \
else \
echo "$${RESULT}" >&2; \
false; \
fi
clean:
@rm -f $(CONFDIR)/*~ $(CONFDIR)/.*~

View File

@@ -1,82 +0,0 @@
# Shorewall Packet Filtering Firewall Export Directory Makefile - V4.2
#
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
#
# (c) 2006 - Tom Eastep (teastep@shorewall.net)
#
# Shorewall documentation is available at http://www.shorewall.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of Version 2 of the GNU General Public License
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
################################################################################
# Place this file in each export directory. Modify each copy to set HOST
# to the name of the remote firewall corresponding to the directory.
#
# To make the 'firewall' script, type "make".
#
# Once the script is compiling correctly, you can install it by
# typing "make install".
#
################################################################################
# V A R I A B L E S
#
# Files in the export directory on which the firewall script does not depend
#
IGNOREFILES = firewall% Makefile% trace% %~
#
# Remote Firewall system
#
HOST = gateway
#
# Save some typing
#
LITEDIR = /var/lib/shorewall-lite
#
# Set this if the remote system has a non-standard modules directory
#
MODULESDIR=
#
# Default target is the firewall script
#
################################################################################
# T A R G E T S
#
all: firewall
#
# Only generate the capabilities file if it doesn't already exist
#
capabilities:
ssh root@$(HOST) "MODULESDIR=$(MODULESDIR) /usr/share/shorewall-lite/shorecap > $(LITEDIR)/capabilities"
scp root@$(HOST):$(LITEDIR)/capabilities .
#
# Compile the firewall script. Using the 'wildcard' function causes "*" to be expanded so that
# 'filter-out' will be presented with the list of files in this directory rather than "*"
#
firewall: $(filter-out $(IGNOREFILES) capabilities , $(wildcard *) ) capabilities
shorewall compile -e . firewall
#
# Only reload on demand.
#
install: firewall
scp firewall firewall.conf root@$(HOST):$(LITEDIR)
ssh root@$(HOST) "/sbin/shorewall-lite restart"
#
# Save running configuration
#
save:
ssh root@$(HOST) "/sbin/shorewall-lite save"
#
# Remove generated files
#
clean:
rm -f capabilities firewall firewall.conf reload

View File

@@ -195,7 +195,7 @@ sub process_accounting_rule1( $$$$$$$$$$$ ) {
$ports = '' if $ports eq 'any' || $ports eq 'all'; $ports = '' if $ports eq 'any' || $ports eq 'all';
$sports = '' if $sports eq 'any' || $sports eq 'all'; $sports = '' if $sports eq 'any' || $sports eq 'all';
fatal_error "USER/GROUP may only be specified in the OUTPUT section" unless $user eq '-' || $asection == OUTPUT; fatal_error "USER/GROUP may only be specified in the OUTPUT section" unless $user eq '-' || $asection == OUTPUT_SECTION;
my $rule = do_proto( $proto, $ports, $sports ) . do_user ( $user ) . do_test ( $mark, $globals{TC_MASK} ) . do_headers( $headers ); my $rule = do_proto( $proto, $ports, $sports ) . do_user ( $user ) . do_test ( $mark, $globals{TC_MASK} ) . do_headers( $headers );
my $prerule = ''; my $prerule = '';
@@ -266,7 +266,7 @@ sub process_accounting_rule1( $$$$$$$$$$$ ) {
if ( $source eq 'any' || $source eq 'all' ) { if ( $source eq 'any' || $source eq 'all' ) {
$source = ALLIP; $source = ALLIP;
} else { } else {
fatal_error "MAC addresses only allowed in the INPUT and FORWARD sections" if $source =~ /~/ && ( $asection == OUTPUT || ! $asection ); fatal_error "MAC addresses only allowed in the INPUT and FORWARD sections" if $source =~ /~/ && ( $asection == OUTPUT_SECTION || ! $asection );
} }
if ( have_bridges && ! $asection ) { if ( have_bridges && ! $asection ) {
@@ -519,9 +519,9 @@ sub setup_accounting() {
while ( $chainswithjumps && $progress ) { while ( $chainswithjumps && $progress ) {
$progress = 0; $progress = 0;
for my $chain1 ( sort keys %accountingjumps ) { for my $chain1 ( keys %accountingjumps ) {
if ( keys %{$accountingjumps{$chain1}} ) { if ( keys %{$accountingjumps{$chain1}} ) {
for my $chain2 ( sort keys %{$accountingjumps{$chain1}} ) { for my $chain2 ( keys %{$accountingjumps{$chain1}} ) {
delete $accountingjumps{$chain1}{$chain2}, $progress = 1 unless $accountingjumps{$chain2}; delete $accountingjumps{$chain1}{$chain2}, $progress = 1 unless $accountingjumps{$chain2};
} }
} else { } else {

File diff suppressed because it is too large Load Diff

View File

@@ -59,7 +59,7 @@ our $have_arptables;
# Initilize the package-globals in the other modules # Initilize the package-globals in the other modules
# #
sub initialize_package_globals( $$$ ) { sub initialize_package_globals( $$$ ) {
Shorewall::Config::initialize($family, $_[1], $_[2]); Shorewall::Config::initialize($family, $export, $_[1], $_[2]);
Shorewall::Chains::initialize ($family, 1, $export ); Shorewall::Chains::initialize ($family, 1, $export );
Shorewall::Zones::initialize ($family, $_[0]); Shorewall::Zones::initialize ($family, $_[0]);
Shorewall::Nat::initialize($family); Shorewall::Nat::initialize($family);
@@ -93,11 +93,10 @@ sub generate_script_1( $ ) {
my $date = compiletime; my $date = compiletime;
emit "#!$config{SHOREWALL_SHELL}\n#\n# Compiled firewall script generated by Shorewall $globals{VERSION} - $date\n#"; emit "#!$config{SHOREWALL_SHELL}\n#\n# Compiled firewall script generated by Shorewall $globals{VERSION} - $date\n#";
copy $globals{SHAREDIRPL} . '/lib.runtime', 0;
copy2 $globals{SHAREDIRPL} . '/lib.common' , $debug;
} }
copy $globals{SHAREDIRPL} . '/lib.runtime', 0;
copy2 $globals{SHAREDIRPL} . '/lib.common' , $debug;
} }
my $lib = find_file 'lib.private'; my $lib = find_file 'lib.private';
@@ -110,7 +109,7 @@ sub generate_script_1( $ ) {
################################################################################ ################################################################################
EOF EOF
for my $exit ( qw/init start tcclear started stop stopped clear refresh refreshed restored/ ) { for my $exit ( qw/init start tcclear started stop stopped clear refresh refreshed restored enabled disabled/ ) {
emit "\nrun_${exit}_exit() {"; emit "\nrun_${exit}_exit() {";
push_indent; push_indent;
append_file $exit or emit 'true'; append_file $exit or emit 'true';
@@ -210,6 +209,8 @@ sub generate_script_2() {
emit ( '[ -f ${g_confdir}/vardir ] && . ${g_confdir}/vardir' ); emit ( '[ -f ${g_confdir}/vardir ] && . ${g_confdir}/vardir' );
emit ( qq([ -n "\${VARDIR:=$shorewallrc1{VARDIR}}" ]) ); emit ( qq([ -n "\${VARDIR:=$shorewallrc1{VARDIR}}" ]) );
emit ( qq([ -n "\${VARLIB:=$shorewallrc1{VARLIB}}" ]) ); emit ( qq([ -n "\${VARLIB:=$shorewallrc1{VARLIB}}" ]) );
emit ( qq([ -n "\${CONFDIR:=$shorewallrc1{CONFDIR}}" ]) );
emit ( qq([ -n "\${SHAREDIR:=$shorewallrc1{SHAREDIR}}" ]) );
emit 'TEMPFILE='; emit 'TEMPFILE=';
@@ -267,7 +268,8 @@ sub generate_script_2() {
emit( '', emit( '',
'chain_exists DOCKER nat && chain_exists DOCKER && g_docker=Yes', 'chain_exists DOCKER nat && chain_exists DOCKER && g_docker=Yes',
); );
emit( 'chain_exists DOCKER-ISOLATION && g_dockernetwork=Yes]' ); emit( 'chain_exists DOCKER-INGRESS && g_dockeringress=Yes' );
emit( 'chain_exists DOCKER-ISOLATION && g_dockernetwork=Yes' );
emit( '' ); emit( '' );
} }
@@ -690,6 +692,7 @@ sub compiler {
set_timestamp( $timestamp ); set_timestamp( $timestamp );
set_debug( $debug , $confess ); set_debug( $debug , $confess );
# #
# S H O R E W A L L R C ,
# S H O R E W A L L . C O N F A N D C A P A B I L I T I E S # S H O R E W A L L . C O N F A N D C A P A B I L I T I E S
# #
get_configuration( $export , $update , $annotate , $inline ); get_configuration( $export , $update , $annotate , $inline );
@@ -701,7 +704,7 @@ sub compiler {
# #
# Allow user to load Perl modules # Allow user to load Perl modules
# #
run_user_exit1 'compile'; run_user_exit 'compile';
# #
# Create a temp file to hold the script # Create a temp file to hold the script
# #
@@ -794,43 +797,15 @@ sub compiler {
emit '}'; # End of setup_common_rules() emit '}'; # End of setup_common_rules()
} }
disable_script;
# #
# R O U T I N G _ A N D _ T R A F F I C _ S H A P I N G # R O U T I N G _ A N D _ T R A F F I C _ S H A P I N G
# (Writes the setup_routing_and_traffic_shaping() function to the compiled script) # (Writes the setup_routing_and_traffic_shaping() function to the compiled script)
# #
enable_script;
#
# Validate the TC files so that the providers will know what interfaces have TC # Validate the TC files so that the providers will know what interfaces have TC
# #
my $tcinterfaces = process_tc; my $tcinterfaces = process_tc;
#
# Generate a function to bring up each provider
#
process_providers( $tcinterfaces ); process_providers( $tcinterfaces );
#
# [Re-]establish Routing
#
if ( $scriptfilename || $debug ) {
emit( "\n#",
'# Setup routing and traffic shaping',
'#',
'setup_routing_and_traffic_shaping() {'
);
push_indent;
}
setup_providers;
#
# TCRules and Traffic Shaping
#
setup_tc( $update );
if ( $scriptfilename || $debug ) {
pop_indent;
emit "}\n"; # End of setup_routing_and_traffic_shaping()
}
$have_arptables = process_arprules if $family == F_IPV4; $have_arptables = process_arprules if $family == F_IPV4;
@@ -841,13 +816,9 @@ sub compiler {
# #
process_tos; process_tos;
# #
# ECN # Setup Masquerade/SNAT
# #
setup_ecn if $family == F_IPV4 && have_capability( 'MANGLE_ENABLED' ) && $config{MANGLE_ENABLED}; setup_snat( $update );
#
# Setup Masquerading/SNAT
#
setup_masq;
# #
# Setup Nat # Setup Nat
# #
@@ -889,6 +860,37 @@ sub compiler {
# #
setup_accounting if $config{ACCOUNTING}; setup_accounting if $config{ACCOUNTING};
enable_script;
#
# Generate a function to bring up each provider
#
if ( $scriptfilename || $debug ) {
emit( "\n#",
'# Setup routing and traffic shaping',
'#',
'setup_routing_and_traffic_shaping() {'
);
push_indent;
}
setup_providers;
#
# TCRules and Traffic Shaping
#
setup_tc( $update );
if ( $scriptfilename || $debug ) {
pop_indent;
emit "}\n"; # End of setup_routing_and_traffic_shaping()
}
#
# ECN
#
setup_ecn if $family == F_IPV4 && have_capability( 'MANGLE_ENABLED' ) && $config{MANGLE_ENABLED};
disable_script;
if ( $scriptfilename ) { if ( $scriptfilename ) {
# #
# Compiling a script - generate the zone by zone matrix # Compiling a script - generate the zone by zone matrix
@@ -943,7 +945,7 @@ sub compiler {
# #
# Copy the footer to the script # Copy the footer to the script
# #
copy $globals{SHAREDIRPL} . 'prog.footer' unless $test; copy $globals{SHAREDIRPL} . 'prog.footer';
disable_script; disable_script;
# #

File diff suppressed because it is too large Load Diff

View File

@@ -63,7 +63,6 @@ our @EXPORT = ( qw( ALLIPv4
validate_host validate_host
validate_range validate_range
ip_range_explicit ip_range_explicit
expand_port_range
allipv4 allipv4
allipv6 allipv6
allip allip
@@ -74,10 +73,6 @@ our @EXPORT = ( qw( ALLIPv4
resolve_proto resolve_proto
resolve_dnsname resolve_dnsname
proto_name proto_name
validate_port
validate_portpair
validate_portpair1
validate_port_list
validate_icmp validate_icmp
validate_icmp6 validate_icmp6
) ); ) );
@@ -389,6 +384,8 @@ sub resolve_proto( $ ) {
my $proto = $_[0]; my $proto = $_[0];
my $number; my $number;
$proto =~ s/:.*//;
if ( $proto =~ /^\d+$/ || $proto =~ /^0x/ ) { if ( $proto =~ /^\d+$/ || $proto =~ /^0x/ ) {
$number = numeric_value ( $proto ); $number = numeric_value ( $proto );
defined $number && $number <= 255 ? $number : undef; defined $number && $number <= 255 ? $number : undef;
@@ -409,113 +406,6 @@ sub proto_name( $ ) {
$proto =~ /^(\d+)$/ ? $prototoname[ $proto ] || scalar getprotobynumber $proto : $proto $proto =~ /^(\d+)$/ ? $prototoname[ $proto ] || scalar getprotobynumber $proto : $proto
} }
sub validate_port( $$ ) {
my ($proto, $port) = @_;
my $value;
if ( $port =~ /^(\d+)$/ || $port =~ /^0x/ ) {
$port = numeric_value $port;
return $port if defined $port && $port && $port <= 65535;
} else {
$proto = proto_name $proto if $proto =~ /^(\d+)$/;
$value = getservbyname( $port, $proto );
}
return $value if defined $value;
fatal_error "The separator for a port range is ':', not '-' ($port)" if $port =~ /^\d+-\d+$/;
fatal_error "Invalid/Unknown $proto port/service ($_[1])" unless defined $value;
}
sub validate_portpair( $$ ) {
my ($proto, $portpair) = @_;
my $what;
my $pair = $portpair;
#
# Accept '-' as a port-range separator
#
$pair =~ tr/-/:/ if $pair =~ /^[-0-9]+$/;
fatal_error "Invalid port range ($portpair)" if $pair =~ tr/:/:/ > 1;
$pair = "0$pair" if substr( $pair, 0, 1 ) eq ':';
$pair = "${pair}65535" if substr( $pair, -1, 1 ) eq ':';
my @ports = split /:/, $pair, 2;
my $protonum = resolve_proto( $proto ) || 0;
$_ = validate_port( $protonum, $_) for grep $_, @ports;
if ( @ports == 2 ) {
$what = 'port range';
fatal_error "Invalid port range ($portpair)" unless $ports[0] < $ports[1];
} else {
$what = 'port';
}
fatal_error "Using a $what ( $portpair ) requires PROTO TCP, UDP, UDPLITE, SCTP or DCCP" unless
defined $protonum && ( $protonum == TCP ||
$protonum == UDP ||
$protonum == UDPLITE ||
$protonum == SCTP ||
$protonum == DCCP );
join ':', @ports;
}
sub validate_portpair1( $$ ) {
my ($proto, $portpair) = @_;
my $what;
fatal_error "Invalid port range ($portpair)" if $portpair =~ tr/-/-/ > 1;
$portpair = "0$portpair" if substr( $portpair, 0, 1 ) eq ':';
$portpair = "${portpair}65535" if substr( $portpair, -1, 1 ) eq ':';
my @ports = split /-/, $portpair, 2;
my $protonum = resolve_proto( $proto ) || 0;
$_ = validate_port( $protonum, $_) for grep $_, @ports;
if ( @ports == 2 ) {
$what = 'port range';
fatal_error "Invalid port range ($portpair)" unless $ports[0] < $ports[1];
} else {
$what = 'port';
}
fatal_error "Using a $what ( $portpair ) requires PROTO TCP, UDP, SCTP or DCCP" unless
defined $protonum && ( $protonum == TCP ||
$protonum == UDP ||
$protonum == SCTP ||
$protonum == DCCP );
join '-', @ports;
}
sub validate_port_list( $$ ) {
my $result = '';
my ( $proto, $list ) = @_;
my @list = split_list( $list, 'port' );
if ( @list > 1 && $list =~ /[:-]/ ) {
require_capability( 'XMULTIPORT' , 'Port ranges in a port list', '' );
}
$proto = proto_name $proto;
for ( @list ) {
my $value = validate_portpair( $proto , $_ );
$result = $result ? join ',', $result, $value : $value;
}
$result;
}
my %icmp_types = ( any => 'any', my %icmp_types = ( any => 'any',
'echo-reply' => 0, 'echo-reply' => 0,
'destination-unreachable' => 3, 'destination-unreachable' => 3,
@@ -569,67 +459,6 @@ sub validate_icmp( $ ) {
fatal_error "Invalid ICMP Type ($type)" fatal_error "Invalid ICMP Type ($type)"
} }
#
# Expands a port range into a minimal list of ( port, mask ) pairs.
# Each port and mask are expressed as 4 hex nibbles without a leading '0x'.
#
# Example:
#
# DB<3> @foo = Shorewall::IPAddrs::expand_port_range( 6, '110:' ); print "@foo\n"
# 006e fffe 0070 fff0 0080 ff80 0100 ff00 0200 fe00 0400 fc00 0800 f800 1000 f000 2000 e000 4000 c000 8000 8000
#
sub expand_port_range( $$ ) {
my ( $proto, $range ) = @_;
if ( $range =~ /^(.*):(.*)$/ ) {
my ( $first, $last ) = ( $1, $2);
my @result;
fatal_error "Invalid port range ($range)" unless $first ne '' or $last ne '';
#
# Supply missing first/last port number
#
$first = 0 if $first eq '';
$last = 65535 if $last eq '';
#
# Validate the ports
#
( $first , $last ) = ( validate_port( $proto, $first || 1 ) , validate_port( $proto, $last ) );
$last++; #Increment last address for limit testing.
#
# Break the range into groups:
#
# - If the first port in the remaining range is odd, then the next group is ( <first>, ffff ).
# - Otherwise, find the largest power of two P that divides the first address such that
# the remaining range has less than or equal to P ports. The next group is
# ( <first> , ~( P-1 ) ).
#
while ( ( my $ports = ( $last - $first ) ) > 0 ) {
my $mask = 0xffff; #Mask for current ports in group.
my $y = 2; #Next power of two to test
my $z = 1; #Number of ports in current group (Previous value of $y).
while ( ( ! ( $first % $y ) ) && ( $y <= $ports ) ) {
$mask <<= 1;
$z = $y;
$y <<= 1;
}
#
#
push @result, sprintf( '%04x', $first ) , sprintf( '%04x' , $mask & 0xffff );
$first += $z;
}
fatal_error "Invalid port range ($range)" unless @result; # first port > last port
@result;
} else {
( sprintf( '%04x' , validate_port( $proto, $range ) ) , 'ffff' );
}
}
sub valid_6address( $ ) { sub valid_6address( $ ) {
my $address = $_[0]; my $address = $_[0];

View File

@@ -127,7 +127,7 @@ sub setup_ecn()
} }
if ( @hosts ) { if ( @hosts ) {
my @interfaces = ( sort { interface_number($a) <=> interface_number($b) } keys %interfaces ); my @interfaces = ( keys %interfaces );
progress_message "$doing ECN control on @interfaces..."; progress_message "$doing ECN control on @interfaces...";
@@ -216,6 +216,7 @@ sub convert_blacklist() {
my $audit = $disposition =~ /^A_/; my $audit = $disposition =~ /^A_/;
my $target = $disposition; my $target = $disposition;
my $orig_target = $target; my $orig_target = $target;
my $warnings = 0;
my @rules; my @rules;
if ( @$zones || @$zones1 ) { if ( @$zones || @$zones1 ) {
@@ -237,12 +238,22 @@ sub convert_blacklist() {
return 0; return 0;
} }
directive_callback(
sub ()
{
warning_message "Omitted rules and compiler directives were not translated" unless $warnings++;
}
);
first_entry "Converting $fn..."; first_entry "Converting $fn...";
while ( read_a_line( NORMAL_READ ) ) { while ( read_a_line( NORMAL_READ ) ) {
my ( $networks, $protocol, $ports, $options ) = my ( $networks, $protocol, $ports, $options ) =
split_line( 'blacklist file', split_rawline2( 'blacklist file',
{ networks => 0, proto => 1, port => 2, options => 3 } ); { networks => 0, proto => 1, port => 2, options => 3 },
{},
4,
);
if ( $options eq '-' ) { if ( $options eq '-' ) {
$options = 'src'; $options = 'src';
@@ -300,6 +311,8 @@ sub convert_blacklist() {
} }
} }
directive_callback(0);
if ( @rules ) { if ( @rules ) {
my $fn1 = find_writable_file( 'blrules' ); my $fn1 = find_writable_file( 'blrules' );
my $blrules; my $blrules;
@@ -312,7 +325,7 @@ sub convert_blacklist() {
transfer_permissions( $fn, $fn1 ); transfer_permissions( $fn, $fn1 );
print $blrules <<'EOF'; print $blrules <<'EOF';
# #
# Shorewall version 5.0 - Blacklist Rules File # Shorewall - Blacklist Rules File
# #
# For information about entries in this file, type "man shorewall-blrules" # For information about entries in this file, type "man shorewall-blrules"
# #
@@ -394,7 +407,8 @@ sub convert_routestopped() {
if ( my $fn = open_file 'routestopped' ) { if ( my $fn = open_file 'routestopped' ) {
my ( @allhosts, %source, %dest , %notrack, @rule ); my ( @allhosts, %source, %dest , %notrack, @rule );
my $seq = 0; my $seq = 0;
my $warnings = 0;
my $date = compiletime; my $date = compiletime;
my ( $stoppedrules, $fn1 ); my ( $stoppedrules, $fn1 );
@@ -406,7 +420,7 @@ sub convert_routestopped() {
transfer_permissions( $fn, $fn1 ); transfer_permissions( $fn, $fn1 );
print $stoppedrules <<'EOF'; print $stoppedrules <<'EOF';
# #
# Shorewall version 5 - Stopped Rules File # Shorewall - Stopped Rules File
# #
# For information about entries in this file, type "man shorewall-stoppedrules" # For information about entries in this file, type "man shorewall-stoppedrules"
# #
@@ -422,6 +436,13 @@ sub convert_routestopped() {
EOF EOF
} }
directive_callback(
sub ()
{
warning_message "Omitted rules and compiler directives were not translated" unless $warnings++;
}
);
first_entry( first_entry(
sub { sub {
my $date = compiletime; my $date = compiletime;
@@ -436,13 +457,16 @@ EOF
while ( read_a_line ( NORMAL_READ ) ) { while ( read_a_line ( NORMAL_READ ) ) {
my ($interface, $hosts, $options , $proto, $ports, $sports ) = my ($interface, $hosts, $options , $proto, $ports, $sports ) =
split_line( 'routestopped file', split_rawline2( 'routestopped file',
{ interface => 0, hosts => 1, options => 2, proto => 3, dport => 4, sport => 5 } ); { interface => 0, hosts => 1, options => 2, proto => 3, dport => 4, sport => 5 },
{},
6,
0,
);
my $interfaceref; my $interfaceref;
fatal_error 'INTERFACE must be specified' if $interface eq '-'; 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 '-'; $hosts = ALLIP unless $hosts && $hosts ne '-';
my $routeback = 0; my $routeback = 0;
@@ -456,8 +480,6 @@ EOF
$hosts = ALLIP if $hosts eq '-'; $hosts = ALLIP if $hosts eq '-';
for my $host ( split /,/, $hosts ) { 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 @hosts, "$interface|$host|$seq";
push @rule, $rule; push @rule, $rule;
} }
@@ -501,6 +523,8 @@ EOF
push @allhosts, @hosts; push @allhosts, @hosts;
} }
directive_callback(0);
for my $host ( @allhosts ) { for my $host ( @allhosts ) {
my ( $interface, $h, $seq ) = split /\|/, $host; my ( $interface, $h, $seq ) = split /\|/, $host;
my $rule = shift @rule; my $rule = shift @rule;
@@ -643,6 +667,7 @@ sub create_docker_rules() {
my $chainref = $filter_table->{FORWARD}; my $chainref = $filter_table->{FORWARD};
add_commands( $chainref, '[ -n "$g_dockeringress" ] && echo "-A FORWARD -j DOCKER-INGRESS" >&3', );
add_commands( $chainref, '[ -n "$g_dockernetwork" ] && echo "-A FORWARD -j DOCKER-ISOLATION" >&3', ); add_commands( $chainref, '[ -n "$g_dockernetwork" ] && echo "-A FORWARD -j DOCKER-ISOLATION" >&3', );
if ( my $dockerref = known_interface('docker0') ) { if ( my $dockerref = known_interface('docker0') ) {
@@ -1004,7 +1029,7 @@ sub add_common_rules ( $ ) {
); );
} }
run_user_exit1 'initdone'; run_user_exit 'initdone';
if ( $upgrade ) { if ( $upgrade ) {
convert_blacklist; convert_blacklist;
@@ -1189,55 +1214,53 @@ sub add_common_rules ( $ ) {
} }
} }
if ( $family == F_IPV4 ) { my $announced = 0;
my $announced = 0;
$list = find_interfaces_by_option 'upnp'; $list = find_interfaces_by_option 'upnp';
if ( @$list ) { if ( @$list ) {
progress_message2 "$doing UPnP"; progress_message2 "$doing UPnP";
$chainref = set_optflags( new_nat_chain( 'UPnP' ), DONT_OPTIMIZE ); $chainref = set_optflags( new_nat_chain( 'UPnP' ), DONT_OPTIMIZE );
add_commands( $chainref, '[ -s /${VARDIR}/.UPnP ] && cat ${VARDIR}/.UPnP >&3' ); add_commands( $chainref, '[ -s /${VARDIR}/.UPnP ] && cat ${VARDIR}/.UPnP >&3' );
my $chainref1; my $chainref1;
if ( $config{MINIUPNPD} ) { if ( $config{MINIUPNPD} ) {
$chainref1 = set_optflags( new_nat_chain( 'MINIUPNPD-POSTROUTING' ), DONT_OPTIMIZE ); $chainref1 = set_optflags( new_nat_chain( 'MINIUPNPD-POSTROUTING' ), DONT_OPTIMIZE );
add_commands( $chainref, '[ -s /${VARDIR}/.MINIUPNPD-POSTROUTING ] && cat ${VARDIR}/.MINIUPNPD-POSTROUTING >&3' ); add_commands( $chainref, '[ -s /${VARDIR}/.MINIUPNPD-POSTROUTING ] && cat ${VARDIR}/.MINIUPNPD-POSTROUTING >&3' );
}
$announced = 1;
for $interface ( @$list ) {
add_ijump_extended $nat_table->{PREROUTING} , j => 'UPnP', get_interface_origin($interface), imatch_source_dev ( $interface );
add_ijump_extended $nat_table->{$globals{POSTROUTING}} , j => 'MINIUPNPD-POSTROUTING' , $origin{MINIUPNPD} , imatch_dest_dev ( $interface ) if $chainref1;
}
} }
$list = find_interfaces_by_option 'upnpclient'; $announced = 1;
if ( @$list ) { for $interface ( @$list ) {
progress_message2 "$doing UPnP" unless $announced; add_ijump_extended $nat_table->{PREROUTING} , j => 'UPnP', get_interface_origin($interface), imatch_source_dev ( $interface );
add_ijump_extended $nat_table->{$globals{POSTROUTING}} , j => 'MINIUPNPD-POSTROUTING' , $origin{MINIUPNPD} , imatch_dest_dev ( $interface ) if $chainref1;
}
}
for $interface ( @$list ) { $list = find_interfaces_by_option 'upnpclient';
my $chainref = $filter_table->{input_option_chain $interface};
my $base = uc var_base get_physical $interface;
my $optional = interface_is_optional( $interface );
my $variable = get_interface_gateway( $interface, ! $optional );
my $origin = get_interface_origin( $interface );
if ( $optional ) { if ( @$list ) {
add_commands( $chainref, progress_message2 "$doing UPnP" unless $announced;
qq(if [ -n "SW_\$${base}_IS_USABLE" -a -n "$variable" ]; then) );
incr_cmd_level( $chainref ); for $interface ( @$list ) {
add_ijump_extended( $chainref, j => 'ACCEPT', $origin, imatch_source_dev( $interface ), s => $variable, p => 'udp' ); my $chainref = $filter_table->{input_option_chain $interface};
decr_cmd_level( $chainref ); my $base = uc var_base get_physical $interface;
add_commands( $chainref, 'fi' ); my $optional = interface_is_optional( $interface );
} else { my $variable = get_interface_gateway( $interface, ! $optional );
add_ijump_extended( $chainref, j => 'ACCEPT', $origin, imatch_source_dev( $interface ), s => $variable, p => 'udp' ); my $origin = get_interface_origin( $interface );
}
if ( $optional ) {
add_commands( $chainref,
qq(if [ -n "SW_\$${base}_IS_USABLE" -a -n "$variable" ]; then) );
incr_cmd_level( $chainref );
add_ijump_extended( $chainref, j => 'ACCEPT', $origin, imatch_source_dev( $interface ), s => $variable, p => 'udp' );
decr_cmd_level( $chainref );
add_commands( $chainref, 'fi' );
} else {
add_ijump_extended( $chainref, j => 'ACCEPT', $origin, imatch_source_dev( $interface ), s => $variable, p => 'udp' );
} }
} }
} }
@@ -1273,7 +1296,7 @@ sub setup_mac_lists( $ ) {
$maclist_interfaces{ $hostref->[0] } = 1; $maclist_interfaces{ $hostref->[0] } = 1;
} }
my @maclist_interfaces = ( sort keys %maclist_interfaces ); my @maclist_interfaces = ( keys %maclist_interfaces );
if ( $phase == 1 ) { if ( $phase == 1 ) {
@@ -1430,8 +1453,6 @@ sub setup_mac_lists( $ ) {
} }
} }
run_user_exit2( 'maclog', $chainref );
log_irule_limit $level, $chainref , $chain , $disposition, [], $tag, 'add', '' if $level ne ''; log_irule_limit $level, $chainref , $chain , $disposition, [], $tag, 'add', '' if $level ne '';
add_ijump $chainref, j => $target; add_ijump $chainref, j => $target;
} }
@@ -1596,7 +1617,7 @@ sub handle_loopback_traffic() {
# Handle conntrack rules # Handle conntrack rules
# #
if ( $notrackref->{referenced} ) { if ( $notrackref->{referenced} ) {
for my $hostref ( sort { $a->{type} cmp $b->{type} } @{defined_zone( $z1 )->{hosts}{ip}{'%vserver%'}} ) { for my $hostref ( @{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;
@@ -1617,8 +1638,8 @@ sub handle_loopback_traffic() {
# #
my $source_hosts_ref = defined_zone( $z1 )->{hosts}; my $source_hosts_ref = defined_zone( $z1 )->{hosts};
for my $typeref ( sort { $a->{type} cmp $b->{type} } values %{$source_hosts_ref} ) { for my $typeref ( values %{$source_hosts_ref} ) {
for my $hostref ( sort { $a->{type} cmp $b->{type} } @{$typeref->{'%vserver%'}} ) { for my $hostref ( @{$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}} ) {
@@ -1640,7 +1661,7 @@ 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 = sort grep $_ ne '%vserver%', @_; my @interfaces = grep $_ ne '%vserver%', @_;
my $dummy; my $dummy;
my $lo_jump_added = interface_zone( loopback_interface ) && ! get_interface_option( loopback_interface, 'destonly' ); my $lo_jump_added = interface_zone( loopback_interface ) && ! get_interface_option( loopback_interface, 'destonly' );
# #
@@ -1657,12 +1678,6 @@ sub add_interface_jumps {
addnatjump $globals{POSTROUTING} , output_chain( $interface ) , imatch_dest_dev( $interface ); addnatjump $globals{POSTROUTING} , output_chain( $interface ) , imatch_dest_dev( $interface );
addnatjump $globals{POSTROUTING} , masq_chain( $interface ) , imatch_dest_dev( $interface ); addnatjump $globals{POSTROUTING} , masq_chain( $interface ) , imatch_dest_dev( $interface );
if ( have_capability 'RAWPOST_TABLE' ) {
insert_ijump ( $rawpost_table->{POSTROUTING}, j => postrouting_chain( $interface ), 0, imatch_dest_dev( $interface) ) if $rawpost_table->{postrouting_chain $interface};
insert_ijump ( $raw_table->{PREROUTING}, j => prerouting_chain( $interface ), 0, imatch_source_dev( $interface) ) if $raw_table->{prerouting_chain $interface};
insert_ijump ( $raw_table->{OUTPUT}, j => output_chain( $interface ), 0, imatch_dest_dev( $interface) ) if $raw_table->{output_chain $interface};
}
add_ijump( $mangle_table->{PREROUTING}, j => 'rpfilter' , imatch_source_dev( $interface ) ) if interface_has_option( $interface, 'rpfilter', $dummy ); add_ijump( $mangle_table->{PREROUTING}, j => 'rpfilter' , imatch_source_dev( $interface ) ) if interface_has_option( $interface, 'rpfilter', $dummy );
} }
# #
@@ -1760,7 +1775,7 @@ sub handle_complex_zone( $$ ) {
my $type = $zoneref->{type}; my $type = $zoneref->{type};
my $source_ref = ( $zoneref->{hosts}{ipsec} ) || {}; my $source_ref = ( $zoneref->{hosts}{ipsec} ) || {};
for my $interface ( sort { interface_number( $a ) <=> interface_number( $b ) } keys %$source_ref ) { for my $interface ( keys %$source_ref ) {
my $sourcechainref = $filter_table->{forward_chain $interface}; my $sourcechainref = $filter_table->{forward_chain $interface};
my @interfacematch; my @interfacematch;
my $interfaceref = find_interface $interface; my $interfaceref = find_interface $interface;
@@ -2272,9 +2287,9 @@ sub generate_matrix() {
# #
# Take care of PREROUTING, INPUT and OUTPUT jumps # Take care of PREROUTING, INPUT and OUTPUT jumps
# #
for my $type ( sort keys %$source_hosts_ref ) { for my $type ( keys %$source_hosts_ref ) {
my $typeref = $source_hosts_ref->{$type}; my $typeref = $source_hosts_ref->{$type};
for my $interface ( sort { interface_number( $a ) <=> interface_number( $b ) } keys %$typeref ) { for my $interface ( keys %$typeref ) {
if ( get_physical( $interface ) eq '+' ) { if ( get_physical( $interface ) eq '+' ) {
# #
# Insert the interface-specific jumps before this one which is not interface-specific # Insert the interface-specific jumps before this one which is not interface-specific
@@ -2359,9 +2374,9 @@ sub generate_matrix() {
my $chainref = $filter_table->{$chain}; #Will be null if $chain is a Netfilter Built-in target like ACCEPT my $chainref = $filter_table->{$chain}; #Will be null if $chain is a Netfilter Built-in target like ACCEPT
for my $type ( sort keys %{$zone1ref->{hosts}} ) { for my $type ( keys %{$zone1ref->{hosts}} ) {
my $typeref = $zone1ref->{hosts}{$type}; my $typeref = $zone1ref->{hosts}{$type};
for my $interface ( sort { interface_number( $a ) <=> interface_number( $b ) } keys %$typeref ) { for my $interface ( keys %$typeref ) {
for my $hostref ( @{$typeref->{$interface}} ) { for my $hostref ( @{$typeref->{$interface}} ) {
next if $hostref->{options}{sourceonly}; next if $hostref->{options}{sourceonly};
if ( $zone ne $zone1 || $num_ifaces > 1 || $hostref->{options}{routeback} ) { if ( $zone ne $zone1 || $num_ifaces > 1 || $hostref->{options}{routeback} ) {
@@ -2433,7 +2448,7 @@ sub setup_mss( ) {
my $clampmss = $config{CLAMPMSS}; my $clampmss = $config{CLAMPMSS};
my $option; my $option;
my @match; my @match;
my $chainref = $filter_table->{FORWARD}; my $chainref = $mangle_table->{FORWARD};
if ( $clampmss ) { if ( $clampmss ) {
if ( "\L$clampmss" eq 'yes' ) { if ( "\L$clampmss" eq 'yes' ) {
@@ -2740,6 +2755,9 @@ EOF
pop_indent; pop_indent;
emit ' emit '
rm -f ${VARDIR}/*.address
rm -f ${VARDIR}/*.gateway
run_stopped_exit'; run_stopped_exit';
my @ipsets = all_ipsets; my @ipsets = all_ipsets;

View File

@@ -36,8 +36,8 @@ use Shorewall::Providers qw( provider_realm );
use strict; use strict;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT = qw( setup_masq setup_nat setup_netmap add_addresses ); our @EXPORT = qw( setup_nat setup_netmap add_addresses );
our %EXPORT_TAGS = ( rules => [ qw ( handle_nat_rule handle_nonat_rule ) ] ); our %EXPORT_TAGS = ( rules => [ qw ( handle_nat_rule handle_nonat_rule process_one_masq convert_masq @addresses_to_add %addresses_to_add ) ] );
our @EXPORT_OK = (); our @EXPORT_OK = ();
Exporter::export_ok_tags('rules'); Exporter::export_ok_tags('rules');
@@ -62,7 +62,7 @@ sub initialize($) {
# #
sub process_one_masq1( $$$$$$$$$$$ ) sub process_one_masq1( $$$$$$$$$$$ )
{ {
my ($interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_; my ( $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_;
my $pre_nat; my $pre_nat;
my $add_snat_aliases = $family == F_IPV4 && $config{ADD_SNAT_ALIASES}; my $add_snat_aliases = $family == F_IPV4 && $config{ADD_SNAT_ALIASES};
@@ -70,10 +70,12 @@ sub process_one_masq1( $$$$$$$$$$$ )
my $baserule = ''; my $baserule = '';
my $inlinematches = ''; my $inlinematches = '';
my $prerule = ''; my $prerule = '';
my $savelist;
# #
# Leading '+' # Leading '+'
# #
$pre_nat = 1 if $interfacelist =~ s/^\+//; $pre_nat = 1 if $interfacelist =~ s/^\+//;
# #
# Check for INLINE # Check for INLINE
# #
@@ -82,7 +84,9 @@ sub process_one_masq1( $$$$$$$$$$$ )
$inlinematches = get_inline_matches(0); $inlinematches = get_inline_matches(0);
} else { } else {
$inlinematches = get_inline_matches(0); $inlinematches = get_inline_matches(0);
} }
$savelist = $interfacelist;
# #
# Handle early matches # Handle early matches
# #
@@ -149,9 +153,12 @@ sub process_one_masq1( $$$$$$$$$$$ )
$baserule .= do_user( $user ) if $user ne '-'; $baserule .= do_user( $user ) if $user ne '-';
$baserule .= do_probability( $probability ) if $probability ne '-'; $baserule .= do_probability( $probability ) if $probability ne '-';
my $target;
for my $fullinterface (split_list $interfacelist, 'interface' ) { for my $fullinterface (split_list $interfacelist, 'interface' ) {
my $rule = ''; my $rule = '';
my $target = 'MASQUERADE ';
$target = 'MASQUERADE ';
# #
# Isolate and verify the interface part # Isolate and verify the interface part
# #
@@ -193,6 +200,7 @@ sub process_one_masq1( $$$$$$$$$$$ )
# Parse the ADDRESSES column # Parse the ADDRESSES column
# #
if ( $addresses ne '-' ) { if ( $addresses ne '-' ) {
my $saveaddresses = $addresses;
if ( $addresses eq 'random' ) { if ( $addresses eq 'random' ) {
require_capability( 'MASQUERADE_TGT', 'Masquerade rules', '') if $family == F_IPV6; require_capability( 'MASQUERADE_TGT', 'Masquerade rules', '') if $family == F_IPV6;
$randomize = '--random '; $randomize = '--random ';
@@ -224,7 +232,7 @@ sub process_one_masq1( $$$$$$$$$$$ )
my $addrlist = ''; my $addrlist = '';
my @addrs = split_list $addresses, 'address'; my @addrs = split_list $addresses, 'address';
fatal_error "Only one IPv6 ADDRESS may be specified" if $family == F_IPV6 && @addrs > 1; fatal_error "Only one ADDRESS may be specified" if @addrs > 1;
for my $addr ( @addrs ) { for my $addr ( @addrs ) {
if ( $addr =~ /^([&%])(.+)$/ ) { if ( $addr =~ /^([&%])(.+)$/ ) {
@@ -240,6 +248,7 @@ sub process_one_masq1( $$$$$$$$$$$ )
# Address Variable # Address Variable
# #
$target = 'SNAT '; $target = 'SNAT ';
if ( $interface =~ /^{([a-zA-Z_]\w*)}$/ ) { if ( $interface =~ /^{([a-zA-Z_]\w*)}$/ ) {
# #
# User-defined address variable # User-defined address variable
@@ -269,14 +278,20 @@ sub process_one_masq1( $$$$$$$$$$$ )
} elsif ( $family == F_IPV4 ) { } elsif ( $family == F_IPV4 ) {
if ( $addr =~ /^.*\..*\..*\./ ) { if ( $addr =~ /^.*\..*\..*\./ ) {
$target = 'SNAT '; $target = 'SNAT ';
my ($ipaddr, $rest) = split ':', $addr; my ($ipaddr, $rest) = split ':', $addr, 2;
if ( $ipaddr =~ /^(.+)-(.+)$/ ) { if ( $ipaddr =~ /^(.+)-(.+)$/ ) {
validate_range( $1, $2 ); validate_range( $1, $2 );
} else { } else {
validate_address $ipaddr, 0; validate_address $ipaddr, 0;
} }
validate_portpair1( $proto, $rest ) if supplied $rest;
$addrlist .= "--to-source $addr "; if ( supplied $rest ) {
validate_portpair1( $proto, $rest );
$addrlist .= "--to-source $addr ";
} else {
$addrlist .= "--to-source $ipaddr";
}
$exceptionrule = do_proto( $proto, '', '' ) if $addr =~ /:/; $exceptionrule = do_proto( $proto, '', '' ) if $addr =~ /:/;
} else { } else {
my $ports = $addr; my $ports = $addr;
@@ -337,6 +352,7 @@ sub process_one_masq1( $$$$$$$$$$$ )
$target .= $randomize; $target .= $randomize;
$target .= $persistent; $target .= $persistent;
$addresses = $saveaddresses;
} else { } else {
require_capability( 'MASQUERADE_TGT', 'Masquerade rules', '' ) if $family == F_IPV6; require_capability( 'MASQUERADE_TGT', 'Masquerade rules', '' ) if $family == F_IPV6;
$add_snat_aliases = 0; $add_snat_aliases = 0;
@@ -386,32 +402,250 @@ sub process_one_masq1( $$$$$$$$$$$ )
} }
sub process_one_masq( ) sub convert_one_masq1( $$$$$$$$$$$$ )
{ {
my ($interfacelist, $networks, $addresses, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = my ( $snat, $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_;
split_line2( 'masq file',
{ interface => 0, source => 1, address => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 },
{}, #Nopad
undef, #Columns
1 ); #Allow inline matches
fatal_error 'INTERFACE must be specified' if $interfacelist eq '-'; my $pre_nat;
my $destnets = '';
my $savelist;
#
# Leading '+'
#
$pre_nat = ( $interfacelist =~ s/^\+// );
#
# Check for INLINE
#
if ( $interfacelist =~ /^INLINE\((.+)\)$/ ) {
$interfacelist = $1;
}
for my $proto ( split_list $protos, 'Protocol' ) { $savelist = $interfacelist;
process_one_masq1( $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ); #
# Parse the remaining part of the INTERFACE column
#
if ( $family == F_IPV4 ) {
if ( $interfacelist =~ /^([^:]+)::([^:]*)$/ ) {
$destnets = $2;
$interfacelist = $1;
} elsif ( $interfacelist =~ /^([^:]+:[^:]+):([^:]+)$/ ) {
$destnets = $2;
$interfacelist = $1;
} elsif ( $interfacelist =~ /^([^:]+):$/ ) {
$interfacelist = $1;
} elsif ( $interfacelist =~ /^([^:]+):([^:]*)$/ ) {
my ( $one, $two ) = ( $1, $2 );
if ( $2 =~ /\./ || $2 =~ /^%/ ) {
$interfacelist = $one;
$destnets = $two;
}
}
} elsif ( $interfacelist =~ /^(.+?):(.+)$/ ) {
$interfacelist = $1;
$destnets = $2;
}
#
# If there is no source or destination then allow all addresses
#
$networks = ALLIP if $networks eq '-';
$destnets = ALLIP if $destnets eq '-';
my $target;
#
# Parse the ADDRESSES column
#
if ( $addresses ne '-' ) {
my $saveaddresses = $addresses;
if ( $addresses ne 'random' ) {
$addresses =~ s/:persistent$//;
$addresses =~ s/:random$//;
if ( $addresses eq 'detect' ) {
$target = 'SNAT';
} elsif ( $addresses eq 'NONAT' ) {
$target = 'CONTINUE';
} elsif ( $addresses ) {
if ( $addresses =~ /^:/ ) {
$target = 'MASQUERADE';
} else {
$target = 'SNAT';
}
}
}
$addresses = $saveaddresses;
} else {
$target = 'MASQUERADE';
}
if ( $snat ) {
$target .= '+' if $pre_nat;
if ( $addresses ne '-' && $addresses ne 'NONAT' ) {
$addresses =~ s/^://;
$target .= '(' . $addresses . ')';
}
my $line = "$target\t$networks\t$savelist\t$proto\t$ports\t$ipsec\t$mark\t$user\t$condition\t$origdest\t$probability";
#
# Supress superfluous trailing dashes
#
$line =~ s/(?:\t-)+$//;
my $raw_matches = fetch_inline_matches;
$line .= join( '', ' ;;', $raw_matches ) if $raw_matches ne ' ';
print $snat "$line\n";
}
progress_message " Masq record \"$rawcurrentline\" Converted";
}
sub process_one_masq( $ )
{
my ( $snat ) = @_;
if ( $snat ) {
unless ( $rawcurrentline =~ /^\s*(?:#.*)?$/ ) {
#
# Line was not blank or all comment
#
my ($interfacelist, $networks, $addresses, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) =
split_rawline2( 'masq file',
{ interface => 0, source => 1, address => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 },
{}, #Nopad
undef, #Columns
1 ); #Allow inline matches
if ( $interfacelist ne '-' ) {
for my $proto ( split_list $protos, 'Protocol' ) {
convert_one_masq1( $snat, $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability );
}
}
}
} else {
my ($interfacelist, $networks, $addresses, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) =
split_line2( 'masq file',
{ interface => 0, source => 1, address => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 },
{}, #Nopad
undef, #Columns
1 ); #Allow inline matches
fatal_error 'INTERFACE must be specified' if $interfacelist eq '-';
for my $proto ( split_list $protos, 'Protocol' ) {
process_one_masq1( $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability );
}
} }
} }
sub open_snat_for_output( $ ) {
my ($fn ) = @_;
my ( $snat, $fn1 );
if ( -f ( $fn1 = find_writable_file( 'snat' ) ) ) {
open( $snat , '>>', $fn1 ) || fatal_error "Unable to open $fn1:$!";
} else {
open( $snat , '>', $fn1 ) || fatal_error "Unable to open $fn1:$!";
#
# Transfer permissions from the existing masq file to the new snat file
#
transfer_permissions( $fn, $fn1 );
if ( $family == F_IPV4 ) {
print $snat <<'EOF';
# #
# Process the masq file # Shorewall - SNAT/Masquerade File
# #
sub setup_masq() # For information about entries in this file, type "man shorewall-snat"
{ #
# See http://shorewall.net/manpages/shorewall-snat.html for additional information
EOF
} else {
print $snat <<'EOF';
#
# Shorewall6 - SNAT/Masquerade File
#
# For information about entries in this file, type "man shorewall6-snat"
#
# See http://shorewall.net/manpages6/shorewall6-snat.html for additional information
EOF
}
print $snat <<'EOF';
###################################################################################################################
#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
EOF
}
return ( $snat, $fn1 );
}
#
# Convert a masq file into the equivalent snat file
#
sub convert_masq() {
if ( my $fn = open_file( 'masq', 1, 1 ) ) { if ( my $fn = open_file( 'masq', 1, 1 ) ) {
my ( $snat, $fn1 ) = open_snat_for_output( $fn );
first_entry( sub { progress_message2 "$doing $fn..."; require_capability 'NAT_ENABLED' , "a non-empty masq file" , 's'; } ); my $have_masq_rules;
process_one_masq while read_a_line( NORMAL_READ ); directive_callback(
sub ()
{
if ( $_[0] eq 'OMITTED' ) {
#
# Convert the raw rule
#
process_one_masq( $snat) if $snat;
} else {
print $snat "$_[1]\n"; 0;
}
}
);
first_entry(
sub {
my $date = compiletime;
progress_message2 "Converting $fn...";
print( $snat
"#\n" ,
"# Rules generated from masq file $fn by Shorewall $globals{VERSION} - $date\n" ,
"#\n" );
}
);
while ( read_a_line( NORMAL_READ ) ) {
#
# Process the file normally
#
process_one_masq(0);
#
# Now Convert it
#
process_one_masq($snat);
$have_masq_rules++;
}
if ( $have_masq_rules ) {
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 {
if ( unlink $fn ) {
warning_message "Empty masq file ($fn) removed";
} else {
warning_message "Unable to remove empty masq file $fn: $!";
}
}
close $snat, directive_callback( 0 );
} }
} }
@@ -556,88 +790,39 @@ sub setup_netmap() {
my @rule = do_iproto( $proto, $dport, $sport ); my @rule = do_iproto( $proto, $dport, $sport );
unless ( $type =~ /:/ ) { my @rulein;
my @rulein; my @ruleout;
my @ruleout;
$net1 = validate_net $net1, 0; $net1 = validate_net $net1, 0;
$net2 = validate_net $net2, 0; $net2 = validate_net $net2, 0;
if ( $interfaceref->{root} ) { if ( $interfaceref->{root} ) {
$interface = $interfaceref->{name} if $interface eq $interfaceref->{physical}; $interface = $interfaceref->{name} if $interface eq $interfaceref->{physical};
} else { } else {
@rulein = imatch_source_dev( $interface ); @rulein = imatch_source_dev( $interface );
@ruleout = imatch_dest_dev( $interface ); @ruleout = imatch_dest_dev( $interface );
$interface = $interfaceref->{name}; $interface = $interfaceref->{name};
} }
require_capability 'NAT_ENABLED', 'Stateful NAT Entries', ''; require_capability 'NETMAP_TARGET', 'Stateful Netmap Entries', '';
if ( $type eq 'DNAT' ) { if ( $type eq 'DNAT' ) {
dest_iexclusion( ensure_chain( 'nat' , input_chain $interface ) , dest_iexclusion( ensure_chain( 'nat' , input_chain $interface ) ,
j => 'NETMAP' , j => 'NETMAP' ,
"--to $net2", "--to $net2",
$net1 , $net1 ,
@rulein , @rulein ,
imatch_source_net( $net3 ) ); imatch_source_net( $net3 ) );
} elsif ( $type eq 'SNAT' ) { } elsif ( $type eq 'SNAT' ) {
source_iexclusion( ensure_chain( 'nat' , output_chain $interface ) , source_iexclusion( ensure_chain( 'nat' , output_chain $interface ) ,
j => 'NETMAP' , j => 'NETMAP' ,
"--to $net2" , "--to $net2" ,
$net1 , $net1 ,
@ruleout , @ruleout ,
imatch_dest_net( $net3 ) ); imatch_dest_net( $net3 ) );
} else {
fatal_error "Invalid type ($type)";
}
} elsif ( $type =~ /^(DNAT|SNAT):([POT])$/ ) {
my ( $target , $chain ) = ( $1, $2 );
my $table = 'raw';
my @match;
require_capability 'RAWPOST_TABLE', 'Stateless NAT Entries', '';
$net2 = validate_net $net2, 0;
unless ( $interfaceref->{root} ) {
@match = imatch_dest_dev( $interface );
$interface = $interfaceref->{name};
}
if ( $chain eq 'P' ) {
$chain = prerouting_chain $interface;
@match = imatch_source_dev( $iface ) unless $iface eq $interface;
} elsif ( $chain eq 'O' ) {
$chain = output_chain $interface;
} else {
$chain = postrouting_chain $interface;
$table = 'rawpost';
}
my $chainref = ensure_chain( $table, $chain );
if ( $target eq 'DNAT' ) {
dest_iexclusion( $chainref ,
j => 'RAWDNAT' ,
"--to-dest $net2" ,
$net1 ,
imatch_source_net( $net3 ) ,
@rule ,
@match
);
} else {
source_iexclusion( $chainref ,
j => 'RAWSNAT' ,
"--to-source $net2" ,
$net1 ,
imatch_dest_net( $net3 ) ,
@rule ,
@match );
}
} else { } else {
fatal_error 'TYPE must be specified' if $type eq '-'; fatal_error 'TYPE must be specified' if $type eq '-';
fatal_error "Invalid TYPE ($type)"; fatal_error "Invalid type ($type)";
} }
progress_message " Network $net1 on $iface mapped to $net2 ($type)"; progress_message " Network $net1 on $iface mapped to $net2 ($type)";
@@ -756,7 +941,17 @@ sub handle_nat_rule( $$$$$$$$$$$$$ ) {
} else { } else {
$server = $1 if $family == F_IPV6 && $server =~ /^\[(.+)\]$/; $server = $1 if $family == F_IPV6 && $server =~ /^\[(.+)\]$/;
fatal_error "Invalid server IP address ($server)" if $server eq ALLIP || $server eq NILIP; fatal_error "Invalid server IP address ($server)" if $server eq ALLIP || $server eq NILIP;
my @servers = validate_address $server, 1;
my @servers;
if ( ( $server =~ /^([&%])(.+)/ ) ) {
$server = record_runtime_address( $1, $2 );
$server =~ s/ $//;
@servers = ( $server );
} else {
@servers = validate_address $server, 1;
}
$server = join ',', @servers; $server = join ',', @servers;
} }

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