Permissions in Android init.rc

Overview

The GPS entries in init.rc should be modified to

  • Set access to the serial port and GPIOs
  • Create and set permissions for directories
  • Run the GPS service without root permissions.

Example:

# For serial port. 
chown root system /dev/ttySC3
chmod 0664 /dev/ttySC3

# For GPIOs for REG_PU and nReset
chown root system /sys/class/gps/GPS_PWR_EN/value
chmod 0664 /sys/class/gps/GPS_PWR_EN/value
    
chown root system /sys/class/gps/GPS_nRST/value
chmod 0664 /sys/class/gps/GPS_nRST/value    

# For NVRAM data of gps daemon
mkdir /data/gps 771 system system
chown system system /data/gps

# Run service
service glgps /system/bin/glgps -c /system/etc/gpsconfig.xml
    socket gps seqpacket 0660 gps system
    user gps
    group system inet sdcard_rw

Service

A service is a program launched at init. Services take the form:

service <name> <pathname> [ <argument> ]*
   <option>
   <option>
   ...

In the example above, there are options for socket, user, and group.

socket creates a unix domain socket and passes its fd to the launched process.

socket <name> <type> <perm> [ <user> [ <group> ] ]

user changes the username before exec'ing a service

user <username>

group changes the groupname bfore exec'ing a service.

group <groupname> [ <groupname> ]*
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines