[PATCH 3/3] virnetdev: Add check for unprivileged daemon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Using virNetDevSetupControl (due to usage of AF_PACKET instead of
AF_LOCAL for the socket call) or even ioctl(SIOCETHTOOL) will fail
for an unprivileged daemon. Since in the long run the caller only
cares if bits are found in order to set a bit in a bitmap, let's
just add a VIR_WARN instead of an error message.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/util/virnetdev.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index d47859e..acf8ba6 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -3154,6 +3154,14 @@ virNetDevSendEthtoolIoctl(const char *ifname, void *cmd)
     int fd;
     struct ifreq ifr;
 
+    /* Won't work if not running as root. Rather than generate
+     * error, just WARN and return.
+     */
+    if (geteuid() != 0) {
+        VIR_WARN("cannot get ETHTOOL feature bits");
+        return ret;
+    }
+
     if ((fd = virNetDevSetupControl(ifname, &ifr)) < 0)
         return ret;
     ifr.ifr_data = cmd;
-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]