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 --- 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); }