loginctl: make session/user arguments optional for a number commands, and imply calling session/user instead
This turns "lock-session", "activate", "unlock-session", "enable-linger", "disable-linger" into commands that take no argument, optionally in which case the callers session/user is implied.
This commit is contained in:
parent
997eadb553
commit
906b76b27b
|
@ -250,22 +250,30 @@
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><command>activate</command> <replaceable>ID</replaceable></term>
|
<term><command>activate</command> <optional><replaceable>ID</replaceable></optional></term>
|
||||||
|
|
||||||
<listitem><para>Activate a
|
<listitem><para>Activate a
|
||||||
session. This brings a session into
|
session. This brings a session into
|
||||||
the foreground, if another session is
|
the foreground, if another session is
|
||||||
currently in the foreground on the
|
currently in the foreground on the
|
||||||
respective seat.</para></listitem>
|
respective seat. Takes a session
|
||||||
|
identifier as argument. If no argument
|
||||||
|
is specified the session of the caller
|
||||||
|
is put into
|
||||||
|
foreground.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><command>lock-session</command> <replaceable>ID</replaceable>...</term>
|
<term><command>lock-session</command> <optional><replaceable>ID</replaceable>...</optional></term>
|
||||||
<term><command>unlock-session</command> <replaceable>ID</replaceable>...</term>
|
<term><command>unlock-session</command> <optional><replaceable>ID</replaceable>...</optional></term>
|
||||||
|
|
||||||
<listitem><para>Activates/deactivates
|
<listitem><para>Activates/deactivates
|
||||||
the screen lock on one or more
|
the screen lock on one or more
|
||||||
sessions, if the session supports it.
|
sessions, if the session supports
|
||||||
|
it. Takes one or more session
|
||||||
|
identifiers as arguments. If no
|
||||||
|
argument is specified the session of
|
||||||
|
the caller is locked/unlocked.
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
@ -353,8 +361,8 @@
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><command>enable-linger</command> <replaceable>USER</replaceable>...</term>
|
<term><command>enable-linger</command> <optional><replaceable>USER</replaceable>...</optional></term>
|
||||||
<term><command>disable-linger</command> <replaceable>USER</replaceable>...</term>
|
<term><command>disable-linger</command> <optional><replaceable>USER</replaceable>...</optional></term>
|
||||||
|
|
||||||
<listitem><para>Enable/disable user
|
<listitem><para>Enable/disable user
|
||||||
lingering for one or more users. If
|
lingering for one or more users. If
|
||||||
|
@ -363,7 +371,11 @@
|
||||||
boot and kept around after
|
boot and kept around after
|
||||||
logouts. This allows users who are not
|
logouts. This allows users who are not
|
||||||
logged in to run long-running
|
logged in to run long-running
|
||||||
services.</para></listitem>
|
services. Takes one or more user names
|
||||||
|
or numeric UIDs as argument. If no
|
||||||
|
argument is specified enables/disables
|
||||||
|
lingering for the user of the session
|
||||||
|
of the caller.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
@ -413,7 +425,7 @@
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><command>show-seat</command> <replaceable>NAME</replaceable>...</term>
|
<term><command>show-seat</command> <optional><replaceable>NAME</replaceable>...</optional></term>
|
||||||
|
|
||||||
<listitem><para>Show properties of one
|
<listitem><para>Show properties of one
|
||||||
or more seats or the manager
|
or more seats or the manager
|
||||||
|
|
|
@ -853,6 +853,15 @@ static int activate(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
polkit_agent_open_if_enabled();
|
polkit_agent_open_if_enabled();
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
/* No argument? Let's convert this into the empty
|
||||||
|
* session name, which the calls will then resolve to
|
||||||
|
* the caller's session. */
|
||||||
|
|
||||||
|
argv = STRV_MAKE(argv[0], "");
|
||||||
|
argc = 2;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
|
|
||||||
r = sd_bus_call_method (
|
r = sd_bus_call_method (
|
||||||
|
@ -920,12 +929,21 @@ static int enable_linger(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
b = streq(argv[0], "enable-linger");
|
b = streq(argv[0], "enable-linger");
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
argv = STRV_MAKE(argv[0], "");
|
||||||
|
argc = 2;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
|
|
||||||
r = get_user_creds((const char**) (argv+i), &uid, NULL, NULL, NULL);
|
if (isempty(argv[i]))
|
||||||
if (r < 0)
|
uid = UID_INVALID;
|
||||||
return log_error_errno(r, "Failed to look up user %s: %m", argv[i]);
|
else {
|
||||||
|
r = get_user_creds((const char**) (argv+i), &uid, NULL, NULL, NULL);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to look up user %s: %m", argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
r = sd_bus_call_method (
|
r = sd_bus_call_method (
|
||||||
bus,
|
bus,
|
||||||
|
@ -1145,9 +1163,9 @@ static int help(int argc, char *argv[], void *userdata) {
|
||||||
" list-sessions List sessions\n"
|
" list-sessions List sessions\n"
|
||||||
" session-status [ID...] Show session status\n"
|
" session-status [ID...] Show session status\n"
|
||||||
" show-session [ID...] Show properties of sessions or the manager\n"
|
" show-session [ID...] Show properties of sessions or the manager\n"
|
||||||
" activate ID Activate a session\n"
|
" activate [ID] Activate a session\n"
|
||||||
" lock-session ID... Screen lock one or more sessions\n"
|
" lock-session [ID...] Screen lock one or more sessions\n"
|
||||||
" unlock-session ID... Screen unlock one or more sessions\n"
|
" unlock-session [ID...] Screen unlock one or more sessions\n"
|
||||||
" lock-sessions Screen lock all current sessions\n"
|
" lock-sessions Screen lock all current sessions\n"
|
||||||
" unlock-sessions Screen unlock all current sessions\n"
|
" unlock-sessions Screen unlock all current sessions\n"
|
||||||
" terminate-session ID... Terminate one or more sessions\n"
|
" terminate-session ID... Terminate one or more sessions\n"
|
||||||
|
@ -1156,8 +1174,8 @@ static int help(int argc, char *argv[], void *userdata) {
|
||||||
" list-users List users\n"
|
" list-users List users\n"
|
||||||
" user-status [USER...] Show user status\n"
|
" user-status [USER...] Show user status\n"
|
||||||
" show-user [USER...] Show properties of users or the manager\n"
|
" show-user [USER...] Show properties of users or the manager\n"
|
||||||
" enable-linger USER... Enable linger state of one or more users\n"
|
" enable-linger [USER...] Enable linger state of one or more users\n"
|
||||||
" disable-linger USER... Disable linger state of one or more users\n"
|
" disable-linger [USER...] Disable linger state of one or more users\n"
|
||||||
" terminate-user USER... Terminate all sessions of one or more users\n"
|
" terminate-user USER... Terminate all sessions of one or more users\n"
|
||||||
" kill-user USER... Send signal to processes of a user\n\n"
|
" kill-user USER... Send signal to processes of a user\n\n"
|
||||||
"Seat Commands:\n"
|
"Seat Commands:\n"
|
||||||
|
@ -1304,9 +1322,9 @@ static int loginctl_main(int argc, char *argv[], sd_bus *bus) {
|
||||||
{ "list-sessions", VERB_ANY, 1, VERB_DEFAULT, list_sessions },
|
{ "list-sessions", VERB_ANY, 1, VERB_DEFAULT, list_sessions },
|
||||||
{ "session-status", VERB_ANY, VERB_ANY, 0, show_session },
|
{ "session-status", VERB_ANY, VERB_ANY, 0, show_session },
|
||||||
{ "show-session", VERB_ANY, VERB_ANY, 0, show_session },
|
{ "show-session", VERB_ANY, VERB_ANY, 0, show_session },
|
||||||
{ "activate", 2, 2, 0, activate },
|
{ "activate", VERB_ANY, 2, 0, activate },
|
||||||
{ "lock-session", 2, VERB_ANY, 0, activate },
|
{ "lock-session", VERB_ANY, VERB_ANY, 0, activate },
|
||||||
{ "unlock-session", 2, VERB_ANY, 0, activate },
|
{ "unlock-session", VERB_ANY, VERB_ANY, 0, activate },
|
||||||
{ "lock-sessions", VERB_ANY, 1, 0, lock_sessions },
|
{ "lock-sessions", VERB_ANY, 1, 0, lock_sessions },
|
||||||
{ "unlock-sessions", VERB_ANY, 1, 0, lock_sessions },
|
{ "unlock-sessions", VERB_ANY, 1, 0, lock_sessions },
|
||||||
{ "terminate-session", 2, VERB_ANY, 0, activate },
|
{ "terminate-session", 2, VERB_ANY, 0, activate },
|
||||||
|
@ -1314,8 +1332,8 @@ static int loginctl_main(int argc, char *argv[], sd_bus *bus) {
|
||||||
{ "list-users", VERB_ANY, 1, 0, list_users },
|
{ "list-users", VERB_ANY, 1, 0, list_users },
|
||||||
{ "user-status", VERB_ANY, VERB_ANY, 0, show_user },
|
{ "user-status", VERB_ANY, VERB_ANY, 0, show_user },
|
||||||
{ "show-user", VERB_ANY, VERB_ANY, 0, show_user },
|
{ "show-user", VERB_ANY, VERB_ANY, 0, show_user },
|
||||||
{ "enable-linger", 2, VERB_ANY, 0, enable_linger },
|
{ "enable-linger", VERB_ANY, VERB_ANY, 0, enable_linger },
|
||||||
{ "disable-linger", 2, VERB_ANY, 0, enable_linger },
|
{ "disable-linger", VERB_ANY, VERB_ANY, 0, enable_linger },
|
||||||
{ "terminate-user", 2, VERB_ANY, 0, terminate_user },
|
{ "terminate-user", 2, VERB_ANY, 0, terminate_user },
|
||||||
{ "kill-user", 2, VERB_ANY, 0, kill_user },
|
{ "kill-user", 2, VERB_ANY, 0, kill_user },
|
||||||
{ "list-seats", VERB_ANY, 1, 0, list_seats },
|
{ "list-seats", VERB_ANY, 1, 0, list_seats },
|
||||||
|
|
Loading…
Reference in New Issue