Explorar o código

check_icmp: Uncheck return values of set*id() family functions

In the unlikely event where setuid() fails, privileges of the
 plugin would not be dropped and commands would be run as root.
 This would lead to privilege escalation.
Jeffrey Bencteux %!s(int64=2) %!d(string=hai) anos
pai
achega
5f704efe58
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      plugins-root/check_icmp.c

+ 3 - 1
plugins-root/check_icmp.c

@@ -725,7 +725,9 @@ int main(int argc, char **argv) {
   }
 
   /* now drop privileges (no effect if not setsuid or geteuid() == 0) */
-  setuid(getuid());
+  if (setuid(getuid()) == -1) {
+    crash("dropping privileges failed");
+  }
 
 #ifdef SO_TIMESTAMP
   if (setsockopt(icmp_sock, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on))) {