1 |
diff -up sudo-1.8.6p3/plugins/sudoers/ldap.c.ldapsearchuidfix sudo-1.8.6p3/plugins/sudoers/ldap.c |
2 |
--- sudo-1.8.6p3/plugins/sudoers/ldap.c.ldapsearchuidfix 2015-12-14 10:13:16.940861298 +0100 |
3 |
+++ sudo-1.8.6p3/plugins/sudoers/ldap.c 2015-12-14 10:13:16.942861298 +0100 |
4 |
@@ -1149,8 +1149,8 @@ sudo_ldap_build_pass1(struct passwd *pw) |
5 |
if (ldap_conf.search_filter) |
6 |
sz += strlen(ldap_conf.search_filter); |
7 |
|
8 |
- /* Then add (|(sudoUser=USERNAME)(sudoUser=ALL)) + NUL */ |
9 |
- sz += 29 + sudo_ldap_value_len(pw->pw_name); |
10 |
+ /* Then add (|(sudoUser=USERNAME)(sudoUser=#uid)(sudoUser=ALL)) + NUL */ |
11 |
+ sz += 29 + (12 + MAX_UID_T_LEN) + sudo_ldap_value_len(pw->pw_name); |
12 |
|
13 |
/* Add space for primary and supplementary groups and gids */ |
14 |
if ((grp = sudo_getgrgid(pw->pw_gid)) != NULL) { |
15 |
@@ -1200,6 +1200,12 @@ sudo_ldap_build_pass1(struct passwd *pw) |
16 |
(void) sudo_ldap_value_cat(buf, pw->pw_name, sz); |
17 |
(void) strlcat(buf, ")", sz); |
18 |
|
19 |
+ /* Append user uid */ |
20 |
+ (void) snprintf(gidbuf, sizeof(gidbuf), "%u", (unsigned int)pw->pw_uid); |
21 |
+ (void) strlcat(buf, "(sudoUser=#", sz); |
22 |
+ (void) strlcat(buf, gidbuf, sz); |
23 |
+ (void) strlcat(buf, ")", sz); |
24 |
+ |
25 |
/* Append primary group and gid */ |
26 |
if (grp != NULL) { |
27 |
(void) strlcat(buf, "(sudoUser=%", sz); |