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. (Thomas Habets)

Conflicts:

	libnet/src/libnet_init.c
  • Loading branch information
sam-github committed May 3, 2010
1 parent 56e3b06 commit 6717422
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
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\n", __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
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 6717422

Please sign in to comment.