From 427da8c37016b9f7543a24144b9ad1bca9b08736 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 21 Apr 2014 03:50:45 +0200 Subject: master server also drops priliveges MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-server.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mds-server.c b/src/mds-server.c index e532c72..9fd4d7a 100644 --- a/src/mds-server.c +++ b/src/mds-server.c @@ -56,6 +56,15 @@ int main(int argc_, char** argv_) argv = argv_; + /* Drop privileges like it's hot. */ + if ((geteuid() == getuid() ? 0 : seteuid(getuid())) || + (getegid() == getgid() ? 0 : setegid(getgid()))) + { + perror(*argv); + return 1; + } + + /* Sanity check the number of command line arguments. */ if (argc > ARGC_LIMIT + LIBEXEC_ARGC_EXTRA_LIMIT) { -- cgit v1.2.3-70-g09d2