//config: help
//config: Configure kernel parameters at runtime.
-//applet:IF_BB_SYSCTL(APPLET(sysctl, BB_DIR_SBIN, BB_SUID_DROP))
+//applet:IF_BB_SYSCTL(APPLET_NOEXEC(sysctl, sysctl, BB_DIR_SBIN, BB_SUID_DROP, sysctl))
//kbuild:lib-$(CONFIG_BB_SYSCTL) += sysctl.o
/* Must do it _after_ config_open(): */
xchdir("/proc/sys");
-//TODO: ';' is comment char too
-//TODO: <space><tab><space>#comment is also comment, not strictly 1st char only
parse_flags = 0;
parse_flags &= ~PARSE_COLLAPSE; // NO (var==val is not var=val) - treat consecutive delimiters as one
parse_flags &= ~PARSE_TRIM; // NO - trim leading and trailing delimiters
parse_flags |= PARSE_GREEDY; // YES - last token takes entire remainder of the line
parse_flags &= ~PARSE_MIN_DIE; // NO - die if < min tokens found
parse_flags &= ~PARSE_EOL_COMMENTS; // NO (only first char) - comments are recognized even if not first char
- while (config_read(parser, token, 2, 2, "#=", parse_flags)) {
+ parse_flags |= PARSE_ALT_COMMENTS;// YES - two comment chars: ';' and '#'
+ /* <space><tab><space>#comment is also comment, not strictly 1st char only */
+ parse_flags |= PARSE_WS_COMMENTS; // YES - comments are recognized even if there is whitespace before
+ while (config_read(parser, token, 2, 2, ";#=", parse_flags)) {
char *tp;
- trim(token[0]);
+
trim(token[1]);
+ tp = trim(token[0]);
sysctl_dots_to_slashes(token[0]);
- tp = xasprintf("%s=%s", token[0], token[1]);
- sysctl_act_on_setting(tp);
- free(tp);
+ /* ^^^converted in-place. tp still points to NUL */
+ /* now, add "=TOKEN1" */
+ *tp++ = '=';
+ overlapping_strcpy(tp, token[1]);
+
+ sysctl_act_on_setting(token[0]);
}
if (ENABLE_FEATURE_CLEAN_UP)
config_close(parser);