I have an Android activity utilizing a JNI library that uses netlink commands to configure a network interface (in this case a socketcan interface). If I run the activity, the network interface configuration fails with an EPERM error from RTNETLINK. The commands that are failing require the CAP_NET_ADMIN capability in order to successfully complete. As such running the code as root succeeds, and also running as root and then limiting the capabilities to only CAP_NET_ADMIN using capset.
I added the following permissions to the applications manifest that gave me the impression that my process would be given the NET_ADMIN capabilities:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.NET_ADMIN" />
This put the process in the inet and net_admin groups, but the process did not receive the CAP_NET_ADMIN capability resulting in the netlink commands failing with EPERM.
In various searches I have made on this topic I have found hints that the capability should be applied. eg, from http://elinux.org/Android_Security
#define GID Capability
AID_NET_BT_ADMIN 3001 Can create an RFCOMM, SCO, or L2CAPP Bluetooth socket
AID_NET_BT 3002 Can create a Bluetooth socket
AID_INET 3003 Can create IPv4 or IPv6 socket
AID_NET_RAW 3004 Can create certain kinds of IPv4 sockets??
AID_NET_ADMIN* 3005 Allow CAP_NET_ADMIN permissions for process
Unfortunately, this doesn't seem to apply to my system.
NOTE: I am running with a system and kernel modified by a chipset vendor, so it is possible that something has been modified that stops this from working.
Does anyone know
- If this should just work?
- What other steps are required to add the capability to a process?
- Whether it is even possible?
NET_ADMIN
permission to your app? Was it signed with the same keys used for the firmware? During installation of the APK on an Android 4.3 device, the permission was removed. Running the commandpm grant <package name> android.permission.NET_ADMIN
(as root) errors out with Operation not allowed: java.lang.SecurityException: Permission android.permission.NET_ADMIN is not a changeable permission type./data
. This resulted in the old certificates still being used (/data/system/packages.xml
). After replacing the four certificates (platform, media, shared, testkey) in recovery and rebooting, I got the permission when signing the APK with my platform key.