]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-login: always return two arrays of same length from sd_seat_get_sessions
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 May 2017 00:48:09 +0000 (20:48 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 May 2017 01:59:09 +0000 (21:59 -0400)
sd_seat_get_sessions returns two arrays, that in principle should always match:
the session names and corresponding uids. The second array could be shorter only
if parsing or uid conversion fails. But in that case there is no way to tell
*which* uid is wrong, so they are *all* useless. It's better to simplify things and
just return an error if parsing fails.

man/sd_seat_get_active.xml
src/libsystemd/sd-login/sd-login.c

index c5e6ddab024b00e082b9f16003011c2741dfea0b..3dd461f83fad97f270919d5757f7c91784015489 100644 (file)
     one (<constant>NULL</constant> terminated) with the session
     identifiers of the sessions and one with the user identifiers of
     the Unix users the sessions belong to. An additional parameter may
-    be used to return the number of entries in the latter array. The
-    two arrays and the latter parameter may be passed as
+    be used to return the number of entries in the latter array. This
+    value is the same the return value, if the latter is nonnegative.
+    The two arrays and the last parameter may be passed as
     <constant>NULL</constant> in case these values need not to be
     determined. The arrays and the strings referenced by them need to
     be freed with the libc
index cdbdc3785664c356d390a9422346c974e0d0914f..ed15efa104f84bd3f6f8d252730486322c6c2ff9 100644 (file)
@@ -723,7 +723,7 @@ _public_ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **ui
 
                                 r = parse_uid(k, b + i);
                                 if (r < 0)
-                                        continue;
+                                        return r;
 
                                 i++;
                         }