Transferred from: http://www.linuxidc.com/Linux/2011-04/35014.htm
Through Property_set ("Ctl.start", service_xx);
To start a service in init.rc is a convenient way to invoke an executable program or a script program
Service Service_xx/system/bin/xx
Disabled
OneShot
However, calling Ctl.start Ctl.stop in the process of a non-aid_root, Aid_system user encounters a permissions problem:
System/core/init/property_service.c
/*
* White List of the UID that is allowed to start/stop services.
* Currently there is no user apps that require.
*/
struct {
const char *service;
unsigned int uid;
unsigned int gid;
} control_perms[] = {
{"Dumpstate", Aid_shell, Aid_log},
{NULL, 0, 0}
};
/*
* Checks permissions for starting/stoping system services.
* Aid_system and Aid_root is always allowed.
*
* Returns 1 if UID allowed, 0 otherwise.
*/
static int check_control_perms (const char *name, int uid, int gid) {
int i;
if (uid = = Aid_system | | uid = = aid_root)
return 1;
/* Search the ACL */
for (i = 0; control_perms[i].service; i++) {
if (strcmp (control_perms[i].service, name) = = 0) {
if (uid && control_perms[i].uid = = UID) | |
(gid && Control_perms[i].gid = = gid)) {
return 1;
}
}
}
return 0;
}
This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/zmyde2010/archive/2011/04/09/6312615.aspx
Only uid = = Aid_system | | UID = = Aid_root
or conform to control_perms[] = {
{"Dumpstate", Aid_shell, Aid_log},
{NULL, 0, 0}
}; UID process is only authorized Star/stop services
So, if we run into a permissions issue, according to log hints, the/system/core/include/private/android_filesystem_config.h
Process definition, add to control_perms[] List
For example, a program with UID ==aid_wifi requires permission to start service_xx
Control_perms[] = {
{"Dumpstate", Aid_shell, Aid_log},
+ {"Service_xx", Aid_wifi, Aid_wifi},
{NULL, 0, 0}
};
Android: Start the permissions issue for service in init.rc "Go"