sd-login: add sd_machine_get_class() call

This commit is contained in:
Lennart Poettering 2014-03-12 20:54:29 +01:00
parent 01f83c1c76
commit 0325941fff
3 changed files with 42 additions and 19 deletions

View File

@ -122,6 +122,13 @@ global:
sd_session_is_remote;
sd_session_get_remote_user;
sd_session_get_remote_host;
local:
*;
};
LIBSYSTEMD_211 {
global:
sd_machine_get_class;
m4_ifdef(`ENABLE_KDBUS',
/* sd-bus */
@ -389,6 +396,4 @@ m4_ifdef(`ENABLE_KDBUS',
sd_utf8_is_valid;
sd_ascii_is_valid;
)
local:
*;
};
} LIBSYSTEMD_209;

View File

@ -249,9 +249,7 @@ _public_ int sd_session_is_active(const char *session) {
if (!s)
return -EIO;
r = parse_boolean(s);
return r;
return parse_boolean(s);
}
_public_ int sd_session_is_remote(const char *session) {
@ -269,9 +267,7 @@ _public_ int sd_session_is_remote(const char *session) {
if (!s)
return -EIO;
r = parse_boolean(s);
return r;
return parse_boolean(s);
}
_public_ int sd_session_get_state(const char *session, char **state) {
@ -308,16 +304,13 @@ _public_ int sd_session_get_uid(const char *session, uid_t *uid) {
return r;
r = parse_env_file(p, NEWLINE, "UID", &s, NULL);
if (r < 0)
return r;
if (!s)
return -EIO;
r = parse_uid(s, uid);
return r;
return parse_uid(s, uid);
}
static int session_get_string(const char *session, const char *field, char **value) {
@ -533,6 +526,8 @@ static int seat_get_can(const char *seat, const char *variable) {
_cleanup_free_ char *p = NULL, *s = NULL;
int r;
assert_return(variable, -EINVAL);
r = file_of_seat(seat, &p);
if (r < 0)
return r;
@ -542,13 +537,10 @@ static int seat_get_can(const char *seat, const char *variable) {
NULL);
if (r < 0)
return r;
if (!s)
return 0;
if (s)
r = parse_boolean(s);
else
r = 0;
return r;
return parse_boolean(s);
}
_public_ int sd_seat_can_multi_session(const char *seat) {
@ -633,6 +625,8 @@ _public_ int sd_get_machine_names(char ***machines) {
char **l = NULL, **a, **b;
int r;
assert_return(machines, -EINVAL);
r = get_files_in_directory("/run/systemd/machines/", &l);
if (r < 0)
return r;
@ -658,6 +652,27 @@ _public_ int sd_get_machine_names(char ***machines) {
return r;
}
_public_ int sd_machine_get_class(const char *machine, char **class) {
_cleanup_free_ char *c = NULL;
const char *p;
int r;
assert_return(filename_is_safe(machine), -EINVAL);
assert_return(class, -EINVAL);
p = strappenda("/run/systemd/machines/", machine);
r = parse_env_file(p, NEWLINE, "CLASS", &c, NULL);
if (r < 0)
return r;
if (!c)
return -EIO;
*class = c;
c = NULL;
return 0;
}
static inline int MONITOR_TO_FD(sd_login_monitor *m) {
return (int) (unsigned long) m - 1;
}

View File

@ -153,6 +153,9 @@ 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);
/* Return the class of machine */
int sd_machine_get_class(const char *machine, char **class);
/* Get all seats, store in *seats. Returns the number of seats. If
* seats is NULL only returns number of seats. */
int sd_get_seats(char ***seats);