* src/nethogs.h: Undo accidental commit.

* src/main.cpp: Properly commit this change.
This commit is contained in:
rain1
2016-04-14 12:41:34 +00:00
parent 2ab1306246
commit b2f008c568
2 changed files with 4 additions and 2 deletions

View File

@@ -177,9 +177,11 @@ int main(int argc, char **argv) {
if (geteuid() != 0) if (geteuid() != 0)
forceExit(false, "You need to be root to run NetHogs!"); forceExit(false, "You need to be root to run NetHogs!");
#else #else
char exe_path[PATH_MAX];
unsigned int caps[5] = {0}; 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) if (((caps[1] >> CAP_NET_ADMIN) & 1) != 1)
forceExit(false, "You need to enable cap_net_admin (and cap_net_raw) to run NetHogs!"); forceExit(false, "You need to enable cap_net_admin (and cap_net_raw) to run NetHogs!");

View File

@@ -53,7 +53,7 @@
* like www.adamantix.org: in that case nethogs shouldn't check if it's * 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. */ * running as root. Take care to give it sufficient privileges though. */
#ifndef NEEDROOT #ifndef NEEDROOT
#define NEEDROOT 0 #define NEEDROOT 1
#endif #endif
#define DEBUG 0 #define DEBUG 0