Repository : ssh://git@open-mesh.org/batctl
On branch : master
commit 86891b51d4194beb04f5090ee3a5932cabf8acb9 Author: Sven Eckelmann sven@narfation.org Date: Sun Jan 22 13:21:06 2017 +0100
batctl: Use geteuid for checks of root privileges
The getuid only shows the UID of the current user. But the EUID is relevant for accessing the debugfs and sysfs files. This check is still to strict when it comes to netlink but avoids a lot of bogus warnings like
Error received: Operation not permitted Error - mesh has not been enabled yet Activate your mesh by adding interfaces to batman-adv
when only the euid of the process was 0 but the interface was actually working.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Simon Wunderlich sw@simonwunderlich.de
86891b51d4194beb04f5090ee3a5932cabf8acb9 functions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/functions.c b/functions.c index c1aaf12..2239440 100644 --- a/functions.c +++ b/functions.c @@ -1141,7 +1141,7 @@ void get_random_bytes(void *buf, size_t buflen)
void check_root_or_die(const char *cmd) { - if (getuid() || getgid()) { + if (geteuid() != 0) { fprintf(stderr, "Error - you must be root to run '%s' !\n", cmd); exit(EXIT_FAILURE); }