Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

My python script needs at least the CAP_NET_RAW capability, because it's using a pcap library, but I don't want to use sudo (and in fact sudo causes my script to not work properly, with the script's use of the subprocess module).

When I try

sudo setcap cap_net_raw=pie test.py

I get

unable to set CAP_SETFCAP effective capability: Operation not permitted

When I do

sudo getcap /sbin/setcap

I get no output, so I have a feeling that setcap needs the CAP_SETFCAP capability? I've only found out about "capabilities" today, and from a quick search I get the feeling that setcap should work out of the box, so I'm lost.



Update:

I should have mentioned that this is on a Virtual Private Server.

$ df -T
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/simfs   simfs    26214400  10373184  15841216  40% /
tmpfs        tmpfs      817152         0    817152   0% /lib/init/rw
tmpfs        tmpfs      817152         0    817152   0% /dev/shm

$ cat /etc/fstab
proc  /proc       proc    defaults    0    0
none  /dev/pts    devpts  rw          0    0
share|improve this question
add comment

1 Answer

Linux ignores the SUID bit on scripts. Would it make sense to honor the FS CAP bits for scripts though the problems are exactly the same?

But that would not cause your error message. You may need the kernel parameter file_caps and the mount option user_xattr for the affected volume.

share|improve this answer
    
Please see my update to the question. Sorry, I don't know much about linux. Is it right that I'll need to edit files in /proc to change a kernel parameter? Do I need to add my own line to /etc/fstab to add user_xattr for /dev/simfs? –  Zantier Jun 19 '13 at 10:57
    
@Zantier You cannot change /proc/cmdline; you have to edit the kernel command line in your boot loader configuration if your kernel requires this parameter. You do not add a line for user_xattr but add it to the existing line. Before you do that you may try mount -o remount,user_xattr /dev/simfs –  Hauke Laging Jun 19 '13 at 11:12
    
$ sudo mount -o remount,user_xattr /dev/simfs gave mount: permission denied. I changed the line in /etc/fstab from proc /proc proc defaults 0 0 to proc /proc proc defaults,user_xattr 0 0 then rebooted. I don't know if there's any indication that it did anything, but it didn't fix my problem. From what I've read, grub should have files in /boot/ and /etc/grub.d/, but my /boot/ directory is empty and /etc/grub.d/ doesn't exist. Thanks for your help. –  Zantier Jun 19 '13 at 14:11
    
@Zantier You cannot change the access rights in /proc; that's kernel area. If your /boot is empty then I am afraid that your system is so broken that I cannot help you (that's really out of the scope of this question). You may try mount /boot; maybe it is not mounted automatically for some reason. –  Hauke Laging Jun 19 '13 at 14:29
    
$ mount /boot gives mount: can't find /boot in /etc/fstab or /etc/mtab. It's probably to do with the way the Virtual Private Servers are set up. Thanks again. –  Zantier Jun 19 '13 at 14:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.