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

Commit 3018f521 authored by Nick Kralevich's avatar Nick Kralevich Committed by The Android Automerger
Browse files

Revert "init: make system properties more secure."

This reverts commit 51e06618.

Bug: 8045561
parent 5bf8a420
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -233,6 +233,11 @@ void service_start(struct service *svc, const char *dynamic_args)
        int fd, sz;

        umask(077);
        if (properties_inited()) {
            get_property_workspace(&fd, &sz);
            sprintf(tmp, "%d,%d", dup(fd), sz);
            add_environment("ANDROID_PROPERTY_WORKSPACE", tmp);
        }

        for (ei = svc->envvars; ei; ei = ei->next)
            add_environment(ei->name, ei->value);
+20 −4
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ struct {
typedef struct {
    void *data;
    size_t size;
    int fd;
} workspace;

static int init_workspace(workspace *w, size_t size)
@@ -122,7 +123,7 @@ static int init_workspace(workspace *w, size_t size)
        /* dev is a tmpfs that we can use to carve a shared workspace
         * out of, so let's do that...
         */
    fd = open(PROP_FILENAME, O_RDWR | O_CREAT | O_NOFOLLOW, 0644);
    fd = open("/dev/__properties__", O_RDWR | O_CREAT | O_NOFOLLOW, 0600);
    if (fd < 0)
        return -1;

@@ -135,8 +136,15 @@ static int init_workspace(workspace *w, size_t size)

    close(fd);

    fd = open("/dev/__properties__", O_RDONLY | O_NOFOLLOW);
    if (fd < 0)
        return -1;

    unlink("/dev/__properties__");

    w->data = data;
    w->size = size;
    w->fd = fd;
    return 0;

out:
@@ -166,6 +174,8 @@ static int init_property_area(void)
    if(init_workspace(&pa_workspace, PA_SIZE))
        return -1;

    fcntl(pa_workspace.fd, F_SETFD, FD_CLOEXEC);

    pa_info_array = (void*) (((char*) pa_workspace.data) + PA_INFO_START);

    pa = pa_workspace.data;
@@ -453,6 +463,12 @@ void handle_property_set_fd()
    }
}

void get_property_workspace(int *fd, int *sz)
{
    *fd = pa_workspace.fd;
    *sz = pa_workspace.size;
}

static void load_properties(char *data)
{
    char *key, *value, *eol, *sol, *tmp;
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ extern void property_init(void);
extern void property_load_boot_defaults(void);
extern void load_persist_props(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);
extern int properties_inited();