Skip to content

Commit

Permalink
Don't explicitly check for UID 0, we may have capabilities even if no…
Browse files Browse the repository at this point in the history
…t root.
  • Loading branch information
ThomasHabets committed May 3, 2010
1 parent 15a4b4d commit aaa383b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
9 changes: 1 addition & 8 deletions libnet/src/libnet_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@ libnet_init(int injection_type, const char *device, char *err_buf)
{
libnet_t *l = NULL;

#if !defined(__WIN32__)
if ((injection_type != LIBNET_NONE) && getuid() && geteuid())
{
snprintf(err_buf, LIBNET_ERRBUF_SIZE,
"%s(): UID or EUID of 0 required", __func__);
goto bad;
}
#else
#if defined(__WIN32__)
WSADATA wsaData;

if ((WSAStartup(0x0202, &wsaData)) != 0)
Expand Down
17 changes: 15 additions & 2 deletions libnet/src/libnet_link_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,15 @@ libnet_open_link(libnet_t *l)
#endif
if (l->fd == -1)
{
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
"socket: %s", strerror(errno));
if (errno == EPERM) {
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
"%s(): UID/EUID 0 or capability CAP_NET_RAW required",
__func__);

} else {
snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
"socket: %s", strerror(errno));
}
goto bad;
}

Expand Down Expand Up @@ -299,5 +306,11 @@ libnet_get_hwaddr(libnet_t *l)
return (NULL);
}

/* ---- Emacs Variables ----
* Local Variables:
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/

/* EOF */

0 comments on commit aaa383b

Please sign in to comment.