analyze: do not connect to DBUS with --offline
authorLuca Boccassi <luca.boccassi@microsoft.com>
Wed, 22 Dec 2021 18:31:15 +0000 (18:31 +0000)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 23 Dec 2021 00:44:42 +0000 (09:44 +0900)
Co-authored-by: Lucas Werkmeister <mail@lucaswerkmeister.de>
src/analyze/analyze-security.c
src/analyze/analyze.c

index d52518677cff8c6d59d869bae8f58c28fa2860e2..2691dc2c86860e7627df09fd27bc14d3855f318d 100644 (file)
@@ -2770,7 +2770,7 @@ int analyze_security(sd_bus *bus,
         _cleanup_(table_unrefp) Table *overview_table = NULL;
         int ret = 0, r;
 
-        assert(bus);
+        assert(!!bus != offline);
 
         if (offline)
                 return offline_security_checks(units, policy, scope, check_man, run_generators, threshold, root, profile, pager_flags, json_format_flags);
index b3e00581ed3236ee28a5c7696a5cfc78f8a002b5..a1908ff442ae1ff619fc70b45ccec270c4314d1f 100644 (file)
@@ -2392,9 +2392,11 @@ static int do_security(int argc, char *argv[], void *userdata) {
         int r;
         unsigned line, column;
 
-        r = acquire_bus(&bus, NULL);
-        if (r < 0)
-                return bus_log_connect_error(r, arg_transport);
+        if (!arg_offline) {
+                r = acquire_bus(&bus, NULL);
+                if (r < 0)
+                        return bus_log_connect_error(r, arg_transport);
+        }
 
         pager_open(arg_pager_flags);