swanctl: Don't print status message if nothing was loaded to stderr
authorTobias Brunner <tobias@strongswan.org>
Wed, 27 Jan 2021 13:51:56 +0000 (14:51 +0100)
committerTobias Brunner <tobias@strongswan.org>
Thu, 4 Feb 2021 15:50:36 +0000 (16:50 +0100)
This is not an error (as reflected by the returned status code) so we
should not print to stderr as output there might still be considered an
error (or at least an audit-worthy event) by some scripts.

src/swanctl/commands/load_authorities.c
src/swanctl/commands/load_conns.c
src/swanctl/commands/load_pools.c

index 32f59b4..832509b 100644 (file)
@@ -292,7 +292,7 @@ int load_authorities_cfg(vici_conn_t *conn, command_format_options_t format,
        }
        if (found == 0)
        {
-               fprintf(stderr, "no authorities found, %u unloaded\n", unloaded);
+               printf("no authorities found, %u unloaded\n", unloaded);
                return 0;
        }
        if (loaded == found)
@@ -301,6 +301,7 @@ int load_authorities_cfg(vici_conn_t *conn, command_format_options_t format,
                           loaded, unloaded);
                return 0;
        }
+
        fprintf(stderr, "loaded %u of %u authorities, %u failed to load, "
                        "%u unloaded\n", loaded, found, found - loaded, unloaded);
        return EINVAL;
index de23816..47e4349 100644 (file)
@@ -410,7 +410,7 @@ int load_conns_cfg(vici_conn_t *conn, command_format_options_t format,
        }
        if (found == 0)
        {
-               fprintf(stderr, "no connections found, %u unloaded\n", unloaded);
+               printf("no connections found, %u unloaded\n", unloaded);
                return 0;
        }
        if (loaded == found)
index 0ff6827..a3bbcfd 100644 (file)
@@ -233,7 +233,7 @@ int load_pools_cfg(vici_conn_t *conn, command_format_options_t format,
        }
        if (found == 0)
        {
-               fprintf(stderr, "no pools found, %u unloaded\n", unloaded);
+               printf("no pools found, %u unloaded\n", unloaded);
                return 0;
        }
        if (loaded == found)