summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pacredir.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/pacredir.c b/pacredir.c
index a079e31..e2a4b1c 100644
--- a/pacredir.c
+++ b/pacredir.c
@@ -662,6 +662,14 @@ int main(int argc, char ** argv) {
if (version > 0 || help > 0)
return EXIT_SUCCESS;
+ if (getuid() == 0) {
+ /* process is running as root, drop privileges */
+ if (verbose > 0)
+ write_log(stdout, "Running as root, meh! Dropping privileges.\n");
+ if (setgid(65534) != 0 || setuid(65534) != 0)
+ write_log(stderr, "Unable to drop user privileges!\n");
+ }
+
/* allocate first struct element as dummy */
hosts = malloc(sizeof(struct hosts));
hosts->host = NULL;