]>
git.ipfire.org Git - people/ms/network.git/blob - functions.firewall-zones
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2012 IPFire Network Development Team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 function firewall_zone_create
() {
26 # Do nothing if the zone configuration already exists.
27 firewall_zone_exists
${zone} && return ${EXIT_OK}
29 # Write defaults to the file.
31 firewall_zone_read
${zone}
32 firewall_zone_write
${zone}
38 function firewall_zone_config
() {
42 print
"$(zone_dir ${zone})/fwsettings"
46 function firewall_zone_exists
() {
47 local file=$
(firewall_zone_config $@
)
49 [ -r "${file}" ] && return ${EXIT_TRUE} || return ${EXIT_FALSE}
52 function firewall_zone_read() {
56 local file=$(firewall_zone_config ${zone})
59 config_read ${file} ${FIREWALL_ZONE_SETTINGS}
62 for arg in ${FIREWALL_ZONE_SETTINGS}; do
63 isset ${arg} && continue
65 default="FIREWALL_ZONE_SETTINGS_
${arg}"
66 assign "${arg}" "${!default}"
72 function firewall_zone_write() {
76 local file=$(firewall_zone_config ${zone})
79 config_write ${file} ${FIREWALL_ZONE_SETTINGS}
83 function firewall_zone_print() {
88 firewall_zone_read ${zone}
89 config_print ${FIREWALL_ZONE_SETTINGS}
95 function firewall_zone_edit() {
100 assert firewall_zone_exists ${zone}
103 # Read current settings.
104 firewall_zone_read ${zone}
106 while [ $# -gt 0 ]; do
109 MASQUERADE4=$(cli_get_val ${1})
112 POLICY=$(cli_get_val ${1})
115 warning "Unknown option
: ${1}"
121 # Sanetize saved value.
122 if enabled MASQUERADE4; then
128 # Write updated settings.
129 firewall_zone_write ${zone}
133 function firewall_zone_reset() {
137 local file=$(firewall_zone_config ${zone})
140 # Remove the configuration file.
144 firewall_zone_create ${zone}