aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2017-10-20 08:31:48 +0200
committerGravatar Christian Hesse <mail@eworm.de>2017-10-20 08:31:48 +0200
commit8b747acc27922a790f740c7e25ffa23939c35c91 (patch)
tree1c2147c39bf3fca5786cb4801bbdea57663265e8
parent29fe863ea50740a191e8ccd9ddabcf4ea5199ac6 (diff)
downloadpacredir-8b747acc27922a790f740c7e25ffa23939c35c91.tar.gz
pacredir-8b747acc27922a790f740c7e25ffa23939c35c91.tar.zst
allow to specify uid and gid in config.h
-rw-r--r--config.def.h4
-rw-r--r--pacredir.c2
2 files changed, 5 insertions, 1 deletions
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");
}