Decouple handle destroying from committing, add fw3_ipt_close() instead
[project/firewall3.git] / main.c
diff --git a/main.c b/main.c
index 5897588..32ff87d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -205,6 +205,7 @@ stop(bool complete)
                        }
 
                        fw3_ipt_commit(handle);
+                       fw3_ipt_close(handle);
                }
 
                family_set(run_state, family, false);
@@ -280,6 +281,8 @@ start(void)
 
                        if (!print_family)
                                fw3_ipt_commit(handle);
+
+                       fw3_ipt_close(handle);
                }
 
                if (!print_family)
@@ -339,6 +342,7 @@ reload(void)
                        fw3_flush_rules(handle, run_state, true);
                        fw3_flush_zones(handle, run_state, true);
                        fw3_ipt_commit(handle);
+                       fw3_ipt_close(handle);
                }
 
                family_set(run_state, family, false);
@@ -369,6 +373,7 @@ start:
                        fw3_print_default_tail_rules(handle, cfg_state, true);
 
                        fw3_ipt_commit(handle);
+                       fw3_ipt_close(handle);
                }
 
                fw3_print_includes(cfg_state, family, true);
@@ -489,9 +494,18 @@ int main(int argc, char **argv)
        if (!strcmp(argv[optind], "print"))
        {
                if (family == FW3_FAMILY_ANY)
+               {
                        family = FW3_FAMILY_V4;
-               else if (family == FW3_FAMILY_V6 && defs->disable_ipv6)
-                       warn("IPv6 rules globally disabled in configuration");
+               }
+               else if (family == FW3_FAMILY_V6)
+               {
+                       if (defs->disable_ipv6)
+                               warn("IPv6 rules globally disabled in configuration");
+#ifdef DISABLE_IPV6
+                       else
+                               warn("IPv6 support is not compiled in");
+#endif
+               }
 
                freopen("/dev/null", "w", stderr);