]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/samba/samba-3.6.99-fix_group_expansion_with_nss_templates.patch
Merge branch 'core110'
[ipfire-2.x.git] / src / patches / samba / samba-3.6.99-fix_group_expansion_with_nss_templates.patch
1 commit 75989f1d0d3ec86bb2046511b962ad72119c750b
2 Author: Andreas Schneider <asn@samba.org>
3 AuthorDate: Mon Nov 18 14:58:04 2013 +0100
4 Commit: Andreas Schneider <asn@samba.org>
5 CommitDate: Wed Feb 5 11:38:44 2014 +0100
6
7 s3-lib: Add grpname to talloc_sub_specified().
8
9 BUG: https://bugzilla.samba.org/show_bug.cgi?id=2191
10 ---
11 source3/include/proto.h | 1 +
12 source3/lib/substitute.c | 31 +++++++++++++++++++++++++------
13 source3/passdb/passdb.c | 8 ++++----
14 source3/passdb/pdb_ldap.c | 24 +++++++++++++++++++++---
15 source3/torture/torture.c | 2 +-
16 source3/utils/net_sam.c | 2 ++
17 source3/winbindd/wb_fill_pwent.c | 4 ++--
18 7 files changed, 56 insertions(+), 16 deletions(-)
19
20 diff --git a/source3/include/proto.h b/source3/include/proto.h
21 index 7303e76..db091ce 100644
22 --- a/source3/include/proto.h
23 +++ b/source3/include/proto.h
24 @@ -365,6 +365,7 @@ char *talloc_sub_basic(TALLOC_CTX *mem_ctx, const char *smb_name,
25 char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
26 const char *input_string,
27 const char *username,
28 + const char *grpname,
29 const char *domain,
30 uid_t uid,
31 gid_t gid);
32 diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
33 index 68328e5..10beed7 100644
34 --- a/source3/lib/substitute.c
35 +++ b/source3/lib/substitute.c
36 @@ -722,6 +722,7 @@ done:
37 char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
38 const char *input_string,
39 const char *username,
40 + const char *grpname,
41 const char *domain,
42 uid_t uid,
43 gid_t gid)
44 @@ -757,9 +758,18 @@ char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
45 break;
46 case 'G' :
47 if (gid != -1) {
48 - a_string = talloc_string_sub(
49 - tmp_ctx, a_string, "%G",
50 - gidtoname(gid));
51 + const char *name;
52 +
53 + if (grpname != NULL) {
54 + name = grpname;
55 + } else {
56 + name = gidtoname(gid);
57 + }
58 +
59 + a_string = talloc_string_sub(tmp_ctx,
60 + a_string,
61 + "%G",
62 + name);
63 } else {
64 a_string = talloc_string_sub(
65 tmp_ctx, a_string,
66 @@ -768,9 +778,18 @@ char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
67 break;
68 case 'g' :
69 if (gid != -1) {
70 - a_string = talloc_string_sub(
71 - tmp_ctx, a_string, "%g",
72 - gidtoname(gid));
73 + const char *name;
74 +
75 + if (grpname != NULL) {
76 + name = grpname;
77 + } else {
78 + name = gidtoname(gid);
79 + }
80 +
81 + a_string = talloc_string_sub(tmp_ctx,
82 + a_string,
83 + "%g",
84 + name);
85 } else {
86 a_string = talloc_string_sub(
87 tmp_ctx, a_string, "%g", "NO_GROUP");
88 diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
89 index 52c1129..493a694 100644
90 --- a/source3/passdb/passdb.c
91 +++ b/source3/passdb/passdb.c
92 @@ -228,16 +228,16 @@ static NTSTATUS samu_set_unix_internal(struct samu *user, const struct passwd *p
93 /* set some basic attributes */
94
95 pdb_set_profile_path(user, talloc_sub_specified(user,
96 - lp_logon_path(), pwd->pw_name, domain, pwd->pw_uid, pwd->pw_gid),
97 + lp_logon_path(), pwd->pw_name, NULL, domain, pwd->pw_uid, pwd->pw_gid),
98 PDB_DEFAULT);
99 pdb_set_homedir(user, talloc_sub_specified(user,
100 - lp_logon_home(), pwd->pw_name, domain, pwd->pw_uid, pwd->pw_gid),
101 + lp_logon_home(), pwd->pw_name, NULL, domain, pwd->pw_uid, pwd->pw_gid),
102 PDB_DEFAULT);
103 pdb_set_dir_drive(user, talloc_sub_specified(user,
104 - lp_logon_drive(), pwd->pw_name, domain, pwd->pw_uid, pwd->pw_gid),
105 + lp_logon_drive(), pwd->pw_name, NULL, domain, pwd->pw_uid, pwd->pw_gid),
106 PDB_DEFAULT);
107 pdb_set_logon_script(user, talloc_sub_specified(user,
108 - lp_logon_script(), pwd->pw_name, domain, pwd->pw_uid, pwd->pw_gid),
109 + lp_logon_script(), pwd->pw_name, NULL, domain, pwd->pw_uid, pwd->pw_gid),
110 PDB_DEFAULT);
111 }
112
113 diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
114 index 9316f40..1665641 100644
115 --- a/source3/passdb/pdb_ldap.c
116 +++ b/source3/passdb/pdb_ldap.c
117 @@ -5399,11 +5399,29 @@ static NTSTATUS ldapsam_create_user(struct pdb_methods *my_methods,
118
119 if (is_machine) {
120 /* TODO: choose a more appropriate default for machines */
121 - homedir = talloc_sub_specified(tmp_ctx, lp_template_homedir(), "SMB_workstations_home", ldap_state->domain_name, uid, gid);
122 + homedir = talloc_sub_specified(tmp_ctx,
123 + lp_template_homedir(),
124 + "SMB_workstations_home",
125 + NULL,
126 + ldap_state->domain_name,
127 + uid,
128 + gid);
129 shell = talloc_strdup(tmp_ctx, "/bin/false");
130 } else {
131 - homedir = talloc_sub_specified(tmp_ctx, lp_template_homedir(), name, ldap_state->domain_name, uid, gid);
132 - shell = talloc_sub_specified(tmp_ctx, lp_template_shell(), name, ldap_state->domain_name, uid, gid);
133 + homedir = talloc_sub_specified(tmp_ctx,
134 + lp_template_homedir(),
135 + name,
136 + NULL,
137 + ldap_state->domain_name,
138 + uid,
139 + gid);
140 + shell = talloc_sub_specified(tmp_ctx,
141 + lp_template_shell(),
142 + name,
143 + NULL,
144 + ldap_state->domain_name,
145 + uid,
146 + gid);
147 }
148 uidstr = talloc_asprintf(tmp_ctx, "%u", (unsigned int)uid);
149 gidstr = talloc_asprintf(tmp_ctx, "%u", (unsigned int)gid);
150 diff --git a/source3/torture/torture.c b/source3/torture/torture.c
151 index d37d83c..def177b 100644
152 --- a/source3/torture/torture.c
153 +++ b/source3/torture/torture.c
154 @@ -5976,7 +5976,7 @@ static bool subst_test(const char *str, const char *user, const char *domain,
155 char *subst;
156 bool result = true;
157
158 - subst = talloc_sub_specified(talloc_tos(), str, user, domain, uid, gid);
159 + subst = talloc_sub_specified(talloc_tos(), str, user, NULL, domain, uid, gid);
160
161 if (strcmp(subst, expected) != 0) {
162 printf("sub_specified(%s, %s, %s, %d, %d) returned [%s], expected "
163 diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c
164 index 0ff7c55..b49bb73 100644
165 --- a/source3/utils/net_sam.c
166 +++ b/source3/utils/net_sam.c
167 @@ -1847,10 +1847,12 @@ doma_done:
168 gidstr = talloc_asprintf(tc, "%u", (unsigned int)domadmins_gid);
169 dir = talloc_sub_specified(tc, lp_template_homedir(),
170 "Administrator",
171 + NULL,
172 get_global_sam_name(),
173 uid, domadmins_gid);
174 shell = talloc_sub_specified(tc, lp_template_shell(),
175 "Administrator",
176 + NULL,
177 get_global_sam_name(),
178 uid, domadmins_gid);
179
180 diff --git a/source3/winbindd/wb_fill_pwent.c b/source3/winbindd/wb_fill_pwent.c
181 index 8f09480..4d94a31 100644
182 --- a/source3/winbindd/wb_fill_pwent.c
183 +++ b/source3/winbindd/wb_fill_pwent.c
184 @@ -181,11 +181,11 @@ static bool fillup_pw_field(const char *lp_template,
185
186 if ((in != NULL) && (in[0] != '\0') && (lp_security() == SEC_ADS)) {
187 templ = talloc_sub_specified(talloc_tos(), in,
188 - username, domname,
189 + username, NULL, domname,
190 uid, gid);
191 } else {
192 templ = talloc_sub_specified(talloc_tos(), lp_template,
193 - username, domname,
194 + username, NULL, domname,
195 uid, gid);
196 }
197
198 commit 5faa0adf0a8c450897d7a61d348a600f889e5bef
199 Author: Andreas Schneider <asn@samba.org>
200 AuthorDate: Mon Nov 18 14:58:14 2013 +0100
201 Commit: Andreas Schneider <asn@samba.org>
202 CommitDate: Wed Feb 5 11:43:17 2014 +0100
203
204 s3-winbind: Pass the group name to fillup_pw_field().
205
206 BUG: https://bugzilla.samba.org/show_bug.cgi?id=2191
207 ---
208 source3/winbindd/wb_fill_pwent.c | 58 +++++++++++++++++++++++++++++-----------
209 1 file changed, 42 insertions(+), 16 deletions(-)
210
211 diff --git a/source3/winbindd/wb_fill_pwent.c b/source3/winbindd/wb_fill_pwent.c
212 index 4d94a31..878c5ad 100644
213 --- a/source3/winbindd/wb_fill_pwent.c
214 +++ b/source3/winbindd/wb_fill_pwent.c
215 @@ -29,6 +29,7 @@ struct wb_fill_pwent_state {
216
217 static bool fillup_pw_field(const char *lp_template,
218 const char *username,
219 + const char *grpname,
220 const char *domname,
221 uid_t uid,
222 gid_t gid,
223 @@ -36,7 +37,7 @@ static bool fillup_pw_field(const char *lp_template,
224 fstring out);
225
226 static void wb_fill_pwent_sid2uid_done(struct tevent_req *subreq);
227 -static void wb_fill_pwent_sid2gid_done(struct tevent_req *subreq);
228 +static void wb_fill_pwent_getgrsid_done(struct tevent_req *subreq);
229
230 struct tevent_req *wb_fill_pwent_send(TALLOC_CTX *mem_ctx,
231 struct tevent_context *ev,
232 @@ -76,33 +77,44 @@ static void wb_fill_pwent_sid2uid_done(struct tevent_req *subreq)
233 return;
234 }
235
236 - subreq = wb_sid2gid_send(state, state->ev, &state->info->group_sid);
237 + subreq = wb_getgrsid_send(state, state->ev, &state->info->group_sid, 1);
238 if (tevent_req_nomem(subreq, req)) {
239 return;
240 }
241 - tevent_req_set_callback(subreq, wb_fill_pwent_sid2gid_done, req);
242 + tevent_req_set_callback(subreq, wb_fill_pwent_getgrsid_done, req);
243 }
244
245 -static void wb_fill_pwent_sid2gid_done(struct tevent_req *subreq)
246 +static void wb_fill_pwent_getgrsid_done(struct tevent_req *subreq)
247 {
248 struct tevent_req *req = tevent_req_callback_data(
249 subreq, struct tevent_req);
250 struct wb_fill_pwent_state *state = tevent_req_data(
251 req, struct wb_fill_pwent_state);
252 struct winbindd_domain *domain;
253 - char *dom_name;
254 + const char *dom_name;
255 + const char *grp_name;
256 fstring user_name, output_username;
257 char *mapped_name = NULL;
258 + struct talloc_dict *members;
259 + TALLOC_CTX *tmp_ctx = talloc_stackframe();
260 NTSTATUS status;
261 -
262 - status = wb_sid2gid_recv(subreq, &state->pw->pw_gid);
263 + bool ok;
264 +
265 + status = wb_getgrsid_recv(subreq,
266 + tmp_ctx,
267 + &dom_name,
268 + &grp_name,
269 + &state->pw->pw_gid,
270 + &members);
271 TALLOC_FREE(subreq);
272 if (tevent_req_nterror(req, status)) {
273 + talloc_free(tmp_ctx);
274 return;
275 }
276
277 domain = find_domain_from_sid_noinit(&state->info->user_sid);
278 if (domain == NULL) {
279 + talloc_free(tmp_ctx);
280 tevent_req_nterror(req, NT_STATUS_NO_SUCH_USER);
281 return;
282 }
283 @@ -133,17 +145,30 @@ static void wb_fill_pwent_sid2gid_done(struct tevent_req *subreq)
284 fstrcpy(state->pw->pw_gecos, state->info->full_name);
285
286 /* Home directory and shell */
287 -
288 - if (!fillup_pw_field(lp_template_homedir(), user_name, dom_name,
289 - state->pw->pw_uid, state->pw->pw_gid,
290 - state->info->homedir, state->pw->pw_dir)) {
291 + ok = fillup_pw_field(lp_template_homedir(),
292 + user_name,
293 + grp_name,
294 + dom_name,
295 + state->pw->pw_uid,
296 + state->pw->pw_gid,
297 + state->info->homedir,
298 + state->pw->pw_dir);
299 + if (!ok) {
300 + talloc_free(tmp_ctx);
301 tevent_req_nterror(req, NT_STATUS_NO_SUCH_USER);
302 return;
303 }
304
305 - if (!fillup_pw_field(lp_template_shell(), user_name, dom_name,
306 - state->pw->pw_uid, state->pw->pw_gid,
307 - state->info->shell, state->pw->pw_shell)) {
308 + ok = fillup_pw_field(lp_template_shell(),
309 + user_name,
310 + grp_name,
311 + dom_name,
312 + state->pw->pw_uid,
313 + state->pw->pw_gid,
314 + state->info->shell,
315 + state->pw->pw_shell);
316 + talloc_free(tmp_ctx);
317 + if (!ok) {
318 tevent_req_nterror(req, NT_STATUS_NO_SUCH_USER);
319 return;
320 }
321 @@ -162,6 +187,7 @@ NTSTATUS wb_fill_pwent_recv(struct tevent_req *req)
322
323 static bool fillup_pw_field(const char *lp_template,
324 const char *username,
325 + const char *grpname,
326 const char *domname,
327 uid_t uid,
328 gid_t gid,
329 @@ -181,11 +207,11 @@ static bool fillup_pw_field(const char *lp_template,
330
331 if ((in != NULL) && (in[0] != '\0') && (lp_security() == SEC_ADS)) {
332 templ = talloc_sub_specified(talloc_tos(), in,
333 - username, NULL, domname,
334 + username, grpname, domname,
335 uid, gid);
336 } else {
337 templ = talloc_sub_specified(talloc_tos(), lp_template,
338 - username, NULL, domname,
339 + username, grpname, domname,
340 uid, gid);
341 }
342
343 commit db176c22f4f3e4c4f38288144d63822c3c191419
344 Author: Volker Lendecke <vl@samba.org>
345 AuthorDate: Thu Jan 16 16:10:25 2014 +0100
346 Commit: Andreas Schneider <asn@samba.org>
347 CommitDate: Wed Feb 5 11:44:15 2014 +0100
348
349 s3-winbind: Improve performance of wb_fill_pwent_sid2uid_done().
350
351 BUG: https://bugzilla.samba.org/show_bug.cgi?id=2191
352
353 Signed-off-by: Volker Lendecke <vl@samba.org>
354 Reviewed-by: Andreas Schneider <asn@samba.org>
355
356 Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
357 Autobuild-Date(master): Thu Jan 16 20:17:24 CET 2014 on sn-devel-104
358
359 (cherry picked from commit 1a43778433934530d77791edd1af538de8b1d8a3)
360 ---
361 source3/winbindd/wb_fill_pwent.c | 2 +-
362 1 file changed, 1 insertion(+), 1 deletion(-)
363
364 diff --git a/source3/winbindd/wb_fill_pwent.c b/source3/winbindd/wb_fill_pwent.c
365 index 878c5ad..9634317 100644
366 --- a/source3/winbindd/wb_fill_pwent.c
367 +++ b/source3/winbindd/wb_fill_pwent.c
368 @@ -77,7 +77,7 @@ static void wb_fill_pwent_sid2uid_done(struct tevent_req *subreq)
369 return;
370 }
371
372 - subreq = wb_getgrsid_send(state, state->ev, &state->info->group_sid, 1);
373 + subreq = wb_getgrsid_send(state, state->ev, &state->info->group_sid, 0);
374 if (tevent_req_nomem(subreq, req)) {
375 return;
376 }