Blame SOURCES/sudo-1.8.23-ldapsearchuidfix.patch

46eb58
diff -up sudo-1.8.23/plugins/sudoers/ldap.c.ldapsearchuidfix sudo-1.8.23/plugins/sudoers/ldap.c
46eb58
--- sudo-1.8.23/plugins/sudoers/ldap.c.ldapsearchuidfix	2018-04-29 21:59:31.000000000 +0200
46eb58
+++ sudo-1.8.23/plugins/sudoers/ldap.c	2018-06-18 08:34:01.202686941 +0200
46eb58
@@ -1189,8 +1189,8 @@ sudo_ldap_build_pass1(LDAP *ld, struct p
46eb58
     if (ldap_conf.search_filter)
46eb58
 	sz += strlen(ldap_conf.search_filter);
46eb58
 
46eb58
-    /* Then add (|(sudoUser=USERNAME)(sudoUser=ALL)) + NUL */
46eb58
-    sz += 29 + sudo_ldap_value_len(pw->pw_name);
46eb58
+    /* Then add (|(sudoUser=USERNAME)(sudoUser=#uid)(sudoUser=ALL)) + NUL */
46eb58
+    sz += 29 + (12 + MAX_UID_T_LEN) + sudo_ldap_value_len(pw->pw_name);
46eb58
 
46eb58
     /* Add space for primary and supplementary groups and gids */
46eb58
     if ((grp = sudo_getgrgid(pw->pw_gid)) != NULL) {
46eb58
@@ -1253,6 +1253,12 @@ sudo_ldap_build_pass1(LDAP *ld, struct p
46eb58
     CHECK_LDAP_VCAT(buf, pw->pw_name, sz);
46eb58
     CHECK_STRLCAT(buf, ")", sz);
46eb58
 
46eb58
+    /* Append user uid */
46eb58
+    (void) snprintf(gidbuf, sizeof(gidbuf), "%u", (unsigned int)pw->pw_uid);
46eb58
+    (void) strlcat(buf, "(sudoUser=#", sz);
46eb58
+    (void) strlcat(buf, gidbuf, sz);
46eb58
+    (void) strlcat(buf, ")", sz);
46eb58
+
46eb58
     /* Append primary group and gid */
46eb58
     if (grp != NULL) {
46eb58
 	CHECK_STRLCAT(buf, "(sudoUser=%", sz);