]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: prepend machine ID to unit ID in list-sockets
authorDavid Tardon <dtardon@redhat.com>
Mon, 20 Feb 2023 19:00:29 +0000 (20:00 +0100)
committerDavid Tardon <dtardon@redhat.com>
Tue, 21 Feb 2023 16:15:12 +0000 (17:15 +0100)
We do it that way in all other list-* functions, so let's be consistent.

src/systemctl/systemctl-list-units.c

index 93ea21acad29f45af7826812c9e6682dab541232..ad0545cd689ec29c889480692c748ba7c1283471 100644 (file)
@@ -398,21 +398,16 @@ static int output_sockets_list(struct socket_info *socket_infos, size_t cs) {
         table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
 
         for (struct socket_info *s = socket_infos; s < socket_infos + cs; s++) {
-                _cleanup_free_ char *j = NULL;
-                const char *path;
+                _cleanup_free_ char *unit = NULL;
 
-                if (s->machine) {
-                        j = strjoin(s->machine, ":", s->path);
-                        if (!j)
-                                return log_oom();
-                        path = j;
-                } else
-                        path = s->path;
+                unit = format_unit_id(s->id, s->machine);
+                if (!unit)
+                        return log_oom();
 
                 r = table_add_many(table,
-                                        TABLE_STRING, path,
+                                        TABLE_STRING, s->path,
                                         TABLE_STRING, s->type,
-                                        TABLE_STRING, s->id);
+                                        TABLE_STRING, unit);
                 if (r < 0)
                         return table_log_add_error(r);