1 |
jpp |
1.1 |
From 0eb6274aacc95601cb9a94922a8176935f336f92 Mon Sep 17 00:00:00 2001 |
2 |
|
|
From: Andreas Schneider <asn@samba.org> |
3 |
|
|
Date: Tue, 20 Jun 2017 10:27:07 +0200 |
4 |
|
|
Subject: [PATCH] s3:winbind: Fix 'winbind normalize names' in wb_getpwsid() |
5 |
|
|
|
6 |
|
|
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12851 |
7 |
|
|
|
8 |
|
|
Signed-off-by: Andreas Schneider <asn@samba.org> |
9 |
|
|
Reviewed-by: Volker Lendecke <vl@samba.org> |
10 |
|
|
--- |
11 |
|
|
source3/winbindd/wb_getpwsid.c | 34 +++++++++++++++++++++++++++++++--- |
12 |
|
|
1 file changed, 31 insertions(+), 3 deletions(-) |
13 |
|
|
|
14 |
|
|
diff --git a/source3/winbindd/wb_getpwsid.c b/source3/winbindd/wb_getpwsid.c |
15 |
|
|
index 8c764f77b08..b0bf6784ba6 100644 |
16 |
|
|
--- a/source3/winbindd/wb_getpwsid.c |
17 |
|
|
+++ b/source3/winbindd/wb_getpwsid.c |
18 |
|
|
@@ -63,7 +63,9 @@ static void wb_getpwsid_queryuser_done(struct tevent_req *subreq) |
19 |
|
|
req, struct wb_getpwsid_state); |
20 |
|
|
struct winbindd_pw *pw = state->pw; |
21 |
|
|
struct wbint_userinfo *info; |
22 |
|
|
+ struct winbindd_domain *domain = NULL; |
23 |
|
|
fstring acct_name, output_username; |
24 |
|
|
+ char *mapped_name = NULL; |
25 |
|
|
char *tmp; |
26 |
|
|
NTSTATUS status; |
27 |
|
|
|
28 |
|
|
@@ -83,8 +85,34 @@ static void wb_getpwsid_queryuser_done(struct tevent_req *subreq) |
29 |
|
|
return; |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
- fill_domain_username(output_username, info->domain_name, |
33 |
|
|
- acct_name, true); |
34 |
|
|
+ domain = find_domain_from_name_noinit(info->domain_name); |
35 |
|
|
+ if (tevent_req_nomem(domain, req)) { |
36 |
|
|
+ return; |
37 |
|
|
+ } |
38 |
|
|
+ |
39 |
|
|
+ /* |
40 |
|
|
+ * TODO: |
41 |
|
|
+ * This function should be called in 'idmap winbind child'. It shouldn't |
42 |
|
|
+ * be a blocking call, but for this we need to add a new function for |
43 |
|
|
+ * winbind.idl. This is a fix which can be backported for now. |
44 |
|
|
+ */ |
45 |
|
|
+ status = normalize_name_map(state, |
46 |
|
|
+ domain, |
47 |
|
|
+ acct_name, |
48 |
|
|
+ &mapped_name); |
49 |
|
|
+ if (NT_STATUS_IS_OK(status)) { |
50 |
|
|
+ fill_domain_username(output_username, |
51 |
|
|
+ info->domain_name, |
52 |
|
|
+ mapped_name, true); |
53 |
|
|
+ fstrcpy(acct_name, mapped_name); |
54 |
|
|
+ } else if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_RENAMED)) { |
55 |
|
|
+ fstrcpy(acct_name, mapped_name); |
56 |
|
|
+ } else { |
57 |
|
|
+ fill_domain_username(output_username, |
58 |
|
|
+ info->domain_name, |
59 |
|
|
+ acct_name, true); |
60 |
|
|
+ } |
61 |
|
|
+ |
62 |
|
|
strlcpy(pw->pw_name, output_username, sizeof(pw->pw_name)); |
63 |
|
|
|
64 |
|
|
strlcpy(pw->pw_gecos, info->full_name ? info->full_name : "", |
65 |
|
|
@@ -101,7 +129,7 @@ static void wb_getpwsid_queryuser_done(struct tevent_req *subreq) |
66 |
|
|
TALLOC_FREE(tmp); |
67 |
|
|
|
68 |
|
|
tmp = talloc_sub_specified( |
69 |
|
|
- state, info->shell, info->acct_name, |
70 |
|
|
+ state, info->shell, acct_name, |
71 |
|
|
info->primary_group_name, info->domain_name, |
72 |
|
|
pw->pw_uid, pw->pw_gid); |
73 |
|
|
if (tevent_req_nomem(tmp, req)) { |
74 |
|
|
-- |
75 |
|
|
2.13.1 |
76 |
|
|
|