chiark / gitweb /
logind: Do not fail display count if a device has no parent
[elogind.git] / src / login / sd-login.c
index c795765620321147baf857672815f3b52531d4b4..ef67040ebc065f0570a6d30ffdb1bd416cb8b8b7 100644 (file)
@@ -630,7 +630,32 @@ _public_ int sd_get_uids(uid_t **users) {
 }
 
 _public_ int sd_get_machine_names(char ***machines) {
-        return get_files_in_directory("/run/systemd/machines/", machines);
+        char **l = NULL, **a, **b;
+        int r;
+
+        r = get_files_in_directory("/run/systemd/machines/", &l);
+        if (r < 0)
+                return r;
+
+        if (l) {
+                r = 0;
+
+                /* Filter out the unit: symlinks */
+                for (a = l, b = l; *a; a++) {
+                        if (startswith(*a, "unit:"))
+                                free(*a);
+                        else {
+                                *b = *a;
+                                b++;
+                                r++;
+                        }
+                }
+
+                *b = NULL;
+        }
+
+        *machines = l;
+        return r;
 }
 
 static inline int MONITOR_TO_FD(sd_login_monitor *m) {