system/corennnnn
修訂 | fe8a6e8e89a6708238bf4da60cad5ccd6c128f8c (tree) |
---|---|
時間 | 2016-07-27 03:49:13 |
作者 | Andrew Boie <andrew.p.boie@inte...> |
Commiter | Jaap Jan Meijer |
init: Add 'readprops' command
This reads the contents of a text file and sets system properties
based on its contents.
Change-Id: Ic03de7ee9afb8a12439d0dff343560011e152beb
For: AXIA-102
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
@@ -675,6 +675,14 @@ int do_stop(int nargs, char **args) | ||
675 | 675 | return 0; |
676 | 676 | } |
677 | 677 | |
678 | +int do_readprops(int nargs, char **args) | |
679 | +{ | |
680 | + if (nargs == 2) { | |
681 | + return load_properties_from_file(args[1], NULL); | |
682 | + } | |
683 | + return -1; | |
684 | +} | |
685 | + | |
678 | 686 | int do_restart(int nargs, char **args) |
679 | 687 | { |
680 | 688 | struct service *svc; |
@@ -177,6 +177,7 @@ static int lookup_keyword(const char *s) | ||
177 | 177 | if (!strcmp(s, "robemod")) return K_probemod; |
178 | 178 | break; |
179 | 179 | case 'r': |
180 | + if (!strcmp(s, "eadprops")) return K_readprops; | |
180 | 181 | if (!strcmp(s, "estart")) return K_restart; |
181 | 182 | if (!strcmp(s, "estorecon")) return K_restorecon; |
182 | 183 | if (!strcmp(s, "estorecon_recursive")) return K_restorecon_recursive; |
@@ -17,6 +17,7 @@ int do_mount_all(int nargs, char **args); | ||
17 | 17 | int do_mount(int nargs, char **args); |
18 | 18 | int do_powerctl(int nargs, char **args); |
19 | 19 | int do_probemod(int nargs, char **args); |
20 | +int do_readprops(int nargs, char **args); | |
20 | 21 | int do_restart(int nargs, char **args); |
21 | 22 | int do_restorecon(int nargs, char **args); |
22 | 23 | int do_restorecon_recursive(int nargs, char **args); |
@@ -81,6 +82,7 @@ enum { | ||
81 | 82 | KEYWORD(on, SECTION, 0, 0) |
82 | 83 | KEYWORD(powerctl, COMMAND, 1, do_powerctl) |
83 | 84 | KEYWORD(probemod, COMMAND, 1, do_probemod) |
85 | + KEYWORD(readprops, COMMAND, 1, do_readprops) | |
84 | 86 | KEYWORD(restart, COMMAND, 1, do_restart) |
85 | 87 | KEYWORD(restorecon, COMMAND, 1, do_restorecon) |
86 | 88 | KEYWORD(restorecon_recursive, COMMAND, 1, do_restorecon_recursive) |
@@ -385,8 +385,6 @@ void get_property_workspace(int *fd, int *sz) | ||
385 | 385 | *sz = pa_workspace.size; |
386 | 386 | } |
387 | 387 | |
388 | -static void load_properties_from_file(const char *, const char *); | |
389 | - | |
390 | 388 | /* |
391 | 389 | * Filter is used to decide which properties to load: NULL loads all keys, |
392 | 390 | * "ro.foo.*" is a prefix match, and "ro.foo.bar" is an exact match. |
@@ -451,14 +449,18 @@ static void load_properties(char *data, const char *filter) | ||
451 | 449 | * Filter is used to decide which properties to load: NULL loads all keys, |
452 | 450 | * "ro.foo.*" is a prefix match, and "ro.foo.bar" is an exact match. |
453 | 451 | */ |
454 | -static void load_properties_from_file(const char* filename, const char* filter) { | |
452 | +int load_properties_from_file(const char* filename, const char* filter) { | |
455 | 453 | Timer t; |
456 | 454 | std::string data; |
457 | 455 | if (read_file(filename, &data)) { |
458 | 456 | data.push_back('\n'); |
459 | 457 | load_properties(&data[0], filter); |
458 | + } else { | |
459 | + ERROR("Unable to read property file '%s'\n", filename); | |
460 | + return -1; | |
460 | 461 | } |
461 | 462 | NOTICE("(Loading properties from %s took %.2fs.)\n", filename, t.duration()); |
463 | + return 0; | |
462 | 464 | } |
463 | 465 | |
464 | 466 | static void load_persistent_properties() { |
@@ -22,6 +22,7 @@ | ||
22 | 22 | |
23 | 23 | extern void property_init(void); |
24 | 24 | extern void property_load_boot_defaults(void); |
25 | +extern int load_properties_from_file(const char *fn, const char *); | |
25 | 26 | extern void load_persist_props(void); |
26 | 27 | extern void load_system_props(void); |
27 | 28 | extern void start_property_service(void); |
@@ -238,6 +238,10 @@ powerctl | ||
238 | 238 | restart <service> |
239 | 239 | Like stop, but doesn't disable the service. |
240 | 240 | |
241 | +readprops <path> | |
242 | + Read and set system properties based on the contents of a text file | |
243 | + at <path> | |
244 | + | |
241 | 245 | restorecon <path> [ <path> ]* |
242 | 246 | Restore the file named by <path> to the security context specified |
243 | 247 | in the file_contexts configuration. |