sd-login: always return two arrays of same length from sd_seat_get_sessions

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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-05-18 20:48:09 -04:00
parent d3cfab3148
commit cc6182e854
2 changed files with 4 additions and 3 deletions

View File

@ -105,8 +105,9 @@
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

View 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++;
}