Android: Start the permissions issue for service in init.rc "Go"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.