Compare stricter in proc_getent
The new proc_getent compares stricter so that e.g. "ro" doesn't match root=/dev/sdaN anymore. So it has to be either "ro" or "ro=".
This commit is contained in:
parent
2471d741f7
commit
0d6ae379f4
23
src/rc/rc.c
23
src/rc/rc.c
@ -173,7 +173,7 @@ proc_getent(const char *ent)
|
|||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *proc, *p, *value = NULL;
|
char *proc, *p, *value = NULL;
|
||||||
size_t i;
|
size_t i, len;
|
||||||
|
|
||||||
if (!exists("/proc/cmdline"))
|
if (!exists("/proc/cmdline"))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -187,16 +187,25 @@ proc_getent(const char *ent)
|
|||||||
i = 0;
|
i = 0;
|
||||||
if (rc_getline(&proc, &i, fp) == -1 || proc == NULL)
|
if (rc_getline(&proc, &i, fp) == -1 || proc == NULL)
|
||||||
eerror("rc_getline: %s", strerror(errno));
|
eerror("rc_getline: %s", strerror(errno));
|
||||||
if (*proc && (p = strstr(proc, ent))) {
|
|
||||||
i = p - proc;
|
if(proc != NULL) {
|
||||||
if (i == '\0' || proc[i - 1] == ' ') {
|
len = strlen(ent);
|
||||||
p += strlen(ent);
|
|
||||||
|
while((p = strsep(&proc, " "))) {
|
||||||
|
if(strncmp(ent, p, len) == 0 && (p[len] == '\0' || p[len] == ' ' || p[len] == '=')) {
|
||||||
|
p += len;
|
||||||
|
|
||||||
if (*p == '=')
|
if (*p == '=')
|
||||||
p++;
|
p++;
|
||||||
value = xstrdup(strsep(&p, " "));
|
|
||||||
|
value = xstrdup(p);
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!value)
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
free(proc);
|
free(proc);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user