Compare commits

..

281 Commits

Author SHA1 Message Date
Tom Eastep
a98c1d5b35 Correct convertion of tcrules->mangle when a writable mangle exists
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 15:23:58 -08:00
Tom Eastep
928f54d37c Correct logging in inline policy actions
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 13:37:59 -08:00
Tom Eastep
073235aa48 Correct typo in action.AllowICMPs
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 13:03:49 -08:00
Tom Eastep
519fef5e87 Clear the firewall on Debian systemd 'stop' command
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 11:53:47 -08:00
Tom Eastep
944651e46d Correct compiler directives WRT omitting
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 11:51:40 -08:00
Tom Eastep
bdf0950317 Correct the handling of tcp-reset
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 11:44:45 -08:00
Tom Eastep
2fb1f9db01 Change AllowICMPs to an inline action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 11:41:05 -08:00
Tom Eastep
c3661ad476 Change macro.ICMPs to an inline action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-07 11:30:38 -08:00
Tom Eastep
a4dcc3f555 Restore logging to the BLACKLIST action
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-03-03 10:19:07 -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
e8a5c45aae Correct FAQ 1e
Signed-off-by: Tom Eastep <teastep@shorewall.net>
2017-02-25 09:10:40 -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
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
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
210 changed files with 9292 additions and 9552 deletions

View File

@@ -365,6 +365,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
@@ -380,6 +386,31 @@ for f in lib.* ; do
echo "Library ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/shorewall/$f" echo "Library ${f#*.} file installed as ${DESTDIR}${SHAREDIR}/shorewall/$f"
done done
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.core
eval sed -i \'s\|/usr/share/\|${SHAREDIR}/\|\' ${DESTDIR}${SHAREDIR}/${PRODUCT}/lib.cli
fi
#
# Install the Man Pages
#
if [ -n "$MANDIR" ]; then
cd manpages
[ -n "$INSTALLD" ] || mkdir -p ${DESTDIR}${MANDIR}/man8/
for f in *.8; do
gzip -9c $f > $f.gz
install_file $f.gz ${DESTDIR}${MANDIR}/man8/$f.gz 644
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
# #

View File

@@ -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=50100
[ -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,48 @@ 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
#
spd_filter()
{
awk \
'BEGIN { skip=0; }; \
/^src/ { skip=0; }; \
/^src 0.0.0.0\/0/ { skip=1; }; \
/^src ::\/0/ { skip=1; }; \
{ if ( skip == 0 ) print; };'
}
#
# Print a heading with leading and trailing black lines
#
heading() {
echo
echo "$@"
echo
}
show_ipsec() {
heading "PFKEY SPD"
$IP -s 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 +1189,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 +1239,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 +1293,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 +1360,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 +1430,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 +1696,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 +1746,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
@@ -1805,6 +1817,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 +1882,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 +1946,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 +2746,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=
@@ -2795,6 +2801,8 @@ determine_capabilities() {
IFACE_MATCH= IFACE_MATCH=
TCPMSS_TARGET= TCPMSS_TARGET=
WAIT_OPTION= WAIT_OPTION=
CPU_FANOUT=
NETMAP_TARGET=
AMANDA_HELPER= AMANDA_HELPER=
FTP_HELPER= FTP_HELPER=
@@ -2829,8 +2837,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 +3000,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 +3101,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
# #
@@ -3211,7 +3225,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
@@ -3290,6 +3303,8 @@ report_capabilities_unsorted() {
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
echo " Kernel Version (KERNELVERSION): $KERNELVERSION" echo " Kernel Version (KERNELVERSION): $KERNELVERSION"
echo " Capabilities Version (CAPVERSION): $CAPVERSION" echo " Capabilities Version (CAPVERSION): $CAPVERSION"
@@ -3339,7 +3354,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 +3409,8 @@ 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 AMANDA_HELPER report_capability1 AMANDA_HELPER
report_capability1 FTP_HELPER report_capability1 FTP_HELPER
@@ -3566,7 +3582,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 +3592,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
@@ -3866,7 +3882,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,6 +4008,7 @@ get_config() {
g_loopback=$(find_loopback_interfaces) g_loopback=$(find_loopback_interfaces)
if [ -z "$g_nopager" ]; then
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER [ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
if [ -n "$PAGER" -a -t 1 ]; then if [ -n "$PAGER" -a -t 1 ]; then
@@ -4010,6 +4027,7 @@ get_config() {
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
@@ -4270,6 +4288,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 +4304,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 +4335,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 +4377,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 +4479,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 +4524,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 +4548,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

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

@@ -0,0 +1,440 @@
#
# Shorewall 5.0 -- /usr/share/shorewall/lib.core
#
# (c) 1999-2015 - 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=50100
#
# 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

@@ -32,11 +32,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

@@ -81,7 +81,6 @@ if [ $# -eq 0 ]; then
. ./shorewallrc . ./shorewallrc
elif [ -f ~/.shorewallrc ]; then elif [ -f ~/.shorewallrc ]; then
. ~/.shorewallrc || exit 1 . ~/.shorewallrc || exit 1
file=./.shorewallrc
elif [ -f /usr/share/shorewall/shorewallrc ]; then elif [ -f /usr/share/shorewall/shorewallrc ]; then
. /usr/share/shorewall/shorewallrc . /usr/share/shorewall/shorewallrc
else else

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

@@ -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,8 +73,10 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ $PRODUCT = shorewall ]; then
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
else else
return 0 return 0
fi fi
@@ -102,7 +104,7 @@ 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
@@ -123,7 +125,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,7 +142,7 @@ 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 if [ -x ${STATEDIR}/firewall ]; then

View File

@@ -44,8 +44,10 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT == shorewall -o $PRODUCT == shorewall6 ]; then if [ $PRODUCT = shorewall ]; then
${SBINDIR}/$PRODUCT $OPTIONS compile -c ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
else else
return 0 return 0
fi fi
@@ -62,7 +64,7 @@ start () {
return 6 #Not configured return 6 #Not configured
fi fi
echo -n "Initializing \"Shorewall-based firewalls\": " printf "Initializing \"Shorewall-based firewalls\": "
for PRODUCT in $PRODUCTS; do for PRODUCT in $PRODUCTS; do
setstatedir setstatedir
@@ -97,7 +99,7 @@ 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

View File

@@ -75,8 +75,10 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ $PRODUCT = shorewall ]; then
${SBINDIR}/$PRODUCT ${OPTIONS} compile $STATEDIR/firewall ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
else else
return 0 return 0
fi fi
@@ -87,7 +89,7 @@ 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 [ -x ${STATEDIR}/firewall ]; then
@@ -112,7 +114,7 @@ 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 if [ -x ${STATEDIR}/firewall ]; then

View File

@@ -81,7 +81,7 @@ 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 [ -x ${STATEDIR}/firewall ]; then
@@ -104,7 +104,7 @@ 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 if [ -x ${STATEDIR}/firewall ]; then

View File

@@ -79,8 +79,10 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ $PRODUCT = shorewall ]; then
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
else else
return 0 return 0
fi fi
@@ -91,7 +93,7 @@ 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 [ -x $STATEDIR/firewall ]; then
@@ -112,7 +114,7 @@ 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 if [ -x ${STATEDIR}/firewall ]; then

View File

@@ -164,10 +164,10 @@ if [ $# -eq 0 ]; then
# #
if [ -f ./shorewallrc ]; then if [ -f ./shorewallrc ]; then
. ./shorewallrc || exit 1 . ./shorewallrc || exit 1
file=~/.shorewallrc file=./shorewallrc
elif [ -f ~/.shorewallrc ]; then elif [ -f ~/.shorewallrc ]; then
. ~/.shorewallrc || exit 1 . ~/.shorewallrc || exit 1
file=./.shorewallrc file=~/.shorewallrc
else else
fatal_error "No configuration file specified and ~/.shorewallrc not found" fatal_error "No configuration file specified and ~/.shorewallrc not found"
fi fi

View File

@@ -33,8 +33,10 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ $PRODUCT = shorewall ]; then
${SBINDIR}/$PRODUCT ${OPTIONS} compile -c ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
else else
return 0 return 0
fi fi
@@ -62,7 +64,7 @@ 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 [ -x ${STATEDIR}/firewall ]; then
@@ -90,7 +92,7 @@ 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 if [ -x ${STATEDIR}/firewall ]; then

View File

@@ -126,7 +126,6 @@ if [ $# -eq 0 ]; then
. ./shorewallrc . ./shorewallrc
elif [ -f ~/.shorewallrc ]; then elif [ -f ~/.shorewallrc ]; then
. ~/.shorewallrc || exit 1 . ~/.shorewallrc || exit 1
file=./.shorewallrc
elif [ -f /usr/share/shorewall/shorewallrc ]; then elif [ -f /usr/share/shorewall/shorewallrc ]; then
. /usr/share/shorewall/shorewallrc . /usr/share/shorewall/shorewallrc
else else

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

@@ -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

@@ -114,7 +114,7 @@ require()
# #
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
@@ -331,7 +331,6 @@ if [ -n "$DESTDIR" ]; then
OWNERSHIP="" OWNERSHIP=""
fi fi
make_directory ${DESTDIR}${SBINDIR} 755
make_directory ${DESTDIR}${INITDIR} 755 make_directory ${DESTDIR}${INITDIR} 755
else else
@@ -362,9 +361,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,17 +371,15 @@ 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_directory ${DESTDIR}${INITDIR} 755 [ -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 mkdir -p ${DESTDIR}${CONFDIR}/$PRODUCT
mkdir -p ${DESTDIR}${SHAREDIR}/$PRODUCT mkdir -p ${DESTDIR}${SHAREDIR}/$PRODUCT
mkdir -p ${DESTDIR}${LIBEXECDIR}/$PRODUCT mkdir -p ${DESTDIR}${LIBEXECDIR}/$PRODUCT
mkdir -p ${DESTDIR}${SBINDIR}
mkdir -p ${DESTDIR}${VARDIR} mkdir -p ${DESTDIR}${VARDIR}
chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT chmod 755 ${DESTDIR}${CONFDIR}/$PRODUCT
@@ -433,15 +430,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
# #
@@ -498,7 +486,7 @@ 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/ mkdir -p ${DESTDIR}${MANDIR}/man5/
for f in *.5; do for f in *.5; do
gzip -c $f > $f.gz gzip -c $f > $f.gz
@@ -506,6 +494,8 @@ if [ -d manpages -a -n "$MANDIR" ]; then
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
mkdir -p ${DESTDIR}${MANDIR}/man8/
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 644
@@ -540,6 +530,11 @@ 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
# #
@@ -555,7 +550,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

File diff suppressed because it is too large Load Diff

View File

@@ -45,19 +45,20 @@
# 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

@@ -125,7 +125,6 @@ if [ $# -eq 0 ]; then
. ./shorewallrc . ./shorewallrc
elif [ -f ~/.shorewallrc ]; then elif [ -f ~/.shorewallrc ]; then
. ~/.shorewallrc || exit 1 . ~/.shorewallrc || exit 1
file=./.shorewallrc
elif [ -f /usr/share/shorewall/shorewallrc ]; then elif [ -f /usr/share/shorewall/shorewallrc ]; then
. /usr/share/shorewall/shorewallrc . /usr/share/shorewall/shorewallrc
else else

View File

@@ -12,6 +12,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!!!!!!!!!
# #
?require AUDIT_TARGET
############################################################################### ###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT #ACTION SOURCE DEST PROTO DPORT SPORT
# #

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

@@ -0,0 +1,11 @@
#
# Shorewall -- /usr/share/shorewall/action.AllowICMPs
#
# This action ACCEPTs needed ICMP types.
#
###############################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER
DEFAULTS ACCEPT
@1 - - icmp fragmentation-needed {comment="Needed ICMP types"}
@1 - - icmp time-exceeded {comment="Needed ICMP types"}

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

@@ -30,7 +30,6 @@ DEFAULTS DROP,-
?if __ADDRTYPE ?if __ADDRTYPE
@1 - - - ;; -m addrtype --dst-type BROADCAST @1 - - - ;; -m addrtype --dst-type BROADCAST
@1 - - - ;; -m addrtype --dst-type MULTICAST
@1 - - - ;; -m addrtype --dst-type ANYCAST @1 - - - ;; -m addrtype --dst-type ANYCAST
?else ?else
?begin perl; ?begin perl;
@@ -50,9 +49,6 @@ add_jump $chainref, $action, 0, "-d \$address ";
decr_cmd_level $chainref; decr_cmd_level $chainref;
add_commands $chainref, 'done'; add_commands $chainref, 'done';
log_rule_limit $level, $chainref, 'Broadcast' , $action, '', $tag, 'add', ' -d 224.0.0.0/4 ' if $level ne '';
add_jump $chainref, $action, 0, '-d 224.0.0.0/4 ';
1; 1;
?end perl; ?end perl;

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,27 @@
#
# 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>)
#
# This is a built-in action.
#
###############################################################################

View File

@@ -0,0 +1,50 @@
#
# Shorewall -- /usr/share/shorewall/action.Multicast
#
# 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.
#
# Multicast[([<action>|-[,{audit|-}])]
#
# Default action is DROP
#
###############################################################################
DEFAULTS DROP,-
?if __ADDRTYPE
@1 - - - ;; -m addrtype --dst-type MULTICAST
?else
?begin perl;
use Shorewall::IPAddrs;
use Shorewall::Config;
use Shorewall::Chains;
my ( $action ) = get_action_params( 1 );
my $chainref = get_action_chain;
my ( $level, $tag ) = get_action_logging;
log_rule_limit $level, $chainref, 'Multicast' , $action, '', $tag, 'add', ' -d 224.0.0.0/4 ' if $level ne '';
add_jump $chainref, $action, 0, '-d 224.0.0.0/4 ';
1;
?end perl;
?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

@@ -0,0 +1,27 @@
#
# 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])]
#
# This is a built-in action.
#
###############################################################################

View File

@@ -0,0 +1,27 @@
#
# 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])]
#
# This is a built-in action.
#
###############################################################################

View File

@@ -0,0 +1,27 @@
#
# 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])]
#
# This is a built-in action.
#
###############################################################################

View File

@@ -0,0 +1,27 @@
#
# 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])]
#
# This is a built-in action.
#
###############################################################################

View File

@@ -0,0 +1,27 @@
#
# 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])]
#
# This is a built-in action.
#
###############################################################################

View File

@@ -0,0 +1,27 @@
#
# 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])]
#
# This is a built-in action.
#
###############################################################################

View File

@@ -0,0 +1,27 @@
#
# 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
#
# This is a built-in action.
#
###############################################################################

View File

@@ -0,0 +1,27 @@
#
# 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])]
#
# This is a built-in action.
#
###############################################################################

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

@@ -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

@@ -120,7 +120,6 @@ our @EXPORT = ( qw(
%chain_table %chain_table
%targets %targets
$raw_table $raw_table
$rawpost_table
$nat_table $nat_table
$mangle_table $mangle_table
$filter_table $filter_table
@@ -197,7 +196,6 @@ our %EXPORT_TAGS = (
ensure_mangle_chain ensure_mangle_chain
ensure_nat_chain ensure_nat_chain
ensure_raw_chain ensure_raw_chain
ensure_rawpost_chain
new_standard_chain new_standard_chain
new_action_chain new_action_chain
new_builtin_chain new_builtin_chain
@@ -266,10 +264,12 @@ our %EXPORT_TAGS = (
set_chain_variables set_chain_variables
mark_firewall_not_started mark_firewall_not_started
mark_firewall6_not_started mark_firewall6_not_started
interface_address
get_interface_address get_interface_address
get_interface_addresses get_interface_addresses
get_interface_bcasts get_interface_bcasts
get_interface_acasts get_interface_acasts
interface_gateway
get_interface_gateway get_interface_gateway
get_interface_mac get_interface_mac
have_global_variables have_global_variables
@@ -416,7 +416,6 @@ our $VERSION = 'MODULEVERSION';
# #
our %chain_table; our %chain_table;
our $raw_table; our $raw_table;
our $rawpost_table;
our $nat_table; our $nat_table;
our $mangle_table; our $mangle_table;
our $filter_table; our $filter_table;
@@ -757,13 +756,11 @@ sub initialize( $$$ ) {
( $family, my $hard, $export ) = @_; ( $family, my $hard, $export ) = @_;
%chain_table = ( raw => {}, %chain_table = ( raw => {},
rawpost => {},
mangle => {}, mangle => {},
nat => {}, nat => {},
filter => {} ); filter => {} );
$raw_table = $chain_table{raw}; $raw_table = $chain_table{raw};
$rawpost_table = $chain_table{rawpost};
$nat_table = $chain_table{nat}; $nat_table = $chain_table{nat};
$mangle_table = $chain_table{mangle}; $mangle_table = $chain_table{mangle};
$filter_table = $chain_table{filter}; $filter_table = $chain_table{filter};
@@ -808,7 +805,6 @@ sub initialize( $$$ ) {
DNAT => 1, DNAT => 1,
MASQUERADE => 1, MASQUERADE => 1,
NETMAP => 1, NETMAP => 1,
NFQUEUE => 1,
NOTRACK => 1, NOTRACK => 1,
RAWDNAT => 1, RAWDNAT => 1,
REDIRECT => 1, REDIRECT => 1,
@@ -1194,9 +1190,16 @@ sub compatible( $$ ) {
} }
} }
# #
# Don't combine chains where each specifies '-m policy' # Don't combine chains where each specifies
# -m policy
# or when one specifies
# -m multiport
# and the other specifies
# --dport or --sport or -m multiport
# #
return ! ( $ref1->{policy} && $ref2->{policy} ); return ! ( $ref1->{policy} && $ref2->{policy} ||
( ( $ref1->{multiport} && ( $ref2->{dport} || $ref2->{sport} || $ref2->{multiport} ) ) ||
( $ref2->{multiport} && ( $ref1->{dport} || $ref1->{sport} ) ) ) );
} }
# #
@@ -1216,6 +1219,7 @@ sub merge_rules( $$$ ) {
if ( exists $fromref->{$option} ) { if ( exists $fromref->{$option} ) {
push( @{$toref->{matches}}, $option ) unless exists $toref->{$option}; push( @{$toref->{matches}}, $option ) unless exists $toref->{$option};
$toref->{$option} = $fromref->{$option}; $toref->{$option} = $fromref->{$option};
$toref->{simple} = 0;
} }
} }
@@ -2717,24 +2721,6 @@ sub ensure_accounting_chain( $$$ )
$chainref->{restricted} = NO_RESTRICT; $chainref->{restricted} = NO_RESTRICT;
$chainref->{ipsec} = $ipsec; $chainref->{ipsec} = $ipsec;
$chainref->{optflags} |= ( DONT_OPTIMIZE | DONT_MOVE | DONT_DELETE ) unless $config{OPTIMIZE_ACCOUNTING}; $chainref->{optflags} |= ( DONT_OPTIMIZE | DONT_MOVE | DONT_DELETE ) unless $config{OPTIMIZE_ACCOUNTING};
if ( $config{CHAIN_SCRIPTS} ) {
unless ( $chain eq 'accounting' ) {
my $file = find_file $chain;
if ( -f $file ) {
progress_message "Running $file...";
my ( $level, $tag ) = ( '', '' );
unless ( my $return = eval `cat $file` ) {
fatal_error "Couldn't parse $file: $@" if $@;
fatal_error "Couldn't do $file: $!" unless defined $return;
fatal_error "Couldn't run $file" unless $return;
}
}
}
}
} }
$chainref; $chainref;
@@ -2747,11 +2733,13 @@ sub accounting_chainrefs() {
grep $_->{accounting} , values %$filter_table; grep $_->{accounting} , values %$filter_table;
} }
sub ensure_mangle_chain($) { sub ensure_mangle_chain($;$$) {
my $chain = $_[0]; my ( $chain, $number, $restriction ) = @_;
my $chainref = ensure_chain 'mangle', $chain; my $chainref = ensure_chain 'mangle', $chain;
$chainref->{referenced} = 1; $chainref->{referenced} = 1;
$chainref->{chainnumber} = $number if $number;
$chainref->{restriction} = $restriction if $restriction;
$chainref; $chainref;
} }
@@ -2771,14 +2759,6 @@ sub ensure_raw_chain($) {
$chainref; $chainref;
} }
sub ensure_rawpost_chain($) {
my $chain = $_[0];
my $chainref = ensure_chain 'rawpost', $chain;
$chainref->{referenced} = 1;
$chainref;
}
# #
# Add a builtin chain # Add a builtin chain
# #
@@ -2977,8 +2957,6 @@ sub initialize_chain_table($) {
new_builtin_chain( 'raw', $chain, 'ACCEPT' )->{insert} = 0; new_builtin_chain( 'raw', $chain, 'ACCEPT' )->{insert} = 0;
} }
new_builtin_chain 'rawpost', 'POSTROUTING', 'ACCEPT';
for my $chain ( qw(INPUT OUTPUT FORWARD) ) { for my $chain ( qw(INPUT OUTPUT FORWARD) ) {
new_builtin_chain 'filter', $chain, 'DROP'; new_builtin_chain 'filter', $chain, 'DROP';
} }
@@ -3041,8 +3019,6 @@ sub initialize_chain_table($) {
new_builtin_chain( 'raw', $chain, 'ACCEPT' )->{insert} = 0; new_builtin_chain( 'raw', $chain, 'ACCEPT' )->{insert} = 0;
} }
new_builtin_chain 'rawpost', 'POSTROUTING', 'ACCEPT';
for my $chain ( qw(INPUT OUTPUT FORWARD) ) { for my $chain ( qw(INPUT OUTPUT FORWARD) ) {
new_builtin_chain 'filter', $chain, 'DROP'; new_builtin_chain 'filter', $chain, 'DROP';
} }
@@ -3346,7 +3322,7 @@ sub check_optimization( $ ) {
# When an unreferenced chain is found, it is deleted unless its 'dont_delete' flag is set. # When an unreferenced chain is found, it is deleted unless its 'dont_delete' flag is set.
# #
sub optimize_level0() { sub optimize_level0() {
for my $table ( qw/raw rawpost mangle nat filter/ ) { for my $table ( qw/raw mangle nat filter/ ) {
my $tableref = $chain_table{$table}; my $tableref = $chain_table{$table};
next unless $tableref; next unless $tableref;
@@ -3596,7 +3572,7 @@ sub optimize_level4( $$ ) {
if ( my $chains = @chains ) { if ( my $chains = @chains ) {
$passes++; $passes++;
progress_message "\n Table $table pass $passes, $chains short chains, level 4b..."; progress_message "\n Table $table pass $passes, $chains short chains, level 4c...";
for my $chainref ( @chains ) { for my $chainref ( @chains ) {
my $name = $chainref->{name}; my $name = $chainref->{name};
@@ -4265,7 +4241,6 @@ sub valid_tables() {
my @table_list; my @table_list;
push @table_list, 'raw' if have_capability( 'RAW_TABLE' ); push @table_list, 'raw' if have_capability( 'RAW_TABLE' );
push @table_list, 'rawpost' if have_capability( 'RAWPOST_TABLE' );
push @table_list, 'nat' if have_capability( 'NAT_ENABLED' ); push @table_list, 'nat' if have_capability( 'NAT_ENABLED' );
push @table_list, 'mangle' if have_capability( 'MANGLE_ENABLED' ) && $config{MANGLE_ENABLED}; push @table_list, 'mangle' if have_capability( 'MANGLE_ENABLED' ) && $config{MANGLE_ENABLED};
push @table_list, 'filter'; #MUST BE LAST!!! push @table_list, 'filter'; #MUST BE LAST!!!
@@ -5773,12 +5748,12 @@ sub have_ipset_rules() {
$ipset_rules; $ipset_rules;
} }
sub get_interface_address( $ ); sub get_interface_address( $;$ );
sub get_interface_gateway ( $;$ ); sub get_interface_gateway ( $;$$ );
sub record_runtime_address( $$;$ ) { sub record_runtime_address( $$;$$ ) {
my ( $addrtype, $interface, $protect ) = @_; my ( $addrtype, $interface, $protect, $provider ) = @_;
if ( $interface =~ /^{([a-zA-Z_]\w*)}$/ ) { if ( $interface =~ /^{([a-zA-Z_]\w*)}$/ ) {
fatal_error "Mixed required/optional usage of address variable $1" if ( $address_variables{$1} || $addrtype ) ne $addrtype; fatal_error "Mixed required/optional usage of address variable $1" if ( $address_variables{$1} || $addrtype ) ne $addrtype;
@@ -5792,9 +5767,9 @@ sub record_runtime_address( $$;$ ) {
my $addr; my $addr;
if ( $addrtype eq '&' ) { if ( $addrtype eq '&' ) {
$addr = get_interface_address( $interface ); $addr = get_interface_address( $interface, $provider );
} else { } else {
$addr = get_interface_gateway( $interface, $protect ); $addr = get_interface_gateway( $interface, $protect, $provider );
} }
$addr . ' '; $addr . ' ';
@@ -5819,12 +5794,18 @@ sub conditional_rule( $$ ) {
if ( $type eq '&' ) { if ( $type eq '&' ) {
$variable = get_interface_address( $interface ); $variable = get_interface_address( $interface );
add_commands( $chainref , "if [ $variable != " . NILIP . ' ]; then' ); add_commands( $chainref , "if [ $variable != " . NILIP . ' ]; then' );
incr_cmd_level $chainref;
} else { } else {
$variable = get_interface_gateway( $interface ); $variable = get_interface_gateway( $interface );
if ( $variable =~ /^\$/ ) {
add_commands( $chainref , qq(if [ -n "$variable" ]; then) ); add_commands( $chainref , qq(if [ -n "$variable" ]; then) );
incr_cmd_level $chainref;
} else {
return 0;
}
} }
incr_cmd_level $chainref;
return 1; return 1;
} }
} elsif ( $type eq '%' && $interface =~ /^{([a-zA-Z_]\w*)}$/ ) { } elsif ( $type eq '%' && $interface =~ /^{([a-zA-Z_]\w*)}$/ ) {
@@ -6785,8 +6766,8 @@ sub interface_address( $ ) {
# #
# Record that the ruleset requires the first IP address on the passed interface # Record that the ruleset requires the first IP address on the passed interface
# #
sub get_interface_address ( $ ) { sub get_interface_address ( $;$ ) {
my ( $logical ) = $_[0]; my ( $logical, $provider ) = @_;
my $interface = get_physical( $logical ); my $interface = get_physical( $logical );
my $variable = interface_address( $interface ); my $variable = interface_address( $interface );
@@ -6796,6 +6777,8 @@ sub get_interface_address ( $ ) {
$interfaceaddr{$interface} = "$variable=\$($function $interface)\n"; $interfaceaddr{$interface} = "$variable=\$($function $interface)\n";
set_interface_option( $logical, 'used_address_variable', 1 ) unless $provider;
"\$$variable"; "\$$variable";
} }
@@ -6856,14 +6839,21 @@ sub interface_gateway( $ ) {
# #
# Record that the ruleset requires the gateway address on the passed interface # Record that the ruleset requires the gateway address on the passed interface
# #
sub get_interface_gateway ( $;$ ) { sub get_interface_gateway ( $;$$ ) {
my ( $logical, $protect ) = @_; my ( $logical, $protect, $provider ) = @_;
my $interface = get_physical $logical; my $interface = get_physical $logical;
my $variable = interface_gateway( $interface ); my $variable = interface_gateway( $interface );
my $gateway = get_interface_option( $interface, 'gateway' );
$global_variables |= ALL_COMMANDS; $global_variables |= ALL_COMMANDS;
if ( $gateway ) {
fatal_error q(A gateway variable cannot be used for a provider interface with GATEWAY set to 'none' in the providers file) if $gateway eq 'none';
fatal_error q(A gateway variable cannot be used for a provider interface with an empty GATEWAY column in the providers file) if $gateway eq 'omitted';
return $gateway if $gateway ne 'detect';
}
if ( interface_is_optional $logical ) { if ( interface_is_optional $logical ) {
$interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface)); $interfacegateways{$interface} = qq([ -n "\$$variable" ] || $variable=\$(detect_gateway $interface));
} else { } else {
@@ -6871,6 +6861,8 @@ sub get_interface_gateway ( $;$ ) {
[ -n "\$$variable" ] || startup_error "Unable to detect the gateway through interface $interface"); [ -n "\$$variable" ] || startup_error "Unable to detect the gateway through interface $interface");
} }
set_interface_option($interface, 'used_gateway_variable', 1) unless $provider;
$protect ? "\${$variable:-" . NILIP . '}' : "\$$variable"; $protect ? "\${$variable:-" . NILIP . '}' : "\$$variable";
} }
@@ -7273,6 +7265,7 @@ sub isolate_dest_interface( $$$$ ) {
my ( $diface, $dnets ); my ( $diface, $dnets );
if ( ( $restriction & PREROUTE_RESTRICT ) && $dest =~ /^detect:(.*)$/ ) { if ( ( $restriction & PREROUTE_RESTRICT ) && $dest =~ /^detect:(.*)$/ ) {
my $niladdr = NILIP;
# #
# DETECT_DNAT_IPADDRS=Yes and we're generating the nat rule # DETECT_DNAT_IPADDRS=Yes and we're generating the nat rule
# #
@@ -7289,14 +7282,14 @@ sub isolate_dest_interface( $$$$ ) {
push_command( $chainref , "for address in $list; do" , 'done' ); push_command( $chainref , "for address in $list; do" , 'done' );
push_command( $chainref , 'if [ $address != 0.0.0.0 ]; then' , 'fi' ) if $optional; push_command( $chainref , "if [ \$address != $niladdr ]; then" , 'fi' ) if $optional;
$rule .= '-d $address '; $rule .= '-d $address ';
} else { } else {
my $interface = $interfaces[0]; my $interface = $interfaces[0];
my $variable = get_interface_address( $interface ); my $variable = get_interface_address( $interface );
push_command( $chainref , "if [ $variable != 0.0.0.0 ]; then" , 'fi') if interface_is_optional( $interface ); push_command( $chainref , "if [ $variable != $niladdr ]; then" , 'fi') if interface_is_optional( $interface );
$rule .= "-d $variable "; $rule .= "-d $variable ";
} }
@@ -7597,7 +7590,7 @@ sub handle_exclusion( $$$$$$$$$$$$$$$$$$$$$ ) {
# #
# Returns the destination interface specified in the rule, if any. # Returns the destination interface specified in the rule, if any.
# #
sub expand_rule( $$$$$$$$$$$$;$ ) sub expand_rule1( $$$$$$$$$$$$;$ )
{ {
my ($chainref , # Chain my ($chainref , # Chain
$restriction, # Determines what to do with interface names in the SOURCE or DEST $restriction, # Determines what to do with interface names in the SOURCE or DEST
@@ -7614,8 +7607,6 @@ sub expand_rule( $$$$$$$$$$$$;$ )
$logname, # Name of chain to name in log messages $logname, # Name of chain to name in log messages
) = @_; ) = @_;
return if $chainref->{complete};
my ( $iiface, $diface, $inets, $dnets, $iexcl, $dexcl, $onets , $oexcl, $trivialiexcl, $trivialdexcl ) = my ( $iiface, $diface, $inets, $dnets, $iexcl, $dexcl, $onets , $oexcl, $trivialiexcl, $trivialdexcl ) =
( '', '', '', '', '', '', '', '', '', '' ); ( '', '', '', '', '', '', '', '', '', '' );
my $chain = $actparams{chain} || $chainref->{name}; my $chain = $actparams{chain} || $chainref->{name};
@@ -7850,6 +7841,78 @@ sub expand_rule( $$$$$$$$$$$$;$ )
$diface; $diface;
} }
sub expand_rule( $$$$$$$$$$$$;$$$ )
{
my ($chainref , # Chain
$restriction, # Determines what to do with interface names in the SOURCE or DEST
$prerule, # Matches that go at the front of the rule
$rule, # Caller's matches that don't depend on the SOURCE, DEST and ORIGINAL DEST
$source, # SOURCE
$dest, # DEST
$origdest, # ORIGINAL DEST
$target, # Target ('-j' part of the rule - may be empty)
$loglevel , # Log level (and tag)
$disposition, # Primtive part of the target (RETURN, ACCEPT, ...)
$exceptionrule,# Caller's matches used in exclusion case
$usergenerated,# Rule came from the IP[6]TABLES target
$logname, # Name of chain to name in log messages
$device, # TC Device Name
$classid, # TC Class Id
) = @_;
return if $chainref->{complete};
my ( @source, @dest );
$source = '' unless defined $source;
$dest = '' unless defined $dest;
if ( $source =~ /\(.+\)/ ) {
@source = split_list3( $source, 'SOURCE' );
} else {
@source = ( $source );
}
if ( $dest =~ /\(.+\)/ ) {
@dest = split_list3( $dest, 'DEST' );
} else {
@dest = ( $dest );
}
for $source ( @source ) {
if ( $source =~ /^(.+?):\((.+)\)$/ ) {
$source = join( ':', $1, $2 );
} elsif ( $source =~ /^\((.+)\)$/ ) {
$source = $1;
}
for $dest ( @dest ) {
if ( $dest =~ /^(.+?):\((.+)\)$/ ) {
$dest = join( ':', $1, $2 );
} elsif ( $dest =~ /^\((.+)\)$/ ) {
$dest = $1;
}
if ( ( my $result = expand_rule1( $chainref ,
$restriction ,
$prerule ,
$rule ,
$source ,
$dest ,
$origdest ,
$target ,
$loglevel ,
$disposition ,
$exceptionrule ,
$usergenerated ,
$logname ,
) ) && $device ) {
fatal_error "Class Id $classid is not associated with device $result" if $device ne $result &&( $config{TC_ENABLED} eq 'Internal' || $config{TC_ENABLED} eq 'Shared' );
}
}
}
}
# #
# Returns true if the passed interface is associated with exactly one zone # Returns true if the passed interface is associated with exactly one zone
# #
@@ -8304,7 +8367,7 @@ sub ensure_ipsets( @ ) {
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
if ( have_capability 'IPSET_V5' ) { if ( have_capability 'IPSET_V5' ) {
emit ( qq( if ! qt \$IPSET list $set -n; then) , emit ( qq( if ! qt \$IPSET list $set -n; then) ,
qq( error_message "WARNING: ipset $set does not exist; creating it as an hash:net set") , qq( error_message "WARNING: ipset $set does not exist; creating it as a hash:net set") ,
qq( \$IPSET create $set hash:net family inet timeout 0${counters}) , qq( \$IPSET create $set hash:net family inet timeout 0${counters}) ,
qq( fi) ); qq( fi) );
} else { } else {
@@ -8315,7 +8378,7 @@ sub ensure_ipsets( @ ) {
} }
} else { } else {
emit ( qq( if ! qt \$IPSET list $set -n; then) , emit ( qq( if ! qt \$IPSET list $set -n; then) ,
qq( error_message "WARNING: ipset $set does not exist; creating it as an hash:net set") , qq( error_message "WARNING: ipset $set does not exist; creating it as a hash:net set") ,
qq( \$IPSET create $set hash:net family inet6 timeout 0${counters}) , qq( \$IPSET create $set hash:net family inet6 timeout 0${counters}) ,
qq( fi) ); qq( fi) );
} }
@@ -8858,7 +8921,7 @@ sub create_chainlist_reload($) {
for my $chain ( @chains ) { for my $chain ( @chains ) {
( $table , $chain ) = split ':', $chain if $chain =~ /:/; ( $table , $chain ) = split ':', $chain if $chain =~ /:/;
fatal_error "Invalid table ( $table )" unless $table =~ /^(nat|mangle|filter|raw|rawpost)$/; fatal_error "Invalid table ( $table )" unless $table =~ /^(nat|mangle|filter|raw)$/;
$chains{$table} = {} unless $chains{$table}; $chains{$table} = {} unless $chains{$table};
@@ -8887,7 +8950,7 @@ sub create_chainlist_reload($) {
enter_cat_mode; enter_cat_mode;
for $table ( qw(raw rawpost nat mangle filter) ) { for $table ( qw(raw nat mangle filter) ) {
my $tableref=$chains{$table}; my $tableref=$chains{$table};
next unless $tableref; next unless $tableref;

View File

@@ -701,7 +701,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
# #
@@ -804,33 +804,8 @@ sub compiler {
# 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

View File

@@ -130,9 +130,11 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
split_list split_list
split_list1 split_list1
split_list2 split_list2
split_list3
split_line split_line
split_line1 split_line1
split_line2 split_line2
split_rawline2
first_entry first_entry
open_file open_file
close_file close_file
@@ -153,8 +155,6 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
propagateconfig propagateconfig
append_file append_file
run_user_exit run_user_exit
run_user_exit1
run_user_exit2
generate_aux_config generate_aux_config
format_warning format_warning
no_comment no_comment
@@ -174,6 +174,7 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
$doing $doing
$done $done
$currentline $currentline
$rawcurrentline
$currentfilename $currentfilename
$debug $debug
$file_format $file_format
@@ -388,7 +389,6 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
HEADER_MATCH => 'Header Match', HEADER_MATCH => 'Header Match',
ACCOUNT_TARGET => 'ACCOUNT Target', ACCOUNT_TARGET => 'ACCOUNT Target',
AUDIT_TARGET => 'AUDIT Target', AUDIT_TARGET => 'AUDIT Target',
RAWPOST_TABLE => 'Rawpost Table',
CONDITION_MATCH => 'Condition Match', CONDITION_MATCH => 'Condition Match',
IPTABLES_S => 'iptables -S', IPTABLES_S => 'iptables -S',
BASIC_FILTER => 'Basic Filter', BASIC_FILTER => 'Basic Filter',
@@ -411,6 +411,8 @@ our %capdesc = ( NAT_ENABLED => 'NAT',
IFACE_MATCH => 'Iface Match', IFACE_MATCH => 'Iface Match',
TCPMSS_TARGET => 'TCPMSS Target', TCPMSS_TARGET => 'TCPMSS Target',
WAIT_OPTION => 'iptables --wait option', WAIT_OPTION => 'iptables --wait option',
CPU_FANOUT => 'NFQUEUE CPU Fanout',
NETMAP_TARGET => 'NETMAP Target',
AMANDA_HELPER => 'Amanda Helper', AMANDA_HELPER => 'Amanda Helper',
FTP_HELPER => 'FTP Helper', FTP_HELPER => 'FTP Helper',
@@ -564,6 +566,7 @@ our $usedcaller;
our $inline_matches; our $inline_matches;
our $currentline; # Current config file line image our $currentline; # Current config file line image
our $rawcurrentline; # Current config file line with no variable expansion
our $currentfile; # File handle reference our $currentfile; # File handle reference
our $currentfilename; # File NAME our $currentfilename; # File NAME
our $currentlinenumber; # Line number our $currentlinenumber; # Line number
@@ -640,6 +643,7 @@ our %eliminated = ( LOGRATE => 1,
WIDE_TC_MARKS => 1, WIDE_TC_MARKS => 1,
HIGH_ROUTE_MARKS => 1, HIGH_ROUTE_MARKS => 1,
BLACKLISTNEWONLY => 1, BLACKLISTNEWONLY => 1,
CHAIN_SCRIPTS => 1,
); );
# #
# Variables involved in ?IF, ?ELSE ?ENDIF processing # Variables involved in ?IF, ?ELSE ?ENDIF processing
@@ -744,8 +748,8 @@ sub initialize( $;$$) {
TC_SCRIPT => '', TC_SCRIPT => '',
EXPORT => 0, EXPORT => 0,
KLUDGEFREE => '', KLUDGEFREE => '',
VERSION => "5.0.9-Beta2", VERSION => "5.1.1-RC1",
CAPVERSION => 50004 , CAPVERSION => 50100 ,
BLACKLIST_LOG_TAG => '', BLACKLIST_LOG_TAG => '',
RELATED_LOG_TAG => '', RELATED_LOG_TAG => '',
MACLIST_LOG_TAG => '', MACLIST_LOG_TAG => '',
@@ -788,6 +792,7 @@ sub initialize( $;$$) {
INVALID_LOG_LEVEL => undef, INVALID_LOG_LEVEL => undef,
UNTRACKED_LOG_LEVEL => undef, UNTRACKED_LOG_LEVEL => undef,
LOG_BACKEND => undef, LOG_BACKEND => undef,
LOG_LEVEL => undef,
# #
# Location of Files # Location of Files
# #
@@ -812,6 +817,7 @@ sub initialize( $;$$) {
ACCEPT_DEFAULT => undef, ACCEPT_DEFAULT => undef,
QUEUE_DEFAULT => undef, QUEUE_DEFAULT => undef,
NFQUEUE_DEFAULT => undef, NFQUEUE_DEFAULT => undef,
BLACKLIST_DEFAULT => undef,
# #
# RSH/RCP Commands # RSH/RCP Commands
# #
@@ -887,7 +893,6 @@ sub initialize( $;$$) {
WARNOLDCAPVERSION => undef, WARNOLDCAPVERSION => undef,
DEFER_DNS_RESOLUTION => undef, DEFER_DNS_RESOLUTION => undef,
USE_RT_NAMES => undef, USE_RT_NAMES => undef,
CHAIN_SCRIPTS => undef,
TRACK_RULES => undef, TRACK_RULES => undef,
REJECT_ACTION => undef, REJECT_ACTION => undef,
INLINE_MATCHES => undef, INLINE_MATCHES => undef,
@@ -901,6 +906,7 @@ sub initialize( $;$$) {
VERBOSE_MESSAGES => undef , VERBOSE_MESSAGES => undef ,
ZERO_MARKS => undef , ZERO_MARKS => undef ,
FIREWALL => undef , FIREWALL => undef ,
BALANCE_PROVIDERS => undef ,
# #
# Packet Disposition # Packet Disposition
# #
@@ -977,7 +983,6 @@ sub initialize( $;$$) {
CONNMARK_MATCH => undef, CONNMARK_MATCH => undef,
XCONNMARK_MATCH => undef, XCONNMARK_MATCH => undef,
RAW_TABLE => undef, RAW_TABLE => undef,
RAWPOST_TABLE => undef,
IPP2P_MATCH => undef, IPP2P_MATCH => undef,
OLD_IPP2P_MATCH => undef, OLD_IPP2P_MATCH => undef,
CLASSIFY_TARGET => undef, CLASSIFY_TARGET => undef,
@@ -1033,6 +1038,8 @@ sub initialize( $;$$) {
IFACE_MATCH => undef, IFACE_MATCH => undef,
TCPMSS_TARGET => undef, TCPMSS_TARGET => undef,
WAIT_OPTION => undef, WAIT_OPTION => undef,
CPU_FANOUT => undef,
NETMAP_TARGET => undef,
AMANDA_HELPER => undef, AMANDA_HELPER => undef,
FTP_HELPER => undef, FTP_HELPER => undef,
@@ -1997,6 +2004,21 @@ sub find_writable_file($) {
"$config_path[0]$filename"; "$config_path[0]$filename";
} }
#
# Determine if a value has been supplied
#
sub supplied( $ ) {
my $val = shift;
defined $val && $val ne '';
}
sub passed( $ ) {
my $val = shift;
defined $val && $val ne '' && $val ne '-';
}
# #
# Split a comma-separated list into a Perl array # Split a comma-separated list into a Perl array
# #
@@ -2055,7 +2077,7 @@ sub split_list1( $$;$ ) {
sub split_list2( $$ ) { sub split_list2( $$ ) {
my ($list, $type ) = @_; my ($list, $type ) = @_;
fatal_error "Invalid $type ($list)" if $list =~ /^:|::/; fatal_error "Invalid $type ($list)" if $list =~ /^:/;
my @list1 = split /:/, $list; my @list1 = split /:/, $list;
my @list2; my @list2;
@@ -2092,6 +2114,7 @@ sub split_list2( $$ ) {
fatal_error "Invalid $type ($list)" if $opencount < 0; fatal_error "Invalid $type ($list)" if $opencount < 0;
} }
} elsif ( $element eq '' ) { } elsif ( $element eq '' ) {
fatal_error "Invalid $type ($list)" unless supplied $_;
push @list2 , $_; push @list2 , $_;
} else { } else {
$element = join ':', $element , $_; $element = join ':', $element , $_;
@@ -2257,21 +2280,6 @@ sub split_columns( $ ) {
@list2; @list2;
} }
#
# Determine if a value has been supplied
#
sub supplied( $ ) {
my $val = shift;
defined $val && $val ne '';
}
sub passed( $ ) {
my $val = shift;
defined $val && $val ne '' && $val ne '-';
}
sub clear_comment(); sub clear_comment();
# #
@@ -2442,6 +2450,25 @@ sub split_line2( $$;$$$ ) {
@line; @line;
} }
#
# Same as above, only it splits the raw current line
#
sub split_rawline2( $$;$$$ ) {
my $savecurrentline = $currentline;
$currentline = $rawcurrentline;
#
# Delete trailing comment
#
$currentline =~ s/\s*#.*//;
my @result = &split_line2( @_ );
$currentline = $savecurrentline;
@result;
}
sub split_line1( $$;$$ ) { sub split_line1( $$;$$ ) {
&split_line2( @_, undef ); &split_line2( @_, undef );
} }
@@ -2686,11 +2713,11 @@ sub directive_info( $$$$ ) {
# Add quotes to the passed value if the passed 'first part' has an odd number of quotes # Add quotes to the passed value if the passed 'first part' has an odd number of quotes
# Return an expression that concatenates $first, $val and $rest # Return an expression that concatenates $first, $val and $rest
# #
sub join_parts( $$$ ) { sub join_parts( $$$$ ) {
my ( $first, $val, $rest ) = @_; my ( $first, $val, $rest, $just_expand ) = @_;
$val = '' unless defined $val; $val = '' unless defined $val;
$val = "'$val'" unless ( $val =~ /^-?\d+$/ || # Value is numeric $val = "'$val'" unless $just_expand || ( $val =~ /^-?\d+$/ || # Value is numeric
( ( ( $first =~ tr/"/"/ ) & 1 ) || # There are an odd number of double quotes preceding the value ( ( ( $first =~ tr/"/"/ ) & 1 ) || # There are an odd number of double quotes preceding the value
( ( $first =~ tr/'/'/ ) & 1 ) ) ); # There are an odd number of single quotes preceding the value ( ( $first =~ tr/'/'/ ) & 1 ) ) ); # There are an odd number of single quotes preceding the value
join( '', $first, $val, $rest ); join( '', $first, $val, $rest );
@@ -2745,7 +2772,7 @@ sub evaluate_expression( $$$$ ) {
exists $capdesc{$var} ? have_capability( $var ) : '' ); exists $capdesc{$var} ? have_capability( $var ) : '' );
} }
$expression = join_parts( $first, $val, $rest ); $expression = join_parts( $first, $val, $rest, $just_expand );
directive_error( "Variable Expansion Loop" , $filename, $linenumber ) if ++$count > 100; directive_error( "Variable Expansion Loop" , $filename, $linenumber ) if ++$count > 100;
} }
@@ -2756,7 +2783,7 @@ sub evaluate_expression( $$$$ ) {
$var = numeric_value( $var ) if $var =~ /^\d/; $var = numeric_value( $var ) if $var =~ /^\d/;
$val = $var ? $actparams{$var} : $chain; $val = $var ? $actparams{$var} : $chain;
$usedcaller = USEDCALLER if $var eq 'caller'; $usedcaller = USEDCALLER if $var eq 'caller';
$expression = join_parts( $first, $val, $rest ); $expression = join_parts( $first, $val, $rest , $just_expand );
directive_error( "Variable Expansion Loop" , $filename, $linenumber ) if ++$count > 100; directive_error( "Variable Expansion Loop" , $filename, $linenumber ) if ++$count > 100;
} }
} }
@@ -2828,7 +2855,7 @@ sub process_compiler_directive( $$$$ ) {
print "CD===> $line\n" if $debug; print "CD===> $line\n" if $debug;
directive_error( "Invalid compiler directive ($line)" , $filename, $linenumber ) unless $line =~ /^\s*\?(IF\s+|ELSE|ELSIF\s+|ENDIF|SET\s+|RESET\s+|FORMAT\s+|COMMENT\s*|ERROR\s+|WARNING\s+|INFO\s+|WARNING!\s+|INFO!\s+)(.*)$/i; directive_error( "Invalid compiler directive ($line)" , $filename, $linenumber ) unless $line =~ /^\s*\?(IF\s+|ELSE|ELSIF\s+|ENDIF|SET\s+|RESET\s+|FORMAT\s+|COMMENT\s*|ERROR\s+|WARNING\s+|INFO\s+|WARNING!\s+|INFO!\s+|REQUIRE\s+)(.*)$/i;
my ($keyword, $expression) = ( uc $1, $2 ); my ($keyword, $expression) = ( uc $1, $2 );
@@ -2968,15 +2995,18 @@ sub process_compiler_directive( $$$$ ) {
} , } ,
ERROR => sub() { ERROR => sub() {
unless ( $omitting ) {
directive_error( evaluate_expression( $expression , directive_error( evaluate_expression( $expression ,
$filename , $filename ,
$linenumber , $linenumber ,
1 ) , 1 ) ,
$filename , $filename ,
$linenumber ) unless $omitting; $linenumber ) unless $omitting;
}
} , } ,
WARNING => sub() { WARNING => sub() {
unless ( $omitting ) {
directive_warning( $config{VERBOSE_MESSAGES} , directive_warning( $config{VERBOSE_MESSAGES} ,
evaluate_expression( $expression , evaluate_expression( $expression ,
$filename , $filename ,
@@ -2984,9 +3014,11 @@ sub process_compiler_directive( $$$$ ) {
1 ), 1 ),
$filename , $filename ,
$linenumber ) unless $omitting; $linenumber ) unless $omitting;
}
} , } ,
INFO => sub() { INFO => sub() {
unless ( $omitting ) {
directive_info( $config{VERBOSE_MESSAGES} , directive_info( $config{VERBOSE_MESSAGES} ,
evaluate_expression( $expression , evaluate_expression( $expression ,
$filename , $filename ,
@@ -2994,9 +3026,11 @@ sub process_compiler_directive( $$$$ ) {
1 ), 1 ),
$filename , $filename ,
$linenumber ) unless $omitting; $linenumber ) unless $omitting;
}
} , } ,
'WARNING!' => sub() { 'WARNING!' => sub() {
unless ( $omitting ) {
directive_warning( ! $config{VERBOSE_MESSAGES} , directive_warning( ! $config{VERBOSE_MESSAGES} ,
evaluate_expression( $expression , evaluate_expression( $expression ,
$filename , $filename ,
@@ -3004,9 +3038,11 @@ sub process_compiler_directive( $$$$ ) {
1 ), 1 ),
$filename , $filename ,
$linenumber ) unless $omitting; $linenumber ) unless $omitting;
}
} , } ,
'INFO!' => sub() { 'INFO!' => sub() {
unless ( $omitting ) {
directive_info( ! $config{VERBOSE_MESSAGES} , directive_info( ! $config{VERBOSE_MESSAGES} ,
evaluate_expression( $expression , evaluate_expression( $expression ,
$filename , $filename ,
@@ -3014,6 +3050,15 @@ sub process_compiler_directive( $$$$ ) {
1 ), 1 ),
$filename , $filename ,
$linenumber ) unless $omitting; $linenumber ) unless $omitting;
}
} ,
REQUIRE => sub() {
unless ( $omitting ) {
fatal_error "?REQUIRE may only be used within action files" unless $actparams{0};
fatal_error "Unknown capability ($expression)" unless exists $capabilities{$expression};
require_capability( $expression, "The $actparams{action} action", 's' );
}
} , } ,
); );
@@ -3026,9 +3071,9 @@ sub process_compiler_directive( $$$$ ) {
if ( $directive_callback ) { if ( $directive_callback ) {
$directive_callback->( $keyword, $line ) $directive_callback->( $keyword, $line )
} else {
$omitting;
} }
$omitting;
} }
# #
@@ -3729,13 +3774,14 @@ sub read_a_line($) {
# #
# Handle directives # Handle directives
# #
if ( /^\s*\?(?:IF|ELSE|ELSIF|ENDIF|SET|RESET|FORMAT|COMMENT|ERROR|WARNING|INFO)/i ) { if ( /^\s*\?(?:IF|ELSE|ELSIF|ENDIF|SET|RESET|FORMAT|COMMENT|ERROR|WARNING|INFO|REQUIRE)/i ) {
$omitting = process_compiler_directive( $omitting, $_, $currentfilename, $. ); $omitting = process_compiler_directive( $omitting, $_, $currentfilename, $. );
next; next;
} }
if ( $omitting ) { if ( $omitting ) {
print "OMIT=> $_\n" if $debug; print "OMIT=> $_\n" if $debug;
$directive_callback->( 'OMITTED', $_ ) if ( $directive_callback );
next; next;
} }
@@ -3790,6 +3836,10 @@ sub read_a_line($) {
# #
handle_first_entry if $first_entry; handle_first_entry if $first_entry;
# #
# Save Raw Image
#
$rawcurrentline = $currentline;
#
# Expand Shell Variables using %params and %actparams # Expand Shell Variables using %params and %actparams
# #
expand_variables( $currentline ) if $options & EXPAND_VARIABLES; expand_variables( $currentline ) if $options & EXPAND_VARIABLES;
@@ -3818,7 +3868,7 @@ sub read_a_line($) {
fatal_error "Invalid SECTION name ($sectionname)" unless $sectionname =~ /^[-_\da-zA-Z]+$/; fatal_error "Invalid SECTION name ($sectionname)" unless $sectionname =~ /^[-_\da-zA-Z]+$/;
fatal_error "This file does not allow ?SECTION" unless $section_function; fatal_error "This file does not allow ?SECTION" unless $section_function;
$section_function->($sectionname); $section_function->($sectionname);
$directive_callback->( 'SECTION', $currentline ) if $directive_callback; $directive_callback->( 'SECTION', $rawcurrentline ) if $directive_callback;
next LINE; next LINE;
} else { } else {
fatal_error "Non-ASCII gunk in file" if ( $options && CHECK_GUNK ) && $currentline =~ /[^\s[:print:]]/; fatal_error "Non-ASCII gunk in file" if ( $options && CHECK_GUNK ) && $currentline =~ /[^\s[:print:]]/;
@@ -4290,6 +4340,22 @@ sub Masquerade_Tgt() {
$result; $result;
} }
sub Netmap_Target() {
have_capability( 'NAT_ENABLED' ) || return '';
my $result = '';
my $address = $family == F_IPV4 ? '1.2.3.0/24' : '2001::/64';
if ( qt1( "$iptables $iptablesw -t nat -N $sillyname" ) ) {
$result = qt1( "$iptables $iptablesw -t nat -A $sillyname -j NETMAP --to $address" );
qt1( "$iptables $iptablesw -t nat -F $sillyname" );
qt1( "$iptables $iptablesw -t nat -X $sillyname" );
}
$result;
}
sub Udpliteredirect() { sub Udpliteredirect() {
have_capability( 'NAT_ENABLED' ) || return ''; have_capability( 'NAT_ENABLED' ) || return '';
@@ -4488,10 +4554,6 @@ sub Raw_Table() {
qt1( "$iptables $iptablesw -t raw -L -n" ); qt1( "$iptables $iptablesw -t raw -L -n" );
} }
sub Rawpost_Table() {
qt1( "$iptables $iptablesw -t rawpost -L -n" );
}
sub Old_IPSet_Match() { sub Old_IPSet_Match() {
my $ipset = $config{IPSET} || 'ipset'; my $ipset = $config{IPSET} || 'ipset';
my $result = 0; my $result = 0;
@@ -4544,11 +4606,11 @@ sub IPSet_Match() {
} }
sub IPSet_Match_Nomatch() { sub IPSet_Match_Nomatch() {
have_capability 'IPSET_MATCH' && $capabilities{IPSET_MATCH_NOMATCH}; have_capability( 'IPSET_MATCH' ) && $capabilities{IPSET_MATCH_NOMATCH};
} }
sub IPSet_Match_Counters() { sub IPSet_Match_Counters() {
have_capability 'IPSET_MATCH' && $capabilities{IPSET_MATCH_COUNTERS}; have_capability( 'IPSET_MATCH' ) && $capabilities{IPSET_MATCH_COUNTERS};
} }
sub IPSET_V5() { sub IPSET_V5() {
@@ -4819,6 +4881,10 @@ sub Tcpmss_Target() {
qt1( "$iptables $iptablesw -A $sillyname -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu" ); qt1( "$iptables $iptablesw -A $sillyname -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu" );
} }
sub Cpu_Fanout() {
have_capability( 'NFQUEUE_TARGET' ) && qt1( "$iptables -A $sillyname -j NFQUEUE --queue-balance 0:3 --queue-cpu-fanout" );
}
our %detect_capability = our %detect_capability =
( ACCOUNT_TARGET =>\&Account_Target, ( ACCOUNT_TARGET =>\&Account_Target,
AMANDA_HELPER => \&Amanda_Helper, AMANDA_HELPER => \&Amanda_Helper,
@@ -4835,6 +4901,7 @@ our %detect_capability =
CONNMARK => \&Connmark, CONNMARK => \&Connmark,
CONNMARK_MATCH => \&Connmark_Match, CONNMARK_MATCH => \&Connmark_Match,
CONNTRACK_MATCH => \&Conntrack_Match, CONNTRACK_MATCH => \&Conntrack_Match,
CPU_FANOUT => \&Cpu_Fanout,
CT_TARGET => \&Ct_Target, CT_TARGET => \&Ct_Target,
DSCP_MATCH => \&Dscp_Match, DSCP_MATCH => \&Dscp_Match,
DSCP_TARGET => \&Dscp_Target, DSCP_TARGET => \&Dscp_Target,
@@ -4878,6 +4945,7 @@ our %detect_capability =
MULTIPORT => \&Multiport, MULTIPORT => \&Multiport,
NAT_ENABLED => \&Nat_Enabled, NAT_ENABLED => \&Nat_Enabled,
NETBIOS_NS_HELPER => \&Netbios_ns_Helper, NETBIOS_NS_HELPER => \&Netbios_ns_Helper,
NETMAP_TARGET => \&Netmap_Target,
NEW_CONNTRACK_MATCH => \&New_Conntrack_Match, NEW_CONNTRACK_MATCH => \&New_Conntrack_Match,
NFACCT_MATCH => \&NFAcct_Match, NFACCT_MATCH => \&NFAcct_Match,
NFQUEUE_TARGET => \&Nfqueue_Target, NFQUEUE_TARGET => \&Nfqueue_Target,
@@ -4893,7 +4961,6 @@ our %detect_capability =
POLICY_MATCH => \&Policy_Match, POLICY_MATCH => \&Policy_Match,
PPTP_HELPER => \&PPTP_Helper, PPTP_HELPER => \&PPTP_Helper,
RAW_TABLE => \&Raw_Table, RAW_TABLE => \&Raw_Table,
RAWPOST_TABLE => \&Rawpost_Table,
REALM_MATCH => \&Realm_Match, REALM_MATCH => \&Realm_Match,
REAP_OPTION => \&Reap_Option, REAP_OPTION => \&Reap_Option,
RECENT_MATCH => \&Recent_Match, RECENT_MATCH => \&Recent_Match,
@@ -5021,7 +5088,6 @@ sub determine_capabilities() {
$capabilities{TPROXY_TARGET} = detect_capability( 'TPROXY_TARGET' ); $capabilities{TPROXY_TARGET} = detect_capability( 'TPROXY_TARGET' );
$capabilities{MANGLE_FORWARD} = detect_capability( 'MANGLE_FORWARD' ); $capabilities{MANGLE_FORWARD} = detect_capability( 'MANGLE_FORWARD' );
$capabilities{RAW_TABLE} = detect_capability( 'RAW_TABLE' ); $capabilities{RAW_TABLE} = detect_capability( 'RAW_TABLE' );
$capabilities{RAWPOST_TABLE} = detect_capability( 'RAWPOST_TABLE' );
$capabilities{IPSET_MATCH} = detect_capability( 'IPSET_MATCH' ); $capabilities{IPSET_MATCH} = detect_capability( 'IPSET_MATCH' );
$capabilities{USEPKTTYPE} = detect_capability( 'USEPKTTYPE' ); $capabilities{USEPKTTYPE} = detect_capability( 'USEPKTTYPE' );
$capabilities{ADDRTYPE} = detect_capability( 'ADDRTYPE' ); $capabilities{ADDRTYPE} = detect_capability( 'ADDRTYPE' );
@@ -5062,6 +5128,8 @@ sub determine_capabilities() {
$capabilities{TARPIT_TARGET} = detect_capability( 'TARPIT_TARGET' ); $capabilities{TARPIT_TARGET} = detect_capability( 'TARPIT_TARGET' );
$capabilities{IFACE_MATCH} = detect_capability( 'IFACE_MATCH' ); $capabilities{IFACE_MATCH} = detect_capability( 'IFACE_MATCH' );
$capabilities{TCPMSS_TARGET} = detect_capability( 'TCPMSS_TARGET' ); $capabilities{TCPMSS_TARGET} = detect_capability( 'TCPMSS_TARGET' );
$capabilities{CPU_FANOUT} = detect_capability( 'CPU_FANOUT' );
$capabilities{NETMAP_TARGET} = detect_capability( 'NETMAP_TARGET' );
unless ( have_capability 'CT_TARGET' ) { unless ( have_capability 'CT_TARGET' ) {
$capabilities{HELPER_MATCH} = detect_capability 'HELPER_MATCH'; $capabilities{HELPER_MATCH} = detect_capability 'HELPER_MATCH';
@@ -5232,9 +5300,24 @@ sub update_config_file( $ ) {
} }
update_default( 'USE_DEFAULT_RT', 'No' ); update_default( 'USE_DEFAULT_RT', 'No' );
if ( $config{USE_DEFAULT_RT} eq '' || $config{USE_DEFAULT_RT} =~ /^no$/i ) {
update_default( 'BALANCE_PROVIDERS', 'No' );
} else {
update_default( 'BALANCE_PROVIDERS', 'Yes' );
}
update_default( 'EXPORTMODULES', 'No' ); update_default( 'EXPORTMODULES', 'No' );
update_default( 'RESTART', 'reload' ); update_default( 'RESTART', 'reload' );
update_default( 'PAGER', $shorewallrc1{DEFAULT_PAGER} ); update_default( 'PAGER', $shorewallrc1{DEFAULT_PAGER} );
update_default( 'LOGFORMAT', 'Shorewall:%s:%s:' );
update_default( 'LOGLIMIT', '' );
if ( $family == F_IPV4 ) {
update_default( 'BLACKLIST_DEFAULT', 'dropBcasts,dropNotSyn,dropInvalid' );
} else {
update_default( 'BLACKLIST_DEFAULT', 'AllowICMPs,dropBcasts,dropNotSyn,dropInvalid' );
}
my $fn; my $fn;
@@ -6183,7 +6266,6 @@ sub get_configuration( $$$$ ) {
default_yes_no 'AUTOCOMMENT' , 'Yes'; default_yes_no 'AUTOCOMMENT' , 'Yes';
default_yes_no 'MULTICAST' , ''; default_yes_no 'MULTICAST' , '';
default_yes_no 'MARK_IN_FORWARD_CHAIN' , ''; default_yes_no 'MARK_IN_FORWARD_CHAIN' , '';
default_yes_no 'CHAIN_SCRIPTS' , 'Yes';
if ( supplied ( $val = $config{TRACK_RULES} ) ) { if ( supplied ( $val = $config{TRACK_RULES} ) ) {
if ( lc( $val ) eq 'file' ) { if ( lc( $val ) eq 'file' ) {
@@ -6238,6 +6320,7 @@ sub get_configuration( $$$$ ) {
default_yes_no 'RESTORE_DEFAULT_ROUTE' , 'Yes'; default_yes_no 'RESTORE_DEFAULT_ROUTE' , 'Yes';
default_yes_no 'AUTOMAKE' , ''; default_yes_no 'AUTOMAKE' , '';
default_yes_no 'TRACK_PROVIDERS' , ''; default_yes_no 'TRACK_PROVIDERS' , '';
default_yes_no 'BALANCE_PROVIDERS' , $config{USE_DEFAULT_RT} ? 'Yes' : '';
unless ( ( $config{NULL_ROUTE_RFC1918} || '' ) =~ /^(?:blackhole|unreachable|prohibit)$/ ) { unless ( ( $config{NULL_ROUTE_RFC1918} || '' ) =~ /^(?:blackhole|unreachable|prohibit)$/ ) {
default_yes_no( 'NULL_ROUTE_RFC1918', '' ); default_yes_no( 'NULL_ROUTE_RFC1918', '' );
@@ -6254,6 +6337,8 @@ sub get_configuration( $$$$ ) {
$config{ACCOUNTING_TABLE} = 'filter'; $config{ACCOUNTING_TABLE} = 'filter';
} }
my %variables = ( SW_DBL_IPSET => '', SW_DBL_TIMEOUT => 0 );
if ( supplied( $val = $config{DYNAMIC_BLACKLIST} ) ) { if ( supplied( $val = $config{DYNAMIC_BLACKLIST} ) ) {
if ( $val =~ /^ipset/ ) { if ( $val =~ /^ipset/ ) {
my %simple_options = ( 'src-dst' => 1, 'disconnect' => 1 ); my %simple_options = ( 'src-dst' => 1, 'disconnect' => 1 );
@@ -6294,6 +6379,9 @@ sub get_configuration( $$$$ ) {
require_capability( 'IPSET_V5', 'DYNAMIC_BLACKLIST=ipset...', 's' ); require_capability( 'IPSET_V5', 'DYNAMIC_BLACKLIST=ipset...', 's' );
$variables{SW_DBL_IPSET} = $set;
$variables{SW_DBL_TIMEOUT} = $globals{DBL_TIMEOUT};
} else { } else {
default_yes_no( 'DYNAMIC_BLACKLIST', 'Yes' ); default_yes_no( 'DYNAMIC_BLACKLIST', 'Yes' );
} }
@@ -6301,6 +6389,8 @@ sub get_configuration( $$$$ ) {
default_yes_no( 'DYNAMIC_BLACKLIST', 'Yes' ); default_yes_no( 'DYNAMIC_BLACKLIST', 'Yes' );
} }
add_variables( %variables );
default_yes_no 'REQUIRE_INTERFACE' , ''; default_yes_no 'REQUIRE_INTERFACE' , '';
default_yes_no 'FORWARD_CLEAR_MARK' , have_capability( 'MARK' ) ? 'Yes' : ''; default_yes_no 'FORWARD_CLEAR_MARK' , have_capability( 'MARK' ) ? 'Yes' : '';
default_yes_no 'COMPLETE' , ''; default_yes_no 'COMPLETE' , '';
@@ -6398,6 +6488,12 @@ sub get_configuration( $$$$ ) {
default_log_level 'INVALID_LOG_LEVEL', ''; default_log_level 'INVALID_LOG_LEVEL', '';
default_log_level 'UNTRACKED_LOG_LEVEL', ''; default_log_level 'UNTRACKED_LOG_LEVEL', '';
if ( supplied( $val = $config{LOG_LEVEL} ) ) {
validate_level( $val );
} else {
$config{LOG_LEVEL} = 'info';
}
if ( supplied( $val = $config{LOG_BACKEND} ) ) { if ( supplied( $val = $config{LOG_BACKEND} ) ) {
if ( $family == F_IPV4 && $val eq 'ULOG' ) { if ( $family == F_IPV4 && $val eq 'ULOG' ) {
$val = 'ipt_ULOG'; $val = 'ipt_ULOG';
@@ -6566,13 +6662,16 @@ sub get_configuration( $$$$ ) {
} }
default 'RESTOREFILE' , 'restore'; default 'RESTOREFILE' , 'restore';
default 'DROP_DEFAULT' , 'Drop';
default 'REJECT_DEFAULT' , 'Reject'; default 'DROP_DEFAULT' , 'none';
default 'REJECT_DEFAULT' , 'none';
default 'BLACKLIST_DEFAULT' , 'none';
default 'QUEUE_DEFAULT' , 'none'; default 'QUEUE_DEFAULT' , 'none';
default 'NFQUEUE_DEFAULT' , 'none'; default 'NFQUEUE_DEFAULT' , 'none';
default 'ACCEPT_DEFAULT' , 'none'; default 'ACCEPT_DEFAULT' , 'none';
for my $default ( qw/DROP_DEFAULT REJECT_DEFAULT QUEUE_DEFAULT NFQUEUE_DEFAULT ACCEPT_DEFAULT/ ) { for my $default ( qw/DROP_DEFAULT REJECT_DEFAULT BLACKLIST_DEFAULT QUEUE_DEFAULT NFQUEUE_DEFAULT ACCEPT_DEFAULT/ ) {
$config{$default} = 'none' if "\L$config{$default}" eq 'none'; $config{$default} = 'none' if "\L$config{$default}" eq 'none';
} }
@@ -6700,32 +6799,7 @@ sub append_file( $;$$ ) {
$result; $result;
} }
#
# Run a Perl extension script
#
sub run_user_exit( $ ) { sub run_user_exit( $ ) {
my $chainref = $_[0];
my $file = find_file $chainref->{name};
if ( $config{CHAIN_SCRIPTS} && -f $file ) {
progress_message2 "Running $file...";
my $command = qq(package Shorewall::User;\nno strict;\n# line 1 "$file"\n) . `cat $file`;
unless (my $return = eval $command ) {
fatal_error "Couldn't parse $file: $@" if $@;
unless ( defined $return ) {
fatal_error "Couldn't do $file: $!" if $!;
fatal_error "Couldn't do $file";
}
fatal_error "$file returned a false value";
}
}
}
sub run_user_exit1( $ ) {
my $file = find_file $_[0]; my $file = find_file $_[0];
if ( -f $file ) { if ( -f $file ) {
@@ -6757,37 +6831,6 @@ sub run_user_exit1( $ ) {
} }
} }
sub run_user_exit2( $$ ) {
my ($file, $chainref) = ( find_file $_[0], $_[1] );
if ( $config{CHAIN_SCRIPTS} && -f $file ) {
progress_message2 "Running $file...";
#
# File may be empty -- in which case eval would fail
#
push_open $file;
if ( read_a_line( STRIP_COMMENTS | SUPPRESS_WHITESPACE | CHECK_GUNK ) ) {
close_file;
pop_open;
unless (my $return = eval `cat $file` ) {
fatal_error "Couldn't parse $file: $@" if $@;
unless ( defined $return ) {
fatal_error "Couldn't do $file: $!" if $!;
fatal_error "Couldn't do $file";
}
fatal_error "$file returned a false value";
}
}
pop_open;
}
}
# #
# Generate the aux config file for Shorewall Lite # Generate the aux config file for Shorewall Lite
# #
@@ -6814,7 +6857,7 @@ sub generate_aux_config() {
emit "#\n# Shorewall auxiliary configuration file created by Shorewall version $globals{VERSION} - $date\n#"; emit "#\n# Shorewall auxiliary configuration file created by Shorewall version $globals{VERSION} - $date\n#";
for my $option ( qw(VERBOSITY LOGFILE LOGFORMAT ARPTABLES IPTABLES IP6TABLES IP TC IPSET PATH SHOREWALL_SHELL SUBSYSLOCK LOCKFILE RESTOREFILE WORKAROUNDS RESTART DYNAMIC_BLACKLIST) ) { for my $option ( qw(VERBOSITY LOGFILE LOGFORMAT ARPTABLES IPTABLES IP6TABLES IP TC IPSET PATH SHOREWALL_SHELL SUBSYSLOCK LOCKFILE RESTOREFILE WORKAROUNDS RESTART DYNAMIC_BLACKLIST PAGER) ) {
conditionally_add_option $option; conditionally_add_option $option;
} }

View File

@@ -472,7 +472,7 @@ sub validate_portpair1( $$ ) {
fatal_error "Invalid port range ($portpair)" if $portpair =~ tr/-/-/ > 1; fatal_error "Invalid port range ($portpair)" if $portpair =~ tr/-/-/ > 1;
$portpair = "0$portpair" if substr( $portpair, 0, 1 ) eq ':'; $portpair = "1$portpair" if substr( $portpair, 0, 1 ) eq ':';
$portpair = "${portpair}65535" if substr( $portpair, -1, 1 ) eq ':'; $portpair = "${portpair}65535" if substr( $portpair, -1, 1 ) eq ':';
my @ports = split /-/, $portpair, 2; my @ports = split /-/, $portpair, 2;
@@ -483,9 +483,10 @@ sub validate_portpair1( $$ ) {
if ( @ports == 2 ) { if ( @ports == 2 ) {
$what = 'port range'; $what = 'port range';
fatal_error "Invalid port range ($portpair)" unless $ports[0] < $ports[1]; fatal_error "Invalid port range ($portpair)" unless $ports[0] && $ports[0] < $ports[1];
} else { } else {
$what = 'port'; $what = 'port';
fatal_error 'Invalid port number (0)' unless $portpair;
} }
fatal_error "Using a $what ( $portpair ) requires PROTO TCP, UDP, SCTP or DCCP" unless fatal_error "Using a $what ( $portpair ) requires PROTO TCP, UDP, SCTP or DCCP" unless

View File

@@ -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"
# #
@@ -395,6 +408,7 @@ sub convert_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;
@@ -1004,7 +1028,7 @@ sub add_common_rules ( $ ) {
); );
} }
run_user_exit1 'initdone'; run_user_exit 'initdone';
if ( $upgrade ) { if ( $upgrade ) {
convert_blacklist; convert_blacklist;
@@ -1430,8 +1454,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;
} }
@@ -1657,12 +1679,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 );
} }
# #
@@ -2740,6 +2756,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
# #
@@ -83,6 +85,8 @@ sub process_one_masq1( $$$$$$$$$$$ )
} 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;
if ( supplied $rest ) {
validate_portpair1( $proto, $rest );
$addrlist .= "--to-source $addr "; $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,8 +402,130 @@ sub process_one_masq1( $$$$$$$$$$$ )
} }
sub process_one_masq( ) sub convert_one_masq1( $$$$$$$$$$$$ )
{ {
my ( $snat, $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) = @_;
my $pre_nat;
my $destnets = '';
my $savelist;
#
# Leading '+'
#
$pre_nat = ( $interfacelist =~ s/^\+// );
#
# Check for INLINE
#
if ( $interfacelist =~ /^INLINE\((.+)\)$/ ) {
$interfacelist = $1;
}
$savelist = $interfacelist;
#
# 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 ) = my ($interfacelist, $networks, $addresses, $protos, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ) =
split_line2( 'masq file', 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 }, { interface => 0, source => 1, address => 2, proto => 3, port => 4, ipsec => 5, mark => 6, user => 7, switch => 8, origdest => 9, probability => 10 },
@@ -400,18 +538,114 @@ sub process_one_masq( )
for my $proto ( split_list $protos, 'Protocol' ) { for my $proto ( split_list $protos, 'Protocol' ) {
process_one_masq1( $interfacelist, $networks, $addresses, $proto, $ports, $ipsec, $mark, $user, $condition, $origdest, $probability ); 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';
#
# Shorewall - SNAT/Masquerade File
#
# 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 );
} }
# #
# Process the masq file # Convert a masq file into the equivalent snat file
# #
sub setup_masq() 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,7 +790,6 @@ 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;
@@ -571,7 +804,7 @@ sub setup_netmap() {
$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 ) ,
@@ -587,57 +820,9 @@ sub setup_netmap() {
$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)";

View File

@@ -220,7 +220,14 @@ sub copy_table( $$$ ) {
' esac', ' esac',
); );
} else { } else {
emit ( " run_ip route add table $number \$net \$route $realm" ); emit ( ' case $net in',
' fe80:*)',
' ;;',
' *)',
" run_ip route add table $number \$net \$route $realm",
' ;;',
' esac',
);
} }
emit ( ' ;;', emit ( ' ;;',
@@ -291,7 +298,14 @@ sub copy_and_edit_table( $$$$$ ) {
' esac', ' esac',
); );
} else { } else {
emit ( " run_ip route add table $id \$net \$route $realm" ); emit ( ' case $net in',
' fe80:*)',
' ;;',
' *)',
" run_ip route add table $id \$net \$route $realm",
' ;;',
' esac',
);
} }
emit ( ' ;;', emit ( ' ;;',
@@ -472,12 +486,14 @@ sub process_a_provider( $ ) {
if ( ( $gw = lc $gateway ) eq 'detect' ) { if ( ( $gw = lc $gateway ) eq 'detect' ) {
fatal_error "Configuring multiple providers through one interface requires an explicit gateway" if $shared; fatal_error "Configuring multiple providers through one interface requires an explicit gateway" if $shared;
$gateway = get_interface_gateway $interface; $gateway = get_interface_gateway( $interface, undef, 1 );
$gatewaycase = 'detect'; $gatewaycase = 'detect';
set_interface_option( $interface, 'gateway', 'detect' );
} elsif ( $gw eq 'none' ) { } elsif ( $gw eq 'none' ) {
fatal_error "Configuring multiple providers through one interface requires a gateway" if $shared; fatal_error "Configuring multiple providers through one interface requires a gateway" if $shared;
$gatewaycase = 'none'; $gatewaycase = 'none';
$gateway = ''; $gateway = '';
set_interface_option( $interface, 'gateway', 'none' );
} elsif ( $gateway && $gateway ne '-' ) { } elsif ( $gateway && $gateway ne '-' ) {
( $gateway, $mac ) = split_host_list( $gateway, 0 ); ( $gateway, $mac ) = split_host_list( $gateway, 0 );
validate_address $gateway, 0; validate_address $gateway, 0;
@@ -491,12 +507,15 @@ sub process_a_provider( $ ) {
} }
$gatewaycase = 'specified'; $gatewaycase = 'specified';
set_interface_option( $interface, 'gateway', $gateway );
} else { } else {
$gatewaycase = 'omitted'; $gatewaycase = 'omitted';
fatal_error "Configuring multiple providers through one interface requires a gateway" if $shared; fatal_error "Configuring multiple providers through one interface requires a gateway" if $shared;
$gateway = ''; $gateway = '';
set_interface_option( $interface, 'gateway', $pseudo ? 'detect' : 'omitted' );
} }
my ( $loose, $track, $balance, $default, $default_balance, $optional, $mtu, $tproxy, $local, $load, $what, $hostroute, $persistent ); my ( $loose, $track, $balance, $default, $default_balance, $optional, $mtu, $tproxy, $local, $load, $what, $hostroute, $persistent );
if ( $pseudo ) { if ( $pseudo ) {
@@ -504,7 +523,7 @@ sub process_a_provider( $ ) {
( 0, 0 , 0 , 0, 0, 1 , '' , 0 , 0, 0, 'interface', 0, 0); ( 0, 0 , 0 , 0, 0, 1 , '' , 0 , 0, 0, 'interface', 0, 0);
} else { } else {
( $loose, $track, $balance , $default, $default_balance, $optional, $mtu, $tproxy , $local, $load, $what , $hostroute, $persistent )= ( $loose, $track, $balance , $default, $default_balance, $optional, $mtu, $tproxy , $local, $load, $what , $hostroute, $persistent )=
( 0, $config{TRACK_PROVIDERS}, 0 , 0, $config{USE_DEFAULT_RT} ? 1 : 0, interface_is_optional( $interface ), '' , 0 , 0, 0, 'provider', 1, 0); ( 0, $config{TRACK_PROVIDERS}, 0 , 0, $config{BALANCE_PROVIDERS} ? 1 : 0, interface_is_optional( $interface ), '' , 0 , 0, 0, 'provider', 1, 0);
} }
unless ( $options eq '-' ) { unless ( $options eq '-' ) {
@@ -584,6 +603,7 @@ sub process_a_provider( $ ) {
fatal_error "A provider interface must have at least one associated zone" unless $tproxy || %{interface_zones($interface)}; fatal_error "A provider interface must have at least one associated zone" unless $tproxy || %{interface_zones($interface)};
unless ( $pseudo ) {
if ( $local ) { if ( $local ) {
fatal_error "GATEWAY not valid with 'local' provider" unless $gatewaycase eq 'omitted'; fatal_error "GATEWAY not valid with 'local' provider" unless $gatewaycase eq 'omitted';
fatal_error "'track' not valid with 'local'" if $track; fatal_error "'track' not valid with 'local'" if $track;
@@ -597,6 +617,23 @@ sub process_a_provider( $ ) {
fatal_error "MARK not allowed with 'tproxy'" if $mark ne '-'; fatal_error "MARK not allowed with 'tproxy'" if $mark ne '-';
fatal_error "'persistent' is not valid with 'tproxy" if $persistent; fatal_error "'persistent' is not valid with 'tproxy" if $persistent;
$mark = $globals{TPROXY_MARK}; $mark = $globals{TPROXY_MARK};
} elsif ( ( my $rf = ( $config{ROUTE_FILTER} eq 'on' ) ) || $interfaceref->{options}{routefilter} ) {
if ( $config{USE_DEFAULT_RT} ) {
if ( $rf ) {
fatal_error "There may be no providers when ROUTE_FILTER=Yes and USE_DEFAULT_RT=Yes";
} else {
fatal_error "Providers interfaces may not specify 'routefilter' when USE_DEFAULT_RT=Yes";
}
} else {
unless ( $balance ) {
if ( $rf ) {
fatal_error "The 'balance' option is required when ROUTE_FILTER=Yes";
} else {
fatal_error "Provider interfaces may not specify 'routefilter' without 'balance' or 'primary'";
}
}
}
}
} }
my $val = 0; my $val = 0;
@@ -725,9 +762,9 @@ sub emit_started_message( $$$$$ ) {
my ( $spaces, $level, $pseudo, $name, $number ) = @_; my ( $spaces, $level, $pseudo, $name, $number ) = @_;
if ( $pseudo ) { if ( $pseudo ) {
emit qq(${spaces}progress_message${level} " Optional interface $name Started"); emit qq(${spaces}progress_message${level} "Optional interface $name Started");
} else { } else {
emit qq(${spaces}progress_message${level} " Provider $name ($number) Started"); emit qq(${spaces}progress_message${level} "Provider $name ($number) Started");
} }
} }
@@ -794,7 +831,7 @@ sub add_a_provider( $$ ) {
} }
if ( $gateway ) { if ( $gateway ) {
$address = get_interface_address $interface unless $address; $address = get_interface_address( $interface, 1 ) unless $address;
emit( qq([ -z "$address" ] && return\n) ); emit( qq([ -z "$address" ] && return\n) );
@@ -920,7 +957,7 @@ CEOF
} }
if ( $gateway ) { if ( $gateway ) {
$address = get_interface_address $interface unless $address; $address = get_interface_address( $interface, 1 ) unless $address;
if ( $hostroute ) { if ( $hostroute ) {
emit qq(run_ip route replace $gateway src $address dev $physical ${mtu}); emit qq(run_ip route replace $gateway src $address dev $physical ${mtu});
@@ -1033,6 +1070,16 @@ CEOF
emit( qq(rm -f \${VARDIR}/${physical}_disabled) ); emit( qq(rm -f \${VARDIR}/${physical}_disabled) );
emit_started_message( '', 2, $pseudo, $table, $number ); emit_started_message( '', 2, $pseudo, $table, $number );
if ( get_interface_option( $interface, 'used_address_variable' ) || get_interface_option( $interface, 'used_gateway_variable' ) ) {
emit( '',
'if [ -n "$g_forcereload" ]; then',
" progress_message2 \"The IP address or gateway of $physical has changed -- forcing reload of the ruleset\"",
' COMMAND=reload',
' detect_configuration',
' define_firewall',
'fi' );
}
pop_indent; pop_indent;
unless ( $pseudo ) { unless ( $pseudo ) {
@@ -1043,6 +1090,17 @@ CEOF
} }
emit "fi\n"; emit "fi\n";
if ( get_interface_option( $interface, 'used_address_variable' ) ) {
my $variable = interface_address( $interface );
emit( "echo \$$variable > \${VARDIR}/${physical}.address" );
}
if ( get_interface_option( $interface, 'used_gateway_variable' ) ) {
my $variable = interface_gateway( $interface );
emit( qq(echo "\$$variable" > \${VARDIR}/${physical}.gateway\n) );
}
} else { } else {
emit( qq(progress_message "Provider $table ($number) Started") ); emit( qq(progress_message "Provider $table ($number) Started") );
} }
@@ -1067,6 +1125,17 @@ CEOF
} else { } else {
emit ( "error_message \"WARNING: Interface $physical is not usable -- Provider $table ($number) not Started\"" ); emit ( "error_message \"WARNING: Interface $physical is not usable -- Provider $table ($number) not Started\"" );
} }
if ( get_interface_option( $interface, 'used_address_variable' ) ) {
my $variable = interface_address( $interface );
emit( "\necho \$$variable > \${VARDIR}/${physical}.address" );
}
if ( get_interface_option( $interface, 'used_gateway_variable' ) ) {
my $variable = interface_gateway( $interface );
emit( qq(\necho "\$$variable" > \${VARDIR}/${physical}.gateway) );
}
} else { } else {
if ( $shared ) { if ( $shared ) {
emit( "fatal_error \"Gateway $gateway is not reachable -- Provider $table ($number) Cannot be Started\"" ); emit( "fatal_error \"Gateway $gateway is not reachable -- Provider $table ($number) Cannot be Started\"" );
@@ -1205,7 +1274,7 @@ sub add_an_rtrule1( $$$$$ ) {
if ( $source eq '-' ) { if ( $source eq '-' ) {
$source = 'from ' . ALLIP; $source = 'from ' . ALLIP;
} elsif ( $source =~ s/^&// ) { } elsif ( $source =~ s/^&// ) {
$source = 'from ' . record_runtime_address '&', $source; $source = 'from ' . record_runtime_address( '&', $source, undef, 1 );
} elsif ( $family == F_IPV4 ) { } elsif ( $family == F_IPV4 ) {
if ( $source =~ /:/ ) { if ( $source =~ /:/ ) {
( my $interface, $source , my $remainder ) = split( /:/, $source, 3 ); ( my $interface, $source , my $remainder ) = split( /:/, $source, 3 );
@@ -1459,7 +1528,18 @@ sub finish_providers() {
if ( $balancing ) { if ( $balancing ) {
emit ( 'if [ -n "$DEFAULT_ROUTE" ]; then' ); emit ( 'if [ -n "$DEFAULT_ROUTE" ]; then' );
if ( $family == F_IPV4 ) {
emit ( " run_ip route replace default scope global table $table \$DEFAULT_ROUTE" ); emit ( " run_ip route replace default scope global table $table \$DEFAULT_ROUTE" );
} else {
emit ( " if echo \$DEFAULT_ROUTE | grep -q 'nexthop.+nexthop'; then",
" qt \$IP -6 route delete default scope global table $table \$DEFAULT_ROUTE",
" run_ip -6 route add default scope global table $table \$DEFAULT_ROUTE",
' else',
" run_ip -6 route replace default scope global table $table \$DEFAULT_ROUTE",
' fi',
'' );
}
if ( $config{USE_DEFAULT_RT} ) { if ( $config{USE_DEFAULT_RT} ) {
emit ( " while qt \$IP -$family route del default table $main; do", emit ( " while qt \$IP -$family route del default table $main; do",
@@ -1512,7 +1592,13 @@ sub finish_providers() {
if ( $fallback ) { if ( $fallback ) {
emit ( 'if [ -n "$FALLBACK_ROUTE" ]; then' ); emit ( 'if [ -n "$FALLBACK_ROUTE" ]; then' );
if ( $family == F_IPV4 ) {
emit( " run_ip route replace default scope global table $default \$FALLBACK_ROUTE" ); emit( " run_ip route replace default scope global table $default \$FALLBACK_ROUTE" );
} else {
emit( " run_ip route delete default scope global table $default \$FALLBACK_ROUTE" );
emit( " run_ip route add default scope global table $default \$FALLBACK_ROUTE" );
}
emit( " progress_message \"Fallback route '\$(echo \$FALLBACK_ROUTE | sed 's/\$\\s*//')' Added\"", emit( " progress_message \"Fallback route '\$(echo \$FALLBACK_ROUTE | sed 's/\$\\s*//')' Added\"",
'else', 'else',
@@ -2139,6 +2225,7 @@ sub handle_optional_interfaces( $ ) {
} }
push_indent; push_indent;
if ( $providerref->{gatewaycase} eq 'detect' ) { if ( $providerref->{gatewaycase} eq 'detect' ) {
emit qq(if interface_is_usable $physical && [ -n "$providerref->{gateway}" ]; then); emit qq(if interface_is_usable $physical && [ -n "$providerref->{gateway}" ]; then);
} else { } else {
@@ -2151,6 +2238,28 @@ sub handle_optional_interfaces( $ ) {
emit( " SW_${wildbase}_IS_USABLE=Yes" ) if $interfaceref->{wildcard}; emit( " SW_${wildbase}_IS_USABLE=Yes" ) if $interfaceref->{wildcard};
emit( 'fi' ); emit( 'fi' );
if ( get_interface_option( $interface, 'used_address_variable' ) ) {
my $variable = interface_address( $interface );
emit( '',
"if [ -f \${VARDIR}/${physical}.address ]; then",
" if [ \$(cat \${VARDIR}/${physical}.address) != \$$variable ]; then",
' g_forcereload=Yes',
' fi',
'fi' );
}
if ( get_interface_option( $interface, 'used_gateway_variable' ) ) {
my $variable = interface_gateway( $interface );
emit( '',
"if [ -f \${VARDIR}/${physical}.gateway ]; then",
" if [ \$(cat \${VARDIR}/${physical}.gateway) != \"\$$variable\" ]; then",
' g_forcereload=Yes',
' fi',
'fi' );
}
pop_indent; pop_indent;
emit( "fi\n" ); emit( "fi\n" );
@@ -2161,6 +2270,7 @@ sub handle_optional_interfaces( $ ) {
my $base = uc var_base( $physical ); my $base = uc var_base( $physical );
my $case = $physical; my $case = $physical;
my $wild = $case =~ s/\+$/*/; my $wild = $case =~ s/\+$/*/;
my $variable = interface_address( $interface );
if ( $wildcards ) { if ( $wildcards ) {
emit( "$case)" ); emit( "$case)" );
@@ -2181,6 +2291,15 @@ sub handle_optional_interfaces( $ ) {
emit ( " SW_${base}_IS_USABLE=Yes" , emit ( " SW_${base}_IS_USABLE=Yes" ,
'fi' ); 'fi' );
if ( get_interface_option( $interface, 'used_address_variable' ) ) {
emit( '',
"if [ -f \${VARDIR}/${physical}.address ]; then",
" if [ \$(cat \${VARDIR}/${physical}.address) != \$$variable ]; then",
' g_forcereload=Yes',
' fi',
'fi' );
}
if ( $wildcards ) { if ( $wildcards ) {
pop_indent, emit( 'fi' ) if $wild; pop_indent, emit( 'fi' ) if $wild;
emit( ';;' ); emit( ';;' );

View File

@@ -122,7 +122,7 @@ sub process_conntrack_rule( $$$$$$$$$$ ) {
fatal_error "Invalid conntrack ACTION (IPTABLES)" unless $1; fatal_error "Invalid conntrack ACTION (IPTABLES)" unless $1;
} }
my ( $tgt, $options ) = split( ' ', $2 ); my ( $tgt, $options ) = split( ' ', $2, 2 );
my $target_type = $builtin_target{$tgt}; my $target_type = $builtin_target{$tgt};
fatal_error "Unknown target ($tgt)" unless $target_type; fatal_error "Unknown target ($tgt)" unless $target_type;
fatal_error "The $tgt TARGET is not allowed in the raw table" unless $target_type & RAW_TABLE; fatal_error "The $tgt TARGET is not allowed in the raw table" unless $target_type & RAW_TABLE;

File diff suppressed because it is too large Load Diff

View File

@@ -42,7 +42,7 @@ use strict;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT = qw( process_tc setup_tc ); our @EXPORT = qw( process_tc setup_tc );
our @EXPORT_OK = qw( process_tc_rule initialize ); our @EXPORT_OK = qw( initialize );
our $VERSION = 'MODULEVERSION'; our $VERSION = 'MODULEVERSION';
our %flow_keys = ( 'src' => 1, our %flow_keys = ( 'src' => 1,
@@ -827,7 +827,7 @@ sub validate_tc_class( ) {
fatal_error "Invalid 'occurs' ($val)" unless defined $occurs && $occurs > 1 && $occurs <= 256; fatal_error "Invalid 'occurs' ($val)" unless defined $occurs && $occurs > 1 && $occurs <= 256;
fatal_error "Invalid 'occurs' ($val)" if $occurs > $globals{TC_MAX}; fatal_error "Invalid 'occurs' ($val)" if $occurs > $globals{TC_MAX};
fatal_error q(Duplicate 'occurs') if $tcref->{occurs} > 1; fatal_error q(Duplicate 'occurs') if $tcref->{occurs} > 1;
fatal_error q(The 'occurs' option is not valid with 'default') if $devref->{default} == $classnumber; fatal_error q(The 'occurs' option is not valid with 'default') if defined($devref->{default}) && $devref->{default} == $classnumber;
fatal_error q(The 'occurs' option is not valid with 'tos') if @{$tcref->{tos}}; fatal_error q(The 'occurs' option is not valid with 'tos') if @{$tcref->{tos}};
warning_message "MARK ($mark) is ignored on an occurring class" if $mark ne '-'; warning_message "MARK ($mark) is ignored on an occurring class" if $mark ne '-';
@@ -1308,6 +1308,8 @@ sub handle_ematch( $$ ) {
$setname =~ s/\+//; $setname =~ s/\+//;
add_ipset($setname);
return "ipset\\($setname $options\\)"; return "ipset\\($setname $options\\)";
} }
@@ -1518,7 +1520,7 @@ sub process_tc_filter2( $$$$$$$$$ ) {
$rule .= ' and' if $have_rule; $rule .= ' and' if $have_rule;
if ( $source =~ /^\+/ ) { if ( $source =~ /^\+/ ) {
$rule = join( '', "\\\n ", handle_ematch( $source, 'src' ) ); $rule .= join( '', "\\\n ", handle_ematch( $source, 'src' ) );
} else { } else {
my @parts = decompose_net_u32( $source ); my @parts = decompose_net_u32( $source );
@@ -1557,10 +1559,10 @@ sub process_tc_filter2( $$$$$$$$$ ) {
$rule .= ' and' if @parts; $rule .= ' and' if @parts;
} }
} }
}
$have_rule = 1; $have_rule = 1;
} }
}
if ( $have_rule ) { if ( $have_rule ) {
push @$filtersref, ( "\nrun_tc $rule\\" , push @$filtersref, ( "\nrun_tc $rule\\" ,
@@ -2148,41 +2150,14 @@ sub process_secmark_rule() {
} }
} }
sub convert_one_tos( $ ) {
sub convert_tos($$) { my ( $mangle ) = @_;
my ( $mangle, $fn1 ) = @_;
my $have_tos = 0;
sub unlink_tos( $ ) {
my $fn = shift;
if ( unlink $fn ) {
warning_message "Empty tos file ($fn) removed";
} else {
warning_message "Unable to remove empty tos file $fn: $!";
}
}
if ( my $fn = open_file 'tos' ) {
first_entry(
sub {
my $date = compiletime;
progress_message2 "Converting $fn...";
print( $mangle
"#\n" ,
"# Rules generated from tos file $fn by Shorewall $globals{VERSION} - $date\n" ,
"#\n" );
}
);
while ( read_a_line( NORMAL_READ ) ) {
$have_tos = 1;
my ($src, $dst, $proto, $ports, $sports , $tos, $mark ) = my ($src, $dst, $proto, $ports, $sports , $tos, $mark ) =
split_line( 'tos file entry', split_rawline2( 'tos file entry',
{ source => 0, dest => 1, proto => 2, dport => 3, sport => 4, tos => 5, mark => 6 } ); { source => 0, dest => 1, proto => 2, dport => 3, sport => 4, tos => 5, mark => 6 },
undef,
7 );
my $chain_designator = 'P'; my $chain_designator = 'P';
@@ -2217,8 +2192,62 @@ sub convert_tos($$) {
$mark = '-' unless supplied $mark; $mark = '-' unless supplied $mark;
print $mangle "TOS($tos):$chain_designator\t$src\t$dst\t$proto\t$ports\t$sports\t-\t$mark\n" print $mangle "TOS($tos):$chain_designator\t$src\t$dst\t$proto\t$ports\t$sports\t-\t$mark\n"
}
sub convert_tos($$) {
my ( $mangle, $fn1 ) = @_;
my $have_tos = 0;
sub unlink_tos( $ ) {
my $fn = shift;
if ( unlink $fn ) {
warning_message "Empty tos file ($fn) removed";
} else {
warning_message "Unable to remove empty tos file $fn: $!";
} }
}
if ( my $fn = open_file 'tos' ) {
directive_callback(
sub ()
{
if ( $_[0] eq 'OMITTED' ) {
#
# Convert the raw rule
#
if ( $rawcurrentline =~ /^\s*(?:#.*)?$/ ) {
print $mangle "$_[1]\n";
} else {
convert_one_tos( $mangle );
$have_tos = 1;
}
} else {
print $mangle "$_[1]\n" unless $_[0] eq 'FORMAT';
}
}
);
first_entry(
sub {
my $date = compiletime;
progress_message2 "Converting $fn...";
print( $mangle
"#\n" ,
"# Rules generated from tos file $fn by Shorewall $globals{VERSION} - $date\n" ,
"#\n" );
}
);
while ( read_a_line( NORMAL_READ ) ) {
convert_one_tos( $mangle );
$have_tos = 1;
}
directive_callback(0);
if ( $have_tos ) { if ( $have_tos ) {
progress_message2 "Converted $fn to $fn1"; progress_message2 "Converted $fn to $fn1";
@@ -2248,9 +2277,10 @@ sub open_mangle_for_output( $ ) {
# #
transfer_permissions( $fn, $fn1 ); transfer_permissions( $fn, $fn1 );
if ( $family == F_IPV4 ) {
print $mangle <<'EOF'; print $mangle <<'EOF';
# #
# Shorewall version 4 - Mangle File # Shorewall -- /etc/shorewall/mangle
# #
# For information about entries in this file, type "man shorewall-mangle" # For information about entries in this file, type "man shorewall-mangle"
# #
@@ -2260,13 +2290,32 @@ sub open_mangle_for_output( $ ) {
# #
# See http://shorewall.net/PacketMarking.html for a detailed description of # See http://shorewall.net/PacketMarking.html for a detailed description of
# the Netfilter/Shorewall packet marking mechanism. # the Netfilter/Shorewall packet marking mechanism.
#################################################################################################################################################### ##############################################################################################################################################################
#ACTION SOURCE DEST PROTO DEST SOURCE USER TEST LENGTH TOS CONNBYTES HELPER PROBABILITY DSCP #ACTION SOURCE DEST PROTO DEST SOURCE USER TEST LENGTH TOS CONNBYTES HELPER PROBABILITY DSCP SWITCH
# PORT(S) PORT(S)
EOF EOF
} else {
print $mangle <<'EOF';
#
# Shorewall6 -- /etc/shorewall6/mangle
#
# For information about entries in this file, type "man shorewall6-mangle"
#
# See http://shorewall.net/traffic_shaping.htm for additional information.
# For usage in selecting among multiple ISPs, see
# http://shorewall.net/MultiISP.html
#
# See http://shorewall.net/PacketMarking.html for a detailed description of
# the Netfilter/Shorewall packet marking mechanism.
#
######################################################################################################################################################################
#ACTION SOURCE DEST PROTO DPORT SPORT USER TEST LENGTH TOS CONNBYTES HELPER HEADERS PROBABILITY DSCP SWITCH
EOF
}
} }
return ( $mangle, $fn1 ); return ( $mangle, $fn1 );
} }
# #
@@ -2276,13 +2325,13 @@ sub setup_tc( $ ) {
$convert = $_[0]; $convert = $_[0];
if ( $config{MANGLE_ENABLED} ) { if ( $config{MANGLE_ENABLED} ) {
ensure_mangle_chain 'tcpre'; ensure_mangle_chain( 'tcpre', PREROUTING, PREROUTE_RESTRICT );
ensure_mangle_chain 'tcout'; ensure_mangle_chain( 'tcout', OUTPUT , OUTPUT_RESTRICT );
if ( have_capability( 'MANGLE_FORWARD' ) ) { if ( have_capability( 'MANGLE_FORWARD' ) ) {
ensure_mangle_chain 'tcfor'; ensure_mangle_chain( 'tcfor', FORWARD , NO_RESTRICT );
ensure_mangle_chain 'tcpost'; ensure_mangle_chain( 'tcpost', POSTROUTING, POSTROUTE_RESTRICT );
ensure_mangle_chain 'tcin'; ensure_mangle_chain( 'tcin', INPUT , INPUT_RESTRICT );
} }
my @mark_part; my @mark_part;
@@ -2335,7 +2384,24 @@ sub setup_tc( $ ) {
# #
( $mangle, $fn1 ) = open_mangle_for_output( $fn ); ( $mangle, $fn1 ) = open_mangle_for_output( $fn );
directive_callback( sub () { print $mangle "$_[1]\n" unless $_[0] eq 'FORMAT'; 0; } ); directive_callback(
sub ()
{
if ( $_[0] eq 'OMITTED' ) {
#
# Convert the raw rule
#
if ( $rawcurrentline =~ /^\s*(?:#.*)?$/ ) {
print $mangle "$_[1]\n";
} else {
process_tc_rule;
$have_tcrules++;
}
} else {
print $mangle "$_[1]\n" unless $_[0] eq 'FORMAT';
}
}
);
first_entry( first_entry(
sub { sub {

View File

@@ -95,7 +95,6 @@ our @EXPORT = ( qw( NOTHING
get_interface_origin get_interface_origin
interface_has_option interface_has_option
set_interface_option set_interface_option
set_interface_provider
interface_zone interface_zone
interface_zones interface_zones
verify_required_interfaces verify_required_interfaces
@@ -195,7 +194,6 @@ our %reservedName = ( all => 1,
# number => <ordinal position in the interfaces file> # number => <ordinal position in the interfaces file>
# physical => <physical interface name> # physical => <physical interface name>
# base => <shell variable base representing this interface> # base => <shell variable base representing this interface>
# provider => <Provider Name, if interface is associated with a provider>
# wildcard => undef|1 # Wildcard Name # wildcard => undef|1 # Wildcard Name
# zones => { zone1 => 1, ... } # zones => { zone1 => 1, ... }
# origin => <where defined> # origin => <where defined>
@@ -398,7 +396,6 @@ sub initialize( $$ ) {
nodbl => SIMPLE_IF_OPTION, nodbl => SIMPLE_IF_OPTION,
nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST, nosmurfs => SIMPLE_IF_OPTION + IF_OPTION_HOST,
optional => SIMPLE_IF_OPTION, optional => SIMPLE_IF_OPTION,
optional => SIMPLE_IF_OPTION,
proxyndp => BINARY_IF_OPTION, proxyndp => BINARY_IF_OPTION,
required => SIMPLE_IF_OPTION, required => SIMPLE_IF_OPTION,
routeback => BINARY_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_HOST + IF_OPTION_VSERVER, routeback => BINARY_IF_OPTION + IF_OPTION_ZONEONLY + IF_OPTION_HOST + IF_OPTION_VSERVER,
@@ -1278,6 +1275,7 @@ sub process_interface( $$ ) {
my $numval = numeric_value $value; my $numval = numeric_value $value;
fatal_error "Invalid value ($value) for option $option" unless defined $numval && $numval <= $maxoptionvalue{$option}; fatal_error "Invalid value ($value) for option $option" unless defined $numval && $numval <= $maxoptionvalue{$option};
require_capability 'TCPMSS_TARGET', "mss=$value", 's' if $option eq 'mss'; require_capability 'TCPMSS_TARGET', "mss=$value", 's' if $option eq 'mss';
$options{logmartians} = 1 if $option eq 'routefilter' && $numval && ! $config{LOG_MARTIANS};
$options{$option} = $numval; $options{$option} = $numval;
$hostoptions{$option} = $numval if $hostopt; $hostoptions{$option} = $numval if $hostopt;
} elsif ( $type == IPLIST_IF_OPTION ) { } elsif ( $type == IPLIST_IF_OPTION ) {

View File

@@ -1,6 +1,6 @@
#! /usr/bin/perl -w #! /usr/bin/perl -w
# #
# The Shoreline Firewall Packet Filtering Firewall Compiler - V4.4 # The Shoreline Firewall Packet Filtering Firewall Compiler
# #
# (c) 2007,2008,2009,2010,2011,2014 - Tom Eastep (teastep@shorewall.net) # (c) 2007,2008,2009,2010,2011,2014 - Tom Eastep (teastep@shorewall.net)
# #

View File

@@ -38,12 +38,11 @@ fi
# #
. /usr/share/shorewall/shorewallrc . /usr/share/shorewall/shorewallrc
g_program=$PRODUCT g_basedir=${SHAREDIR}/shorewall
g_sharedir="$SHAREDIR/shorewall"
g_confdir="$CONFDIR/$PRODUCT"
g_readrc=1
. $g_sharedir/lib.cli . $g_basedir/lib.cli
setup_product_environment
CONFIG_PATH="$2" CONFIG_PATH="$2"

View File

@@ -349,7 +349,7 @@ replace_default_route() # $1 = USE_DEFAULT_RT
case "$default_route" in case "$default_route" in
*metric*) *metric*)
# #
# Don't restore a default route with a metric unless USE_DEFAULT_RT=Yes. Otherwise, we only replace the one with metric 0 # Don't restore a default route with a metric unless USE_DEFAULT_RT=Yes or =Exact. Otherwise, we only replace the one with metric 0
# #
[ -n "$1" ] && qt $IP -$g_family route replace $default_route && progress_message "Default Route (${default_route# }) restored" [ -n "$1" ] && qt $IP -$g_family route replace $default_route && progress_message "Default Route (${default_route# }) restored"
default_route= default_route=
@@ -526,13 +526,6 @@ debug_restore_input() {
qt1 $g_tool -t raw -P $chain ACCEPT qt1 $g_tool -t raw -P $chain ACCEPT
done done
qt1 $g_tool -t rawpost -F
qt1 $g_tool -t rawpost -X
for chain in POSTROUTING; do
qt1 $g_tool -t rawpost -P $chain ACCEPT
done
qt1 $g_tool -t nat -F qt1 $g_tool -t nat -F
qt1 $g_tool -t nat -X qt1 $g_tool -t nat -X
@@ -582,9 +575,6 @@ debug_restore_input() {
'*'raw) '*'raw)
table=raw table=raw
;; ;;
'*'rawpost)
table=rawpost
;;
'*'mangle) '*'mangle)
table=mangle table=mangle
;; ;;

View File

@@ -128,6 +128,9 @@ g_compiled=
g_file= g_file=
g_docker= g_docker=
g_dockernetwork= g_dockernetwork=
g_forcereload=
[ -n "$SERVICEDIR" ] && SUBSYSLOCK=
initialize initialize

View File

@@ -1,6 +1,6 @@
# #
# Shorewall - Sample Masq file for two-interface configuration. # Shorewall - Sample Params File for universal configuration.
# Copyright (C) 2006-2015 by the Shorewall Team # Copyright (C) 2006-2014 by the Shorewall Team
# #
# This library is free software; you can redistribute it and/or # This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
@@ -8,12 +8,6 @@
# version 2.1 of the License, or (at your option) any later version. # version 2.1 of the License, or (at your option) any later version.
# #
# See the file README.txt for further details. # See the file README.txt for further details.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-masq" # For information on entries in this file, type "man shorewall-params"
################################################################################################################ ######################################################################################################################################################################################################
#INTERFACE:DEST SOURCE ADDRESS PROTO PORT(S) IPSEC MARK USER/ SWITCH ORIGINAL
# GROUP DEST
eth0 10.0.0.0/8,\
169.254.0.0/16,\
172.16.0.0/12,\
192.168.0.0/16

View File

@@ -7,7 +7,6 @@
# http://www.shorewall.net/manpages/shorewall-policy.html # http://www.shorewall.net/manpages/shorewall-policy.html
# #
############################################################################### ###############################################################################
#SOURCE DEST POLICY LOG LIMIT: CONNLIMIT: #SOURCE DEST POLICY LOGLEVEL RATE CONNLIMIT
# LEVEL BURST MASK
$FW net ACCEPT $FW net ACCEPT
net all DROP net all DROP $LOG_LEVEL

View File

@@ -1,6 +1,6 @@
############################################################################### ###############################################################################
# #
# Shorewall Version 4.4 -- /etc/shorewall/shorewall.conf # Shorewall Version 5 -- /etc/shorewall/shorewall.conf
# #
# For information about the settings in this file, type "man shorewall.conf" # For information about the settings in this file, type "man shorewall.conf"
# #
@@ -33,6 +33,8 @@ FIREWALL=
# L O G G I N G # L O G G I N G
############################################################################### ###############################################################################
LOG_LEVEL=info
BLACKLIST_LOG_LEVEL= BLACKLIST_LOG_LEVEL=
INVALID_LOG_LEVEL= INVALID_LOG_LEVEL=
@@ -47,25 +49,25 @@ LOGALLNEW=
LOGFILE=/var/log/messages LOGFILE=/var/log/messages
LOGFORMAT="Shorewall:%s:%s:" LOGFORMAT="%s %s "
LOGTAGONLY=No LOGTAGONLY=No
LOGLIMIT= LOGLIMIT="s:1/sec:10"
MACLIST_LOG_LEVEL=info MACLIST_LOG_LEVEL=$LOG_LEVEL
RELATED_LOG_LEVEL= RELATED_LOG_LEVEL=
RPFILTER_LOG_LEVEL=info RPFILTER_LOG_LEVEL=$LOG_LEVEL
SFILTER_LOG_LEVEL=info SFILTER_LOG_LEVEL=$LOG_LEVEL
SMURF_LOG_LEVEL=info SMURF_LOG_LEVEL=$LOG_LEVEL
STARTUP_LOG=/var/log/shorewall-init.log STARTUP_LOG=/var/log/shorewall-init.log
TCP_FLAGS_LOG_LEVEL=info TCP_FLAGS_LOG_LEVEL=$LOG_LEVEL
UNTRACKED_LOG_LEVEL= UNTRACKED_LOG_LEVEL=
@@ -75,7 +77,7 @@ UNTRACKED_LOG_LEVEL=
ARPTABLES= ARPTABLES=
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
GEOIPDIR=/usr/share/xt_geoip/LE GEOIPDIR=/usr/share/xt_geoip/LE
@@ -107,11 +109,12 @@ TC=
# D E F A U L T A C T I O N S / M A C R O S # D E F A U L T A C T I O N S / M A C R O S
############################################################################### ###############################################################################
ACCEPT_DEFAULT="none" ACCEPT_DEFAULT=none
DROP_DEFAULT="Drop" BLACKLIST_DEFAULT="Broadcast(DROP),Multicast(DROP),AllowICMPs,dropNotSyn:$LOG_LEVEL,dropInvalid:$LOG_LEVEL,DropDNSrep:$LOG_LEVEL"
NFQUEUE_DEFAULT="none" DROP_DEFAULT="Broadcast(DROP),Multicast(DROP),AllowICMPs"
QUEUE_DEFAULT="none" NFQUEUE_DEFAULT=none
REJECT_DEFAULT="Reject" QUEUE_DEFAULT=none
REJECT_DEFAULT="Broadcast(DROP),Multicast(DROP)"
############################################################################### ###############################################################################
# R S H / R C P C O M M A N D S # R S H / R C P C O M M A N D S
@@ -140,12 +143,12 @@ AUTOHELPERS=Yes
AUTOMAKE=Yes AUTOMAKE=Yes
BALANCE_PROVIDERS=No
BASIC_FILTERS=No BASIC_FILTERS=No
BLACKLIST="NEW,INVALID,UNTRACKED" BLACKLIST="NEW,INVALID,UNTRACKED"
CHAIN_SCRIPTS=No
CLAMPMSS=No CLAMPMSS=No
CLEAR_TC=Yes CLEAR_TC=Yes
@@ -293,5 +296,3 @@ PROVIDER_OFFSET=
MASK_BITS= MASK_BITS=
ZONE_BITS=0 ZONE_BITS=0
#LAST LINE -- DO NOT REMOVE

View File

@@ -1,6 +1,6 @@
# #
# Shorewall - Sample Masq file for three-interface configuration. # Shorewall - Sample Params File for one-interface configuration.
# Copyright (C) 2006-2015 by the Shorewall Team # Copyright (C) 2006-2014 by the Shorewall Team
# #
# This library is free software; you can redistribute it and/or # This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
@@ -8,12 +8,6 @@
# version 2.1 of the License, or (at your option) any later version. # version 2.1 of the License, or (at your option) any later version.
# #
# See the file README.txt for further details. # See the file README.txt for further details.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-masq" # For information on entries in this file, type "man shorewall-params"
################################################################################################################ ######################################################################################################################################################################################################
#INTERFACE:DEST SOURCE ADDRESS PROTO PORT(S) IPSEC MARK USER/ SWITCH ORIGINAL
# GROUP DEST
eth0 10.0.0.0/8,\
169.254.0.0/16,\
172.16.0.0/12,\
192.168.0.0/16

View File

@@ -11,8 +11,8 @@
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-policy" # For information about entries in this file, type "man shorewall-policy"
############################################################################### ###############################################################################
#SOURCE DEST POLICY LOG LEVEL LIMIT:BURST #SOURCE DEST POLICY LOGLEVEL RATE CONNLIMIT
$FW net ACCEPT $FW net ACCEPT
net all DROP info net all DROP $LOG_LEVEL
# The FOLLOWING POLICY MUST BE LAST # The FOLLOWING POLICY MUST BE LAST
all all REJECT info all all REJECT $LOG_LEVEL

View File

@@ -44,6 +44,8 @@ FIREWALL=
# L O G G I N G # L O G G I N G
############################################################################### ###############################################################################
LOG_LEVEL=info
BLACKLIST_LOG_LEVEL= BLACKLIST_LOG_LEVEL=
INVALID_LOG_LEVEL= INVALID_LOG_LEVEL=
@@ -58,25 +60,25 @@ LOGALLNEW=
LOGFILE=/var/log/messages LOGFILE=/var/log/messages
LOGFORMAT="Shorewall:%s:%s:" LOGFORMAT="%s %s "
LOGTAGONLY=No LOGTAGONLY=No
LOGLIMIT= LOGLIMIT="s:1/sec:10"
MACLIST_LOG_LEVEL=info MACLIST_LOG_LEVEL="$LOG_LEVEL"
RELATED_LOG_LEVEL= RELATED_LOG_LEVEL=
RPFILTER_LOG_LEVEL=info RPFILTER_LOG_LEVEL="$LOG_LEVEL"
SFILTER_LOG_LEVEL=info SFILTER_LOG_LEVEL="$LOG_LEVEL"
SMURF_LOG_LEVEL=info SMURF_LOG_LEVEL="$LOG_LEVEL"
STARTUP_LOG=/var/log/shorewall-init.log STARTUP_LOG=/var/log/shorewall-init.log
TCP_FLAGS_LOG_LEVEL=info TCP_FLAGS_LOG_LEVEL="$LOG_LEVEL"
UNTRACKED_LOG_LEVEL= UNTRACKED_LOG_LEVEL=
@@ -86,7 +88,7 @@ UNTRACKED_LOG_LEVEL=
ARPTABLES= ARPTABLES=
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
GEOIPDIR=/usr/share/xt_geoip/LE GEOIPDIR=/usr/share/xt_geoip/LE
@@ -118,11 +120,12 @@ TC=
# D E F A U L T A C T I O N S / M A C R O S # D E F A U L T A C T I O N S / M A C R O S
############################################################################### ###############################################################################
ACCEPT_DEFAULT="none" ACCEPT_DEFAULT=none
DROP_DEFAULT="Drop" BLACKLIST_DEFAULT="Broadcast(DROP),Multicast(DROP),AllowICMPs,dropNotSyn:$LOG_LEVEL,dropInvalid:$LOG_LEVEL,DropDNSrep:$LOG_LEVEL"
NFQUEUE_DEFAULT="none" DROP_DEFAULT="Broadcast(DROP),Multicast(DROP),AllowICMPs"
QUEUE_DEFAULT="none" NFQUEUE_DEFAULT=none
REJECT_DEFAULT="Reject" QUEUE_DEFAULT=none
REJECT_DEFAULT="Broadcast(DROP),Multicast(DROP)"
############################################################################### ###############################################################################
# R S H / R C P C O M M A N D S # R S H / R C P C O M M A N D S
@@ -151,12 +154,12 @@ AUTOHELPERS=Yes
AUTOMAKE=Yes AUTOMAKE=Yes
BALANCE_PROVIDERS=No
BASIC_FILTERS=No BASIC_FILTERS=No
BLACKLIST="NEW,INVALID,UNTRACKED" BLACKLIST="NEW,INVALID,UNTRACKED"
CHAIN_SCRIPTS=No
CLAMPMSS=No CLAMPMSS=No
CLEAR_TC=Yes CLEAR_TC=Yes
@@ -304,5 +307,3 @@ PROVIDER_OFFSET=
MASK_BITS= MASK_BITS=
ZONE_BITS=0 ZONE_BITS=0
#LAST LINE -- DO NOT REMOVE

View File

@@ -0,0 +1,13 @@
#
# Shorewall - Sample Params File for three-interface configuration.
# Copyright (C) 2006-2014 by the Shorewall Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# See the file README.txt for further details.
#------------------------------------------------------------------------------------------------------------
# For information on entries in this file, type "man shorewall-params"
######################################################################################################################################################################################################

View File

@@ -11,9 +11,9 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-policy" # For information about entries in this file, type "man shorewall-policy"
############################################################################### ###############################################################################
#SOURCE DEST POLICY LOG LEVEL LIMIT:BURST #SOURCE DEST POLICY LOGLEVEL RATE CONNLIMIT
loc net ACCEPT loc net ACCEPT
net all DROP info net all DROP $LOG_LEVEL
# THE FOLLOWING POLICY MUST BE LAST # THE FOLLOWING POLICY MUST BE LAST
all all REJECT info all all REJECT $LOG_LEVEL

View File

@@ -41,6 +41,8 @@ FIREWALL=
# L O G G I N G # L O G G I N G
############################################################################### ###############################################################################
LOG_LEVEL=info
BLACKLIST_LOG_LEVEL= BLACKLIST_LOG_LEVEL=
INVALID_LOG_LEVEL= INVALID_LOG_LEVEL=
@@ -55,25 +57,25 @@ LOGALLNEW=
LOGFILE=/var/log/messages LOGFILE=/var/log/messages
LOGFORMAT="Shorewall:%s:%s:" LOGFORMAT="%s %s "
LOGTAGONLY=No LOGTAGONLY=No
LOGLIMIT= LOGLIMIT="s:1/sec:10"
MACLIST_LOG_LEVEL=info MACLIST_LOG_LEVEL=$LOG_LEVEL
RELATED_LOG_LEVEL= RELATED_LOG_LEVEL=
RPFILTER_LOG_LEVEL=info RPFILTER_LOG_LEVEL=$LOG_LEVEL
SFILTER_LOG_LEVEL=info SFILTER_LOG_LEVEL=$LOG_LEVEL
SMURF_LOG_LEVEL=info SMURF_LOG_LEVEL=$LOG_LEVEL
STARTUP_LOG=/var/log/shorewall-init.log STARTUP_LOG=/var/log/shorewall-init.log
TCP_FLAGS_LOG_LEVEL=info TCP_FLAGS_LOG_LEVEL=$LOG_LEVEL
UNTRACKED_LOG_LEVEL= UNTRACKED_LOG_LEVEL=
@@ -83,7 +85,7 @@ UNTRACKED_LOG_LEVEL=
ARPTABLES= ARPTABLES=
CONFIG_PATH=${CONFDIR}/shorewall:${SHAREDIR}/shorewall CONFIG_PATH="${CONFDIR}/shorewall:${SHAREDIR}/shorewall"
GEOIPDIR=/usr/share/xt_geoip/LE GEOIPDIR=/usr/share/xt_geoip/LE
@@ -115,11 +117,12 @@ TC=
# D E F A U L T A C T I O N S / M A C R O S # D E F A U L T A C T I O N S / M A C R O S
############################################################################### ###############################################################################
ACCEPT_DEFAULT="none" ACCEPT_DEFAULT=none
DROP_DEFAULT="Drop" BLACKLIST_DEFAULT="Broadcast(DROP),Multicast(DROP),AllowICMPs,dropNotSyn:$LOG_LEVEL,dropInvalid:$LOG_LEVEL,DropDNSrep:$LOG_LEVEL"
NFQUEUE_DEFAULT="none" DROP_DEFAULT="Broadcast(DROP),Multicast(DROP),AllowICMPs"
QUEUE_DEFAULT="none" NFQUEUE_DEFAULT=none
REJECT_DEFAULT="Reject" QUEUE_DEFAULT=none
REJECT_DEFAULT="Broadcast(DROP),Multicast(DROP)"
############################################################################### ###############################################################################
# R S H / R C P C O M M A N D S # R S H / R C P C O M M A N D S
@@ -148,12 +151,12 @@ AUTOHELPERS=Yes
AUTOMAKE=Yes AUTOMAKE=Yes
BALANCE_PROVIDERS=No
BASIC_FILTERS=No BASIC_FILTERS=No
BLACKLIST="NEW,INVALID,UNTRACKED" BLACKLIST="NEW,INVALID,UNTRACKED"
CHAIN_SCRIPTS=No
CLAMPMSS=Yes CLAMPMSS=Yes
CLEAR_TC=Yes CLEAR_TC=Yes
@@ -301,5 +304,3 @@ PROVIDER_OFFSET=
MASK_BITS= MASK_BITS=
ZONE_BITS=0 ZONE_BITS=0
#LAST LINE -- DO NOT REMOVE

View File

@@ -0,0 +1,23 @@
#
# Shorewall - Sample SNAT/Masqueradee File for three-interface configuration.
# Copyright (C) 2006-2016 by the Shorewall Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# See the file README.txt for further details.
#------------------------------------------------------------------------------
# For information about entries in this file, type "man shorewall-snat"
#
# See http://shorewall.net/manpages/shorewall-snat.html for more information
###########################################################################################################################################
#ACTION SOURCE DEST PROTO PORT IPSEC MARK USER SWITCH ORIGDEST PROBABILITY
#
# Rules generated from masq file /home/teastep/shorewall/trunk/Shorewall/Samples/three-interfaces/masq by Shorewall 5.0.13-RC1 - Sat Oct 15 11:43:47 PDT 2016
#
MASQUERADE 10.0.0.0/8,\
169.254.0.0/16,\
172.16.0.0/12,\
192.168.0.0/16 eth0

View File

@@ -0,0 +1,13 @@
#
# Shorewall - Sample Params File for two-interface configuration.
# Copyright (C) 2006-2014 by the Shorewall Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# See the file README.txt for further details.
#------------------------------------------------------------------------------------------------------------
# For information on entries in this file, type "man shorewall-params"
######################################################################################################################################################################################################

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