Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

cat /proc/net/wireless does not show statistics for wireless devices unless it is run as root, even though the permissions on the file are 444. The same seems to apply when accessing statistics via iwlib. Is there a way to cat this file and see the values without requiring the command be run as root?

share|improve this question

I came across this issue yesterday and found two methods:

1. Sudoers

Add a rule allowing the command access without a password.

# visudo

Replacing username:

...
username ALL=(ALL) NOPASSWD: /bin/cat /proc/net/wireless
...

Some downsides include auth log pollution, especially if checking signal every few seconds, as well as the need to add sudo to these scripts.

2. Capabilities

Give the binary CAP_NET_ADMIN

# setcap cap_net_admin+ep /bin/cat

+ to add and - to remove

  • e: Effective - This means the capability is “activated”.
  • p: Permitted - This means the capability can be used/is allowed.
  • i: Inherited - The capability is kept by child/subprocesses upon execve() for example.

More info at man cap_from_text

Disclaimer: CAP_NET_ADMIN is a form of elevated privilege. Allowing harm to things like network configuration and firewalls. In my case I only need it for grep used in an i3 blocklet. I am not sure myself what the risk is in this case and would appreciate commentary.

share|improve this answer

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.