login: wrap CanTTY and CanGraphical seat attributes in libsystemd-login
This commit is contained in:
parent
7ea9cb9120
commit
20747498c6
|
@ -72,6 +72,16 @@
|
||||||
<funcdef>int <function>sd_seat_can_multi_session</function></funcdef>
|
<funcdef>int <function>sd_seat_can_multi_session</function></funcdef>
|
||||||
<paramdef>const char* <parameter>seat</parameter></paramdef>
|
<paramdef>const char* <parameter>seat</parameter></paramdef>
|
||||||
</funcprototype>
|
</funcprototype>
|
||||||
|
|
||||||
|
<funcprototype>
|
||||||
|
<funcdef>int <function>sd_seat_can_tty</function></funcdef>
|
||||||
|
<paramdef>const char* <parameter>seat</parameter></paramdef>
|
||||||
|
</funcprototype>
|
||||||
|
|
||||||
|
<funcprototype>
|
||||||
|
<funcdef>int <function>sd_seat_can_graphical</function></funcdef>
|
||||||
|
<paramdef>const char* <parameter>seat</parameter></paramdef>
|
||||||
|
</funcprototype>
|
||||||
</funcsynopsis>
|
</funcsynopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
|
|
||||||
|
@ -111,6 +121,15 @@
|
||||||
sessions in parallel (whith only one being active at a
|
sessions in parallel (whith only one being active at a
|
||||||
time).</para>
|
time).</para>
|
||||||
|
|
||||||
|
<para><function>sd_seat_can_tty()</function> may be
|
||||||
|
used to determine whether a specific seat provides TTY
|
||||||
|
functionality, i.e. is useful as a text console.</para>
|
||||||
|
|
||||||
|
<para><function>sd_seat_can_graphical()</function> may
|
||||||
|
be used to determine whether a specific seat provides
|
||||||
|
graphics functionality, i.e. is useful as a graphics
|
||||||
|
display.</para>
|
||||||
|
|
||||||
<para>If the <literal>seat</literal> parameter of any
|
<para>If the <literal>seat</literal> parameter of any
|
||||||
of these functions is passed as NULL the operation is
|
of these functions is passed as NULL the operation is
|
||||||
executed for the seat of the session of the calling
|
executed for the seat of the session of the calling
|
||||||
|
@ -126,8 +145,10 @@
|
||||||
<function>sd_seat_get_sessions()</function> returns
|
<function>sd_seat_get_sessions()</function> returns
|
||||||
the number of entries in the session identifier
|
the number of entries in the session identifier
|
||||||
array. If the test succeeds
|
array. If the test succeeds
|
||||||
<function>sd_seat_can_multi_session</function> returns
|
<function>sd_seat_can_multi_session</function>,
|
||||||
a positive integer, if it fails 0. On failure, these
|
<function>sd_seat_can_tty</function> and
|
||||||
|
<function>sd_seat_can_graphical</function> return a
|
||||||
|
positive integer, if it fails 0. On failure, these
|
||||||
calls return a negative errno-style error code.</para>
|
calls return a negative errno-style error code.</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
@ -135,8 +156,10 @@
|
||||||
<title>Notes</title>
|
<title>Notes</title>
|
||||||
|
|
||||||
<para>The <function>sd_seat_get_active()</function>,
|
<para>The <function>sd_seat_get_active()</function>,
|
||||||
<function>sd_seat_get_sessions()</function>, and
|
<function>sd_seat_get_sessions()</function>,
|
||||||
<function>sd_seat_can_multi_session()</function> interfaces
|
<function>sd_seat_can_multi_session()</function>,
|
||||||
|
<function>sd_seat_can_tty()</function> and
|
||||||
|
<function>sd_seat_can_grapical()</function> interfaces
|
||||||
are available as shared library, which can be compiled
|
are available as shared library, which can be compiled
|
||||||
and linked to with the
|
and linked to with the
|
||||||
<literal>libsystemd-login</literal>
|
<literal>libsystemd-login</literal>
|
||||||
|
|
|
@ -198,9 +198,13 @@
|
||||||
<para>If the test succeeds
|
<para>If the test succeeds
|
||||||
<function>sd_session_is_active()</function> returns a
|
<function>sd_session_is_active()</function> returns a
|
||||||
positive integer, if it fails 0. On success
|
positive integer, if it fails 0. On success
|
||||||
|
<function>sd_session_get_state()</function>,
|
||||||
<function>sd_session_get_uid()</function>,
|
<function>sd_session_get_uid()</function>,
|
||||||
<function>sd_session_get_service()</function> and
|
<function>sd_session_get_seat()</function>,
|
||||||
<function>sd_session_get_seat()</function> return 0 or
|
<function>sd_session_get_service()</function>,
|
||||||
|
<function>sd_session_get_type()</function>,
|
||||||
|
<function>sd_session_get_class()</function> and
|
||||||
|
<function>sd_session_get_display()</function> return 0 or
|
||||||
a positive integer. On failure, these calls return a
|
a positive integer. On failure, these calls return a
|
||||||
negative errno-style error code.</para>
|
negative errno-style error code.</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
@ -209,9 +213,13 @@
|
||||||
<title>Notes</title>
|
<title>Notes</title>
|
||||||
|
|
||||||
<para>The <function>sd_session_is_active()</function>,
|
<para>The <function>sd_session_is_active()</function>,
|
||||||
|
<function>sd_session_get_state()</function>,
|
||||||
<function>sd_session_get_uid()</function>,
|
<function>sd_session_get_uid()</function>,
|
||||||
<function>sd_session_get_service()</function> and
|
<function>sd_session_get_seat()</function>,
|
||||||
<function>sd_session_get_seat()</function> interfaces
|
<function>sd_session_get_service()</function>,
|
||||||
|
<function>sd_session_get_type()</function>,
|
||||||
|
<function>sd_session_get_class()</function> and
|
||||||
|
<function>sd_session_get_display()</function> interfaces
|
||||||
are available as shared library, which can be compiled
|
are available as shared library, which can be compiled
|
||||||
and linked to with the
|
and linked to with the
|
||||||
<literal>libsystemd-login</literal>
|
<literal>libsystemd-login</literal>
|
||||||
|
|
|
@ -50,4 +50,6 @@ global:
|
||||||
LIBSYSTEMD_LOGIN_186 {
|
LIBSYSTEMD_LOGIN_186 {
|
||||||
global:
|
global:
|
||||||
sd_session_get_state;
|
sd_session_get_state;
|
||||||
|
sd_seat_can_tty;
|
||||||
|
sd_seat_can_graphical;
|
||||||
} LIBSYSTEMD_LOGIN_43;
|
} LIBSYSTEMD_LOGIN_43;
|
||||||
|
|
|
@ -583,7 +583,7 @@ _public_ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **ui
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
_public_ int sd_seat_can_multi_session(const char *seat) {
|
static int seat_get_can(const char *seat, const char *variable) {
|
||||||
char *p, *s = NULL;
|
char *p, *s = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -592,7 +592,7 @@ _public_ int sd_seat_can_multi_session(const char *seat) {
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = parse_env_file(p, NEWLINE,
|
r = parse_env_file(p, NEWLINE,
|
||||||
"CAN_MULTI_SESSION", &s,
|
variable, &s,
|
||||||
NULL);
|
NULL);
|
||||||
free(p);
|
free(p);
|
||||||
|
|
||||||
|
@ -610,6 +610,18 @@ _public_ int sd_seat_can_multi_session(const char *seat) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_public_ int sd_seat_can_multi_session(const char *seat) {
|
||||||
|
return seat_get_can(seat, "CAN_MULTI_SESSION");
|
||||||
|
}
|
||||||
|
|
||||||
|
_public_ int sd_seat_can_tty(const char *seat) {
|
||||||
|
return seat_get_can(seat, "CAN_TTY");
|
||||||
|
}
|
||||||
|
|
||||||
|
_public_ int sd_seat_can_graphical(const char *seat) {
|
||||||
|
return seat_get_can(seat, "CAN_GRAPHICAL");
|
||||||
|
}
|
||||||
|
|
||||||
_public_ int sd_get_seats(char ***seats) {
|
_public_ int sd_get_seats(char ***seats) {
|
||||||
return get_files_in_directory("/run/systemd/seats/", seats);
|
return get_files_in_directory("/run/systemd/seats/", seats);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,14 @@ int main(int argc, char* argv[]) {
|
||||||
assert_se(r >= 0);
|
assert_se(r >= 0);
|
||||||
printf("can do multi session = %s\n", yes_no(r));
|
printf("can do multi session = %s\n", yes_no(r));
|
||||||
|
|
||||||
|
r = sd_seat_can_tty(seat);
|
||||||
|
assert_se(r >= 0);
|
||||||
|
printf("can do tty = %s\n", yes_no(r));
|
||||||
|
|
||||||
|
r = sd_seat_can_graphical(seat);
|
||||||
|
assert_se(r >= 0);
|
||||||
|
printf("can do graphical = %s\n", yes_no(r));
|
||||||
|
|
||||||
assert_se(sd_uid_get_state(u, &state) >= 0);
|
assert_se(sd_uid_get_state(u, &state) >= 0);
|
||||||
printf("state = %s\n", state);
|
printf("state = %s\n", state);
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,12 @@ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **uid, unsign
|
||||||
/* Return whether the seat is multi-session capable */
|
/* Return whether the seat is multi-session capable */
|
||||||
int sd_seat_can_multi_session(const char *seat);
|
int sd_seat_can_multi_session(const char *seat);
|
||||||
|
|
||||||
|
/* Return whether the seat is TTY capable, i.e. suitable for showing console UIs */
|
||||||
|
int sd_seat_can_tty(const char *seat);
|
||||||
|
|
||||||
|
/* Return whether the seat is graphics capable, i.e. suitable for showing graphical UIs */
|
||||||
|
int sd_seat_can_graphical(const char *seat);
|
||||||
|
|
||||||
/* Get all seats, store in *seats. Returns the number of seats. If
|
/* Get all seats, store in *seats. Returns the number of seats. If
|
||||||
* seats is NULL only returns number of seats. */
|
* seats is NULL only returns number of seats. */
|
||||||
int sd_get_seats(char ***seats);
|
int sd_get_seats(char ***seats);
|
||||||
|
|
Loading…
Reference in New Issue