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
|
/* In shells the last item takes precedence, so we need to remove
|
||||||
any prior values we may already have */
|
any prior values we may already have */
|
||||||
TAILQ_FOREACH(cline, config, entries) {
|
TAILQ_FOREACH(cline, config, entries) {
|
||||||
p = strchr(cline->value, '=');
|
i = strlen(entry);
|
||||||
if (p && strncmp(entry, cline->value,
|
if (strncmp(entry, cline->value, i) == 0 && cline->value[i] == '=') {
|
||||||
(size_t)(p - cline->value)) == 0)
|
|
||||||
{
|
|
||||||
/* We have a match now - to save time we directly replace it */
|
/* We have a match now - to save time we directly replace it */
|
||||||
free(cline->value);
|
free(cline->value);
|
||||||
cline->value = newline;
|
cline->value = newline;
|
||||||
@ -202,15 +200,13 @@ rc_config_value(RC_STRINGLIST *list, const char *entry)
|
|||||||
{
|
{
|
||||||
RC_STRING *line;
|
RC_STRING *line;
|
||||||
char *p;
|
char *p;
|
||||||
size_t len, dif;
|
size_t len;
|
||||||
|
|
||||||
len = strlen(entry);
|
len = strlen(entry);
|
||||||
TAILQ_FOREACH(line, list, entries) {
|
TAILQ_FOREACH(line, list, entries) {
|
||||||
p = strchr(line->value, '=');
|
p = strchr(line->value, '=');
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
dif = (p - line->value);
|
if (strncmp(entry, line->value, len) == 0 && line->value[len] == '=')
|
||||||
if (dif == len &&
|
|
||||||
strncmp(entry, line->value, dif) == 0)
|
|
||||||
return ++p;
|
return ++p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user