From 8b747acc27922a790f740c7e25ffa23939c35c91 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 20 Oct 2017 08:31:48 +0200 Subject: allow to specify uid and gid in config.h --- config.def.h | 4 ++++ pacredir.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index fd31880..74b718d 100644 --- a/config.def.h +++ b/config.def.h @@ -8,6 +8,10 @@ #ifndef _CONFIG_H #define _CONFIG_H +/* drop privileges by changing uid and gid to these */ +#define DROP_PRIV_UID 65534 +#define DROP_PRIV_GID 65534 + /* website url */ #define WEBSITE "https://github.com/eworm-de/pacredir#pacredir" diff --git a/pacredir.c b/pacredir.c index e2a4b1c..0b034a8 100644 --- a/pacredir.c +++ b/pacredir.c @@ -666,7 +666,7 @@ int main(int argc, char ** argv) { /* 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) + if (setgid(DROP_PRIV_GID) != 0 || setuid(DROP_PRIV_UID) != 0) write_log(stderr, "Unable to drop user privileges!\n"); } -- cgit v1.2.3-54-g00ecf