Gentoo Archives: gentoo-commits

From: Christian Ruppert <idl0r@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/
Date: Fri, 30 Dec 2011 15:03:42
Message-Id: 0d6ae379f43fdab9516e6ed949ba9563972c0c65.idl0r@gentoo
1 commit: 0d6ae379f43fdab9516e6ed949ba9563972c0c65
2 Author: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
3 AuthorDate: Fri Dec 30 00:44:15 2011 +0000
4 Commit: Christian Ruppert <idl0r <AT> gentoo <DOT> org>
5 CommitDate: Fri Dec 30 15:03:24 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=0d6ae379
7
8 Compare stricter in proc_getent
9
10 The new proc_getent compares stricter so that e.g. "ro" doesn't match
11 root=/dev/sdaN anymore.
12 So it has to be either "ro" or "ro=".
13
14 ---
15 src/rc/rc.c | 27 ++++++++++++++++++---------
16 1 files changed, 18 insertions(+), 9 deletions(-)
17
18 diff --git a/src/rc/rc.c b/src/rc/rc.c
19 index ad16f7d..05c99fa 100644
20 --- a/src/rc/rc.c
21 +++ b/src/rc/rc.c
22 @@ -173,7 +173,7 @@ proc_getent(const char *ent)
23 {
24 FILE *fp;
25 char *proc, *p, *value = NULL;
26 - size_t i;
27 + size_t i, len;
28
29 if (!exists("/proc/cmdline"))
30 return NULL;
31 @@ -187,16 +187,25 @@ proc_getent(const char *ent)
32 i = 0;
33 if (rc_getline(&proc, &i, fp) == -1 || proc == NULL)
34 eerror("rc_getline: %s", strerror(errno));
35 - if (*proc && (p = strstr(proc, ent))) {
36 - i = p - proc;
37 - if (i == '\0' || proc[i - 1] == ' ') {
38 - p += strlen(ent);
39 - if (*p == '=')
40 - p++;
41 - value = xstrdup(strsep(&p, " "));
42 +
43 + if(proc != NULL) {
44 + len = strlen(ent);
45 +
46 + while((p = strsep(&proc, " "))) {
47 + if(strncmp(ent, p, len) == 0 && (p[len] == '\0' || p[len] == ' ' || p[len] == '=')) {
48 + p += len;
49 +
50 + if (*p == '=')
51 + p++;
52 +
53 + value = xstrdup(p);
54 + }
55 }
56 - } else
57 + }
58 +
59 + if(!value)
60 errno = ENOENT;
61 +
62 fclose(fp);
63 free(proc);