[systemd-commits] 2 commits - TODO man/loginctl.xml src/login

Lennart Poettering lennart at kemper.freedesktop.org
Sun Jul 29 08:10:11 PDT 2012


 TODO                       |    2 ++
 man/loginctl.xml           |    8 ++++++++
 src/login/71-seat.rules.in |    2 ++
 src/login/loginctl.c       |   44 ++++++++++++++++++++++++++++++++++++++++++++
 src/login/logind-dbus.c    |   13 +++++++++++++
 5 files changed, 69 insertions(+)

New commits:
commit 7212a8a99ee863698f5feaa00abb4b99f3996a1a
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Jul 29 17:08:47 2012 +0200

    logind: add new loginctl lock-sessions command

diff --git a/TODO b/TODO
index 59ba7a2..16c429f 100644
--- a/TODO
+++ b/TODO
@@ -39,6 +39,8 @@ Bugfixes:
 
 Features:
 
+* wiki: document new logind LockSessions() call
+
 * initialize the hostname from the fs label of /, if /etc/hostname does not exist?
 
 * logind: different policy actions for idle, suspend, shutdown blockers: allow idle blockers by default, don't allow suspend blockers by default
diff --git a/man/loginctl.xml b/man/loginctl.xml
index 49fc1ff..5c703a9 100644
--- a/man/loginctl.xml
+++ b/man/loginctl.xml
@@ -243,6 +243,14 @@
                         </varlistentry>
 
                         <varlistentry>
+                                <term><command>lock-sessions</command></term>
+
+                                <listitem><para>Activate the screen
+                                lock on all current sessions
+                                supporting it.</para></listitem>
+                        </varlistentry>
+
+                        <varlistentry>
                                 <term><command>terminate-session [ID...]</command></term>
 
                                 <listitem><para>Terminates a
diff --git a/src/login/71-seat.rules.in b/src/login/71-seat.rules.in
index 03005b6..f554d7f 100644
--- a/src/login/71-seat.rules.in
+++ b/src/login/71-seat.rules.in
@@ -43,4 +43,6 @@ SUBSYSTEM=="usb", ATTR{idVendor}=="17e9", ATTR{idProduct}=="401a", ATTR{product}
 TAG=="seat", ENV{ID_PATH}=="", IMPORT{builtin}="path_id"
 TAG=="seat", ENV{ID_FOR_SEAT}=="", ENV{ID_PATH_TAG}!="", ENV{ID_FOR_SEAT}="$env{SUBSYSTEM}-$env{ID_PATH_TAG}"
 
+SUBSYSTEM=="input", ATTR{name}=="Wiebetech LLC Wiebetech", RUN+="@rootbindir@/loginctl lock-sessions"
+
 LABEL="seat_end"
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index 7b751e7..b80b2e6 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -1604,6 +1604,48 @@ finish:
         return ret;
 }
 
+static int lock_sessions(DBusConnection *bus, char **args, unsigned n) {
+        DBusMessage *m = NULL, *reply = NULL;
+        int ret = 0;
+        DBusError error;
+
+        assert(bus);
+        assert(args);
+
+        dbus_error_init(&error);
+
+        polkit_agent_open_if_enabled();
+
+        m = dbus_message_new_method_call(
+                        "org.freedesktop.login1",
+                        "/org/freedesktop/login1",
+                        "org.freedesktop.login1.Manager",
+                        "LockSessions");
+        if (!m) {
+                log_error("Could not allocate message.");
+                ret = -ENOMEM;
+                goto finish;
+        }
+
+        reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error);
+        if (!reply) {
+                log_error("Failed to issue method call: %s", bus_error_message(&error));
+                ret = -EIO;
+                goto finish;
+        }
+
+finish:
+        if (m)
+                dbus_message_unref(m);
+
+        if (reply)
+                dbus_message_unref(reply);
+
+        dbus_error_free(&error);
+
+        return ret;
+}
+
 static int terminate_seat(DBusConnection *bus, char **args, unsigned n) {
         DBusMessage *m = NULL;
         int ret = 0;
@@ -1679,6 +1721,7 @@ static int help(void) {
                "  activate [ID]                   Activate a session\n"
                "  lock-session [ID...]            Screen lock one or more sessions\n"
                "  unlock-session [ID...]          Screen unlock one or more sessions\n"
+               "  lock-sessions                   Screen lock all current sessions\n"
                "  terminate-session [ID...]       Terminate one or more sessions\n"
                "  kill-session [ID...]            Send signal to processes of a session\n"
                "  list-users                      List users\n"
@@ -1820,6 +1863,7 @@ static int loginctl_main(DBusConnection *bus, int argc, char *argv[], DBusError
                 { "activate",              EQUAL,  2, activate         },
                 { "lock-session",          MORE,   2, activate         },
                 { "unlock-session",        MORE,   2, activate         },
+                { "lock-sessions",         EQUAL,  1, lock_sessions    },
                 { "terminate-session",     MORE,   2, activate         },
                 { "kill-session",          MORE,   2, kill_session     },
                 { "list-users",            EQUAL,  1, list_users       },

commit fa2b196da12642d3560f5766eef09ffca7c31f7b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Jul 29 16:17:06 2012 +0200

    logind: add LockSessions() call to lock all local sessions at once

diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index a2ead86..86ca654 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -98,6 +98,7 @@
         "  <method name=\"UnlockSession\">\n"                           \
         "   <arg name=\"id\" type=\"s\" direction=\"in\"/>\n"           \
         "  </method>\n"                                                 \
+        "  <method name=\"LockSessions\"/>\n"                           \
         "  <method name=\"KillSession\">\n"                             \
         "   <arg name=\"id\" type=\"s\" direction=\"in\"/>\n"           \
         "   <arg name=\"who\" type=\"s\" direction=\"in\"/>\n"          \
@@ -1745,6 +1746,18 @@ static DBusHandlerResult manager_message_handler(
                 if (!reply)
                         goto oom;
 
+        } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "LockSessions")) {
+                Session *session;
+                Iterator i;
+
+                HASHMAP_FOREACH(session, m->sessions, i)
+                        if (session_send_lock(session, true) < 0)
+                                goto oom;
+
+                reply = dbus_message_new_method_return(message);
+                if (!reply)
+                        goto oom;
+
         } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "KillSession")) {
                 const char *swho;
                 int32_t signo;



More information about the systemd-commits mailing list