logind: introduce an explicit session class for cronjobs and similar
cronjobs are neither interactive user session, nor lock screens, nor login screens, hence they should get their own class.
This commit is contained in:
parent
05d0c3e1fd
commit
e2acb67baa
|
@ -353,21 +353,28 @@ static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMess
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
dbus_message_iter_get_basic(&iter, &type);
|
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 ||
|
if (!dbus_message_iter_next(&iter) ||
|
||||||
!dbus_message_iter_next(&iter) ||
|
|
||||||
dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
|
dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
dbus_message_iter_get_basic(&iter, &class);
|
dbus_message_iter_get_basic(&iter, &class);
|
||||||
if (isempty(class))
|
if (isempty(class))
|
||||||
c = SESSION_USER;
|
c = _SESSION_CLASS_INVALID;
|
||||||
else
|
else {
|
||||||
c = session_class_from_string(class);
|
c = session_class_from_string(class);
|
||||||
|
if (c < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (c < 0 ||
|
if (!dbus_message_iter_next(&iter) ||
|
||||||
!dbus_message_iter_next(&iter) ||
|
|
||||||
dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
|
dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
|
||||||
return -EINVAL;
|
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)
|
dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BOOLEAN)
|
||||||
return -EINVAL;
|
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);
|
dbus_message_iter_get_basic(&iter, &remote);
|
||||||
|
|
||||||
if (!dbus_message_iter_next(&iter) ||
|
if (!dbus_message_iter_next(&iter) ||
|
||||||
|
@ -993,7 +1016,6 @@ static int have_multiple_sessions(
|
||||||
* count, and non-login sessions do not count either. */
|
* count, and non-login sessions do not count either. */
|
||||||
HASHMAP_FOREACH(session, m->sessions, i)
|
HASHMAP_FOREACH(session, m->sessions, i)
|
||||||
if (session->class == SESSION_USER &&
|
if (session->class == SESSION_USER &&
|
||||||
(session->type == SESSION_TTY || session->type == SESSION_X11) &&
|
|
||||||
session->user->uid != uid)
|
session->user->uid != uid)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -1056,7 +1056,8 @@ DEFINE_STRING_TABLE_LOOKUP(session_type, SessionType);
|
||||||
static const char* const session_class_table[_SESSION_CLASS_MAX] = {
|
static const char* const session_class_table[_SESSION_CLASS_MAX] = {
|
||||||
[SESSION_USER] = "user",
|
[SESSION_USER] = "user",
|
||||||
[SESSION_GREETER] = "greeter",
|
[SESSION_GREETER] = "greeter",
|
||||||
[SESSION_LOCK_SCREEN] = "lock-screen"
|
[SESSION_LOCK_SCREEN] = "lock-screen",
|
||||||
|
[SESSION_BACKGROUND] = "background"
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_STRING_TABLE_LOOKUP(session_class, SessionClass);
|
DEFINE_STRING_TABLE_LOOKUP(session_class, SessionClass);
|
||||||
|
|
|
@ -37,6 +37,15 @@ typedef enum SessionState {
|
||||||
_SESSION_STATE_INVALID = -1
|
_SESSION_STATE_INVALID = -1
|
||||||
} SessionState;
|
} SessionState;
|
||||||
|
|
||||||
|
typedef enum SessionClass {
|
||||||
|
SESSION_USER,
|
||||||
|
SESSION_GREETER,
|
||||||
|
SESSION_LOCK_SCREEN,
|
||||||
|
SESSION_BACKGROUND,
|
||||||
|
_SESSION_CLASS_MAX,
|
||||||
|
_SESSION_CLASS_INVALID = -1
|
||||||
|
} SessionClass;
|
||||||
|
|
||||||
typedef enum SessionType {
|
typedef enum SessionType {
|
||||||
SESSION_UNSPECIFIED,
|
SESSION_UNSPECIFIED,
|
||||||
SESSION_TTY,
|
SESSION_TTY,
|
||||||
|
@ -45,14 +54,6 @@ typedef enum SessionType {
|
||||||
_SESSION_TYPE_INVALID = -1
|
_SESSION_TYPE_INVALID = -1
|
||||||
} SessionType;
|
} SessionType;
|
||||||
|
|
||||||
typedef enum SessionClass {
|
|
||||||
SESSION_USER,
|
|
||||||
SESSION_GREETER,
|
|
||||||
SESSION_LOCK_SCREEN,
|
|
||||||
_SESSION_CLASS_MAX,
|
|
||||||
_SESSION_CLASS_INVALID = -1
|
|
||||||
} SessionClass;
|
|
||||||
|
|
||||||
typedef enum KillWho {
|
typedef enum KillWho {
|
||||||
KILL_LEADER,
|
KILL_LEADER,
|
||||||
KILL_ALL,
|
KILL_ALL,
|
||||||
|
|
|
@ -440,9 +440,10 @@ _public_ PAM_EXTERN int pam_sm_open_session(
|
||||||
seat = strempty(seat);
|
seat = strempty(seat);
|
||||||
|
|
||||||
if (strchr(tty, ':')) {
|
if (strchr(tty, ':')) {
|
||||||
/* A tty with a colon is usually an X11 display, place
|
/* A tty with a colon is usually an X11 display,
|
||||||
* there to show up in utmp. We rearrange things and
|
* placed there to show up in utmp. We rearrange
|
||||||
* don't pretend that an X display was a tty */
|
* things and don't pretend that an X display was a
|
||||||
|
* tty. */
|
||||||
|
|
||||||
if (isempty(display))
|
if (isempty(display))
|
||||||
display = tty;
|
display = tty;
|
||||||
|
@ -482,7 +483,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
|
||||||
if (isempty(class))
|
if (isempty(class))
|
||||||
class = class_pam;
|
class = class_pam;
|
||||||
if (isempty(class))
|
if (isempty(class))
|
||||||
class = "user";
|
class = streq(type, "unspecified") ? "background" : "user";
|
||||||
|
|
||||||
remote = !isempty(remote_host) &&
|
remote = !isempty(remote_host) &&
|
||||||
!streq(remote_host, "localhost") &&
|
!streq(remote_host, "localhost") &&
|
||||||
|
|
Loading…
Reference in a new issue