chiark / gitweb /
logind: add UnlockSessions() clal to complement LockSessions()
authorLennart Poettering <lennart@poettering.net>
Thu, 24 Jan 2013 04:29:37 +0000 (05:29 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 24 Jan 2013 04:29:37 +0000 (05:29 +0100)
man/loginctl.xml
src/login/loginctl.c
src/login/logind-dbus.c

index 8a20d18..9d082cf 100644 (file)
 
                         <varlistentry>
                                 <term><command>lock-sessions</command></term>
+                                <term><command>unlock-sessions</command></term>
 
-                                <listitem><para>Activate the screen
-                                lock on all current sessions
-                                supporting it.</para></listitem>
+                                <listitem><para>Activates/deactivates
+                                the screen lock on all current
+                                sessions supporting
+                                it.</para></listitem>
                         </varlistentry>
 
                         <varlistentry>
index 0e57e08..473c77b 100644 (file)
@@ -1287,6 +1287,8 @@ static int flush_devices(DBusConnection *bus, char **args, unsigned n) {
 }
 
 static int lock_sessions(DBusConnection *bus, char **args, unsigned n) {
+        assert(args);
+
         polkit_agent_open_if_enabled();
 
         return bus_method_call_with_reply (
@@ -1294,7 +1296,7 @@ static int lock_sessions(DBusConnection *bus, char **args, unsigned n) {
                         "org.freedesktop.login1",
                         "/org/freedesktop/login1",
                         "org.freedesktop.login1.Manager",
-                        "LockSessions",
+                        streq(args[0], "lock-sessions") ? "LockSessions" : "UnlockSessions",
                         NULL,
                         NULL,
                         DBUS_TYPE_INVALID);
@@ -1348,6 +1350,7 @@ static int help(void) {
                "  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"
+               "  unlock-sessions                 Screen unlock 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"
@@ -1496,6 +1499,7 @@ static int loginctl_main(DBusConnection *bus, int argc, char *argv[], DBusError
                 { "lock-session",          MORE,   2, activate         },
                 { "unlock-session",        MORE,   2, activate         },
                 { "lock-sessions",         EQUAL,  1, lock_sessions    },
+                { "unlock-sessions",       EQUAL,  1, lock_sessions    },
                 { "terminate-session",     MORE,   2, activate         },
                 { "kill-session",          MORE,   2, kill_session     },
                 { "list-users",            EQUAL,  1, list_users       },
index 1717584..0960aab 100644 (file)
         "   <arg name=\"id\" type=\"s\" direction=\"in\"/>\n"           \
         "  </method>\n"                                                 \
         "  <method name=\"LockSessions\"/>\n"                           \
+        "  <method name=\"UnlockSessions\"/>\n"                         \
         "  <method name=\"KillSession\">\n"                             \
         "   <arg name=\"id\" type=\"s\" direction=\"in\"/>\n"           \
         "   <arg name=\"who\" type=\"s\" direction=\"in\"/>\n"          \
@@ -1853,8 +1854,10 @@ static DBusHandlerResult manager_message_handler(
                 if (!reply)
                         goto oom;
 
-        } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "LockSessions")) {
-                r = session_send_lock_all(m, true);
+        } else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "LockSessions") ||
+                   dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "UnlockSessions")) {
+
+                r = session_send_lock_all(m, streq(dbus_message_get_member(message), "LockSessions"));
                 if (r < 0)
                         bus_send_error_reply(connection, message, NULL, r);