mirror of
https://github.com/systemd/systemd
synced 2024-09-06 00:41:36 +00:00
loginctl: kill calling user when invoked with empty string
A suggested by: #19711
This commit is contained in:
parent
9caf9859b4
commit
68892f94ae
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue