summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/libsystemd.sym.m411
-rw-r--r--src/login/sd-login.c47
-rw-r--r--src/systemd/sd-login.h3
3 files changed, 42 insertions, 19 deletions
diff --git a/src/libsystemd/libsystemd.sym.m4 b/src/libsystemd/libsystemd.sym.m4
index 9c29169e7c..290eabe1a0 100644
--- a/src/libsystemd/libsystemd.sym.m4
+++ b/src/libsystemd/libsystemd.sym.m4
@@ -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;
diff --git a/src/login/sd-login.c b/src/login/sd-login.c
index ef67040ebc..4ad250eb37 100644
--- a/src/login/sd-login.c
+++ b/src/login/sd-login.c
@@ -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;
}
diff --git a/src/systemd/sd-login.h b/src/systemd/sd-login.h
index 6de6932a75..d6cfbc3133 100644
--- a/src/systemd/sd-login.h
+++ b/src/systemd/sd-login.h
@@ -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);