[systemd-commits] 3 commits - src/libsystemd-login.sym src/logind-dbus.c src/logind-seat-dbus.c src/pam-module.c src/sd-login.c src/sd-login.h src/test-login.c TODO
Lennart Poettering
lennart at kemper.freedesktop.org
Tue Jul 26 14:09:57 PDT 2011
TODO | 2 --
src/libsystemd-login.sym | 1 +
src/logind-dbus.c | 6 +++++-
src/logind-seat-dbus.c | 18 +++++++++---------
src/pam-module.c | 26 ++++++++++++++++++++++++--
src/sd-login.c | 30 ++++++++++++++++++++++++++++++
src/sd-login.h | 3 +++
src/test-login.c | 4 ++++
8 files changed, 76 insertions(+), 14 deletions(-)
New commits:
commit bbc732830876ce75a95c57ccf8677f74e4569efc
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Jul 26 23:09:34 2011 +0200
pam: set XDG_SEAT and XDG_VTNR when logging in
diff --git a/src/logind-dbus.c b/src/logind-dbus.c
index 035847c..b8f7d67 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 a3ce246..dd05f93 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) {
commit add30678a1bf284ecd79438d219c45ca7a1c9f51
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Jul 26 23:09:09 2011 +0200
sd-login: add new call sd_seat_can_multi_session()
diff --git a/TODO b/TODO
index 0a1f98d..ba36794 100644
--- a/TODO
+++ b/TODO
@@ -225,8 +225,6 @@ Features:
* readahead: btrfs/LVM SSD detection
-* add separate man page for [Install] settings
-
* allow runtime changing of log level and target
* drop cap bounding set in readahead and other services
diff --git a/src/libsystemd-login.sym b/src/libsystemd-login.sym
index cd5f52c..0d51fa7 100644
--- a/src/libsystemd-login.sym
+++ b/src/libsystemd-login.sym
@@ -20,6 +20,7 @@ global:
sd_login_monitor_unref;
sd_pid_get_owner_uid;
sd_pid_get_session;
+ sd_seat_can_multi_session;
sd_seat_get_active;
sd_seat_get_sessions;
sd_session_get_seat;
diff --git a/src/sd-login.c b/src/sd-login.c
index 2c5b153..d44a1fc 100644
--- a/src/sd-login.c
+++ b/src/sd-login.c
@@ -522,6 +522,36 @@ _public_ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **ui
return 0;
}
+_public_ int sd_seat_can_multi_session(const char *seat) {
+ char *p, *s = NULL;
+ int r;
+
+ if (!seat)
+ return -EINVAL;
+
+ p = strappend("/run/systemd/seats/", seat);
+ if (!p)
+ return -ENOMEM;
+
+ r = parse_env_file(p, NEWLINE,
+ "IS_VTCONSOLE", &s,
+ NULL);
+ free(p);
+
+ if (r < 0) {
+ free(s);
+ return r;
+ }
+
+ if (s) {
+ r = parse_boolean(s);
+ free(s);
+ } else
+ r = 0;
+
+ return r;
+}
+
_public_ int sd_get_seats(char ***seats) {
if (!seats)
diff --git a/src/sd-login.h b/src/sd-login.h
index c6835e1..1623a7d 100644
--- a/src/sd-login.h
+++ b/src/sd-login.h
@@ -82,6 +82,9 @@ int sd_seat_get_active(const char *seat, char **session, uid_t *uid);
/* Return sessions and users on seat */
int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **uid, unsigned *n_uids);
+/* Return whether the seat is multi-session capable */
+int sd_seat_can_multi_session(const char *seat);
+
/* Get all seats */
int sd_get_seats(char ***seats);
diff --git a/src/test-login.c b/src/test-login.c
index 21cd3a1..9cd9c27 100644
--- a/src/test-login.c
+++ b/src/test-login.c
@@ -71,6 +71,10 @@ int main(int argc, char* argv[]) {
assert_se(sd_session_get_seat(session, &seat) >= 0);
printf("seat = %s\n", seat);
+ r = sd_seat_can_multi_session(seat);
+ assert_se(r >= 0);
+ printf("can do multi session = %s\n", yes_no(r));
+
assert_se(sd_uid_get_state(u, &state) >= 0);
printf("state = %s\n", state);
commit 64559e8b4e81897bab3659aea27791467a579566
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Jul 26 21:49:29 2011 +0200
logind: rename can_activate_sessions to can_multi_session
diff --git a/src/logind-dbus.c b/src/logind-dbus.c
index f39941c..035847c 100644
--- a/src/logind-dbus.c
+++ b/src/logind-dbus.c
@@ -577,7 +577,6 @@ static int trigger_device(Manager *m, struct udev_device *d) {
}
}
-
if (udev_enumerate_scan_devices(e) < 0) {
r = -EIO;
goto finish;
diff --git a/src/logind-seat-dbus.c b/src/logind-seat-dbus.c
index 669e83e..3a916ee 100644
--- a/src/logind-seat-dbus.c
+++ b/src/logind-seat-dbus.c
@@ -35,7 +35,7 @@
" </method>\n" \
" <property name=\"Id\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"ActiveSession\" type=\"so\" access=\"read\"/>\n" \
- " <property name=\"CanActivateSessions\" type=\"b\" access=\"read\"/>\n" \
+ " <property name=\"CanMultiSession\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"Sessions\" type=\"a(so)\" access=\"read\"/>\n" \
" <property name=\"IdleHint\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"IdleSinceHint\" type=\"t\" access=\"read\"/>\n" \
@@ -133,7 +133,7 @@ static int bus_seat_append_sessions(DBusMessageIter *i, const char *property, vo
return 0;
}
-static int bus_seat_append_can_activate(DBusMessageIter *i, const char *property, void *data) {
+static int bus_seat_append_multi_session(DBusMessageIter *i, const char *property, void *data) {
Seat *s = data;
dbus_bool_t b;
@@ -213,13 +213,13 @@ static DBusHandlerResult seat_message_dispatch(
DBusMessage *message) {
const BusProperty properties[] = {
- { "org.freedesktop.login1.Seat", "Id", bus_property_append_string, "s", s->id },
- { "org.freedesktop.login1.Seat", "ActiveSession", bus_seat_append_active, "(so)", s },
- { "org.freedesktop.login1.Seat", "CanActivateSessions", bus_seat_append_can_activate, "b", s },
- { "org.freedesktop.login1.Seat", "Sessions", bus_seat_append_sessions, "a(so)", s },
- { "org.freedesktop.login1.Seat", "IdleHint", bus_seat_append_idle_hint, "b", s },
- { "org.freedesktop.login1.Seat", "IdleSinceHint", bus_seat_append_idle_hint_since, "t", s },
- { "org.freedesktop.login1.Seat", "IdleSinceHintMonotonic", bus_seat_append_idle_hint_since, "t", s },
+ { "org.freedesktop.login1.Seat", "Id", bus_property_append_string, "s", s->id },
+ { "org.freedesktop.login1.Seat", "ActiveSession", bus_seat_append_active, "(so)", s },
+ { "org.freedesktop.login1.Seat", "CanMultiSession", bus_seat_append_multi_session, "b", s },
+ { "org.freedesktop.login1.Seat", "Sessions", bus_seat_append_sessions, "a(so)", s },
+ { "org.freedesktop.login1.Seat", "IdleHint", bus_seat_append_idle_hint, "b", s },
+ { "org.freedesktop.login1.Seat", "IdleSinceHint", bus_seat_append_idle_hint_since, "t", s },
+ { "org.freedesktop.login1.Seat", "IdleSinceHintMonotonic", bus_seat_append_idle_hint_since, "t", s },
{ NULL, NULL, NULL, NULL, NULL }
};
More information about the systemd-commits
mailing list