From 6bd03ad564c651cca6527e60f9b519b251c9deea Mon Sep 17 00:00:00 2001
From: MadMaurice <madmaurice@zom.bi>
Date: Fri, 15 Jan 2021 20:22:22 +0100
Subject: [PATCH] Add sanity check

As a sanity check whether we're able to regain root after dropping
it. If we are able to, then something went wrong.
---
 main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/main.c b/main.c
index 548b494..30480d1 100644
--- a/main.c
+++ b/main.c
@@ -29,6 +29,12 @@ void drop_root(void) {
       printf("Failed to drop root privileges with setegid (%d)\n", err);
       exit(err);
     }
+
+  // sanity check
+  if(seteuid(0) != -1) {
+    printf("Sanity check failed. I was able to regain root.\n");
+    exit(1);
+  }
 }
 
 void forward_signal(int sig)