Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Unified Diff: system_utils.cc

Issue 3493012: Security patches: RestartJob ignores pid, argv[0]; kill runs as child UID (Closed) Base URL: http://git.chromium.org/git/login_manager.git
Patch Set: added comments, using -1 as suid in setresuid() calls Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « system_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: system_utils.cc
diff --git a/system_utils.cc b/system_utils.cc
index 305b01974cb5d3de34a4ba3602f591657d9de1dc..c7639fa03ec7226b6c8225f8d0ab2fac32082828 100644
--- a/system_utils.cc
+++ b/system_utils.cc
@@ -23,9 +23,20 @@ namespace login_manager {
SystemUtils::SystemUtils() {}
SystemUtils::~SystemUtils() {}
-int SystemUtils::kill(pid_t pid, int signal) {
- LOG(INFO) << "Sending " << signal << " to " << pid;
- return ::kill(pid, signal);
+int SystemUtils::kill(pid_t pid, uid_t owner, int signal) {
+ LOG(INFO) << "Sending " << signal << " to " << pid << " as " << owner;
+ uid_t uid, euid, suid;
+ getresuid(&uid, &euid, &suid);
+ if (setresuid(owner, owner, -1)) {
+ PLOG(ERROR) << "Couldn't assume uid " << owner;
+ return -1;
+ }
+ int ret = ::kill(pid, signal);
+ if (setresuid(uid, euid, -1)) {
+ PLOG(ERROR) << "Couldn't return to root";
+ return -1;
+ }
+ return ret;
}
bool SystemUtils::ChildIsGone(pid_t child_spec, int timeout) {
« no previous file with comments | « system_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698