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
7 s3-lib: Add grpname to talloc_sub_specified().
9 BUG: https://bugzilla.samba.org/show_bug.cgi?id=2191
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(-)
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,
28 + const char *grpname,
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,
40 + const char *grpname,
44 @@ -757,9 +758,18 @@ char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
48 - a_string = talloc_string_sub(
49 - tmp_ctx, a_string, "%G",
53 + if (grpname != NULL) {
56 + name = gidtoname(gid);
59 + a_string = talloc_string_sub(tmp_ctx,
64 a_string = talloc_string_sub(
66 @@ -768,9 +778,18 @@ char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
70 - a_string = talloc_string_sub(
71 - tmp_ctx, a_string, "%g",
75 + if (grpname != NULL) {
78 + name = gidtoname(gid);
81 + a_string = talloc_string_sub(tmp_ctx,
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 */
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),
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),
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),
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),
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,
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",
126 + ldap_state->domain_name,
129 shell = talloc_strdup(tmp_ctx, "/bin/false");
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(),
137 + ldap_state->domain_name,
140 + shell = talloc_sub_specified(tmp_ctx,
141 + lp_template_shell(),
144 + ldap_state->domain_name,
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,
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);
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(),
172 get_global_sam_name(),
174 shell = talloc_sub_specified(tc, lp_template_shell(),
177 get_global_sam_name(),
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,
186 if ((in != NULL) && (in[0] != '\0') && (lp_security() == SEC_ADS)) {
187 templ = talloc_sub_specified(talloc_tos(), in,
189 + username, NULL, domname,
192 templ = talloc_sub_specified(talloc_tos(), lp_template,
194 + username, NULL, domname,
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
204 s3-winbind: Pass the group name to fillup_pw_field().
206 BUG: https://bugzilla.samba.org/show_bug.cgi?id=2191
208 source3/winbindd/wb_fill_pwent.c | 58 +++++++++++++++++++++++++++++-----------
209 1 file changed, 42 insertions(+), 16 deletions(-)
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 {
217 static bool fillup_pw_field(const char *lp_template,
218 const char *username,
219 + const char *grpname,
223 @@ -36,7 +37,7 @@ static bool fillup_pw_field(const char *lp_template,
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);
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)
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)) {
241 - tevent_req_set_callback(subreq, wb_fill_pwent_sid2gid_done, req);
242 + tevent_req_set_callback(subreq, wb_fill_pwent_getgrsid_done, req);
245 -static void wb_fill_pwent_sid2gid_done(struct tevent_req *subreq)
246 +static void wb_fill_pwent_getgrsid_done(struct tevent_req *subreq)
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;
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();
262 - status = wb_sid2gid_recv(subreq, &state->pw->pw_gid);
265 + status = wb_getgrsid_recv(subreq,
269 + &state->pw->pw_gid,
272 if (tevent_req_nterror(req, status)) {
273 + talloc_free(tmp_ctx);
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);
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);
286 /* Home directory and shell */
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(),
297 + state->info->homedir,
298 + state->pw->pw_dir);
300 + talloc_free(tmp_ctx);
301 tevent_req_nterror(req, NT_STATUS_NO_SUCH_USER);
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(),
314 + state->info->shell,
315 + state->pw->pw_shell);
316 + talloc_free(tmp_ctx);
318 tevent_req_nterror(req, NT_STATUS_NO_SUCH_USER);
321 @@ -162,6 +187,7 @@ NTSTATUS wb_fill_pwent_recv(struct tevent_req *req)
323 static bool fillup_pw_field(const char *lp_template,
324 const char *username,
325 + const char *grpname,
329 @@ -181,11 +207,11 @@ static bool fillup_pw_field(const char *lp_template,
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,
337 templ = talloc_sub_specified(talloc_tos(), lp_template,
338 - username, NULL, domname,
339 + username, grpname, domname,
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
349 s3-winbind: Improve performance of wb_fill_pwent_sid2uid_done().
351 BUG: https://bugzilla.samba.org/show_bug.cgi?id=2191
353 Signed-off-by: Volker Lendecke <vl@samba.org>
354 Reviewed-by: Andreas Schneider <asn@samba.org>
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
359 (cherry picked from commit 1a43778433934530d77791edd1af538de8b1d8a3)
361 source3/winbindd/wb_fill_pwent.c | 2 +-
362 1 file changed, 1 insertion(+), 1 deletion(-)
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)
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)) {