File: 0003-systemd-prefer-resolvectl-over-systemd-resolve.patch

package info (click to toggle)
sosreport 4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 2,800 kB
  • sloc: python: 20,375; sh: 166; makefile: 3
file content (37 lines) | stat: -rw-r--r-- 1,586 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Description: Prefer resolvectl over systemd-resolve
 The latter is a deprecated compat symlink.
Author: Michael Biebl <biebl@debian.org>
Origin: upstream, https://github.com/sosreport/sos/commit/110757df526d79b2b257077bef78d2553f43e4a7
Bug: https://github.com/sosreport/sos/pull/2385
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=979264
--- a/sos/report/plugins/systemd.py
+++ b/sos/report/plugins/systemd.py
@@ -10,6 +10,7 @@
 
 from sos.report.plugins import (Plugin, RedHatPlugin, DebianPlugin,
                                 UbuntuPlugin, CosPlugin, SoSPredicate)
+from sos.utilities import is_executable
 
 
 class Systemd(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, CosPlugin):
@@ -47,11 +48,17 @@
             "timedatectl"
         ])
 
-        # systemd-resolve command starts systemd-resolved service if that
+        # resolvectl command starts systemd-resolved service if that
         # is not running, so gate the commands by this predicate
+        if is_executable('resolvectl'):
+            resolvectl_status = 'resolvectl status'
+            resolvectl_statistics = 'resolvectl statistics'
+        else:
+            resolvectl_status = 'systemd-resolve --status'
+            resolvectl_statistics = 'systemd-resolve --statistics'
         self.add_cmd_output([
-            "systemd-resolve --status",
-            "systemd-resolve --statistics",
+            resolvectl_status,
+            resolvectl_statistics,
         ], pred=SoSPredicate(self, services=["systemd-resolved"]))
 
         self.add_cmd_output("systemd-analyze plot",