|
Zbigniew Jędrzejewski-Szmek |
399a2a |
From 33ff9ced04684fe88e988fe06573ad73c8d9c20a Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
Date: Sat, 7 Feb 2015 11:16:04 -0500
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
Subject: [PATCH] systemctl: check validity of PID we received
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
(cherry picked from commit d028e01814a405e83c400c60545785d35dba2a17)
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
---
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
src/systemctl/systemctl.c | 5 ++++-
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
index 6b93ec8446..3da4d3d4f1 100644
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
--- a/src/systemctl/systemctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
+++ b/src/systemctl/systemctl.c
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
@@ -2881,6 +2881,9 @@ static int check_inhibitors(sd_bus *bus, enum action a) {
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
if (!sv)
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
return log_oom();
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
+ if ((pid_t) pid < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
+ return log_error_errno(ERANGE, "Bad PID %"PRIu32": %m", pid);
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
+
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
if (!strv_contains(sv,
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
a == ACTION_HALT ||
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
a == ACTION_POWEROFF ||
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
@@ -2892,7 +2895,7 @@ static int check_inhibitors(sd_bus *bus, enum action a) {
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
user = uid_to_name(uid);
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
log_warning("Operation inhibited by \"%s\" (PID "PID_FMT" \"%s\", user %s), reason is \"%s\".",
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
- who, pid, strna(comm), strna(user), why);
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
+ who, (pid_t) pid, strna(comm), strna(user), why);
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
c++;
|
|
Zbigniew Jędrzejewski-Szmek |
399a2a |
}
|