blob: b092077cc47eb7fb45b5ea084dab99b5ea1733bb [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <stdio.h>
18#include <stdlib.h>
19#include <unistd.h>
20#include <string.h>
21#include <ctype.h>
22#include <fcntl.h>
23#include <stdarg.h>
24#include <dirent.h>
25#include <limits.h>
26#include <errno.h>
27
28#include <cutils/misc.h>
29#include <cutils/sockets.h>
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080030
31#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
32#include <sys/_system_properties.h>
33
34#include <sys/socket.h>
35#include <sys/un.h>
36#include <sys/select.h>
37#include <sys/types.h>
38#include <netinet/in.h>
39#include <sys/mman.h>
40#include <sys/atomics.h>
41#include <private/android_filesystem_config.h>
42
43#include "property_service.h"
44#include "init.h"
Colin Cross3899e9f2010-04-13 20:35:46 -070045#include "util.h"
Colin Crossed8a7d82010-04-19 17:05:34 -070046#include "log.h"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080047
48#define PERSISTENT_PROPERTY_DIR "/data/property"
49
50static int persistent_properties_loaded = 0;
Colin Cross3294bbb2010-04-19 17:11:33 -070051static int property_area_inited = 0;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080052
Colin Crossd11beb22010-04-13 19:33:37 -070053static int property_set_fd = -1;
54
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080055/* White list of permissions for setting property services. */
56struct {
57 const char *prefix;
58 unsigned int uid;
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -040059 unsigned int gid;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080060} property_perms[] = {
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -040061 { "net.rmnet0.", AID_RADIO, 0 },
62 { "net.gprs.", AID_RADIO, 0 },
63 { "net.ppp", AID_RADIO, 0 },
Amol Bhatkarcf015972011-02-18 17:54:17 -060064 { "net.qmi", AID_RADIO, 0 },
Benoit Goby7100f642011-07-25 18:02:06 -070065 { "net.lte", AID_RADIO, 0 },
Benoit Goby22bfc4c2011-07-28 18:09:55 -070066 { "net.cdma", AID_RADIO, 0 },
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -040067 { "ril.", AID_RADIO, 0 },
68 { "gsm.", AID_RADIO, 0 },
69 { "persist.radio", AID_RADIO, 0 },
70 { "net.dns", AID_RADIO, 0 },
Benoit Goby5da93582011-08-22 12:12:37 -070071 { "sys.usb.config", AID_RADIO, 0 },
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -040072 { "net.", AID_SYSTEM, 0 },
73 { "dev.", AID_SYSTEM, 0 },
74 { "runtime.", AID_SYSTEM, 0 },
75 { "hw.", AID_SYSTEM, 0 },
76 { "sys.", AID_SYSTEM, 0 },
77 { "service.", AID_SYSTEM, 0 },
78 { "wlan.", AID_SYSTEM, 0 },
jeonghoon.lim8c0350f2012-07-03 12:04:38 -070079 { "bluetooth.", AID_SYSTEM, 0 },
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -040080 { "dhcp.", AID_SYSTEM, 0 },
81 { "dhcp.", AID_DHCP, 0 },
Romain Guy45fa13f2012-04-27 15:19:30 -070082 { "debug.", AID_SYSTEM, 0 },
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -040083 { "debug.", AID_SHELL, 0 },
84 { "log.", AID_SHELL, 0 },
85 { "service.adb.root", AID_SHELL, 0 },
Mike Lockwood58aa5b02010-12-10 09:48:41 -080086 { "service.adb.tcp.port", AID_SHELL, 0 },
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -040087 { "persist.sys.", AID_SYSTEM, 0 },
88 { "persist.service.", AID_SYSTEM, 0 },
Oscar Montemayoref4e2152009-11-12 12:02:24 -080089 { "persist.security.", AID_SYSTEM, 0 },
Ravi Nagarajana8afd722012-08-02 04:58:21 -070090 { "persist.service.bdroid.", AID_BLUETOOTH, 0 },
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -040091 { NULL, 0, 0 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080092};
93
94/*
95 * White list of UID that are allowed to start/stop services.
96 * Currently there are no user apps that require.
97 */
98struct {
99 const char *service;
100 unsigned int uid;
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400101 unsigned int gid;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800102} control_perms[] = {
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400103 { "dumpstate",AID_SHELL, AID_LOG },
Wink Savillecfa0d842010-10-03 13:30:11 -0700104 { "ril-daemon",AID_RADIO, AID_RADIO },
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400105 {NULL, 0, 0 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800106};
107
108typedef struct {
109 void *data;
110 size_t size;
111 int fd;
112} workspace;
113
114static int init_workspace(workspace *w, size_t size)
115{
116 void *data;
117 int fd;
118
Brian Swetland25b15be2010-07-13 16:43:56 -0700119 /* dev is a tmpfs that we can use to carve a shared workspace
120 * out of, so let's do that...
121 */
122 fd = open("/dev/__properties__", O_RDWR | O_CREAT, 0600);
123 if (fd < 0)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800124 return -1;
125
Brian Swetland25b15be2010-07-13 16:43:56 -0700126 if (ftruncate(fd, size) < 0)
127 goto out;
128
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800129 data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
130 if(data == MAP_FAILED)
131 goto out;
132
Brian Swetland25b15be2010-07-13 16:43:56 -0700133 close(fd);
134
135 fd = open("/dev/__properties__", O_RDONLY);
136 if (fd < 0)
137 return -1;
138
139 unlink("/dev/__properties__");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800140
141 w->data = data;
142 w->size = size;
143 w->fd = fd;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800144 return 0;
145
146out:
147 close(fd);
148 return -1;
149}
150
151/* (8 header words + 247 toc words) = 1020 bytes */
152/* 1024 bytes header and toc + 247 prop_infos @ 128 bytes = 32640 bytes */
153
154#define PA_COUNT_MAX 247
155#define PA_INFO_START 1024
156#define PA_SIZE 32768
157
158static workspace pa_workspace;
159static prop_info *pa_info_array;
160
161extern prop_area *__system_property_area__;
162
163static int init_property_area(void)
164{
165 prop_area *pa;
166
167 if(pa_info_array)
168 return -1;
169
170 if(init_workspace(&pa_workspace, PA_SIZE))
171 return -1;
172
173 fcntl(pa_workspace.fd, F_SETFD, FD_CLOEXEC);
174
175 pa_info_array = (void*) (((char*) pa_workspace.data) + PA_INFO_START);
176
177 pa = pa_workspace.data;
178 memset(pa, 0, PA_SIZE);
179 pa->magic = PROP_AREA_MAGIC;
180 pa->version = PROP_AREA_VERSION;
181
182 /* plug into the lib property services */
183 __system_property_area__ = pa;
Colin Cross3294bbb2010-04-19 17:11:33 -0700184 property_area_inited = 1;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800185 return 0;
186}
187
188static void update_prop_info(prop_info *pi, const char *value, unsigned len)
189{
190 pi->serial = pi->serial | 1;
191 memcpy(pi->value, value, len + 1);
192 pi->serial = (len << 24) | ((pi->serial + 1) & 0xffffff);
193 __futex_wake(&pi->serial, INT32_MAX);
194}
195
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800196/*
197 * Checks permissions for starting/stoping system services.
198 * AID_SYSTEM and AID_ROOT are always allowed.
199 *
200 * Returns 1 if uid allowed, 0 otherwise.
201 */
Colin Crossd11beb22010-04-13 19:33:37 -0700202static int check_control_perms(const char *name, unsigned int uid, unsigned int gid) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800203 int i;
204 if (uid == AID_SYSTEM || uid == AID_ROOT)
205 return 1;
206
207 /* Search the ACL */
208 for (i = 0; control_perms[i].service; i++) {
209 if (strcmp(control_perms[i].service, name) == 0) {
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400210 if ((uid && control_perms[i].uid == uid) ||
211 (gid && control_perms[i].gid == gid)) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800212 return 1;
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400213 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800214 }
215 }
216 return 0;
217}
218
219/*
220 * Checks permissions for setting system properties.
221 * Returns 1 if uid allowed, 0 otherwise.
222 */
Colin Crossd11beb22010-04-13 19:33:37 -0700223static int check_perms(const char *name, unsigned int uid, unsigned int gid)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800224{
225 int i;
226 if (uid == 0)
227 return 1;
228
229 if(!strncmp(name, "ro.", 3))
230 name +=3;
231
232 for (i = 0; property_perms[i].prefix; i++) {
233 int tmp;
234 if (strncmp(property_perms[i].prefix, name,
235 strlen(property_perms[i].prefix)) == 0) {
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400236 if ((uid && property_perms[i].uid == uid) ||
237 (gid && property_perms[i].gid == gid)) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800238 return 1;
239 }
240 }
241 }
242
243 return 0;
244}
245
246const char* property_get(const char *name)
247{
248 prop_info *pi;
249
250 if(strlen(name) >= PROP_NAME_MAX) return 0;
251
252 pi = (prop_info*) __system_property_find(name);
253
254 if(pi != 0) {
255 return pi->value;
256 } else {
257 return 0;
258 }
259}
260
Tammo Spalink3dfe6c62009-08-26 10:13:20 +0800261static void write_persistent_property(const char *name, const char *value)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800262{
263 const char *tempPath = PERSISTENT_PROPERTY_DIR "/.temp";
264 char path[PATH_MAX];
265 int fd, length;
266
267 snprintf(path, sizeof(path), "%s/%s", PERSISTENT_PROPERTY_DIR, name);
268
269 fd = open(tempPath, O_WRONLY|O_CREAT|O_TRUNC, 0600);
270 if (fd < 0) {
271 ERROR("Unable to write persistent property to temp file %s errno: %d\n", tempPath, errno);
Tammo Spalink3dfe6c62009-08-26 10:13:20 +0800272 return;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800273 }
274 write(fd, value, strlen(value));
275 close(fd);
276
277 if (rename(tempPath, path)) {
278 unlink(tempPath);
279 ERROR("Unable to rename persistent property file %s to %s\n", tempPath, path);
280 }
281}
282
283int property_set(const char *name, const char *value)
284{
285 prop_area *pa;
286 prop_info *pi;
287
288 int namelen = strlen(name);
289 int valuelen = strlen(value);
290
291 if(namelen >= PROP_NAME_MAX) return -1;
292 if(valuelen >= PROP_VALUE_MAX) return -1;
293 if(namelen < 1) return -1;
294
295 pi = (prop_info*) __system_property_find(name);
296
297 if(pi != 0) {
298 /* ro.* properties may NEVER be modified once set */
299 if(!strncmp(name, "ro.", 3)) return -1;
300
301 pa = __system_property_area__;
302 update_prop_info(pi, value, valuelen);
303 pa->serial++;
304 __futex_wake(&pa->serial, INT32_MAX);
305 } else {
306 pa = __system_property_area__;
307 if(pa->count == PA_COUNT_MAX) return -1;
308
309 pi = pa_info_array + pa->count;
310 pi->serial = (valuelen << 24);
311 memcpy(pi->name, name, namelen + 1);
312 memcpy(pi->value, value, valuelen + 1);
313
314 pa->toc[pa->count] =
315 (namelen << 24) | (((unsigned) pi) - ((unsigned) pa));
316
317 pa->count++;
318 pa->serial++;
319 __futex_wake(&pa->serial, INT32_MAX);
320 }
321 /* If name starts with "net." treat as a DNS property. */
Mike Lockwoodb3779552009-05-08 14:27:42 -0400322 if (strncmp("net.", name, strlen("net.")) == 0) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800323 if (strcmp("net.change", name) == 0) {
324 return 0;
325 }
Tammo Spalink3dfe6c62009-08-26 10:13:20 +0800326 /*
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800327 * The 'net.change' property is a special property used track when any
328 * 'net.*' property name is updated. It is _ONLY_ updated here. Its value
329 * contains the last updated 'net.*' property.
330 */
331 property_set("net.change", name);
332 } else if (persistent_properties_loaded &&
Mike Lockwoodb3779552009-05-08 14:27:42 -0400333 strncmp("persist.", name, strlen("persist.")) == 0) {
Tammo Spalink3dfe6c62009-08-26 10:13:20 +0800334 /*
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800335 * Don't write properties to disk until after we have read all default properties
336 * to prevent them from being overwritten by default values.
337 */
Tammo Spalink3dfe6c62009-08-26 10:13:20 +0800338 write_persistent_property(name, value);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800339 }
340 property_changed(name, value);
341 return 0;
342}
343
Colin Crossd11beb22010-04-13 19:33:37 -0700344void handle_property_set_fd()
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800345{
346 prop_msg msg;
347 int s;
348 int r;
349 int res;
350 struct ucred cr;
351 struct sockaddr_un addr;
352 socklen_t addr_size = sizeof(addr);
353 socklen_t cr_size = sizeof(cr);
354
Colin Crossd11beb22010-04-13 19:33:37 -0700355 if ((s = accept(property_set_fd, (struct sockaddr *) &addr, &addr_size)) < 0) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800356 return;
357 }
358
359 /* Check socket options here */
360 if (getsockopt(s, SOL_SOCKET, SO_PEERCRED, &cr, &cr_size) < 0) {
361 close(s);
362 ERROR("Unable to recieve socket options\n");
363 return;
364 }
365
Mike Lockwoodd18678f2011-07-01 14:48:50 -0400366 r = TEMP_FAILURE_RETRY(recv(s, &msg, sizeof(msg), 0));
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800367 if(r != sizeof(prop_msg)) {
Mike Lockwoodd18678f2011-07-01 14:48:50 -0400368 ERROR("sys_prop: mis-match msg size recieved: %d expected: %d errno: %d\n",
369 r, sizeof(prop_msg), errno);
Brad Fitzpatrick9f1e0e32011-03-30 12:39:56 -0700370 close(s);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800371 return;
372 }
373
374 switch(msg.cmd) {
375 case PROP_MSG_SETPROP:
376 msg.name[PROP_NAME_MAX-1] = 0;
377 msg.value[PROP_VALUE_MAX-1] = 0;
378
379 if(memcmp(msg.name,"ctl.",4) == 0) {
Brad Fitzpatrick71ead182011-04-01 08:24:13 -0700380 // Keep the old close-socket-early behavior when handling
381 // ctl.* properties.
382 close(s);
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400383 if (check_control_perms(msg.value, cr.uid, cr.gid)) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800384 handle_control_message((char*) msg.name + 4, (char*) msg.value);
385 } else {
Wink Savillecfa0d842010-10-03 13:30:11 -0700386 ERROR("sys_prop: Unable to %s service ctl [%s] uid:%d gid:%d pid:%d\n",
387 msg.name + 4, msg.value, cr.uid, cr.gid, cr.pid);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800388 }
389 } else {
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400390 if (check_perms(msg.name, cr.uid, cr.gid)) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800391 property_set((char*) msg.name, (char*) msg.value);
392 } else {
393 ERROR("sys_prop: permission denied uid:%d name:%s\n",
394 cr.uid, msg.name);
395 }
Brad Fitzpatrick71ead182011-04-01 08:24:13 -0700396
397 // Note: bionic's property client code assumes that the
398 // property server will not close the socket until *AFTER*
399 // the property is written to memory.
400 close(s);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800401 }
402 break;
403
404 default:
Brad Fitzpatrick71ead182011-04-01 08:24:13 -0700405 close(s);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800406 break;
407 }
408}
409
410void get_property_workspace(int *fd, int *sz)
411{
412 *fd = pa_workspace.fd;
413 *sz = pa_workspace.size;
414}
415
416static void load_properties(char *data)
417{
418 char *key, *value, *eol, *sol, *tmp;
419
420 sol = data;
421 while((eol = strchr(sol, '\n'))) {
422 key = sol;
423 *eol++ = 0;
424 sol = eol;
425
426 value = strchr(key, '=');
427 if(value == 0) continue;
428 *value++ = 0;
429
430 while(isspace(*key)) key++;
431 if(*key == '#') continue;
432 tmp = value - 2;
433 while((tmp > key) && isspace(*tmp)) *tmp-- = 0;
434
435 while(isspace(*value)) value++;
436 tmp = eol - 2;
437 while((tmp > value) && isspace(*tmp)) *tmp-- = 0;
438
439 property_set(key, value);
440 }
441}
442
443static void load_properties_from_file(const char *fn)
444{
445 char *data;
446 unsigned sz;
447
448 data = read_file(fn, &sz);
449
450 if(data != 0) {
451 load_properties(data);
452 free(data);
453 }
454}
455
456static void load_persistent_properties()
457{
458 DIR* dir = opendir(PERSISTENT_PROPERTY_DIR);
459 struct dirent* entry;
460 char path[PATH_MAX];
461 char value[PROP_VALUE_MAX];
462 int fd, length;
463
464 if (dir) {
465 while ((entry = readdir(dir)) != NULL) {
Mike Lockwoodb3779552009-05-08 14:27:42 -0400466 if (strncmp("persist.", entry->d_name, strlen("persist.")))
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800467 continue;
468#if HAVE_DIRENT_D_TYPE
469 if (entry->d_type != DT_REG)
470 continue;
471#endif
472 /* open the file and read the property value */
473 snprintf(path, sizeof(path), "%s/%s", PERSISTENT_PROPERTY_DIR, entry->d_name);
474 fd = open(path, O_RDONLY);
475 if (fd >= 0) {
476 length = read(fd, value, sizeof(value) - 1);
477 if (length >= 0) {
478 value[length] = 0;
479 property_set(entry->d_name, value);
480 } else {
481 ERROR("Unable to read persistent property file %s errno: %d\n", path, errno);
482 }
483 close(fd);
484 } else {
485 ERROR("Unable to open persistent property file %s errno: %d\n", path, errno);
486 }
487 }
488 closedir(dir);
489 } else {
490 ERROR("Unable to open persistent property directory %s errno: %d\n", PERSISTENT_PROPERTY_DIR, errno);
491 }
Tammo Spalink3dfe6c62009-08-26 10:13:20 +0800492
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800493 persistent_properties_loaded = 1;
494}
495
Dima Zavin88861122011-12-19 11:21:32 -0800496void property_init(void)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800497{
498 init_property_area();
Dima Zavin88861122011-12-19 11:21:32 -0800499}
500
501void property_load_boot_defaults(void)
502{
503 load_properties_from_file(PROP_PATH_RAMDISK_DEFAULT);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800504}
505
Colin Cross3294bbb2010-04-19 17:11:33 -0700506int properties_inited(void)
507{
508 return property_area_inited;
509}
510
Ken Sumrallc5c51032011-03-08 17:01:29 -0800511/* When booting an encrypted system, /data is not mounted when the
512 * property service is started, so any properties stored there are
513 * not loaded. Vold triggers init to load these properties once it
514 * has mounted /data.
515 */
516void load_persist_props(void)
517{
Nick Kralevich0dbda7e2012-01-18 13:38:34 -0800518#ifdef ALLOW_LOCAL_PROP_OVERRIDE
Ken Sumrallc5c51032011-03-08 17:01:29 -0800519 load_properties_from_file(PROP_PATH_LOCAL_OVERRIDE);
Nick Kralevich0dbda7e2012-01-18 13:38:34 -0800520#endif /* ALLOW_LOCAL_PROP_OVERRIDE */
Ken Sumrallc5c51032011-03-08 17:01:29 -0800521 /* Read persistent properties after all default values have been loaded. */
522 load_persistent_properties();
523}
524
Colin Crossd11beb22010-04-13 19:33:37 -0700525void start_property_service(void)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800526{
527 int fd;
528
529 load_properties_from_file(PROP_PATH_SYSTEM_BUILD);
530 load_properties_from_file(PROP_PATH_SYSTEM_DEFAULT);
Nick Kralevich0dbda7e2012-01-18 13:38:34 -0800531#ifdef ALLOW_LOCAL_PROP_OVERRIDE
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800532 load_properties_from_file(PROP_PATH_LOCAL_OVERRIDE);
Nick Kralevich0dbda7e2012-01-18 13:38:34 -0800533#endif /* ALLOW_LOCAL_PROP_OVERRIDE */
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800534 /* Read persistent properties after all default values have been loaded. */
535 load_persistent_properties();
536
537 fd = create_socket(PROP_SERVICE_NAME, SOCK_STREAM, 0666, 0, 0);
Colin Crossd11beb22010-04-13 19:33:37 -0700538 if(fd < 0) return;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800539 fcntl(fd, F_SETFD, FD_CLOEXEC);
540 fcntl(fd, F_SETFL, O_NONBLOCK);
541
542 listen(fd, 8);
Colin Crossd11beb22010-04-13 19:33:37 -0700543 property_set_fd = fd;
544}
545
546int get_property_set_fd()
547{
548 return property_set_fd;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800549}