diff --git a/src/main.cpp b/src/main.cpp index b4bb3e9..bc01334 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -177,9 +177,11 @@ int main(int argc, char **argv) { if (geteuid() != 0) forceExit(false, "You need to be root to run NetHogs!"); #else + char exe_path[PATH_MAX]; unsigned int caps[5] = {0}; - getxattr(argv[0], "security.capability", (char *)caps, sizeof(caps)); + readlink("/proc/self/exe", exe_path, PATH_MAX); + getxattr(exe_path, "security.capability", (char *)caps, sizeof(caps)); if (((caps[1] >> CAP_NET_ADMIN) & 1) != 1) forceExit(false, "You need to enable cap_net_admin (and cap_net_raw) to run NetHogs!"); diff --git a/src/nethogs.h b/src/nethogs.h index bae80f0..08f1add 100644 --- a/src/nethogs.h +++ b/src/nethogs.h @@ -53,7 +53,7 @@ * like www.adamantix.org: in that case nethogs shouldn't check if it's * running as root. Take care to give it sufficient privileges though. */ #ifndef NEEDROOT -#define NEEDROOT 0 +#define NEEDROOT 1 #endif #define DEBUG 0