Is there any way to get current wireless SSID without root permission?
iwconfig tells me ESSID, but only if I run it as root.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you take a look at the source code of the
iwconfig(wireless_tools), you’ll see this line:This line is responsible for the get of ESSID (wireless.h). And i think that only root have permissions (out of the box) to do this, so the function
iw_get_ext(defined iniwlib.hfromwireless_toolspackage) which callioctlwill returnEPERM(Operation not permitted).You have 2 solutions:
Use the
setuidto allow the user to useiwconfigcommand:sudo chmod u+s /sbin/iwconfigYou can also try to do some hacking with the
CAP_NET_ADMINcapability which allow some specific capabilities to a specific user. Here some links aboutCAP_NET_ADMIN:http://packetlife.net/blog/2010/mar/19/sniffing-wireshark-non-root-user/
http://peternixon.net/news/2012/01/28/configure-tcpdump-work-non-root-user-opensuse-using-file-system-capabilities/
http://www.lids.org/lids-howto/node48.html
http://lwn.net/Articles/430462/
Finally you can use
straceto trace all system calls and to confirm thatioctlcall is the responsible for this:as
rootdo this:And the same as normal user:
And compare the results.