Compare commits

...

397 Commits

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

 - Correct the error message

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

View File

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

View File

@@ -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,24 +4008,26 @@ get_config() {
g_loopback=$(find_loopback_interfaces) g_loopback=$(find_loopback_interfaces)
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER if [ -z "$g_nopager" ]; then
[ -n "$PAGER" ] || PAGER=$DEFAULT_PAGER
if [ -n "$PAGER" -a -t 1 ]; then if [ -n "$PAGER" -a -t 1 ]; then
case $PAGER in case $PAGER in
/*) /*)
g_pager="$PAGER" g_pager="$PAGER"
[ -f "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist" [ -f "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist"
;; ;;
*) *)
g_pager=$(mywhich $PAGER 2> /dev/null) g_pager=$(mywhich $PAGER 2> /dev/null)
[ -n "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist" [ -n "$g_pager" ] || fatal_error "PAGER=$PAGER does not exist"
;; ;;
esac esac
[ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable" [ -x "$g_pager" ] || fatal_error "PAGER $g_pager is not executable"
g_pager="| $g_pager" g_pager="| $g_pager"
fi fi
fi
if [ -n "$DYNAMIC_BLACKLIST" ]; then if [ -n "$DYNAMIC_BLACKLIST" ]; then
setup_dbl setup_dbl
@@ -4246,12 +4264,17 @@ usage() # $1 = exit status
echo " reenable <interface>" echo " reenable <interface>"
ecko " refresh [ -d ] [ -n ] [ -T ] [ -D <directory> ] [ <chain>... ]" ecko " refresh [ -d ] [ -n ] [ -T ] [ -D <directory> ] [ <chain>... ]"
echo " reject <address> ..." echo " reject <address> ..."
ecko " reload [ -s ] [ -c ] [ -r <root user> ] [ -T ] [ -i ] [ <directory> ] <system>"
if [ -n "$g_lite" ]; then
echo " reload [ -n ] [ -p ] [ -f ] [ -C ] [ <directory> ]"
else
echo " reload [ -n ] [ -p ] [-d] [ -f ] [ -c ] [ -T ] [ -i ] [ -C ] [ <directory> ]"
fi
if [ -z "$g_lite" ]; then if [ -z "$g_lite" ]; then
echo " remote-reload [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>" echo " remote-reload [ -n ] [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>"
echo " remote-restart [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>" echo " remote-restart [ -n ] [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>"
echo " remote-start [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>" echo " remote-start [ -n ] [ -s ] [ -c ] [ -r <root-name> ] [ -T ] [ -i ] [ <directory> ] <system>"
fi fi
echo " reset [ <chain> ... ]" echo " reset [ <chain> ... ]"
@@ -4270,6 +4293,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 +4309,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 +4340,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 +4382,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 +4484,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 +4529,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 +4553,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

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

View File

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

View File

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

@@ -1,5 +1,5 @@
# #
# Debian Shorewall 4.5 rc file # Debian Shorewall 5.0 rc file
# #
BUILD= #Default is to detect the build system BUILD= #Default is to detect the build system
HOST=debian HOST=debian
@@ -14,7 +14,7 @@ INITDIR= #Directory where SysV init scripts are installed.
INITFILE= #Name of the product's installed SysV init script INITFILE= #Name of the product's installed SysV init script
INITSOURCE=init.debian.sh #Name of the distributed file to be installed as the SysV init script INITSOURCE=init.debian.sh #Name of the distributed file to be installed as the SysV init script
ANNOTATED= #If non-zero, annotated configuration files are installed ANNOTATED= #If non-zero, annotated configuration files are installed
SYSCONFFILE=default.debian #Name of the distributed file to be installed in $SYSCONFDIR SYSCONFFILE=default.debian.systemd #Name of the distributed file to be installed in $SYSCONFDIR
SERVICEFILE=$PRODUCT.service.debian #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service SERVICEFILE=$PRODUCT.service.debian #Name of the file to install in $SYSTEMD. Default is $PRODUCT.service
SYSCONFDIR=/etc/default #Directory where SysV init parameter files are installed SYSCONFDIR=/etc/default #Directory where SysV init parameter files are installed
SERVICEDIR=/lib/systemd/system #Directory where .service files are installed (systems running systemd only) SERVICEDIR=/lib/systemd/system #Directory where .service files are installed (systems running systemd only)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -33,9 +33,11 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ ! -x "$STATEDIR/firewall" ]; then if [ ! -x $STATEDIR/firewall ]; then
if [ $PRODUCT == shorewall -o $PRODUCT == shorewall6 ]; then if [ $PRODUCT = shorewall ]; then
${SBINDIR}/$PRODUCT $OPTIONS compile ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
fi fi
fi fi
} }

View File

@@ -31,8 +31,10 @@ setstatedir() {
[ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT} [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
if [ ! -x $STATEDIR/firewall ]; then if [ ! -x $STATEDIR/firewall ]; then
if [ $PRODUCT = shorewall -o $PRODUCT = shorewall6 ]; then if [ $PRODUCT = shorewall ]; then
${SBINDIR}/$PRODUCT compile ${SBINDIR}/shorewall compile
elif [ $PRODUCT = shorewall6 ]; then
${SBINDIR}/shorewall -6 compile
fi fi
fi fi
} }

View File

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

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

View File

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

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -25,7 +25,7 @@
# #
. /usr/share/shorewall/shorewallrc . /usr/share/shorewall/shorewallrc
prog="shorewall-lite" prog="shorewall -l"
shorewall="${SBINDIR}/$prog" shorewall="${SBINDIR}/$prog"
logger="logger -i -t $prog" logger="logger -i -t $prog"
lockfile="/var/lock/subsys/$prog" lockfile="/var/lock/subsys/$prog"
@@ -38,7 +38,7 @@ if [ -f ${SYSCONFDIR}/$prog ]; then
fi fi
start() { start() {
echo -n $"Starting Shorewall: " printf $"Starting Shorewall: "
$shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger $shorewall $OPTIONS start $STARTOPTIONS 2>&1 | $logger
retval=${PIPESTATUS[0]} retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then if [[ $retval == 0 ]]; then
@@ -52,7 +52,7 @@ start() {
} }
stop() { stop() {
echo -n $"Stopping Shorewall: " printf $"Stopping Shorewall: "
$shorewall $OPTIONS stop 2>&1 | $logger $shorewall $OPTIONS stop 2>&1 | $logger
retval=${PIPESTATUS[0]} retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then if [[ $retval == 0 ]]; then
@@ -68,7 +68,7 @@ stop() {
restart() { restart() {
# Note that we don't simply stop and start since shorewall has a built in # Note that we don't simply stop and start since shorewall has a built in
# restart which stops the firewall if running and then starts it. # restart which stops the firewall if running and then starts it.
echo -n $"Restarting Shorewall: " printf $"Restarting Shorewall: "
$shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger $shorewall $OPTIONS restart $RESTARTOPTIONS 2>&1 | $logger
retval=${PIPESTATUS[0]} retval=${PIPESTATUS[0]}
if [[ $retval == 0 ]]; then if [[ $retval == 0 ]]; then

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

@@ -519,9 +519,9 @@ sub setup_accounting() {
while ( $chainswithjumps && $progress ) { while ( $chainswithjumps && $progress ) {
$progress = 0; $progress = 0;
for my $chain1 ( sort keys %accountingjumps ) { for my $chain1 ( keys %accountingjumps ) {
if ( keys %{$accountingjumps{$chain1}} ) { if ( keys %{$accountingjumps{$chain1}} ) {
for my $chain2 ( sort keys %{$accountingjumps{$chain1}} ) { for my $chain2 ( keys %{$accountingjumps{$chain1}} ) {
delete $accountingjumps{$chain1}{$chain2}, $progress = 1 unless $accountingjumps{$chain2}; delete $accountingjumps{$chain1}{$chain2}, $progress = 1 unless $accountingjumps{$chain2};
} }
} else { } else {

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
@@ -405,18 +405,17 @@ our $VERSION = 'MODULEVERSION';
# Provider Chains for provider <p> # Provider Chains for provider <p>
# Load Balance - ~<p> # Load Balance - ~<p>
# #
# Zone-pair chains for rules chain <z12z2> # Zone-pair chains for rules chain <z1-z2>
# #
# Syn Flood - @<z12z2> # Syn Flood - @<z1-z2>
# Blacklist - <z12z2>~ # Blacklist - <z1-z2>~
# Established - ^<z12z2> # Established - ^<z1-z2>
# Related - +<z12z2> # Related - +<z1-z2>
# Invalid - _<z12z2> # Invalid - _<z1-z2>
# Untracked - &<z12z2> # Untracked - &<z1-z2>
# #
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;
@@ -435,7 +434,7 @@ use constant { STANDARD => 0x1, #defined by Netfilter
REDIRECT => 0x20, #'REDIRECT' REDIRECT => 0x20, #'REDIRECT'
ACTION => 0x40, #An action (may be built-in) ACTION => 0x40, #An action (may be built-in)
MACRO => 0x80, #A Macro MACRO => 0x80, #A Macro
LOGRULE => 0x100, #'LOG','NFLOG' LOGRULE => 0x100, #'LOG','ULOG','NFLOG'
NFQ => 0x200, #'NFQUEUE' NFQ => 0x200, #'NFQUEUE'
CHAIN => 0x400, #Manual Chain CHAIN => 0x400, #Manual Chain
SET => 0x800, #SET SET => 0x800, #SET
@@ -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,
@@ -1085,11 +1081,11 @@ sub format_option( $$ ) {
assert( ! reftype $value ); assert( ! reftype $value );
my $rule = ''; my $rule;
$value =~ s/\s*$//; $value =~ s/\s*$//;
$rule .= join( ' ' , ' -m', $option, $value ); $rule = join( ' ' , ' -m', $option, $value );
$rule; $rule;
} }
@@ -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,10 +1219,11 @@ 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;
} }
} }
for my $option ( grep ! $opttype{$_} || $_ eq 'nfacct' || $_ eq 'recent', sort { $b cmp $a } keys %$fromref ) { for my $option ( grep ! $opttype{$_} || $_ eq 'nfacct' || $_ eq 'recent', keys %$fromref ) {
set_rule_option( $toref, $option, $fromref->{$option} ); set_rule_option( $toref, $option, $fromref->{$option} );
} }
@@ -1235,7 +1239,7 @@ sub merge_rules( $$$ ) {
set_rule_option( $toref, 'policy', $fromref->{policy} ) if exists $fromref->{policy}; set_rule_option( $toref, 'policy', $fromref->{policy} ) if exists $fromref->{policy};
for my $option ( grep( get_opttype( $_, 0 ) == EXPENSIVE, sort keys %$fromref ) ) { for my $option ( grep( get_opttype( $_, 0 ) == EXPENSIVE, keys %$fromref ) ) {
set_rule_option( $toref, $option, $fromref->{$option} ); set_rule_option( $toref, $option, $fromref->{$option} );
} }
@@ -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};
@@ -3715,7 +3691,7 @@ sub optimize_level8( $$$ ) {
} }
if ( $progress ) { if ( $progress ) {
my @rename = sort keys %rename; my @rename = keys %rename;
# #
# First create aliases for each renamed chain and change the {name} member. # First create aliases for each renamed chain and change the {name} member.
# #
@@ -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!!!
@@ -4581,7 +4556,8 @@ sub do_proto( $$$;$ )
if ( $proto ne '' ) { if ( $proto ne '' ) {
my $synonly = ( $proto =~ s/:syn$//i ); my $synonly = ( $proto =~ s/:(!)?syn$//i );
my $notsyn = $1;
my $invert = ( $proto =~ s/^!// ? '! ' : '' ); my $invert = ( $proto =~ s/^!// ? '! ' : '' );
my $protonum = resolve_proto $proto; my $protonum = resolve_proto $proto;
@@ -4599,7 +4575,7 @@ sub do_proto( $$$;$ )
$output = "${invert}-p ${proto} "; $output = "${invert}-p ${proto} ";
} else { } else {
fatal_error '":syn" is only allowed with tcp' unless $proto == TCP && ! $invert; fatal_error '":syn" is only allowed with tcp' unless $proto == TCP && ! $invert;
$output = "-p $proto --syn "; $output = $notsyn ? "-p $proto ! --syn " : "-p $proto --syn ";
} }
fatal_error "SOURCE/DEST PORT(S) not allowed with PROTO !$pname" if $invert && ($ports ne '' || $sports ne ''); fatal_error "SOURCE/DEST PORT(S) not allowed with PROTO !$pname" if $invert && ($ports ne '' || $sports ne '');
@@ -5773,12 +5749,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 +5768,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 +5795,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 );
add_commands( $chainref , qq(if [ -n "$variable" ]; then) );
if ( $variable =~ /^\$/ ) {
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 +6767,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 +6778,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 +6840,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 +6862,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";
} }
@@ -6988,13 +6981,13 @@ sub set_global_variables( $$ ) {
if ( $conditional ) { if ( $conditional ) {
my ( $interface, @interfaces ); my ( $interface, @interfaces );
@interfaces = sort keys %interfaceaddr; @interfaces = keys %interfaceaddr;
for $interface ( @interfaces ) { for $interface ( @interfaces ) {
emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $interfaceaddr{$interface}) ); emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $interfaceaddr{$interface}) );
} }
@interfaces = sort keys %interfacegateways; @interfaces = keys %interfacegateways;
for $interface ( @interfaces ) { for $interface ( @interfaces ) {
emit( qq(if [ -z "\$interface" -o "\$interface" = "$interface" ]; then) ); emit( qq(if [ -z "\$interface" -o "\$interface" = "$interface" ]; then) );
@@ -7004,36 +6997,36 @@ sub set_global_variables( $$ ) {
emit( qq(fi\n) ); emit( qq(fi\n) );
} }
@interfaces = sort keys %interfacemacs; @interfaces = keys %interfacemacs;
for $interface ( @interfaces ) { for $interface ( @interfaces ) {
emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $interfacemacs{$interface}) ); emit( qq([ -z "\$interface" -o "\$interface" = "$interface" ] && $interfacemacs{$interface}) );
} }
} else { } else {
emit $_ for sort values %interfaceaddr; emit $_ for values %interfaceaddr;
emit "$_\n" for sort values %interfacegateways; emit "$_\n" for values %interfacegateways;
emit $_ for sort values %interfacemacs; emit $_ for values %interfacemacs;
} }
if ( $setall ) { if ( $setall ) {
emit $_ for sort values %interfaceaddrs; emit $_ for values %interfaceaddrs;
emit $_ for sort values %interfacenets; emit $_ for values %interfacenets;
unless ( have_capability( 'ADDRTYPE' ) ) { unless ( have_capability( 'ADDRTYPE' ) ) {
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
emit 'ALL_BCASTS="$(get_all_bcasts) 255.255.255.255"'; emit 'ALL_BCASTS="$(get_all_bcasts) 255.255.255.255"';
emit $_ for sort values %interfacebcasts; emit $_ for values %interfacebcasts;
} else { } else {
emit 'ALL_ACASTS="$(get_all_acasts)"'; emit 'ALL_ACASTS="$(get_all_acasts)"';
emit $_ for sort values %interfaceacasts; emit $_ for values %interfaceacasts;
} }
} }
} }
} }
sub verify_address_variables() { sub verify_address_variables() {
for my $variable ( sort keys %address_variables ) { for my $variable ( keys %address_variables ) {
my $type = $address_variables{$variable}; my $type = $address_variables{$variable};
my $address = "\$$variable"; my $address = "\$$variable";
@@ -7273,6 +7266,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 +7283,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 +7591,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 +7608,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 +7842,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
# #
@@ -7879,7 +7943,7 @@ sub add_interface_options( $ ) {
# #
# Generate a digest for each chain # Generate a digest for each chain
# #
for my $chainref ( sort { $a->{name} cmp $b->{name} } values %input_chains, values %forward_chains ) { for my $chainref ( values %input_chains, values %forward_chains ) {
my $digest = ''; my $digest = '';
assert( $chainref ); assert( $chainref );
@@ -7898,7 +7962,7 @@ sub add_interface_options( $ ) {
# Insert jumps to the interface chains into the rules chains # Insert jumps to the interface chains into the rules chains
# #
for my $zone1 ( off_firewall_zones ) { for my $zone1 ( off_firewall_zones ) {
my @input_interfaces = sort keys %{zone_interfaces( $zone1 )}; my @input_interfaces = keys %{zone_interfaces( $zone1 )};
my @forward_interfaces = @input_interfaces; my @forward_interfaces = @input_interfaces;
if ( @input_interfaces > 1 ) { if ( @input_interfaces > 1 ) {
@@ -7984,7 +8048,7 @@ sub add_interface_options( $ ) {
for my $zone1 ( firewall_zone, vserver_zones ) { for my $zone1 ( firewall_zone, vserver_zones ) {
for my $zone2 ( off_firewall_zones ) { for my $zone2 ( off_firewall_zones ) {
my $chainref = $filter_table->{rules_chain( $zone1, $zone2 )}; my $chainref = $filter_table->{rules_chain( $zone1, $zone2 )};
my @interfaces = sort keys %{zone_interfaces( $zone2 )}; my @interfaces = keys %{zone_interfaces( $zone2 )};
my $chain1ref; my $chain1ref;
for my $interface ( @interfaces ) { for my $interface ( @interfaces ) {
@@ -8265,6 +8329,7 @@ EOF
sub ensure_ipsets( @ ) { sub ensure_ipsets( @ ) {
my $set; my $set;
my $counters = have_capability( 'IPSET_MATCH_COUNTERS' ) ? ' counters' : '';
if ( $globals{DBL_TIMEOUT} ne '' && $_[0] eq $globals{DBL_IPSET} ) { if ( $globals{DBL_TIMEOUT} ne '' && $_[0] eq $globals{DBL_IPSET} ) {
shift; shift;
@@ -8277,12 +8342,12 @@ sub ensure_ipsets( @ ) {
emit( q( #), emit( q( #),
q( # Set the timeout for the dynamic blacklisting ipset), q( # Set the timeout for the dynamic blacklisting ipset),
q( #), q( #),
qq( \$IPSET -exist create $globals{DBL_IPSET} hash:net family inet timeout $globals{DBL_TIMEOUT} counters) ); qq( \$IPSET -exist create $globals{DBL_IPSET} hash:net family inet timeout $globals{DBL_TIMEOUT}${counters}) );
} else { } else {
emit( q( #), emit( q( #),
q( # Set the timeout for the dynamic blacklisting ipset), q( # Set the timeout for the dynamic blacklisting ipset),
q( #), q( #),
qq( \$IPSET -exist create $globals{DBL_IPSET} hash:net family inet6 timeout $globals{DBL_TIMEOUT} counters) ); qq( \$IPSET -exist create $globals{DBL_IPSET} hash:net family inet6 timeout $globals{DBL_TIMEOUT}${counters}) );
} }
pop_indent; pop_indent;
@@ -8303,8 +8368,8 @@ 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 {
emit ( qq( if ! qt \$IPSET -L $set -n; then) , emit ( qq( if ! qt \$IPSET -L $set -n; then) ,
@@ -8314,8 +8379,8 @@ 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) );
} }
@@ -8389,7 +8454,7 @@ sub create_save_ipsets() {
# #
$ipsets{$_} = 1 for ( @ipsets, @{$globals{SAVED_IPSETS}} ); $ipsets{$_} = 1 for ( @ipsets, @{$globals{SAVED_IPSETS}} );
my @sets = sort keys %ipsets; my @sets = keys %ipsets;
emit( '' , emit( '' ,
' rm -f $file' , ' rm -f $file' ,
@@ -8565,7 +8630,7 @@ sub create_load_ipsets() {
# #
sub create_nfobjects() { sub create_nfobjects() {
my @objects = ( sort keys %nfobjects ); my @objects = ( keys %nfobjects );
if ( @objects ) { if ( @objects ) {
if ( $config{NFACCT} ) { if ( $config{NFACCT} ) {
@@ -8580,7 +8645,7 @@ sub create_nfobjects() {
} }
} }
for ( sort keys %nfobjects ) { for ( keys %nfobjects ) {
emit( qq(if ! qt \$NFACCT get $_; then), emit( qq(if ! qt \$NFACCT get $_; then),
qq( \$NFACCT add $_), qq( \$NFACCT add $_),
qq(fi\n) ); qq(fi\n) );
@@ -8857,7 +8922,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};
@@ -8886,7 +8951,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;
@@ -9056,7 +9121,7 @@ sub initialize_switches() {
if ( keys %switches ) { if ( keys %switches ) {
emit( 'if [ $COMMAND = start ]; then' ); emit( 'if [ $COMMAND = start ]; then' );
push_indent; push_indent;
for my $switch ( sort keys %switches ) { for my $switch ( keys %switches ) {
my $setting = $switches{$switch}; my $setting = $switches{$switch};
my $file = "/proc/net/nf_condition/$switch"; my $file = "/proc/net/nf_condition/$switch";
emit "[ -f $file ] && echo $setting->{setting} > $file"; emit "[ -f $file ] && echo $setting->{setting} > $file";

View File

@@ -93,11 +93,10 @@ sub generate_script_1( $ ) {
my $date = compiletime; my $date = compiletime;
emit "#!$config{SHOREWALL_SHELL}\n#\n# Compiled firewall script generated by Shorewall $globals{VERSION} - $date\n#"; emit "#!$config{SHOREWALL_SHELL}\n#\n# Compiled firewall script generated by Shorewall $globals{VERSION} - $date\n#";
copy $globals{SHAREDIRPL} . '/lib.runtime', 0;
copy2 $globals{SHAREDIRPL} . '/lib.common' , $debug;
} }
copy $globals{SHAREDIRPL} . '/lib.runtime', 0;
copy2 $globals{SHAREDIRPL} . '/lib.common' , $debug;
} }
my $lib = find_file 'lib.private'; my $lib = find_file 'lib.private';
@@ -701,7 +700,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 +803,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 +815,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 +859,37 @@ sub compiler {
# #
setup_accounting if $config{ACCOUNTING}; setup_accounting if $config{ACCOUNTING};
enable_script;
#
# Generate a function to bring up each provider
#
if ( $scriptfilename || $debug ) {
emit( "\n#",
'# Setup routing and traffic shaping',
'#',
'setup_routing_and_traffic_shaping() {'
);
push_indent;
}
setup_providers;
#
# TCRules and Traffic Shaping
#
setup_tc( $update );
if ( $scriptfilename || $debug ) {
pop_indent;
emit "}\n"; # End of setup_routing_and_traffic_shaping()
}
#
# ECN
#
setup_ecn if $family == F_IPV4 && have_capability( 'MANGLE_ENABLED' ) && $config{MANGLE_ENABLED};
disable_script;
if ( $scriptfilename ) { if ( $scriptfilename ) {
# #
# Compiling a script - generate the zone by zone matrix # Compiling a script - generate the zone by zone matrix
@@ -943,7 +944,7 @@ sub compiler {
# #
# Copy the footer to the script # Copy the footer to the script
# #
copy $globals{SHAREDIRPL} . 'prog.footer' unless $test; copy $globals{SHAREDIRPL} . 'prog.footer';
disable_script; disable_script;
# #

View File

@@ -86,6 +86,9 @@ our @EXPORT = qw(
kernel_version kernel_version
compiletime compiletime
F_IPV4
F_IPV6
); );
our @EXPORT_OK = qw( $shorewall_dir initialize shorewall); our @EXPORT_OK = qw( $shorewall_dir initialize shorewall);
@@ -130,9 +133,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 +158,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 +177,7 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
$doing $doing
$done $done
$currentline $currentline
$rawcurrentline
$currentfilename $currentfilename
$debug $debug
$file_format $file_format
@@ -195,9 +199,6 @@ our %EXPORT_TAGS = ( internal => [ qw( create_temp_script
PARMSMODIFIED PARMSMODIFIED
USEDCALLER USEDCALLER
F_IPV4
F_IPV6
TCP TCP
UDP UDP
@@ -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.4-Beta1",
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,8 @@ sub initialize( $;$$) {
VERBOSE_MESSAGES => undef , VERBOSE_MESSAGES => undef ,
ZERO_MARKS => undef , ZERO_MARKS => undef ,
FIREWALL => undef , FIREWALL => undef ,
BALANCE_PROVIDERS => undef ,
PERL_HASH_SEED => undef ,
# #
# Packet Disposition # Packet Disposition
# #
@@ -977,7 +984,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 +1039,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,
@@ -1085,7 +1093,7 @@ sub initialize( $;$$) {
%compiler_params = (); %compiler_params = ();
%actparams = ( 0 => 0, loglevel => '', logtag => '', chain => '', disposition => '', caller => '' ); %actparams = ( 0 => 0, loglevel => '', logtag => '', chain => '', disposition => '', caller => '', callfile => '', callline => '' );
$parmsmodified = 0; $parmsmodified = 0;
$usedcaller = 0; $usedcaller = 0;
%ipsets = (); %ipsets = ();
@@ -1211,7 +1219,7 @@ sub compiletime() {
sub currentlineinfo() { sub currentlineinfo() {
my $linenumber = $currentlinenumber || 1; my $linenumber = $currentlinenumber || 1;
if ( $currentfile ) { if ( $currentfilename ) {
my $lineinfo = " $currentfilename "; my $lineinfo = " $currentfilename ";
if ( $linenumber eq 'EOF' ) { if ( $linenumber eq 'EOF' ) {
@@ -1997,6 +2005,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 +2078,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 +2115,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 , $_;
@@ -2154,7 +2178,7 @@ sub split_list3( $$ ) {
$element = join ',', $element , $_; $element = join ',', $element , $_;
} }
} }
unless ( $opencount == 0 ) { unless ( $opencount == 0 ) {
fatal_error "Invalid $type ($list)"; fatal_error "Invalid $type ($list)";
} }
@@ -2209,7 +2233,7 @@ sub split_list4( $ ) {
sub split_columns( $ ) { sub split_columns( $ ) {
my ($list) = @_; my ($list) = @_;
return split ' ', $list unless $list =~ /\(/; return split ' ', $list unless $list =~ /[()]/;
my @list1 = split ' ', $list; my @list1 = split ' ', $list;
my @list2; my @list2;
@@ -2250,28 +2274,11 @@ sub split_columns( $ ) {
} }
} }
unless ( $opencount == 0 ) { fatal_error "Mismatched parentheses ($list)" unless $opencount == 0;
fatal_error "Mismatched parentheses ($list)";
}
@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();
# #
@@ -2280,7 +2287,7 @@ sub clear_comment();
# ensure that it has an appropriate number of columns. # ensure that it has an appropriate number of columns.
# supply '-' in omitted trailing columns. # supply '-' in omitted trailing columns.
# Handles all of the supported forms of column/pair specification # Handles all of the supported forms of column/pair specification
# Handles segragating raw iptables input in INLINE rules # Handles segragating raw iptables input in rules
# #
sub split_line2( $$;$$$ ) { sub split_line2( $$;$$$ ) {
my ( $description, $columnsref, $nopad, $maxcolumns, $inline ) = @_; my ( $description, $columnsref, $nopad, $maxcolumns, $inline ) = @_;
@@ -2429,12 +2436,12 @@ sub split_line2( $$;$$$ ) {
} }
} else { } else {
fatal_error "Unknown column ($1)" unless exists $columnsref->{$column}; fatal_error "Unknown column ($1)" unless exists $columnsref->{$column};
$column = $columnsref->{$column};
fatal_error "Non-ASCII gunk in file" if $columns =~ /[^\s[:print:]]/;
$value = $1 if $value =~ /^"([^"]+)"$/; $value = $1 if $value =~ /^"([^"]+)"$/;
$value =~ s/\\"/"/g; $value =~ s/\\"/"/g;
fatal_error "Non-ASCII gunk in the value of the $column column" if $columns =~ /[^\s[:print:]]/; fatal_error "Non-ASCII gunk in the value of the $column column" if $value =~ /[^\s[:print:]]/;
$line[$column] = $value; my $colnum = $columnsref->{$column};
warning_message qq(Replacing "$line[$colnum]" with "$value" in the ) . uc( $column ) . ' column' if $line[$colnum] ne '-';
$line[$colnum] = $value;
} }
} }
} }
@@ -2442,6 +2449,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,13 +2712,13 @@ 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 +2771,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;
} }
@@ -2755,8 +2781,8 @@ sub evaluate_expression( $$$$ ) {
my ( $first, $var, $rest ) = ( $1, $3, $4); my ( $first, $var, $rest ) = ( $1, $3, $4);
$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 =~ /^(?:caller|callfile|callline)$/;
$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;
} }
} }
@@ -2791,7 +2817,6 @@ sub evaluate_expression( $$$$ ) {
# #
# Not a simple one-term expression -- compile it # Not a simple one-term expression -- compile it
# #
declare_passed unless $evals++; declare_passed unless $evals++;
$val = eval qq(package Shorewall::User; $val = eval qq(package Shorewall::User;
@@ -2808,6 +2833,7 @@ sub evaluate_expression( $$$$ ) {
$val; $val;
} }
sub pop_open();
# #
# Set callback # Set callback
# #
@@ -2815,6 +2841,40 @@ sub directive_callback( $ ) {
$directive_callback = shift; $directive_callback = shift;
} }
sub directive_message( \&$$$$ ) {
my ( $functptr, $verbose, $expression, $filename, $linenumber ) = @_;
unless ( $omitting ) {
if ( $actparams{0} ) {
#
# When issuing a message from an action, report the action invocation
# site rather than the action file and line number.
#
# Avoid double-reporting by temporarily removing the invocation site
# from the open stack.
#
my $saveopens = pop @openstack;
$functptr->( $verbose ,
evaluate_expression( $expression ,
$filename ,
$linenumber ,
1 ),
$actparams{callfile} ,
$actparams{callline} );
push @openstack, $saveopens;
} else {
$functptr->( $verbose ,
evaluate_expression( $expression ,
$filename ,
$linenumber ,
1 ),
$filename ,
$linenumber );
}
}
}
# #
# Each entry in @ifstack consists of a 4-tupple # Each entry in @ifstack consists of a 4-tupple
# #
@@ -2828,7 +2888,8 @@ 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 );
@@ -2930,15 +2991,16 @@ sub process_compiler_directive( $$$$ ) {
$var = $2 || 'chain'; $var = $2 || 'chain';
directive_error( "Shorewall variables may only be RESET in the body of an action", $filename, $linenumber ) unless $actparams{0}; directive_error( "Shorewall variables may only be RESET in the body of an action", $filename, $linenumber ) unless $actparams{0};
if ( exists $actparams{$var} ) { if ( exists $actparams{$var} ) {
if ( $var =~ /^loglevel|logtag|chain|disposition|caller$/ ) { if ( $var =~ /^(?:loglevel|logtag|chain|disposition|caller|callfile|callline)$/ ) {
$actparams{$var} = ''; $actparams{$var} = '';
} else { } else {
delete $actparams{$var} delete $actparams{$var}
} }
$parmsmodified = PARMSMODIFIED if @ifstack > $ifstack;
} else { } else {
directive_warning( 'Yes', "Shorewall variable $2 does not exist", $filename, $linenumber ); directive_warning( 'Yes', "Shorewall variable $2 does not exist", $filename, $linenumber );
} }
} else { } else {
if ( exists $variables{$2} ) { if ( exists $variables{$2} ) {
delete $variables{$2}; delete $variables{$2};
@@ -2968,52 +3030,87 @@ sub process_compiler_directive( $$$$ ) {
} , } ,
ERROR => sub() { ERROR => sub() {
directive_error( evaluate_expression( $expression , unless ( $omitting ) {
$filename , if ( $actparams{0} ) {
$linenumber , close $currentfile;
1 ) , #
$filename , # Avoid 'missing ?ENDIF' error in pop_open'
$linenumber ) unless $omitting; #
@ifstack = ();
#
# Avoid double-reporting the action invocation site
#
pop_open;
directive_error( evaluate_expression( $expression ,
$filename ,
$linenumber ,
1 ) ,
$actparams{callfile} ,
$actparams{callline} );
} else {
directive_error( evaluate_expression( $expression ,
$filename ,
$linenumber ,
1 ) ,
$filename ,
$linenumber ) unless $omitting;
}
}
} , } ,
WARNING => sub() { WARNING => sub() {
directive_warning( $config{VERBOSE_MESSAGES} , directive_message( &directive_warning ,
evaluate_expression( $expression , $config{VERBOSE_MESSAGES},
$filename , $expression ,
$linenumber ,
1 ),
$filename , $filename ,
$linenumber ) unless $omitting; $linenumber );
} , } ,
INFO => sub() { INFO => sub() {
directive_info( $config{VERBOSE_MESSAGES} , directive_message( &directive_info,
evaluate_expression( $expression , $config{VERBOSE_MESSAGES} ,
$filename , $expression ,
$linenumber , $filename ,
1 ), $linenumber );
$filename ,
$linenumber ) unless $omitting;
} , } ,
'WARNING!' => sub() { 'WARNING!' => sub() {
directive_warning( ! $config{VERBOSE_MESSAGES} , directive_message( &directive_warning ,
evaluate_expression( $expression , ! $config{VERBOSE_MESSAGES} ,
$filename , $expression ,
$linenumber ,
1 ),
$filename , $filename ,
$linenumber ) unless $omitting; $linenumber );
} , } ,
'INFO!' => sub() { 'INFO!' => sub() {
directive_info( ! $config{VERBOSE_MESSAGES} , directive_message( &directive_info ,
evaluate_expression( $expression , ! $config{VERBOSE_MESSAGES} ,
$filename , $expression ,
$linenumber , $filename ,
1 ), $linenumber );
$filename , } ,
$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 ( my $capdesc = $capdesc{$expression} );
unless ( have_capability( $expression ) ) {
close $currentfile;
#
# Avoid 'missing ?ENDIF' error in pop_open'
#
@ifstack = ();
#
# Avoid double-reporting the action call site
#
pop_open;
directive_error( "The $actparams{action} action requires the $capdesc capability",
$actparams{callfile} ,
$actparams{callline} );
}
}
} , } ,
); );
@@ -3026,9 +3123,9 @@ sub process_compiler_directive( $$$$ ) {
if ( $directive_callback ) { if ( $directive_callback ) {
$directive_callback->( $keyword, $line ) $directive_callback->( $keyword, $line )
} else {
$omitting;
} }
$omitting;
} }
# #
@@ -3514,6 +3611,8 @@ sub push_action_params( $$$$$$ ) {
$actparams{loglevel} = $loglevel; $actparams{loglevel} = $loglevel;
$actparams{logtag} = $logtag; $actparams{logtag} = $logtag;
$actparams{caller} = $caller; $actparams{caller} = $caller;
$actparams{callfile} = $currentfilename;
$actparams{callline} = $currentlinenumber;
$actparams{disposition} = '' if $chainref->{action}; $actparams{disposition} = '' if $chainref->{action};
# #
# The Shorewall variable '@chain' has non-word characters other than hyphen removed # The Shorewall variable '@chain' has non-word characters other than hyphen removed
@@ -3644,6 +3743,7 @@ sub expand_variables( \$ ) {
$usedcaller = USEDCALLER if $var eq 'caller'; $usedcaller = USEDCALLER if $var eq 'caller';
} else { } else {
fatal_error "Undefined shell variable (\$$var)" unless $config{IGNOREUNKNOWNVARIABLES} || exists $config{$var}; fatal_error "Undefined shell variable (\$$var)" unless $config{IGNOREUNKNOWNVARIABLES} || exists $config{$var};
$val = $config{$var};
} }
$val = '' unless defined $val; $val = '' unless defined $val;
@@ -3729,13 +3829,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 +3891,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 +3923,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 +4395,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 +4609,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 +4661,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 +4936,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 +4956,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 +5000,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 +5016,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 +5143,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 +5183,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 +5355,24 @@ sub update_config_file( $ ) {
} }
update_default( 'USE_DEFAULT_RT', 'No' ); update_default( 'USE_DEFAULT_RT', 'No' );
update_default( 'EXPORTMODULES', 'No' );
update_default( 'RESTART', 'reload' ); if ( $config{USE_DEFAULT_RT} eq '' || $config{USE_DEFAULT_RT} =~ /^no$/i ) {
update_default( 'PAGER', $shorewallrc1{DEFAULT_PAGER} ); update_default( 'BALANCE_PROVIDERS', 'No' );
} else {
update_default( 'BALANCE_PROVIDERS', 'Yes' );
}
update_default( 'EXPORTMODULES', 'No' );
update_default( 'RESTART', 'reload' );
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;
@@ -5285,8 +5423,12 @@ sub update_config_file( $ ) {
} }
} }
if ( supplied $val ) {
$val = conditional_quote $val; #
# Log LEVEL and DEFAULT settings often contain parens
#
$val = ($var =~ /(?:LEVEL|DEFAULT)$/) ? qq("$val") : conditional_quote $val;
}
$_ = "$var=$val\n"; $_ = "$var=$val\n";
} }
@@ -5349,6 +5491,7 @@ EOF
sub process_shorewall_conf( $$ ) { sub process_shorewall_conf( $$ ) {
my ( $update, $annotate ) = @_; my ( $update, $annotate ) = @_;
my $file = find_file "$product.conf"; my $file = find_file "$product.conf";
my @vars;
if ( -f $file ) { if ( -f $file ) {
$globals{CONFIGDIR} = $configfile = $file; $globals{CONFIGDIR} = $configfile = $file;
@@ -5362,7 +5505,7 @@ sub process_shorewall_conf( $$ ) {
# Don't expand shell variables or allow embedded scripting # Don't expand shell variables or allow embedded scripting
# #
while ( read_a_line( STRIP_COMMENTS | SUPPRESS_WHITESPACE | CHECK_GUNK ) ) { while ( read_a_line( STRIP_COMMENTS | SUPPRESS_WHITESPACE | CHECK_GUNK ) ) {
if ( $currentline =~ /^\s*([a-zA-Z]\w*)=(.*?)\s*$/ ) { if ( $currentline =~ /^\s*([a-zA-Z]\w*)=(.*)$/ ) {
my ($var, $val) = ($1, $2); my ($var, $val) = ($1, $2);
if ( exists $config{$var} ) { if ( exists $config{$var} ) {
@@ -5381,6 +5524,12 @@ sub process_shorewall_conf( $$ ) {
next; next;
} }
if ( $update ) {
push @vars, $var;
} else {
expand_variables( $val ) unless $val =~ /^'.*'$/;
}
$config{$var} = ( $val =~ /\"([^\"]*)\"$/ ? $1 : $val ); $config{$var} = ( $val =~ /\"([^\"]*)\"$/ ? $1 : $val );
warning_message "Option $var=$val is deprecated" warning_message "Option $var=$val is deprecated"
@@ -5401,14 +5550,19 @@ sub process_shorewall_conf( $$ ) {
# #
# Now update the config file if asked # Now update the config file if asked
# #
update_config_file( $annotate ) if $update; if ( $update ) {
# update_config_file( $annotate );
# Config file update requires that the option values not have #
# Shell variables expanded. We do that now. # Config file update requires that the option values not have
# # Shell variables expanded. We do that now.
for ( values %config ) { #
if ( supplied $_ ) { # To handle options like LOG_LEVEL, we process the options
expand_variables( $_ ) unless /^'(.+)'$/; # in the order in which they appear in the .conf file.
#
for ( @vars ) {
if ( supplied( my $val = $config{$_} ) ) {
expand_variables( $config{$_} ) unless $val =~ /^'.*'$/;
}
} }
} }
} }
@@ -6183,7 +6337,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 +6391,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 +6408,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 +6450,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 +6460,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 +6559,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 +6733,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 +6870,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 +6902,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 +6928,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

@@ -389,6 +389,8 @@ sub resolve_proto( $ ) {
my $proto = $_[0]; my $proto = $_[0];
my $number; my $number;
$proto =~ s/:.*//;
if ( $proto =~ /^\d+$/ || $proto =~ /^0x/ ) { if ( $proto =~ /^\d+$/ || $proto =~ /^0x/ ) {
$number = numeric_value ( $proto ); $number = numeric_value ( $proto );
defined $number && $number <= 255 ? $number : undef; defined $number && $number <= 255 ? $number : undef;
@@ -472,7 +474,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 +485,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

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

View File

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

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,20 +507,23 @@ 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 ) {
( $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, 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,19 +603,37 @@ 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)};
if ( $local ) { unless ( $pseudo ) {
fatal_error "GATEWAY not valid with 'local' provider" unless $gatewaycase eq 'omitted'; if ( $local ) {
fatal_error "'track' not valid with 'local'" if $track; fatal_error "GATEWAY not valid with 'local' provider" unless $gatewaycase eq 'omitted';
fatal_error "DUPLICATE not valid with 'local'" if $duplicate ne '-'; fatal_error "'track' not valid with 'local'" if $track;
fatal_error "'persistent' is not valid with 'local" if $persistent; fatal_error "DUPLICATE not valid with 'local'" if $duplicate ne '-';
} elsif ( $tproxy ) { fatal_error "'persistent' is not valid with 'local" if $persistent;
fatal_error "Only one 'tproxy' provider is allowed" if $tproxies++; } elsif ( $tproxy ) {
fatal_error "GATEWAY not valid with 'tproxy' provider" unless $gatewaycase eq 'omitted'; fatal_error "Only one 'tproxy' provider is allowed" if $tproxies++;
fatal_error "'track' not valid with 'tproxy'" if $track; fatal_error "GATEWAY not valid with 'tproxy' provider" unless $gatewaycase eq 'omitted';
fatal_error "DUPLICATE not valid with 'tproxy'" if $duplicate ne '-'; fatal_error "'track' not valid with 'tproxy'" if $track;
fatal_error "MARK not allowed with 'tproxy'" if $mark ne '-'; fatal_error "DUPLICATE not valid with 'tproxy'" if $duplicate ne '-';
fatal_error "'persistent' is not valid with 'tproxy" if $persistent; fatal_error "MARK not allowed with 'tproxy'" if $mark ne '-';
$mark = $globals{TPROXY_MARK}; fatal_error "'persistent' is not valid with 'tproxy" if $persistent;
$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' );
emit ( " run_ip route replace default scope global table $table \$DEFAULT_ROUTE" );
if ( $family == F_IPV4 ) {
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' );
emit( " run_ip route replace default scope global table $default \$FALLBACK_ROUTE" );
if ( $family == F_IPV4 ) {
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',
@@ -1713,7 +1799,7 @@ sub map_provider_to_interface() {
my $haveoptional; my $haveoptional;
for my $providerref ( sort { $a->{number} cmp $b->{number} } values %providers ) { for my $providerref ( values %providers ) {
if ( $providerref->{optional} ) { if ( $providerref->{optional} ) {
unless ( $haveoptional++ ) { unless ( $haveoptional++ ) {
emit( 'if [ -n "$interface" ]; then', emit( 'if [ -n "$interface" ]; then',
@@ -1877,7 +1963,7 @@ sub compile_updown() {
} }
my @nonshared = ( grep $providers{$_}->{optional}, my @nonshared = ( grep $providers{$_}->{optional},
sort( { $providers{$a}->{number} <=> $providers{$b}->{number} } values %provider_interfaces ) ); values %provider_interfaces );
if ( @nonshared ) { if ( @nonshared ) {
my $interfaces = join( '|', map $providers{$_}->{physical}, @nonshared ); my $interfaces = join( '|', map $providers{$_}->{physical}, @nonshared );
@@ -2072,7 +2158,7 @@ sub handle_optional_interfaces( $ ) {
# names but they might derive from wildcard interface entries. Optional interfaces which do not have # names but they might derive from wildcard interface entries. Optional interfaces which do not have
# wildcard physical names are also included in the providers table. # wildcard physical names are also included in the providers table.
# #
for my $providerref ( grep $_->{optional} , sort { $a->{number} <=> $b->{number} } values %providers ) { for my $providerref ( grep $_->{optional} , values %providers ) {
push @interfaces, $providerref->{interface}; push @interfaces, $providerref->{interface};
$wildcards ||= $providerref->{wildcard}; $wildcards ||= $providerref->{wildcard};
} }
@@ -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

@@ -154,7 +154,7 @@ sub setup_proxy_arp() {
emit ''; emit '';
for my $interface ( sort keys %reset ) { for my $interface ( keys %reset ) {
unless ( $set{interface} ) { unless ( $set{interface} ) {
my $physical = get_physical $interface; my $physical = get_physical $interface;
emit ( "if [ -f /proc/sys/net/ipv$family/conf/$physical/$proc_file ]; then" , emit ( "if [ -f /proc/sys/net/ipv$family/conf/$physical/$proc_file ]; then" ,
@@ -163,7 +163,7 @@ sub setup_proxy_arp() {
} }
} }
for my $interface ( sort keys %set ) { for my $interface ( keys %set ) {
my $physical = get_physical $interface; my $physical = get_physical $interface;
emit ( "if [ -f /proc/sys/net/ipv$family/conf/$physical/$proc_file ]; then" , emit ( "if [ -f /proc/sys/net/ipv$family/conf/$physical/$proc_file ]; then" ,
" echo 1 > /proc/sys/net/ipv$family/conf/$physical/$proc_file" ); " echo 1 > /proc/sys/net/ipv$family/conf/$physical/$proc_file" );

View File

@@ -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,9 +1559,9 @@ sub process_tc_filter2( $$$$$$$$$ ) {
$rule .= ' and' if @parts; $rule .= ' and' if @parts;
} }
} }
$have_rule = 1;
} }
$have_rule = 1;
} }
if ( $have_rule ) { if ( $have_rule ) {
@@ -1922,7 +1924,7 @@ sub process_traffic_shaping() {
my ( $options, $redopts ) = ( '', $tcref->{redopts} ); my ( $options, $redopts ) = ( '', $tcref->{redopts} );
for my $option ( sort keys %validredoptions ) { for my $option ( keys %validredoptions ) {
my $type = $validredoptions{$option}; my $type = $validredoptions{$option};
if ( my $value = $redopts->{$option} ) { if ( my $value = $redopts->{$option} ) {
@@ -1941,7 +1943,7 @@ sub process_traffic_shaping() {
my ( $options, $codelopts ) = ( '', $tcref->{codelopts} ); my ( $options, $codelopts ) = ( '', $tcref->{codelopts} );
for my $option ( sort keys %validcodeloptions ) { for my $option ( keys %validcodeloptions ) {
my $type = $validcodeloptions{$option}; my $type = $validcodeloptions{$option};
if ( my $value = $codelopts->{$option} ) { if ( my $value = $codelopts->{$option} ) {
@@ -2148,6 +2150,50 @@ sub process_secmark_rule() {
} }
} }
sub convert_one_tos( $ ) {
my ( $mangle ) = @_;
my ($src, $dst, $proto, $ports, $sports , $tos, $mark ) =
split_rawline2( 'tos file entry',
{ source => 0, dest => 1, proto => 2, dport => 3, sport => 4, tos => 5, mark => 6 },
undef,
7 );
my $chain_designator = 'P';
decode_tos($tos, 1);
my ( $srczone , $source , $remainder );
if ( $family == F_IPV4 ) {
( $srczone , $source , $remainder ) = split( /:/, $src, 3 );
fatal_error 'Invalid SOURCE' if defined $remainder;
} elsif ( $src =~ /^(.+?):<(.*)>\s*$/ || $src =~ /^(.+?):\[(.*)\]\s*$/ ) {
$srczone = $1;
$source = $2;
} else {
$srczone = $src;
}
if ( $srczone eq firewall_zone ) {
$chain_designator = 'O';
$src = $source || '-';
} else {
$src =~ s/^all:?//;
}
$dst =~ s/^all:?//;
$src = '-' unless supplied $src;
$dst = '-' unless supplied $dst;
$proto = '-' unless supplied $proto;
$ports = '-' unless supplied $ports;
$sports = '-' unless supplied $sports;
$mark = '-' unless supplied $mark;
print $mangle "TOS($tos):$chain_designator\t$src\t$dst\t$proto\t$ports\t$sports\t-\t$mark\n"
}
sub convert_tos($$) { sub convert_tos($$) {
my ( $mangle, $fn1 ) = @_; my ( $mangle, $fn1 ) = @_;
@@ -2165,6 +2211,25 @@ sub convert_tos($$) {
} }
if ( my $fn = open_file 'tos' ) { 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( first_entry(
sub { sub {
my $date = compiletime; my $date = compiletime;
@@ -2178,48 +2243,12 @@ sub convert_tos($$) {
while ( read_a_line( NORMAL_READ ) ) { while ( read_a_line( NORMAL_READ ) ) {
convert_one_tos( $mangle );
$have_tos = 1; $have_tos = 1;
my ($src, $dst, $proto, $ports, $sports , $tos, $mark ) =
split_line( 'tos file entry',
{ source => 0, dest => 1, proto => 2, dport => 3, sport => 4, tos => 5, mark => 6 } );
my $chain_designator = 'P';
decode_tos($tos, 1);
my ( $srczone , $source , $remainder );
if ( $family == F_IPV4 ) {
( $srczone , $source , $remainder ) = split( /:/, $src, 3 );
fatal_error 'Invalid SOURCE' if defined $remainder;
} elsif ( $src =~ /^(.+?):<(.*)>\s*$/ || $src =~ /^(.+?):\[(.*)\]\s*$/ ) {
$srczone = $1;
$source = $2;
} else {
$srczone = $src;
}
if ( $srczone eq firewall_zone ) {
$chain_designator = 'O';
$src = $source || '-';
} else {
$src =~ s/^all:?//;
}
$dst =~ s/^all:?//;
$src = '-' unless supplied $src;
$dst = '-' unless supplied $dst;
$proto = '-' unless supplied $proto;
$ports = '-' unless supplied $ports;
$sports = '-' unless supplied $sports;
$mark = '-' unless supplied $mark;
print $mangle "TOS($tos):$chain_designator\t$src\t$dst\t$proto\t$ports\t$sports\t-\t$mark\n"
} }
directive_callback(0);
if ( $have_tos ) { if ( $have_tos ) {
progress_message2 "Converted $fn to $fn1"; progress_message2 "Converted $fn to $fn1";
if ( rename $fn, "$fn.bak" ) { if ( rename $fn, "$fn.bak" ) {
@@ -2248,9 +2277,10 @@ sub open_mangle_for_output( $ ) {
# #
transfer_permissions( $fn, $fn1 ); transfer_permissions( $fn, $fn1 );
print $mangle <<'EOF'; if ( $family == F_IPV4 ) {
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
@@ -109,24 +108,6 @@ our @EXPORT = ( qw( NOTHING
our @EXPORT_OK = qw( initialize ); our @EXPORT_OK = qw( initialize );
our $VERSION = 'MODULEVERSION'; our $VERSION = 'MODULEVERSION';
#
# IPSEC Option types
#
use constant { NOTHING => 'NOTHING',
NUMERIC => '0x[\da-fA-F]+|\d+',
NETWORK => '\d+.\d+.\d+.\d+(\/\d+)?',
IPSECPROTO => 'ah|esp|ipcomp',
IPSECMODE => 'tunnel|transport'
};
#
# Option columns
#
use constant { IN_OUT => 1,
IN => 2,
OUT => 3 };
# #
# Zone Table. # Zone Table.
# #
@@ -195,7 +176,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>
@@ -223,6 +203,26 @@ our $zonemarkincr;
our $zonemarklimit; our $zonemarklimit;
our $loopback_interface; our $loopback_interface;
#
# IPSEC Option types
#
use constant { NOTHING => 'NOTHING',
NUMERIC => '0x[\da-fA-F]+|\d+',
IPSECPROTO => 'ah|esp|ipcomp',
IPSECMODE => 'tunnel|transport'
};
sub NETWORK() {
$family == F_IPV4 ? '\d+.\d+.\d+.\d+(\/\d+)?' : '(?:[0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}(?:\/d+)?';
}
#
# Option columns
#
use constant { IN_OUT => 1,
IN => 2,
OUT => 3 };
use constant { FIREWALL => 1, use constant { FIREWALL => 1,
IP => 2, IP => 2,
BPORT => 4, BPORT => 4,
@@ -278,19 +278,7 @@ our %maxoptionvalue = ( routefilter => 2, mss => 100000 , wait => 120 , ignore =
our %validhostoptions; our %validhostoptions;
our %validzoneoptions = ( mss => NUMERIC, our %validzoneoptions;
nomark => NOTHING,
blacklist => NOTHING,
dynamic_shared => NOTHING,
strict => NOTHING,
next => NOTHING,
reqid => NUMERIC,
spi => NUMERIC,
proto => IPSECPROTO,
mode => IPSECMODE,
"tunnel-src" => NETWORK,
"tunnel-dst" => NETWORK,
);
use constant { UNRESTRICTED => 1, NOFW => 2 , COMPLEX => 8, IN_OUT_ONLY => 16 }; use constant { UNRESTRICTED => 1, NOFW => 2 , COMPLEX => 8, IN_OUT_ONLY => 16 };
# #
@@ -332,6 +320,20 @@ sub initialize( $$ ) {
$minroot = 0; $minroot = 0;
$loopback_interface = ''; $loopback_interface = '';
%validzoneoptions = ( mss => NUMERIC,
nomark => NOTHING,
blacklist => NOTHING,
dynamic_shared => NOTHING,
strict => NOTHING,
next => NOTHING,
reqid => NUMERIC,
spi => NUMERIC,
proto => IPSECPROTO,
mode => IPSECMODE,
"tunnel-src" => NETWORK,
"tunnel-dst" => NETWORK,
);
if ( $family == F_IPV4 ) { if ( $family == F_IPV4 ) {
%validinterfaceoptions = (arp_filter => BINARY_IF_OPTION, %validinterfaceoptions = (arp_filter => BINARY_IF_OPTION,
arp_ignore => ENUM_IF_OPTION, arp_ignore => ENUM_IF_OPTION,
@@ -398,7 +400,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,
@@ -410,6 +411,8 @@ sub initialize( $$ ) {
forward => BINARY_IF_OPTION, forward => BINARY_IF_OPTION,
physical => STRING_IF_OPTION + IF_OPTION_HOST, physical => STRING_IF_OPTION + IF_OPTION_HOST,
unmanaged => SIMPLE_IF_OPTION, unmanaged => SIMPLE_IF_OPTION,
upnp => SIMPLE_IF_OPTION,
upnpclient => SIMPLE_IF_OPTION,
wait => NUMERIC_IF_OPTION + IF_OPTION_WILDOK, wait => NUMERIC_IF_OPTION + IF_OPTION_WILDOK,
); );
%validhostoptions = ( %validhostoptions = (
@@ -716,10 +719,10 @@ sub zone_report()
my $printed = 0; my $printed = 0;
if ( $hostref ) { if ( $hostref ) {
for my $type ( sort keys %$hostref ) { for my $type ( keys %$hostref ) {
my $interfaceref = $hostref->{$type}; my $interfaceref = $hostref->{$type};
for my $interface ( sort keys %$interfaceref ) { for my $interface ( keys %$interfaceref ) {
my $iref = $interfaces{$interface}; my $iref = $interfaces{$interface};
my $arrayref = $interfaceref->{$interface}; my $arrayref = $interfaceref->{$interface};
@@ -769,10 +772,10 @@ sub dump_zone_contents() {
$entry .= ( " mark=" . in_hex( $zoneref->{mark} ) ) if exists $zoneref->{mark}; $entry .= ( " mark=" . in_hex( $zoneref->{mark} ) ) if exists $zoneref->{mark};
if ( $hostref ) { if ( $hostref ) {
for my $type ( sort keys %$hostref ) { for my $type ( keys %$hostref ) {
my $interfaceref = $hostref->{$type}; my $interfaceref = $hostref->{$type};
for my $interface ( sort keys %$interfaceref ) { for my $interface ( keys %$interfaceref ) {
my $iref = $interfaces{$interface}; my $iref = $interfaces{$interface};
my $arrayref = $interfaceref->{$interface}; my $arrayref = $interfaceref->{$interface};
@@ -1278,6 +1281,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 ) {
@@ -1315,7 +1319,7 @@ sub process_interface( $$ ) {
assert(0); assert(0);
} }
} elsif ( $type == STRING_IF_OPTION ) { } elsif ( $type == STRING_IF_OPTION ) {
fatal_error "The '$option' option requires a value" unless defined $value; fatal_error "The '$option' option requires a value" unless supplied $value;
if ( $option eq 'physical' ) { if ( $option eq 'physical' ) {
fatal_error "Invalid interface name ($interface)" if $interface =~ /[()\[\]\*\?%]/; fatal_error "Invalid interface name ($interface)" if $interface =~ /[()\[\]\*\?%]/;
@@ -2221,9 +2225,9 @@ sub find_hosts_by_option( $ ) {
} }
for my $zone ( grep ! ( $zones{$_}{type} & FIREWALL ) , @zones ) { for my $zone ( grep ! ( $zones{$_}{type} & FIREWALL ) , @zones ) {
for my $type (sort keys %{$zones{$zone}{hosts}} ) { for my $type (keys %{$zones{$zone}{hosts}} ) {
my $interfaceref = $zones{$zone}{hosts}->{$type}; my $interfaceref = $zones{$zone}{hosts}->{$type};
for my $interface ( sort keys %$interfaceref ) { for my $interface ( keys %$interfaceref ) {
my $arrayref = $interfaceref->{$interface}; my $arrayref = $interfaceref->{$interface};
for my $host ( @{$arrayref} ) { for my $host ( @{$arrayref} ) {
my $ipsec = $host->{ipsec}; my $ipsec = $host->{ipsec};
@@ -2251,9 +2255,9 @@ sub find_zone_hosts_by_option( $$ ) {
my @hosts; my @hosts;
unless ( $zones{$zone}{type} & FIREWALL ) { unless ( $zones{$zone}{type} & FIREWALL ) {
for my $type (sort keys %{$zones{$zone}{hosts}} ) { for my $type (keys %{$zones{$zone}{hosts}} ) {
my $interfaceref = $zones{$zone}{hosts}->{$type}; my $interfaceref = $zones{$zone}{hosts}->{$type};
for my $interface ( sort keys %$interfaceref ) { for my $interface ( keys %$interfaceref ) {
my $arrayref = $interfaceref->{$interface}; my $arrayref = $interfaceref->{$interface};
for my $host ( @{$arrayref} ) { for my $host ( @{$arrayref} ) {
if ( my $value = $host->{options}{$option} ) { if ( my $value = $host->{options}{$option} ) {

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)
# #
@@ -43,6 +43,8 @@
# --inline # Update alternative column specifications # --inline # Update alternative column specifications
# --update # Update configuration to current release # --update # Update configuration to current release
# #
# If the <filename> is omitted, then a 'check' operation is performed.
#
use strict; use strict;
use FindBin; use FindBin;
use lib "$FindBin::Bin"; use lib "$FindBin::Bin";

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"

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