diff options
author | Nick Kralevich | 2013-01-23 11:24:33 -0600 |
---|---|---|
committer | Nick Kralevich | 2013-01-23 11:30:17 -0600 |
commit | 7ece0a862cf97e85bbe69458a32a2bd165456874 (patch) | |
tree | d1e56d84dea31d4a19e0d8b9afd47d0e6b97a0b1 /init/property_service.c | |
parent | 2840647b15fe91069aee02ce0e203943346bf294 (diff) | |
download | platform-system-core-7ece0a862cf97e85bbe69458a32a2bd165456874.tar.gz platform-system-core-7ece0a862cf97e85bbe69458a32a2bd165456874.tar.xz platform-system-core-7ece0a862cf97e85bbe69458a32a2bd165456874.zip |
property_service: make /dev/__properties__ readable
Currently, system properties are passed via the environment
variable ANDROID_PROPERTY_WORKSPACE and a file descriptor passed
from parent to child. This is insecure for setuid executables,
as the environment variable can be changed by the caller.
Make the /dev/__properties__ file accessible, so an app can
get properties directly from the file, rather than relying on
environment variables.
Preserve the environment variable for compatibility with pre-existing
apps.
Bug: 8045561
Change-Id: If81e2b705eca43ddd8b491871aceff59c0e00387
Diffstat (limited to 'init/property_service.c')
-rwxr-xr-x | init/property_service.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/init/property_service.c b/init/property_service.c index 61dd86fdc..578000154 100755 --- a/init/property_service.c +++ b/init/property_service.c | |||
@@ -123,7 +123,7 @@ static int init_workspace(workspace *w, size_t size) | |||
123 | /* dev is a tmpfs that we can use to carve a shared workspace | 123 | /* dev is a tmpfs that we can use to carve a shared workspace |
124 | * out of, so let's do that... | 124 | * out of, so let's do that... |
125 | */ | 125 | */ |
126 | fd = open("/dev/__properties__", O_RDWR | O_CREAT | O_NOFOLLOW, 0600); | 126 | fd = open(PROP_FILENAME, O_RDWR | O_CREAT | O_NOFOLLOW, 0644); |
127 | if (fd < 0) | 127 | if (fd < 0) |
128 | return -1; | 128 | return -1; |
129 | 129 | ||
@@ -136,12 +136,10 @@ static int init_workspace(workspace *w, size_t size) | |||
136 | 136 | ||
137 | close(fd); | 137 | close(fd); |
138 | 138 | ||
139 | fd = open("/dev/__properties__", O_RDONLY | O_NOFOLLOW); | 139 | fd = open(PROP_FILENAME, O_RDONLY | O_NOFOLLOW); |
140 | if (fd < 0) | 140 | if (fd < 0) |
141 | return -1; | 141 | return -1; |
142 | 142 | ||
143 | unlink("/dev/__properties__"); | ||
144 | |||
145 | w->data = data; | 143 | w->data = data; |
146 | w->size = size; | 144 | w->size = size; |
147 | w->fd = fd; | 145 | w->fd = fd; |