]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkctl: check netns only if networkd is running
authorMike Yuan <me@yhndnzj.com>
Sun, 2 Apr 2023 18:20:32 +0000 (02:20 +0800)
committerMike Yuan <me@yhndnzj.com>
Sun, 21 May 2023 07:46:22 +0000 (15:46 +0800)
src/network/networkctl.c

index 9b21afe405b70e7cfa87173e675618ca4fcc913f..5ef3cbabec8c57bbdc00ea91cd28e624e309ac29 100644 (file)
@@ -120,12 +120,12 @@ static int acquire_bus(sd_bus **ret) {
         if (r < 0)
                 return log_error_errno(r, "Failed to connect system bus: %m");
 
-        r = check_netns_match(bus);
-        if (r < 0)
-                return r;
-
-        if (!networkd_is_running())
-                fprintf(stderr, "WARNING: systemd-networkd is not running, output will be incomplete.\n\n");
+        if (networkd_is_running()) {
+                r = check_netns_match(bus);
+                if (r < 0)
+                        return r;
+        } else
+                log_warning("systemd-networkd is not running, output might be incomplete.");
 
         *ret = TAKE_PTR(bus);
         return 0;