summaryrefslogtreecommitdiff
path: root/src/login/logind-session.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-02-14 21:33:51 +0100
committerLennart Poettering <lennart@poettering.net>2012-02-14 21:37:49 +0100
commit55efac6cbcea0d8edda9c6820620ceb390009e7a (patch)
tree4cd4a938607d1ee6b8fd20e40d49d441bf134117 /src/login/logind-session.c
parent6edd7ca1624f89c9a36067b721a0280e748acb17 (diff)
login: track login class (i.e. one of "user", "greeter", "lock-screen") for each session
This introduces the new PAM environment variable XDG_SESSION_CLASS. If not set, defaults to "user". This is useful for apps that want to distuingish real user logins from "fake" ones which just exist to show a gdm login screen or a lock screen.
Diffstat (limited to 'src/login/logind-session.c')
-rw-r--r--src/login/logind-session.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index c0d953296..af9c12dcd 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -145,6 +145,11 @@ int session_save(Session *s) {
"TYPE=%s\n",
session_type_to_string(s->type));
+ if (s->class >= 0)
+ fprintf(f,
+ "CLASS=%s\n",
+ session_class_to_string(s->class));
+
if (s->cgroup_path)
fprintf(f,
"CGROUP=%s\n",
@@ -225,7 +230,8 @@ int session_load(Session *s) {
*vtnr = NULL,
*leader = NULL,
*audit_id = NULL,
- *type = NULL;
+ *type = NULL,
+ *class = NULL;
int k, r;
@@ -245,6 +251,7 @@ int session_load(Session *s) {
"VTNR", &vtnr,
"LEADER", &leader,
"TYPE", &type,
+ "CLASS", &class,
NULL);
if (r < 0)
@@ -297,6 +304,14 @@ int session_load(Session *s) {
s->type = t;
}
+ if (class) {
+ SessionClass c;
+
+ c = session_class_from_string(class);
+ if (c >= 0)
+ s->class = c;
+ }
+
if (s->fifo_path) {
int fd;
@@ -947,6 +962,14 @@ static const char* const session_type_table[_SESSION_TYPE_MAX] = {
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"
+};
+
+DEFINE_STRING_TABLE_LOOKUP(session_class, SessionClass);
+
static const char* const kill_who_table[_KILL_WHO_MAX] = {
[KILL_LEADER] = "leader",
[KILL_ALL] = "all"