If you look at the source code iwconfig( wireless_tools ), you will see this line:
iwconfig.c:639: if(iw_get_ext(skfd, ifname, SIOCGIWESSID, &wrq) < 0)
This line is responsible for obtaining the ESSID ( wireless.h ). And I think that only root has permissions (out of the box) for this, so the function iw_get_ext(defined in the package iwlib.hfrom wireless_tools) that calls ioctlwill return EPERM( Operation not permitted).
static inline int
iw_get_ext(int skfd,
const char * ifname,
int request,
struct iwreq * pwrq)
{
strncpy(pwrq->ifr_name, ifname, IFNAMSIZ);
return(ioctl(skfd, request, pwrq));
}
You have 2 solutions:
Use setuidso that the user can use the command iwconfig:
sudo chmod u+s /sbin/iwconfig
CAP_NET_ADMIN, . CAP_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/
, strace , ioctl :
root :
, :
$strace /sbin/iwconfig your_interface_name > strace_iwconfig_normal.log
.