In Android 4, the following simple line of C-code with Permission denied error does not work as root :
online_socket = socket(AF_INET, SOCK_DGRAM, 0);
I have root access to the device, but you want to start this process as an unprivileged user.
Note that the error occurs even before the socket binding.
I think there are some security settings that need to be configured? Can anyone tell me where to look?
In this case, O / S is really Android, but I think the problem is really Linux related (since Android is based on the Linux kernel).
For those who are wondering: this is a special program that works in a full ( debootstrap ped) installation of Debian Jessie, running in Android 4.
Update
I found out that Android Kernel has a special extension CONFIG_ANDROID_PARANOID_NETWORK , which allows access to the network only to users in the groups AID_INET and AID_NET_RAW .
However, even after adding the user to these groups, socket() is still rejected (and ping seems to have the same BTW problem).
uid=5(imp) gid=51(imp) groups=51(imp),3003(aid_inet),3004(aid_net_raw),3005(aid_admin),3001(aid_bt),3002(aid_bt_net)
I canβt say if this CONFIG_ANDROID_PARANOID_NETWORK flag is CONFIG_ANDROID_PARANOID_NETWORK in this particular kernel, since I do not have access to the configuration file.
Update 2
I found out that both root and my unprivileged user imp can actually successfully call socket() - at least using the group setting described above.
However, calling the same process as root and then switching to imp using the seteuid() system call does not allow socket() to succeed. Any ideas?
android sockets permissions
Udo g
source share