]> git.ipfire.org Git - people/amarx/ipfire-3.x.git/blame - libnet/patches/libnet-1.1.4-capability.patch
Move all packages to root.
[people/amarx/ipfire-3.x.git] / libnet / patches / libnet-1.1.4-capability.patch
CommitLineData
b50476c9
SS
1Patch by Robert Scheck <robert@fedoraproject.org> for libnet >= 1.1.4, which backports
2capability support instead of explicitly checking for UID 0. Further information can be
3found at the following links:
4
5 - https://bugzilla.redhat.com/show_bug.cgi?id=589770
6 - http://github.com/sam-github/libnet/commit/671742244c20804c9e935326e3649dac3382f17a
7
8--- libnet-1.1.4/src/libnet_init.c 2009-06-05 02:31:44.000000000 +0200
9+++ libnet-1.1.4/src/libnet_init.c.capability 2010-07-09 22:57:10.000000000 +0200
10@@ -44,14 +44,7 @@
11 {
12 libnet_t *l = NULL;
13
14-#if !defined(__WIN32__)
15- if (getuid() && geteuid())
16- {
17- snprintf(err_buf, LIBNET_ERRBUF_SIZE,
18- "%s(): UID or EUID of 0 required\n", __func__);
19- goto bad;
20- }
21-#else
22+#if defined(__WIN32__)
23 WSADATA wsaData;
24
25 if ((WSAStartup(0x0202, &wsaData)) != 0)
26--- libnet-1.1.4/src/libnet_link_linux.c 2009-06-05 02:31:44.000000000 +0200
27+++ libnet-1.1.4/src/libnet_link_linux.c.capability 2010-07-09 22:58:33.000000000 +0200
28@@ -90,8 +90,15 @@
29
30 if (ioctl(l->fd, SIOCGIFHWADDR, &ifr) < 0 )
31 {
32- snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
33- "SIOCGIFHWADDR: %s", strerror(errno));
34+ if (errno == EPERM) {
35+ snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
36+ "%s(): UID/EUID 0 or capability CAP_NET_RAW required",
37+ __func__);
38+
39+ } else {
40+ snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
41+ "socket: %s", strerror(errno));
42+ }
43 goto bad;
44 }
45