summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-07-26 23:09:34 +0200
committerLennart Poettering <lennart@poettering.net>2011-07-26 23:09:34 +0200
commitbbc732830876ce75a95c57ccf8677f74e4569efc (patch)
treeb8b35c136ae14e4657724515077cf63e5761e9c9 /src
parentadd30678a1bf284ecd79438d219c45ca7a1c9f51 (diff)
pam: set XDG_SEAT and XDG_VTNR when logging in
Diffstat (limited to 'src')
-rw-r--r--src/logind-dbus.c5
-rw-r--r--src/pam-module.c26
2 files changed, 29 insertions, 2 deletions
diff --git a/src/logind-dbus.c b/src/logind-dbus.c
index 035847c622..b8f7d6718b 100644
--- a/src/logind-dbus.c
+++ b/src/logind-dbus.c
@@ -72,6 +72,8 @@
" <arg name=\"path\" type=\"o\" direction=\"out\"/>\n" \
" <arg name=\"runtime_path\" type=\"o\" direction=\"out\"/>\n" \
" <arg name=\"fd\" type=\"h\" direction=\"out\"/>\n" \
+ " <arg name=\"seat\" type=\"s\" direction=\"out\"/>\n" \
+ " <arg name=\"vtnr\" type=\"u\" direction=\"out\"/>\n" \
" </method>\n" \
" <method name=\"ActivateSession\">\n" \
" <arg name=\"id\" type=\"s\" direction=\"in\"/>\n" \
@@ -519,12 +521,15 @@ static int bus_manager_create_session(Manager *m, DBusMessage *message, DBusMess
goto fail;
}
+ seat = s ? s->id : "";
b = dbus_message_append_args(
reply,
DBUS_TYPE_STRING, &session->id,
DBUS_TYPE_OBJECT_PATH, &p,
DBUS_TYPE_STRING, &session->user->runtime_path,
DBUS_TYPE_UNIX_FD, &fifo_fd,
+ DBUS_TYPE_STRING, &seat,
+ DBUS_TYPE_UINT32, &vtnr,
DBUS_TYPE_INVALID);
free(p);
diff --git a/src/pam-module.c b/src/pam-module.c
index a3ce2468d5..dd05f93d42 100644
--- a/src/pam-module.c
+++ b/src/pam-module.c
@@ -445,8 +445,8 @@ _public_ PAM_EXTERN int pam_sm_open_session(
pam_get_item(handle, PAM_TTY, (const void**) &tty);
pam_get_item(handle, PAM_RUSER, (const void**) &remote_user);
pam_get_item(handle, PAM_RHOST, (const void**) &remote_host);
- seat = pam_getenv(handle, "LOGIN_SEAT");
- cvtnr = pam_getenv(handle, "LOGIN_VTNR");
+ seat = pam_getenv(handle, "XDG_SEAT");
+ cvtnr = pam_getenv(handle, "XDG_VTNR");
service = strempty(service);
tty = strempty(tty);
@@ -529,6 +529,8 @@ _public_ PAM_EXTERN int pam_sm_open_session(
DBUS_TYPE_OBJECT_PATH, &object_path,
DBUS_TYPE_STRING, &runtime_path,
DBUS_TYPE_UNIX_FD, &session_fd,
+ DBUS_TYPE_STRING, &seat,
+ DBUS_TYPE_UINT32, &vtnr,
DBUS_TYPE_INVALID)) {
pam_syslog(handle, LOG_ERR, "Failed to parse message: %s", bus_error_message(&error));
r = PAM_SESSION_ERR;
@@ -547,6 +549,26 @@ _public_ PAM_EXTERN int pam_sm_open_session(
goto finish;
}
+ if (!isempty(seat)) {
+ r = pam_misc_setenv(handle, "XDG_SEAT", seat, 0);
+ if (r != PAM_SUCCESS) {
+ pam_syslog(handle, LOG_ERR, "Failed to set seat.");
+ goto finish;
+ }
+ }
+
+ if (vtnr > 0) {
+ char buf[11];
+ snprintf(buf, sizeof(buf), "%u", vtnr);
+ char_array_0(buf);
+
+ r = pam_misc_setenv(handle, "XDG_VTNR", buf, 0);
+ if (r != PAM_SUCCESS) {
+ pam_syslog(handle, LOG_ERR, "Failed to set virtual terminal number.");
+ goto finish;
+ }
+ }
+
if (session_fd >= 0) {
r = pam_set_data(handle, "systemd.session-fd", INT_TO_PTR(session_fd+1), NULL);
if (r != PAM_SUCCESS) {