Loading init/init.c +1 −4 Original line number Diff line number Diff line Loading @@ -250,14 +250,12 @@ void service_start(struct service *svc, const char *dynamic_args) for (ei = svc->envvars; ei; ei = ei->next) add_environment(ei->name, ei->value); setsockcreatecon(scon); for (si = svc->sockets; si; si = si->next) { int socket_type = ( !strcmp(si->type, "stream") ? SOCK_STREAM : (!strcmp(si->type, "dgram") ? SOCK_DGRAM : SOCK_SEQPACKET)); int s = create_socket(si->name, socket_type, si->perm, si->uid, si->gid); si->perm, si->uid, si->gid, si->socketcon ?: scon); if (s >= 0) { publish_socket(si->name, s); } Loading @@ -265,7 +263,6 @@ void service_start(struct service *svc, const char *dynamic_args) freecon(scon); scon = NULL; setsockcreatecon(NULL); if (svc->ioprio_class != IoSchedClass_NONE) { if (android_set_ioprio(getpid(), svc->ioprio_class, svc->ioprio_pri)) { Loading init/init.h +1 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ struct socketinfo { uid_t uid; gid_t gid; int perm; const char *socketcon; }; struct svcenvinfo { Loading init/init_parser.c +3 −1 Original line number Diff line number Diff line Loading @@ -768,7 +768,7 @@ static void parse_line_service(struct parse_state *state, int nargs, char **args svc->envvars = ei; break; } case K_socket: {/* name type perm [ uid gid ] */ case K_socket: {/* name type perm [ uid gid context ] */ struct socketinfo *si; if (nargs < 4) { parse_error(state, "socket option requires name, type, perm arguments\n"); Loading @@ -791,6 +791,8 @@ static void parse_line_service(struct parse_state *state, int nargs, char **args si->uid = decode_uid(args[4]); if (nargs > 5) si->gid = decode_uid(args[5]); if (nargs > 6) si->socketcon = args[6]; si->next = svc->sockets; svc->sockets = si; break; Loading init/property_service.c +1 −1 Original line number Diff line number Diff line Loading @@ -554,7 +554,7 @@ void start_property_service(void) /* Read persistent properties after all default values have been loaded. */ load_persistent_properties(); fd = create_socket(PROP_SERVICE_NAME, SOCK_STREAM, 0666, 0, 0); fd = create_socket(PROP_SERVICE_NAME, SOCK_STREAM, 0666, 0, 0, NULL); if(fd < 0) return; fcntl(fd, F_SETFD, FD_CLOEXEC); fcntl(fd, F_SETFL, O_NONBLOCK); Loading init/readme.txt +4 −1 Original line number Diff line number Diff line Loading @@ -70,10 +70,13 @@ disabled setenv <name> <value> Set the environment variable <name> to <value> in the launched process. socket <name> <type> <perm> [ <user> [ <group> ] ] socket <name> <type> <perm> [ <user> [ <group> [ <context> ] ] ] Create a unix domain socket named /dev/socket/<name> and pass its fd to the launched process. <type> must be "dgram", "stream" or "seqpacket". User and group default to 0. Context is the SELinux security context for the socket. It defaults to the service security context, as specified by seclabel or computed based on the service executable file security context. user <username> Change to username before exec'ing this service. Loading Loading
init/init.c +1 −4 Original line number Diff line number Diff line Loading @@ -250,14 +250,12 @@ void service_start(struct service *svc, const char *dynamic_args) for (ei = svc->envvars; ei; ei = ei->next) add_environment(ei->name, ei->value); setsockcreatecon(scon); for (si = svc->sockets; si; si = si->next) { int socket_type = ( !strcmp(si->type, "stream") ? SOCK_STREAM : (!strcmp(si->type, "dgram") ? SOCK_DGRAM : SOCK_SEQPACKET)); int s = create_socket(si->name, socket_type, si->perm, si->uid, si->gid); si->perm, si->uid, si->gid, si->socketcon ?: scon); if (s >= 0) { publish_socket(si->name, s); } Loading @@ -265,7 +263,6 @@ void service_start(struct service *svc, const char *dynamic_args) freecon(scon); scon = NULL; setsockcreatecon(NULL); if (svc->ioprio_class != IoSchedClass_NONE) { if (android_set_ioprio(getpid(), svc->ioprio_class, svc->ioprio_pri)) { Loading
init/init.h +1 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ struct socketinfo { uid_t uid; gid_t gid; int perm; const char *socketcon; }; struct svcenvinfo { Loading
init/init_parser.c +3 −1 Original line number Diff line number Diff line Loading @@ -768,7 +768,7 @@ static void parse_line_service(struct parse_state *state, int nargs, char **args svc->envvars = ei; break; } case K_socket: {/* name type perm [ uid gid ] */ case K_socket: {/* name type perm [ uid gid context ] */ struct socketinfo *si; if (nargs < 4) { parse_error(state, "socket option requires name, type, perm arguments\n"); Loading @@ -791,6 +791,8 @@ static void parse_line_service(struct parse_state *state, int nargs, char **args si->uid = decode_uid(args[4]); if (nargs > 5) si->gid = decode_uid(args[5]); if (nargs > 6) si->socketcon = args[6]; si->next = svc->sockets; svc->sockets = si; break; Loading
init/property_service.c +1 −1 Original line number Diff line number Diff line Loading @@ -554,7 +554,7 @@ void start_property_service(void) /* Read persistent properties after all default values have been loaded. */ load_persistent_properties(); fd = create_socket(PROP_SERVICE_NAME, SOCK_STREAM, 0666, 0, 0); fd = create_socket(PROP_SERVICE_NAME, SOCK_STREAM, 0666, 0, 0, NULL); if(fd < 0) return; fcntl(fd, F_SETFD, FD_CLOEXEC); fcntl(fd, F_SETFL, O_NONBLOCK); Loading
init/readme.txt +4 −1 Original line number Diff line number Diff line Loading @@ -70,10 +70,13 @@ disabled setenv <name> <value> Set the environment variable <name> to <value> in the launched process. socket <name> <type> <perm> [ <user> [ <group> ] ] socket <name> <type> <perm> [ <user> [ <group> [ <context> ] ] ] Create a unix domain socket named /dev/socket/<name> and pass its fd to the launched process. <type> must be "dgram", "stream" or "seqpacket". User and group default to 0. Context is the SELinux security context for the socket. It defaults to the service security context, as specified by seclabel or computed based on the service executable file security context. user <username> Change to username before exec'ing this service. Loading