From 1272a895b2e2f105b8389f3b26ed25683e6d766c Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Sun, 23 Jun 2019 15:58:16 +0200 Subject: [PATCH] Correct handling of setuid bit when using popen --- check_smart/check_smart.cpp | 6 ++++++ 1 file changed, 6 insertions(+), 0 deletions(-) diff --git a/check_smart/check_smart.cpp b/check_smart/check_smart.cpp index d6fb436..0945582 100644 --- a/check_smart/check_smart.cpp +++ b/check_smart/check_smart.cpp @@ -101,7 +101,13 @@ int main(int argc, char **argv) for(int i = 1; i < argc; i++) { string output; + int uid = getuid(); + int gid = getgid(); + setuid(0); + setgid(0); int rc = exec(command + argv[i],&output); + setuid(uid); + setgid(gid); if(rc) { cout << "Error reading SMART data from disk" << endl; -- libgit2 0.22.2