* Possibly, detect whether SysV init scripts can do reloading by looking for "echo Usage:" lines
-* Add XDG_SESSION_CLASS
-
* figure out whether we should leave dbus around during shutdown
* support closing all fds via RLIMIT_NOFILE instead of /proc, in order to make chroot stuff work.
sd_pid_get_unit;
sd_session_get_service;
} LIBSYSTEMD_LOGIN_31;
+
+LIBSYSTEMD_LOGIN_43 {
+global:
+ sd_session_get_type;
+ sd_session_get_class;
+} LIBSYSTEMD_LOGIN_38;
return r;
}
-_public_ int sd_session_get_seat(const char *session, char **seat) {
+static int session_get_string(const char *session, const char *field, char **value) {
char *p, *s = NULL;
int r;
- if (!seat)
+ if (!value)
return -EINVAL;
r = file_of_session(session, &p);
if (r < 0)
return r;
- r = parse_env_file(p, NEWLINE, "SEAT", &s, NULL);
+ r = parse_env_file(p, NEWLINE, field, &s, NULL);
free(p);
if (r < 0) {
if (isempty(s))
return -ENOENT;
- *seat = s;
+ *value = s;
return 0;
}
-_public_ int sd_session_get_service(const char *session, char **service) {
- char *p, *s = NULL;
- int r;
-
- if (!service)
- return -EINVAL;
-
- r = file_of_session(session, &p);
- if (r < 0)
- return r;
-
- r = parse_env_file(p, NEWLINE, "SERVICE", &s, NULL);
- free(p);
+_public_ int sd_session_get_seat(const char *session, char **seat) {
+ return session_get_string(session, "SEAT", seat);
+}
- if (r < 0) {
- free(s);
- return r;
- }
+_public_ int sd_session_get_service(const char *session, char **service) {
+ return session_get_string(session, "SERVICE", service);
+}
- if (isempty(s))
- return -ENOENT;
+_public_ int sd_session_get_type(const char *session, char **type) {
+ return session_get_string(session, "TYPE", type);
+}
- *service = s;
- return 0;
+_public_ int sd_session_get_class(const char *session, char **class) {
+ return session_get_string(session, "CLASS", class);
}
static int file_of_seat(const char *seat, char **_p) {
int main(int argc, char* argv[]) {
int r, k;
uid_t u, u2;
- char *seat;
+ char *seat, *type, *class;
char *session;
char *state;
char *session2;
printf("uid = %lu\n", (unsigned long) u);
assert_se(u == u2);
+ assert_se(sd_session_get_type(session, &type) >= 0);
+ printf("type = %s\n", type);
+ free(type);
+
+ assert_se(sd_session_get_class(session, &class) >= 0);
+ printf("class = %s\n", class);
+ free(class);
+
assert_se(sd_session_get_seat(session, &seat) >= 0);
printf("seat = %s\n", seat);
printf("seats = %s\n", t);
free(t);
+ assert_se(sd_get_seats(NULL) == r);
+
r = sd_seat_get_active(NULL, &t, NULL);
assert_se(r >= 0);
printf("active session on current seat = %s\n", t);
free(t);
- assert_se(sd_get_seats(NULL) == r);
-
r = sd_get_sessions(&sessions);
assert_se(r >= 0);
assert_se(r == (int) strv_length(sessions));
/* Determine the (PAM) service name this session was registered by. */
int sd_session_get_service(const char *session, char **service);
+/* Determine the type of this session, i.e. one of "tty", "x11" or "unspecified". */
+int sd_session_get_type(const char *session, char **type);
+
+/* Determine the class of this session, i.e. one of "user", "greeter" or "lock-screen". */
+int sd_session_get_class(const char *session, char **class);
+
/* Return active session and user of seat */
int sd_seat_get_active(const char *seat, char **session, uid_t *uid);