diff options
author | Sam Roberts <vieuxtech@gmail.com> | 2010-05-03 16:24:13 -0700 |
---|---|---|
committer | Sam Roberts <vieuxtech@gmail.com> | 2010-05-03 16:24:13 -0700 |
commit | 671742244c20804c9e935326e3649dac3382f17a (patch) | |
tree | 9141941ae8176e26daaeb6e8651de01e4f73165d | |
parent | 56e3b06a535cfea19ee433510601e40a8facde60 (diff) | |
download | libnet-671742244c20804c9e935326e3649dac3382f17a.tar.gz |
Don't explicitly check for UID 0, we may have capabilities even if not root. (Thomas Habets)
Conflicts:
libnet/src/libnet_init.c
-rw-r--r-- | libnet/src/libnet_init.c | 9 | ||||
-rw-r--r-- | libnet/src/libnet_link_linux.c | 17 |
2 files changed, 16 insertions, 10 deletions
diff --git a/libnet/src/libnet_init.c b/libnet/src/libnet_init.c index b6ff7ec..5cc1577 100644 --- a/libnet/src/libnet_init.c +++ b/libnet/src/libnet_init.c @@ -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) diff --git a/libnet/src/libnet_link_linux.c b/libnet/src/libnet_link_linux.c index f87502d..7b6ddc6 100644 --- a/libnet/src/libnet_link_linux.c +++ b/libnet/src/libnet_link_linux.c @@ -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; } @@ -299,5 +306,11 @@ bad: return (NULL); } +/* ---- Emacs Variables ---- + * Local Variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ /* EOF */ |