diff --git a/man/loginctl.xml b/man/loginctl.xml
index 56a86e56ef..bef3be71c9 100644
--- a/man/loginctl.xml
+++ b/man/loginctl.xml
@@ -113,18 +113,18 @@
terminate-sessionID…
- Terminates a session. This kills all processes
- of the session and deallocates all resources attached to the
- session.
+ Terminates a session. This kills all processes of the session and deallocates all
+ resources attached to the session. If the argument is specified as empty string the session invoking
+ the command is terminated.kill-sessionID…
- Send a signal to one or more processes of the
- session. Use to select which
- process to kill. Use to select the
- signal to send.
+ Send a signal to one or more processes of the session. Use
+ to select which process to kill. Use to
+ select the signal to send. If the argument is specified as empty string the signal is sent to the
+ session invoking the command.
@@ -184,17 +184,17 @@
terminate-userUSER…
- Terminates all sessions of a user. This kills
- all processes of all sessions of the user and deallocates all
- runtime resources attached to the user.
+ Terminates all sessions of a user. This kills all processes of all sessions of the
+ user and deallocates all runtime resources attached to the user. If the argument is specified as
+ empty string the sessions of the user invoking the command are terminated.kill-userUSER…
- Send a signal to all processes of a user. Use
- to select the signal to send.
-
+ Send a signal to all processes of a user. Use to select
+ the signal to send. If the argument is specified as empty string the signal is sent to the sessions
+ of the user invoking the command.
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index 7a2b13e442..cbb6518f4d 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -1086,9 +1086,15 @@ static int terminate_user(int argc, char *argv[], void *userdata) {
for (int i = 1; i < argc; i++) {
uid_t uid;
- r = get_user_creds((const char**) (argv+i), &uid, NULL, NULL, NULL, 0);
- if (r < 0)
- return log_error_errno(r, "Failed to look up user %s: %m", argv[i]);
+ if (isempty(argv[i]))
+ uid = getuid();
+ else {
+ const char *u = argv[i];
+
+ r = get_user_creds(&u, &uid, NULL, NULL, NULL, 0);
+ if (r < 0)
+ return log_error_errno(r, "Failed to look up user %s: %m", argv[i]);
+ }
r = bus_call_method(bus, bus_login_mgr, "TerminateUser", &error, NULL, "u", (uint32_t) uid);
if (r < 0)
@@ -1114,9 +1120,15 @@ static int kill_user(int argc, char *argv[], void *userdata) {
for (int i = 1; i < argc; i++) {
uid_t uid;
- r = get_user_creds((const char**) (argv+i), &uid, NULL, NULL, NULL, 0);
- if (r < 0)
- return log_error_errno(r, "Failed to look up user %s: %m", argv[i]);
+ if (isempty(argv[i]))
+ uid = getuid();
+ else {
+ const char *u = argv[i];
+
+ r = get_user_creds(&u, &uid, NULL, NULL, NULL, 0);
+ if (r < 0)
+ return log_error_errno(r, "Failed to look up user %s: %m", argv[i]);
+ }
r = bus_call_method(
bus,