3

I've been trying to get an application to run properly, but it seems to be unable to find any network interfaces. It is designed to run without administrative rights, and so requires specific file capabilities. However, it is still unable to find any network interfaces through libpcap.

I tried out a simple script to replicate the behavior using libpcap to list network interfaces in order to test out the problem:

#include <stdio.h>
#include <pcap.h>

int main(int argc, char *argv[]) {
    char *dev, errbuf[PCAP_ERRBUF_SIZE];

    dev = pcap_lookupdev(errbuf);
    if(dev == NULL) {
        printf("Error: %s\n", errbuf);
        return(2);
    }

    printf("Device: %s\n", dev);
    return(0);
}

Applying file capabilities and verifying that they were applied,

$ sudo setcap cap_net_raw,cap_net_admin=eip pcap_test
$ getcap pcap_test
pcap_test = cap_net_admin,cap_net_raw+eip

It still is unable to find any network interfaces even though it claims to have the correct permissions. Running as super user works without problem, of course.

$ ./pcap_test
Error: no suitable device found
$ sudo ./pcap_test
Device: eth0

Going through this identical sequence works as desired under Ubuntu 14.04 (with kernel version 3.13.0-35-generic as well as previous versions), but I haven't been able to get it to work under Mint 17 or 17.1 (with kernel version 3.13.0-24-generic).

Are there any changes to the kernel that affects file capabilities? Anything relevant I've found online is several years old and is in reference to an outdated kernel. Thanks!

1 Answer 1

2

The issue turned out to be due to the fact that I was working on a home partition that was mounted with the nosuid option. I had not realized that this option limits root privileges through file capabilities.

Applying the file capabilities and running from my root partition (mounted without the nosuid option) worked as desired.

1
  • Oh my god, thank you so much. I was banging my head against a wall trying to get ambient caps to raise and it would always error out for inexplicable reasons. I put the binary into /tmp for testing which defaults to nosuid...
    – Atemu
    Mar 17 at 17:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .