Do not skip similar config options
OpenRC goes through the config and checks each option for duplicates. Lets say we're on "rc_logger" currently and its the last option in the config file and we previously defined rc_logger_path. It now goes through all previous config options and compares those against the current one "rc_logger" *but* it compares only the first N bytes, in this case strlen("rc_logger"). So it strips the _path from "rc_logger_path" which ends up into "rc_logger" and it compares that against the current one (also "rc_logger"), it would then simply override the previous definition. This patch fixes this behaviour to always compare the full option / variable names.
This commit is contained in:
parent
0c7032840b
commit
ef22868f36
@ -173,10 +173,8 @@ rc_config_load(const char *file)
|
||||
/* In shells the last item takes precedence, so we need to remove
|
||||
any prior values we may already have */
|
||||
TAILQ_FOREACH(cline, config, entries) {
|
||||
p = strchr(cline->value, '=');
|
||||
if (p && strncmp(entry, cline->value,
|
||||
(size_t)(p - cline->value)) == 0)
|
||||
{
|
||||
i = strlen(entry);
|
||||
if (strncmp(entry, cline->value, i) == 0 && cline->value[i] == '=') {
|
||||
/* We have a match now - to save time we directly replace it */
|
||||
free(cline->value);
|
||||
cline->value = newline;
|
||||
@ -202,15 +200,13 @@ rc_config_value(RC_STRINGLIST *list, const char *entry)
|
||||
{
|
||||
RC_STRING *line;
|
||||
char *p;
|
||||
size_t len, dif;
|
||||
size_t len;
|
||||
|
||||
len = strlen(entry);
|
||||
TAILQ_FOREACH(line, list, entries) {
|
||||
p = strchr(line->value, '=');
|
||||
if (p != NULL) {
|
||||
dif = (p - line->value);
|
||||
if (dif == len &&
|
||||
strncmp(entry, line->value, dif) == 0)
|
||||
if (strncmp(entry, line->value, len) == 0 && line->value[len] == '=')
|
||||
return ++p;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user