do not save state when printing rules
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 19 Feb 2013 21:36:31 +0000 (22:36 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 19 Feb 2013 23:03:17 +0000 (00:03 +0100)
main.c

diff --git a/main.c b/main.c
index d94d0e9..3ef7243 100644 (file)
--- a/main.c
+++ b/main.c
@@ -261,7 +261,7 @@ start(struct fw3_state *state, bool restart)
                if (!family_loaded(state, family) || !restore_pipe(family, false))
                        continue;
 
-               if (!restart && family_running(statefile, family))
+               if (!print_rules && !restart && family_running(statefile, family))
                {
                        warn("The %s firewall appears to be started already. "
                             "If it is indeed empty, remove the %s file and retry.",
@@ -299,7 +299,7 @@ start(struct fw3_state *state, bool restart)
 
        fw3_free_statefile(statefile);
 
-       if (!rv)
+       if (!rv && !print_rules)
                fw3_write_statefile(state);
 
        return rv;
@@ -406,6 +406,9 @@ int main(int argc, char **argv)
 
        if (!strcmp(argv[optind], "print"))
        {
+               if (use_family == FW3_FAMILY_ANY)
+                       use_family = FW3_FAMILY_V4;
+
                freopen("/dev/null", "w", stderr);
 
                state->disable_ipsets = true;