From 4dbce6bcb353940bfcc77f13fa0bcb14713f3112 Mon Sep 17 00:00:00 2001 From: Daniel Graziotin Date: Fri, 19 Oct 2012 18:25:10 +0200 Subject: [PATCH] Fixes #23 --- src/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.c b/src/main.c index ff50a26..31378d7 100644 --- a/src/main.c +++ b/src/main.c @@ -24,6 +24,7 @@ #include "daemon.h" #include "global.h" #include "minunit.h" +#include int daemonize = 1; int verbose = 0; @@ -74,6 +75,13 @@ int main(int argc, char *argv[]) } } + uid_t uid=getuid(), euid=geteuid(); + if (!(uid<0 || uid!=euid)) { + syslog(LOG_INFO, "Mbpfan not started with root privileges. Exiting."); + printf("Mbpfan not started with root privileges. Exiting.\n"); + exit(0); + } + // pointer to mbpfan() function in mbpfan.c void (*fan_control)() = mbpfan; go_daemon(fan_control);