diff options
Diffstat (limited to 'init')
-rwxr-xr-x | init/init.c | 10 | ||||
-rw-r--r-- | init/property_service.c | 21 | ||||
-rw-r--r-- | init/property_service.h | 6 |
3 files changed, 21 insertions, 16 deletions
diff --git a/init/init.c b/init/init.c index b45fcc5..ba2c0d3 100755 --- a/init/init.c +++ b/init/init.c @@ -639,8 +639,6 @@ void open_devnull_stdio(void) int main(int argc, char **argv) { - int device_fd = -1; - int property_set_fd = -1; int signal_recv_fd = -1; int fd_count; int s[2]; @@ -772,7 +770,7 @@ int main(int argc, char **argv) * after the ro.foo properties are set above so * that /data/local.prop cannot interfere with them. */ - property_set_fd = start_property_service(); + start_property_service(); /* create a signalling mechanism for the sigchld handler */ if (socketpair(AF_UNIX, SOCK_STREAM, 0, s) == 0) { @@ -786,7 +784,7 @@ int main(int argc, char **argv) /* make sure we actually have all the pieces we need */ if ((get_device_fd() < 0) || - (property_set_fd < 0) || + (get_property_set_fd() < 0) || (signal_recv_fd < 0)) { ERROR("init startup failure\n"); return 1; @@ -806,7 +804,7 @@ int main(int argc, char **argv) ufds[0].fd = get_device_fd(); ufds[0].events = POLLIN; - ufds[1].fd = property_set_fd; + ufds[1].fd = get_property_set_fd(); ufds[1].events = POLLIN; ufds[2].fd = signal_recv_fd; ufds[2].events = POLLIN; @@ -873,7 +871,7 @@ int main(int argc, char **argv) handle_device_fd(); if (ufds[1].revents == POLLIN) - handle_property_set_fd(property_set_fd); + handle_property_set_fd(); if (ufds[3].revents == POLLIN) handle_keychord(); } diff --git a/init/property_service.c b/init/property_service.c index d2505dd..28160f8 100644 --- a/init/property_service.c +++ b/init/property_service.c @@ -48,6 +48,8 @@ static int persistent_properties_loaded = 0; +static int property_set_fd = -1; + /* White list of permissions for setting property services. */ struct { const char *prefix; @@ -187,7 +189,7 @@ static int property_write(prop_info *pi, const char *value) * * Returns 1 if uid allowed, 0 otherwise. */ -static int check_control_perms(const char *name, int uid, int gid) { +static int check_control_perms(const char *name, unsigned int uid, unsigned int gid) { int i; if (uid == AID_SYSTEM || uid == AID_ROOT) return 1; @@ -208,7 +210,7 @@ static int check_control_perms(const char *name, int uid, int gid) { * Checks permissions for setting system properties. * Returns 1 if uid allowed, 0 otherwise. */ -static int check_perms(const char *name, unsigned int uid, int gid) +static int check_perms(const char *name, unsigned int uid, unsigned int gid) { int i; if (uid == 0) @@ -344,7 +346,7 @@ static int property_list(void (*propfn)(const char *key, const char *value, void return 0; } -void handle_property_set_fd(int fd) +void handle_property_set_fd() { prop_msg msg; int s; @@ -355,7 +357,7 @@ void handle_property_set_fd(int fd) socklen_t addr_size = sizeof(addr); socklen_t cr_size = sizeof(cr); - if ((s = accept(fd, (struct sockaddr *) &addr, &addr_size)) < 0) { + if ((s = accept(property_set_fd, (struct sockaddr *) &addr, &addr_size)) < 0) { return; } @@ -493,7 +495,7 @@ void property_init(void) load_properties_from_file(PROP_PATH_RAMDISK_DEFAULT); } -int start_property_service(void) +void start_property_service(void) { int fd; @@ -504,10 +506,15 @@ int start_property_service(void) load_persistent_properties(); fd = create_socket(PROP_SERVICE_NAME, SOCK_STREAM, 0666, 0, 0); - if(fd < 0) return -1; + if(fd < 0) return; fcntl(fd, F_SETFD, FD_CLOEXEC); fcntl(fd, F_SETFL, O_NONBLOCK); listen(fd, 8); - return fd; + property_set_fd = fd; +} + +int get_property_set_fd() +{ + return property_set_fd; } diff --git a/init/property_service.h b/init/property_service.h index d12f1f3..5bfa46c 100644 --- a/init/property_service.h +++ b/init/property_service.h @@ -17,12 +17,12 @@ #ifndef _INIT_PROPERTY_H #define _INIT_PROPERTY_H -extern void handle_property_fd(int fd); -extern void handle_property_set_fd(int fd); +extern void handle_property_set_fd(void); extern void property_init(void); -extern int start_property_service(void); +extern void start_property_service(void); void get_property_workspace(int *fd, int *sz); extern const char* property_get(const char *name); extern int property_set(const char *name, const char *value); +int get_property_set_fd(void); #endif /* _INIT_PROPERTY_H */ |