summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/login/logind-dbus.c38
-rw-r--r--src/login/logind-session.c3
-rw-r--r--src/login/logind-session.h17
-rw-r--r--src/login/pam-module.c9
4 files changed, 46 insertions, 21 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index aa212d1fed..230dd2b4b5 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -353,21 +353,28 @@ static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMess
return -EINVAL;
dbus_message_iter_get_basic(&iter, &type);
- t = session_type_from_string(type);
+ if (isempty(type))
+ t = _SESSION_TYPE_INVALID;
+ else {
+ t = session_type_from_string(type);
+ if (t < 0)
+ return -EINVAL;
+ }
- if (t < 0 ||
- !dbus_message_iter_next(&iter) ||
+ if (!dbus_message_iter_next(&iter) ||
dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return -EINVAL;
dbus_message_iter_get_basic(&iter, &class);
if (isempty(class))
- c = SESSION_USER;
- else
+ c = _SESSION_CLASS_INVALID;
+ else {
c = session_class_from_string(class);
+ if (c < 0)
+ return -EINVAL;
+ }
- if (c < 0 ||
- !dbus_message_iter_next(&iter) ||
+ if (!dbus_message_iter_next(&iter) ||
dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
return -EINVAL;
@@ -441,6 +448,22 @@ static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMess
dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BOOLEAN)
return -EINVAL;
+ if (t == _SESSION_TYPE_INVALID) {
+ if (!isempty(display))
+ t = SESSION_X11;
+ else if (!isempty(tty))
+ t = SESSION_TTY;
+ else
+ t = SESSION_UNSPECIFIED;
+ }
+
+ if (c == _SESSION_CLASS_INVALID) {
+ if (!isempty(display) || !isempty(tty))
+ c = SESSION_USER;
+ else
+ c = SESSION_BACKGROUND;
+ }
+
dbus_message_iter_get_basic(&iter, &remote);
if (!dbus_message_iter_next(&iter) ||
@@ -993,7 +1016,6 @@ static int have_multiple_sessions(
* count, and non-login sessions do not count either. */
HASHMAP_FOREACH(session, m->sessions, i)
if (session->class == SESSION_USER &&
- (session->type == SESSION_TTY || session->type == SESSION_X11) &&
session->user->uid != uid)
return true;
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 97c24d094b..508336d4d3 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -1056,7 +1056,8 @@ DEFINE_STRING_TABLE_LOOKUP(session_type, SessionType);
static const char* const session_class_table[_SESSION_CLASS_MAX] = {
[SESSION_USER] = "user",
[SESSION_GREETER] = "greeter",
- [SESSION_LOCK_SCREEN] = "lock-screen"
+ [SESSION_LOCK_SCREEN] = "lock-screen",
+ [SESSION_BACKGROUND] = "background"
};
DEFINE_STRING_TABLE_LOOKUP(session_class, SessionClass);
diff --git a/src/login/logind-session.h b/src/login/logind-session.h
index 7598afa618..c8dd181e7b 100644
--- a/src/login/logind-session.h
+++ b/src/login/logind-session.h
@@ -37,22 +37,23 @@ typedef enum SessionState {
_SESSION_STATE_INVALID = -1
} SessionState;
-typedef enum SessionType {
- SESSION_UNSPECIFIED,
- SESSION_TTY,
- SESSION_X11,
- _SESSION_TYPE_MAX,
- _SESSION_TYPE_INVALID = -1
-} SessionType;
-
typedef enum SessionClass {
SESSION_USER,
SESSION_GREETER,
SESSION_LOCK_SCREEN,
+ SESSION_BACKGROUND,
_SESSION_CLASS_MAX,
_SESSION_CLASS_INVALID = -1
} SessionClass;
+typedef enum SessionType {
+ SESSION_UNSPECIFIED,
+ SESSION_TTY,
+ SESSION_X11,
+ _SESSION_TYPE_MAX,
+ _SESSION_TYPE_INVALID = -1
+} SessionType;
+
typedef enum KillWho {
KILL_LEADER,
KILL_ALL,
diff --git a/src/login/pam-module.c b/src/login/pam-module.c
index c8f4dae77e..609317e9dd 100644
--- a/src/login/pam-module.c
+++ b/src/login/pam-module.c
@@ -440,9 +440,10 @@ _public_ PAM_EXTERN int pam_sm_open_session(
seat = strempty(seat);
if (strchr(tty, ':')) {
- /* A tty with a colon is usually an X11 display, place
- * there to show up in utmp. We rearrange things and
- * don't pretend that an X display was a tty */
+ /* A tty with a colon is usually an X11 display,
+ * placed there to show up in utmp. We rearrange
+ * things and don't pretend that an X display was a
+ * tty. */
if (isempty(display))
display = tty;
@@ -482,7 +483,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
if (isempty(class))
class = class_pam;
if (isempty(class))
- class = "user";
+ class = streq(type, "unspecified") ? "background" : "user";
remote = !isempty(remote_host) &&
!streq(remote_host, "localhost") &&