Blame SOURCES/sudo-1.8.6p3-ldapconfparse.patch

1b092f
diff -up sudo-1.8.6p3/plugins/sudoers/ldap.c.confparse sudo-1.8.6p3/plugins/sudoers/ldap.c
1b092f
--- sudo-1.8.6p3/plugins/sudoers/ldap.c.confparse	2012-11-23 15:46:41.801008370 +0100
1b092f
+++ sudo-1.8.6p3/plugins/sudoers/ldap.c	2012-11-23 15:46:07.903885738 +0100
1b092f
@@ -1343,6 +1343,32 @@ sudo_ldap_parse_keyword(const char *keyw
1b092f
     debug_return_bool(false);
1b092f
 }
1b092f
 
1b092f
+/*
1b092f
+ * Read a line of input, remove whole line comments and strip off leading
1b092f
+ * and trailing spaces.  Returns static storage that is reused.
1b092f
+ */
1b092f
+static char *
1b092f
+sudo_ldap_parseln(FILE *fp)
1b092f
+{
1b092f
+    size_t len;
1b092f
+    char *cp = NULL;
1b092f
+    static char buf[LINE_MAX];
1b092f
+
1b092f
+    if (fgets(buf, sizeof(buf), fp) != NULL) {
1b092f
+	/* Remove comments */
1b092f
+	if (*buf == '#')
1b092f
+	    *buf = '\0';
1b092f
+
1b092f
+	/* Trim leading and trailing whitespace/newline */
1b092f
+	len = strlen(buf);
1b092f
+	while (len > 0 && isspace((unsigned char)buf[len - 1]))
1b092f
+	    buf[--len] = '\0';
1b092f
+	for (cp = buf; isblank(*cp); cp++)
1b092f
+	    continue;
1b092f
+    }
1b092f
+    return(cp);
1b092f
+}
1b092f
+
1b092f
 static bool
1b092f
 sudo_ldap_read_config(void)
1b092f
 {
1b092f
@@ -1364,7 +1390,7 @@ sudo_ldap_read_config(void)
1b092f
     if ((fp = fopen(_PATH_LDAP_CONF, "r")) == NULL)
1b092f
 	debug_return_bool(false);
1b092f
 
1b092f
-    while ((cp = sudo_parseln(fp)) != NULL) {
1b092f
+    while ((cp = sudo_ldap_parseln(fp)) != NULL) {
1b092f
 	if (*cp == '\0')
1b092f
 	    continue;		/* skip empty line */
1b092f