diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-05-18 20:48:09 -0400 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-07-25 09:46:52 +0200 |
commit | c25b9ce75a7b1a440c788154c21353d3d1dbe337 (patch) | |
tree | d0f38b4b7fc346e9f9c7a08cd5fecd5a727edfc2 | |
parent | 502ca32e2b63522a0ba088ede194215b98f432bc (diff) |
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.
-rw-r--r-- | man/sd_seat_get_active.xml | 5 | ||||
-rw-r--r-- | src/libelogind/sd-login/sd-login.c | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/man/sd_seat_get_active.xml b/man/sd_seat_get_active.xml index b4d044282..33a8697ff 100644 --- a/man/sd_seat_get_active.xml +++ b/man/sd_seat_get_active.xml @@ -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 diff --git a/src/libelogind/sd-login/sd-login.c b/src/libelogind/sd-login/sd-login.c index e3cc3628f..c431384b4 100644 --- a/src/libelogind/sd-login/sd-login.c +++ b/src/libelogind/sd-login/sd-login.c @@ -775,7 +775,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++; } |