summaryrefslogtreecommitdiffstats
path: root/init/builtins.c
diff options
context:
space:
mode:
authorDima Zavin <dima@android.com>2012-12-19 09:46:39 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2012-12-19 09:46:39 -0800
commit7ec62dbd9d2bd7369fa074bf002f642b03e6dd39 (patch)
treecc3f2b3ecab78f78b723c1976606ed338e17d987 /init/builtins.c
parent22e9136661f55122d4ed4b081f61fd63e9ce3685 (diff)
parent82ea44f88fed158fd807ef5b79100295b1163941 (diff)
downloadsystem_core-7ec62dbd9d2bd7369fa074bf002f642b03e6dd39.zip
system_core-7ec62dbd9d2bd7369fa074bf002f642b03e6dd39.tar.gz
system_core-7ec62dbd9d2bd7369fa074bf002f642b03e6dd39.tar.bz2
am 82ea44f8: Merge "Change setsebool syntax to be consistent with other init built-ins."
* commit '82ea44f88fed158fd807ef5b79100295b1163941': Change setsebool syntax to be consistent with other init built-ins.
Diffstat (limited to 'init/builtins.c')
-rw-r--r--init/builtins.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/init/builtins.c b/init/builtins.c
index baa3e7f..dc7900e 100644
--- a/init/builtins.c
+++ b/init/builtins.c
@@ -754,34 +754,29 @@ int do_restorecon(int nargs, char **args) {
}
int do_setsebool(int nargs, char **args) {
- SELboolean *b = alloca(nargs * sizeof(SELboolean));
- char *v;
- int i;
+ const char *name = args[1];
+ const char *value = args[2];
+ SELboolean b;
+ int ret;
if (is_selinux_enabled() <= 0)
return 0;
- for (i = 1; i < nargs; i++) {
- char *name = args[i];
- v = strchr(name, '=');
- if (!v) {
- ERROR("setsebool: argument %s had no =\n", name);
- return -EINVAL;
- }
- *v++ = 0;
- b[i-1].name = name;
- if (!strcmp(v, "1") || !strcasecmp(v, "true") || !strcasecmp(v, "on"))
- b[i-1].value = 1;
- else if (!strcmp(v, "0") || !strcasecmp(v, "false") || !strcasecmp(v, "off"))
- b[i-1].value = 0;
- else {
- ERROR("setsebool: invalid value %s\n", v);
- return -EINVAL;
- }
+ b.name = name;
+ if (!strcmp(value, "1") || !strcasecmp(value, "true") || !strcasecmp(value, "on"))
+ b.value = 1;
+ else if (!strcmp(value, "0") || !strcasecmp(value, "false") || !strcasecmp(value, "off"))
+ b.value = 0;
+ else {
+ ERROR("setsebool: invalid value %s\n", value);
+ return -EINVAL;
}
- if (security_set_boolean_list(nargs - 1, b, 0) < 0)
- return -errno;
+ if (security_set_boolean_list(1, &b, 0) < 0) {
+ ret = -errno;
+ ERROR("setsebool: could not set %s to %s\n", name, value);
+ return ret;
+ }
return 0;
}