Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d11beb2b authored by Colin Cross's avatar Colin Cross
Browse files

init: Move property_set_fd to property_service.c

Change-Id: Ic7a19073eae8f353d48cabee80fa9722b35a82b5
parent ca7648dd
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -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();
    }
+14 −7
Original line number Diff line number Diff line
@@ -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;
}
+3 −3
Original line number Diff line number Diff line
@@ -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 */