1 |
diff -up sudo-1.8.6p3/plugins/sudoers/ldap.c.confparse sudo-1.8.6p3/plugins/sudoers/ldap.c |
2 |
--- sudo-1.8.6p3/plugins/sudoers/ldap.c.confparse 2012-11-23 15:46:41.801008370 +0100 |
3 |
+++ sudo-1.8.6p3/plugins/sudoers/ldap.c 2012-11-23 15:46:07.903885738 +0100 |
4 |
@@ -1343,6 +1343,32 @@ sudo_ldap_parse_keyword(const char *keyw |
5 |
debug_return_bool(false); |
6 |
} |
7 |
|
8 |
+/* |
9 |
+ * Read a line of input, remove whole line comments and strip off leading |
10 |
+ * and trailing spaces. Returns static storage that is reused. |
11 |
+ */ |
12 |
+static char * |
13 |
+sudo_ldap_parseln(FILE *fp) |
14 |
+{ |
15 |
+ size_t len; |
16 |
+ char *cp = NULL; |
17 |
+ static char buf[LINE_MAX]; |
18 |
+ |
19 |
+ if (fgets(buf, sizeof(buf), fp) != NULL) { |
20 |
+ /* Remove comments */ |
21 |
+ if (*buf == '#') |
22 |
+ *buf = '\0'; |
23 |
+ |
24 |
+ /* Trim leading and trailing whitespace/newline */ |
25 |
+ len = strlen(buf); |
26 |
+ while (len > 0 && isspace((unsigned char)buf[len - 1])) |
27 |
+ buf[--len] = '\0'; |
28 |
+ for (cp = buf; isblank(*cp); cp++) |
29 |
+ continue; |
30 |
+ } |
31 |
+ return(cp); |
32 |
+} |
33 |
+ |
34 |
static bool |
35 |
sudo_ldap_read_config(void) |
36 |
{ |
37 |
@@ -1364,7 +1390,7 @@ sudo_ldap_read_config(void) |
38 |
if ((fp = fopen(_PATH_LDAP_CONF, "r")) == NULL) |
39 |
debug_return_bool(false); |
40 |
|
41 |
- while ((cp = sudo_parseln(fp)) != NULL) { |
42 |
+ while ((cp = sudo_ldap_parseln(fp)) != NULL) { |
43 |
if (*cp == '\0') |
44 |
continue; /* skip empty line */ |
45 |
|