blob: 471c3dc4b43654705178b747a7e068f8d1bb0123 [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 },
79 { "dhcp.", AID_SYSTEM, 0 },
80 { "dhcp.", AID_DHCP, 0 },
Romain Guy45fa13f2012-04-27 15:19:30 -070081 { "debug.", AID_SYSTEM, 0 },
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -040082 { "debug.", AID_SHELL, 0 },
83 { "log.", AID_SHELL, 0 },
84 { "service.adb.root", AID_SHELL, 0 },
Mike Lockwood58aa5b02010-12-10 09:48:41 -080085 { "service.adb.tcp.port", AID_SHELL, 0 },
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -040086 { "persist.sys.", AID_SYSTEM, 0 },
87 { "persist.service.", AID_SYSTEM, 0 },
Oscar Montemayoref4e2152009-11-12 12:02:24 -080088 { "persist.security.", AID_SYSTEM, 0 },
Stephen Smalleyae6f3d72012-05-01 15:02:53 -040089 { "selinux." , AID_SYSTEM, 0 },
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -040090 { NULL, 0, 0 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080091};
92
93/*
94 * White list of UID that are allowed to start/stop services.
95 * Currently there are no user apps that require.
96 */
97struct {
98 const char *service;
99 unsigned int uid;
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400100 unsigned int gid;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800101} control_perms[] = {
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400102 { "dumpstate",AID_SHELL, AID_LOG },
Wink Savillecfa0d842010-10-03 13:30:11 -0700103 { "ril-daemon",AID_RADIO, AID_RADIO },
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400104 {NULL, 0, 0 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800105};
106
107typedef struct {
108 void *data;
109 size_t size;
110 int fd;
111} workspace;
112
113static int init_workspace(workspace *w, size_t size)
114{
115 void *data;
116 int fd;
117
Brian Swetland25b15be2010-07-13 16:43:56 -0700118 /* dev is a tmpfs that we can use to carve a shared workspace
119 * out of, so let's do that...
120 */
121 fd = open("/dev/__properties__", O_RDWR | O_CREAT, 0600);
122 if (fd < 0)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800123 return -1;
124
Brian Swetland25b15be2010-07-13 16:43:56 -0700125 if (ftruncate(fd, size) < 0)
126 goto out;
127
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800128 data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
129 if(data == MAP_FAILED)
130 goto out;
131
Brian Swetland25b15be2010-07-13 16:43:56 -0700132 close(fd);
133
134 fd = open("/dev/__properties__", O_RDONLY);
135 if (fd < 0)
136 return -1;
137
138 unlink("/dev/__properties__");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800139
140 w->data = data;
141 w->size = size;
142 w->fd = fd;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800143 return 0;
144
145out:
146 close(fd);
147 return -1;
148}
149
150/* (8 header words + 247 toc words) = 1020 bytes */
151/* 1024 bytes header and toc + 247 prop_infos @ 128 bytes = 32640 bytes */
152
153#define PA_COUNT_MAX 247
154#define PA_INFO_START 1024
155#define PA_SIZE 32768
156
157static workspace pa_workspace;
158static prop_info *pa_info_array;
159
160extern prop_area *__system_property_area__;
161
162static int init_property_area(void)
163{
164 prop_area *pa;
165
166 if(pa_info_array)
167 return -1;
168
169 if(init_workspace(&pa_workspace, PA_SIZE))
170 return -1;
171
172 fcntl(pa_workspace.fd, F_SETFD, FD_CLOEXEC);
173
174 pa_info_array = (void*) (((char*) pa_workspace.data) + PA_INFO_START);
175
176 pa = pa_workspace.data;
177 memset(pa, 0, PA_SIZE);
178 pa->magic = PROP_AREA_MAGIC;
179 pa->version = PROP_AREA_VERSION;
180
181 /* plug into the lib property services */
182 __system_property_area__ = pa;
Colin Cross3294bbb2010-04-19 17:11:33 -0700183 property_area_inited = 1;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800184 return 0;
185}
186
187static void update_prop_info(prop_info *pi, const char *value, unsigned len)
188{
189 pi->serial = pi->serial | 1;
190 memcpy(pi->value, value, len + 1);
191 pi->serial = (len << 24) | ((pi->serial + 1) & 0xffffff);
192 __futex_wake(&pi->serial, INT32_MAX);
193}
194
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800195/*
196 * Checks permissions for starting/stoping system services.
197 * AID_SYSTEM and AID_ROOT are always allowed.
198 *
199 * Returns 1 if uid allowed, 0 otherwise.
200 */
Colin Crossd11beb22010-04-13 19:33:37 -0700201static int check_control_perms(const char *name, unsigned int uid, unsigned int gid) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800202 int i;
203 if (uid == AID_SYSTEM || uid == AID_ROOT)
204 return 1;
205
206 /* Search the ACL */
207 for (i = 0; control_perms[i].service; i++) {
208 if (strcmp(control_perms[i].service, name) == 0) {
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400209 if ((uid && control_perms[i].uid == uid) ||
210 (gid && control_perms[i].gid == gid)) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800211 return 1;
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400212 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800213 }
214 }
215 return 0;
216}
217
218/*
219 * Checks permissions for setting system properties.
220 * Returns 1 if uid allowed, 0 otherwise.
221 */
Colin Crossd11beb22010-04-13 19:33:37 -0700222static int check_perms(const char *name, unsigned int uid, unsigned int gid)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800223{
224 int i;
225 if (uid == 0)
226 return 1;
227
228 if(!strncmp(name, "ro.", 3))
229 name +=3;
230
231 for (i = 0; property_perms[i].prefix; i++) {
232 int tmp;
233 if (strncmp(property_perms[i].prefix, name,
234 strlen(property_perms[i].prefix)) == 0) {
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400235 if ((uid && property_perms[i].uid == uid) ||
236 (gid && property_perms[i].gid == gid)) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800237 return 1;
238 }
239 }
240 }
241
242 return 0;
243}
244
245const char* property_get(const char *name)
246{
247 prop_info *pi;
248
249 if(strlen(name) >= PROP_NAME_MAX) return 0;
250
251 pi = (prop_info*) __system_property_find(name);
252
253 if(pi != 0) {
254 return pi->value;
255 } else {
256 return 0;
257 }
258}
259
Tammo Spalink3dfe6c62009-08-26 10:13:20 +0800260static void write_persistent_property(const char *name, const char *value)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800261{
262 const char *tempPath = PERSISTENT_PROPERTY_DIR "/.temp";
263 char path[PATH_MAX];
264 int fd, length;
265
266 snprintf(path, sizeof(path), "%s/%s", PERSISTENT_PROPERTY_DIR, name);
267
268 fd = open(tempPath, O_WRONLY|O_CREAT|O_TRUNC, 0600);
269 if (fd < 0) {
270 ERROR("Unable to write persistent property to temp file %s errno: %d\n", tempPath, errno);
Tammo Spalink3dfe6c62009-08-26 10:13:20 +0800271 return;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800272 }
273 write(fd, value, strlen(value));
274 close(fd);
275
276 if (rename(tempPath, path)) {
277 unlink(tempPath);
278 ERROR("Unable to rename persistent property file %s to %s\n", tempPath, path);
279 }
280}
281
282int property_set(const char *name, const char *value)
283{
284 prop_area *pa;
285 prop_info *pi;
286
287 int namelen = strlen(name);
288 int valuelen = strlen(value);
289
290 if(namelen >= PROP_NAME_MAX) return -1;
291 if(valuelen >= PROP_VALUE_MAX) return -1;
292 if(namelen < 1) return -1;
293
294 pi = (prop_info*) __system_property_find(name);
295
296 if(pi != 0) {
297 /* ro.* properties may NEVER be modified once set */
298 if(!strncmp(name, "ro.", 3)) return -1;
299
300 pa = __system_property_area__;
301 update_prop_info(pi, value, valuelen);
302 pa->serial++;
303 __futex_wake(&pa->serial, INT32_MAX);
304 } else {
305 pa = __system_property_area__;
306 if(pa->count == PA_COUNT_MAX) return -1;
307
308 pi = pa_info_array + pa->count;
309 pi->serial = (valuelen << 24);
310 memcpy(pi->name, name, namelen + 1);
311 memcpy(pi->value, value, valuelen + 1);
312
313 pa->toc[pa->count] =
314 (namelen << 24) | (((unsigned) pi) - ((unsigned) pa));
315
316 pa->count++;
317 pa->serial++;
318 __futex_wake(&pa->serial, INT32_MAX);
319 }
320 /* If name starts with "net." treat as a DNS property. */
Mike Lockwoodb3779552009-05-08 14:27:42 -0400321 if (strncmp("net.", name, strlen("net.")) == 0) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800322 if (strcmp("net.change", name) == 0) {
323 return 0;
324 }
Tammo Spalink3dfe6c62009-08-26 10:13:20 +0800325 /*
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800326 * The 'net.change' property is a special property used track when any
327 * 'net.*' property name is updated. It is _ONLY_ updated here. Its value
328 * contains the last updated 'net.*' property.
329 */
330 property_set("net.change", name);
331 } else if (persistent_properties_loaded &&
Mike Lockwoodb3779552009-05-08 14:27:42 -0400332 strncmp("persist.", name, strlen("persist.")) == 0) {
Tammo Spalink3dfe6c62009-08-26 10:13:20 +0800333 /*
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800334 * Don't write properties to disk until after we have read all default properties
335 * to prevent them from being overwritten by default values.
336 */
Tammo Spalink3dfe6c62009-08-26 10:13:20 +0800337 write_persistent_property(name, value);
Stephen Smalleyae6f3d72012-05-01 15:02:53 -0400338#ifdef HAVE_SELINUX
339 } else if (strcmp("selinux.reload_policy", name) == 0 &&
340 strcmp("1", value) == 0) {
341 selinux_reload_policy();
342#endif
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800343 }
344 property_changed(name, value);
345 return 0;
346}
347
Colin Crossd11beb22010-04-13 19:33:37 -0700348void handle_property_set_fd()
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800349{
350 prop_msg msg;
351 int s;
352 int r;
353 int res;
354 struct ucred cr;
355 struct sockaddr_un addr;
356 socklen_t addr_size = sizeof(addr);
357 socklen_t cr_size = sizeof(cr);
358
Colin Crossd11beb22010-04-13 19:33:37 -0700359 if ((s = accept(property_set_fd, (struct sockaddr *) &addr, &addr_size)) < 0) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800360 return;
361 }
362
363 /* Check socket options here */
364 if (getsockopt(s, SOL_SOCKET, SO_PEERCRED, &cr, &cr_size) < 0) {
365 close(s);
366 ERROR("Unable to recieve socket options\n");
367 return;
368 }
369
Mike Lockwoodd18678f2011-07-01 14:48:50 -0400370 r = TEMP_FAILURE_RETRY(recv(s, &msg, sizeof(msg), 0));
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800371 if(r != sizeof(prop_msg)) {
Mike Lockwoodd18678f2011-07-01 14:48:50 -0400372 ERROR("sys_prop: mis-match msg size recieved: %d expected: %d errno: %d\n",
373 r, sizeof(prop_msg), errno);
Brad Fitzpatrick9f1e0e32011-03-30 12:39:56 -0700374 close(s);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800375 return;
376 }
377
378 switch(msg.cmd) {
379 case PROP_MSG_SETPROP:
380 msg.name[PROP_NAME_MAX-1] = 0;
381 msg.value[PROP_VALUE_MAX-1] = 0;
382
383 if(memcmp(msg.name,"ctl.",4) == 0) {
Brad Fitzpatrick71ead182011-04-01 08:24:13 -0700384 // Keep the old close-socket-early behavior when handling
385 // ctl.* properties.
386 close(s);
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400387 if (check_control_perms(msg.value, cr.uid, cr.gid)) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800388 handle_control_message((char*) msg.name + 4, (char*) msg.value);
389 } else {
Wink Savillecfa0d842010-10-03 13:30:11 -0700390 ERROR("sys_prop: Unable to %s service ctl [%s] uid:%d gid:%d pid:%d\n",
391 msg.name + 4, msg.value, cr.uid, cr.gid, cr.pid);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800392 }
393 } else {
Mike Lockwoodc5e7ef22009-09-02 18:08:52 -0400394 if (check_perms(msg.name, cr.uid, cr.gid)) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800395 property_set((char*) msg.name, (char*) msg.value);
396 } else {
397 ERROR("sys_prop: permission denied uid:%d name:%s\n",
398 cr.uid, msg.name);
399 }
Brad Fitzpatrick71ead182011-04-01 08:24:13 -0700400
401 // Note: bionic's property client code assumes that the
402 // property server will not close the socket until *AFTER*
403 // the property is written to memory.
404 close(s);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800405 }
406 break;
407
408 default:
Brad Fitzpatrick71ead182011-04-01 08:24:13 -0700409 close(s);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800410 break;
411 }
412}
413
414void get_property_workspace(int *fd, int *sz)
415{
416 *fd = pa_workspace.fd;
417 *sz = pa_workspace.size;
418}
419
420static void load_properties(char *data)
421{
422 char *key, *value, *eol, *sol, *tmp;
423
424 sol = data;
425 while((eol = strchr(sol, '\n'))) {
426 key = sol;
427 *eol++ = 0;
428 sol = eol;
429
430 value = strchr(key, '=');
431 if(value == 0) continue;
432 *value++ = 0;
433
434 while(isspace(*key)) key++;
435 if(*key == '#') continue;
436 tmp = value - 2;
437 while((tmp > key) && isspace(*tmp)) *tmp-- = 0;
438
439 while(isspace(*value)) value++;
440 tmp = eol - 2;
441 while((tmp > value) && isspace(*tmp)) *tmp-- = 0;
442
443 property_set(key, value);
444 }
445}
446
447static void load_properties_from_file(const char *fn)
448{
449 char *data;
450 unsigned sz;
451
452 data = read_file(fn, &sz);
453
454 if(data != 0) {
455 load_properties(data);
456 free(data);
457 }
458}
459
460static void load_persistent_properties()
461{
462 DIR* dir = opendir(PERSISTENT_PROPERTY_DIR);
463 struct dirent* entry;
464 char path[PATH_MAX];
465 char value[PROP_VALUE_MAX];
466 int fd, length;
467
468 if (dir) {
469 while ((entry = readdir(dir)) != NULL) {
Mike Lockwoodb3779552009-05-08 14:27:42 -0400470 if (strncmp("persist.", entry->d_name, strlen("persist.")))
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800471 continue;
472#if HAVE_DIRENT_D_TYPE
473 if (entry->d_type != DT_REG)
474 continue;
475#endif
476 /* open the file and read the property value */
477 snprintf(path, sizeof(path), "%s/%s", PERSISTENT_PROPERTY_DIR, entry->d_name);
478 fd = open(path, O_RDONLY);
479 if (fd >= 0) {
480 length = read(fd, value, sizeof(value) - 1);
481 if (length >= 0) {
482 value[length] = 0;
483 property_set(entry->d_name, value);
484 } else {
485 ERROR("Unable to read persistent property file %s errno: %d\n", path, errno);
486 }
487 close(fd);
488 } else {
489 ERROR("Unable to open persistent property file %s errno: %d\n", path, errno);
490 }
491 }
492 closedir(dir);
493 } else {
494 ERROR("Unable to open persistent property directory %s errno: %d\n", PERSISTENT_PROPERTY_DIR, errno);
495 }
Tammo Spalink3dfe6c62009-08-26 10:13:20 +0800496
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800497 persistent_properties_loaded = 1;
498}
499
Dima Zavin88861122011-12-19 11:21:32 -0800500void property_init(void)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800501{
502 init_property_area();
Dima Zavin88861122011-12-19 11:21:32 -0800503}
504
505void property_load_boot_defaults(void)
506{
507 load_properties_from_file(PROP_PATH_RAMDISK_DEFAULT);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800508}
509
Colin Cross3294bbb2010-04-19 17:11:33 -0700510int properties_inited(void)
511{
512 return property_area_inited;
513}
514
Ken Sumrallc5c51032011-03-08 17:01:29 -0800515/* When booting an encrypted system, /data is not mounted when the
516 * property service is started, so any properties stored there are
517 * not loaded. Vold triggers init to load these properties once it
518 * has mounted /data.
519 */
520void load_persist_props(void)
521{
Nick Kralevich0dbda7e2012-01-18 13:38:34 -0800522#ifdef ALLOW_LOCAL_PROP_OVERRIDE
Ken Sumrallc5c51032011-03-08 17:01:29 -0800523 load_properties_from_file(PROP_PATH_LOCAL_OVERRIDE);
Nick Kralevich0dbda7e2012-01-18 13:38:34 -0800524#endif /* ALLOW_LOCAL_PROP_OVERRIDE */
Ken Sumrallc5c51032011-03-08 17:01:29 -0800525 /* Read persistent properties after all default values have been loaded. */
526 load_persistent_properties();
527}
528
Colin Crossd11beb22010-04-13 19:33:37 -0700529void start_property_service(void)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800530{
531 int fd;
532
533 load_properties_from_file(PROP_PATH_SYSTEM_BUILD);
534 load_properties_from_file(PROP_PATH_SYSTEM_DEFAULT);
Nick Kralevich0dbda7e2012-01-18 13:38:34 -0800535#ifdef ALLOW_LOCAL_PROP_OVERRIDE
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800536 load_properties_from_file(PROP_PATH_LOCAL_OVERRIDE);
Nick Kralevich0dbda7e2012-01-18 13:38:34 -0800537#endif /* ALLOW_LOCAL_PROP_OVERRIDE */
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800538 /* Read persistent properties after all default values have been loaded. */
539 load_persistent_properties();
540
541 fd = create_socket(PROP_SERVICE_NAME, SOCK_STREAM, 0666, 0, 0);
Colin Crossd11beb22010-04-13 19:33:37 -0700542 if(fd < 0) return;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800543 fcntl(fd, F_SETFD, FD_CLOEXEC);
544 fcntl(fd, F_SETFL, O_NONBLOCK);
545
546 listen(fd, 8);
Colin Crossd11beb22010-04-13 19:33:37 -0700547 property_set_fd = fd;
548}
549
550int get_property_set_fd()
551{
552 return property_set_fd;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800553}