summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-connectivity/samba/samba-4.1.12/01-fix-force-user-sec-ads.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-oe/recipes-connectivity/samba/samba-4.1.12/01-fix-force-user-sec-ads.patch')
-rw-r--r--meta-oe/recipes-connectivity/samba/samba-4.1.12/01-fix-force-user-sec-ads.patch1448
1 files changed, 1448 insertions, 0 deletions
diff --git a/meta-oe/recipes-connectivity/samba/samba-4.1.12/01-fix-force-user-sec-ads.patch b/meta-oe/recipes-connectivity/samba/samba-4.1.12/01-fix-force-user-sec-ads.patch
new file mode 100644
index 000000000..6c08cccc6
--- /dev/null
+++ b/meta-oe/recipes-connectivity/samba/samba-4.1.12/01-fix-force-user-sec-ads.patch
@@ -0,0 +1,1448 @@
1From 80f3551d4f594438dcc93dd82a7953c4a913badd Mon Sep 17 00:00:00 2001
2From: Andreas Schneider <asn@samba.org>
3Date: Mon, 16 Dec 2013 12:57:20 +0100
4Subject: [PATCH 1/7] s3-lib: Add winbind_lookup_usersids().
5
6Pair-Programmed-With: Guenther Deschner <gd@samba.org>
7Signed-off-by: Guenther Deschner <gd@samba.org>
8Signed-off-by: Andreas Schneider <asn@samba.org>
9Reviewed-by: Andrew Bartlett <abartlet@samba.org>
10
11(cherry picked from commit 241e98d8ee099f9cc5feb835085b4abd2b1ee663)
12---
13 source3/lib/winbind_util.c | 34 +++++
14 source3/lib/winbind_util.h | 4 +
15 source3/passdb/ABI/pdb-0.1.0.sigs | 311 ++++++++++++++++++++++++++++++++++++++
16 source3/wscript_build | 2 +-
17 4 files changed, 350 insertions(+), 1 deletion(-)
18 create mode 100644 source3/passdb/ABI/pdb-0.1.0.sigs
19
20diff --git a/source3/lib/winbind_util.c b/source3/lib/winbind_util.c
21index b458ebe..f62682b 100644
22--- a/source3/lib/winbind_util.c
23+++ b/source3/lib/winbind_util.c
24@@ -342,6 +342,40 @@ bool winbind_get_sid_aliases(TALLOC_CTX *mem_ctx,
25 return true;
26 }
27
28+bool winbind_lookup_usersids(TALLOC_CTX *mem_ctx,
29+ const struct dom_sid *user_sid,
30+ uint32_t *p_num_sids,
31+ struct dom_sid **p_sids)
32+{
33+ wbcErr ret;
34+ struct wbcDomainSid dom_sid;
35+ struct wbcDomainSid *sid_list = NULL;
36+ uint32_t num_sids;
37+
38+ memcpy(&dom_sid, user_sid, sizeof(dom_sid));
39+
40+ ret = wbcLookupUserSids(&dom_sid,
41+ false,
42+ &num_sids,
43+ &sid_list);
44+ if (ret != WBC_ERR_SUCCESS) {
45+ return false;
46+ }
47+
48+ *p_sids = talloc_array(mem_ctx, struct dom_sid, num_sids);
49+ if (*p_sids == NULL) {
50+ wbcFreeMemory(sid_list);
51+ return false;
52+ }
53+
54+ memcpy(*p_sids, sid_list, sizeof(dom_sid) * num_sids);
55+
56+ *p_num_sids = num_sids;
57+ wbcFreeMemory(sid_list);
58+
59+ return true;
60+}
61+
62 #else /* WITH_WINBIND */
63
64 struct passwd * winbind_getpwnam(const char * name)
65diff --git a/source3/lib/winbind_util.h b/source3/lib/winbind_util.h
66index 541bb95..abbc5a9 100644
67--- a/source3/lib/winbind_util.h
68+++ b/source3/lib/winbind_util.h
69@@ -58,5 +58,9 @@ bool winbind_get_sid_aliases(TALLOC_CTX *mem_ctx,
70 size_t num_members,
71 uint32_t **pp_alias_rids,
72 size_t *p_num_alias_rids);
73+bool winbind_lookup_usersids(TALLOC_CTX *mem_ctx,
74+ const struct dom_sid *user_sid,
75+ uint32_t *p_num_sids,
76+ struct dom_sid **p_sids);
77
78 #endif /* __LIB__WINBIND_UTIL_H__ */
79diff --git a/source3/passdb/ABI/pdb-0.1.0.sigs b/source3/passdb/ABI/pdb-0.1.0.sigs
80new file mode 100644
81index 0000000..f4de9c4
82--- /dev/null
83+++ b/source3/passdb/ABI/pdb-0.1.0.sigs
84@@ -0,0 +1,311 @@
85+PDB_secrets_clear_domain_protection: bool (const char *)
86+PDB_secrets_fetch_domain_guid: bool (const char *, struct GUID *)
87+PDB_secrets_fetch_domain_sid: bool (const char *, struct dom_sid *)
88+PDB_secrets_mark_domain_protected: bool (const char *)
89+PDB_secrets_store_domain_guid: bool (const char *, struct GUID *)
90+PDB_secrets_store_domain_sid: bool (const char *, const struct dom_sid *)
91+account_policy_get: bool (enum pdb_policy_type, uint32_t *)
92+account_policy_get_default: bool (enum pdb_policy_type, uint32_t *)
93+account_policy_get_desc: const char *(enum pdb_policy_type)
94+account_policy_name_to_typenum: enum pdb_policy_type (const char *)
95+account_policy_names_list: void (TALLOC_CTX *, const char ***, int *)
96+account_policy_set: bool (enum pdb_policy_type, uint32_t)
97+add_initial_entry: NTSTATUS (gid_t, const char *, enum lsa_SidType, const char *, const char *)
98+algorithmic_pdb_gid_to_group_rid: uint32_t (gid_t)
99+algorithmic_pdb_rid_is_user: bool (uint32_t)
100+algorithmic_pdb_uid_to_user_rid: uint32_t (uid_t)
101+algorithmic_pdb_user_rid_to_uid: uid_t (uint32_t)
102+algorithmic_rid_base: int (void)
103+builtin_domain_name: const char *(void)
104+cache_account_policy_get: bool (enum pdb_policy_type, uint32_t *)
105+cache_account_policy_set: bool (enum pdb_policy_type, uint32_t)
106+create_builtin_administrators: NTSTATUS (const struct dom_sid *)
107+create_builtin_users: NTSTATUS (const struct dom_sid *)
108+decode_account_policy_name: const char *(enum pdb_policy_type)
109+get_account_pol_db: struct db_context *(void)
110+get_account_policy_attr: const char *(enum pdb_policy_type)
111+get_domain_group_from_sid: bool (struct dom_sid, GROUP_MAP *)
112+get_primary_group_sid: NTSTATUS (TALLOC_CTX *, const char *, struct passwd **, struct dom_sid **)
113+get_privileges_for_sid_as_set: NTSTATUS (TALLOC_CTX *, PRIVILEGE_SET **, struct dom_sid *)
114+get_privileges_for_sids: bool (uint64_t *, struct dom_sid *, int)
115+get_trust_pw_clear: bool (const char *, char **, const char **, enum netr_SchannelType *)
116+get_trust_pw_hash: bool (const char *, uint8_t *, const char **, enum netr_SchannelType *)
117+gid_to_sid: void (struct dom_sid *, gid_t)
118+gid_to_unix_groups_sid: void (gid_t, struct dom_sid *)
119+grab_named_mutex: struct named_mutex *(TALLOC_CTX *, const char *, int)
120+grant_all_privileges: bool (const struct dom_sid *)
121+grant_privilege_by_name: bool (const struct dom_sid *, const char *)
122+grant_privilege_set: bool (const struct dom_sid *, struct lsa_PrivilegeSet *)
123+groupdb_tdb_init: const struct mapping_backend *(void)
124+init_account_policy: bool (void)
125+init_buffer_from_samu: uint32_t (uint8_t **, struct samu *, bool)
126+init_samu_from_buffer: bool (struct samu *, uint32_t, uint8_t *, uint32_t)
127+initialize_password_db: bool (bool, struct tevent_context *)
128+is_dc_trusted_domain_situation: bool (const char *)
129+is_privileged_sid: bool (const struct dom_sid *)
130+local_password_change: NTSTATUS (const char *, int, const char *, char **, char **)
131+login_cache_delentry: bool (const struct samu *)
132+login_cache_init: bool (void)
133+login_cache_read: bool (struct samu *, struct login_cache *)
134+login_cache_shutdown: bool (void)
135+login_cache_write: bool (const struct samu *, const struct login_cache *)
136+lookup_builtin_name: bool (const char *, uint32_t *)
137+lookup_builtin_rid: bool (TALLOC_CTX *, uint32_t, const char **)
138+lookup_global_sam_name: bool (const char *, int, uint32_t *, enum lsa_SidType *)
139+lookup_name: bool (TALLOC_CTX *, const char *, int, const char **, const char **, struct dom_sid *, enum lsa_SidType *)
140+lookup_name_smbconf: bool (TALLOC_CTX *, const char *, int, const char **, const char **, struct dom_sid *, enum lsa_SidType *)
141+lookup_sid: bool (TALLOC_CTX *, const struct dom_sid *, const char **, const char **, enum lsa_SidType *)
142+lookup_sids: NTSTATUS (TALLOC_CTX *, int, const struct dom_sid **, int, struct lsa_dom_info **, struct lsa_name_info **)
143+lookup_unix_group_name: bool (const char *, struct dom_sid *)
144+lookup_unix_user_name: bool (const char *, struct dom_sid *)
145+lookup_wellknown_name: bool (TALLOC_CTX *, const char *, struct dom_sid *, const char **)
146+lookup_wellknown_sid: bool (TALLOC_CTX *, const struct dom_sid *, const char **, const char **)
147+make_pdb_method: NTSTATUS (struct pdb_methods **)
148+make_pdb_method_name: NTSTATUS (struct pdb_methods **, const char *)
149+max_algorithmic_gid: gid_t (void)
150+max_algorithmic_uid: uid_t (void)
151+my_sam_name: const char *(void)
152+pdb_add_aliasmem: NTSTATUS (const struct dom_sid *, const struct dom_sid *)
153+pdb_add_group_mapping_entry: NTSTATUS (GROUP_MAP *)
154+pdb_add_groupmem: NTSTATUS (TALLOC_CTX *, uint32_t, uint32_t)
155+pdb_add_sam_account: NTSTATUS (struct samu *)
156+pdb_build_fields_present: uint32_t (struct samu *)
157+pdb_capabilities: uint32_t (void)
158+pdb_copy_sam_account: bool (struct samu *, struct samu *)
159+pdb_create_alias: NTSTATUS (const char *, uint32_t *)
160+pdb_create_builtin: NTSTATUS (uint32_t)
161+pdb_create_builtin_alias: NTSTATUS (uint32_t, gid_t)
162+pdb_create_dom_group: NTSTATUS (TALLOC_CTX *, const char *, uint32_t *)
163+pdb_create_user: NTSTATUS (TALLOC_CTX *, const char *, uint32_t, uint32_t *)
164+pdb_decode_acct_ctrl: uint32_t (const char *)
165+pdb_default_add_aliasmem: NTSTATUS (struct pdb_methods *, const struct dom_sid *, const struct dom_sid *)
166+pdb_default_add_group_mapping_entry: NTSTATUS (struct pdb_methods *, GROUP_MAP *)
167+pdb_default_alias_memberships: NTSTATUS (struct pdb_methods *, TALLOC_CTX *, const struct dom_sid *, const struct dom_sid *, size_t, uint32_t **, size_t *)
168+pdb_default_create_alias: NTSTATUS (struct pdb_methods *, const char *, uint32_t *)
169+pdb_default_del_aliasmem: NTSTATUS (struct pdb_methods *, const struct dom_sid *, const struct dom_sid *)
170+pdb_default_delete_alias: NTSTATUS (struct pdb_methods *, const struct dom_sid *)
171+pdb_default_delete_group_mapping_entry: NTSTATUS (struct pdb_methods *, struct dom_sid)
172+pdb_default_enum_aliasmem: NTSTATUS (struct pdb_methods *, const struct dom_sid *, TALLOC_CTX *, struct dom_sid **, size_t *)
173+pdb_default_enum_group_mapping: NTSTATUS (struct pdb_methods *, const struct dom_sid *, enum lsa_SidType, GROUP_MAP ***, size_t *, bool)
174+pdb_default_get_aliasinfo: NTSTATUS (struct pdb_methods *, const struct dom_sid *, struct acct_info *)
175+pdb_default_getgrgid: NTSTATUS (struct pdb_methods *, GROUP_MAP *, gid_t)
176+pdb_default_getgrnam: NTSTATUS (struct pdb_methods *, GROUP_MAP *, const char *)
177+pdb_default_getgrsid: NTSTATUS (struct pdb_methods *, GROUP_MAP *, struct dom_sid)
178+pdb_default_set_aliasinfo: NTSTATUS (struct pdb_methods *, const struct dom_sid *, struct acct_info *)
179+pdb_default_update_group_mapping_entry: NTSTATUS (struct pdb_methods *, GROUP_MAP *)
180+pdb_del_aliasmem: NTSTATUS (const struct dom_sid *, const struct dom_sid *)
181+pdb_del_groupmem: NTSTATUS (TALLOC_CTX *, uint32_t, uint32_t)
182+pdb_del_trusted_domain: NTSTATUS (const char *)
183+pdb_del_trusteddom_pw: bool (const char *)
184+pdb_delete_alias: NTSTATUS (const struct dom_sid *)
185+pdb_delete_dom_group: NTSTATUS (TALLOC_CTX *, uint32_t)
186+pdb_delete_group_mapping_entry: NTSTATUS (struct dom_sid)
187+pdb_delete_sam_account: NTSTATUS (struct samu *)
188+pdb_delete_secret: NTSTATUS (const char *)
189+pdb_delete_user: NTSTATUS (TALLOC_CTX *, struct samu *)
190+pdb_element_is_changed: bool (const struct samu *, enum pdb_elements)
191+pdb_element_is_set_or_changed: bool (const struct samu *, enum pdb_elements)
192+pdb_encode_acct_ctrl: char *(uint32_t, size_t)
193+pdb_enum_alias_memberships: NTSTATUS (TALLOC_CTX *, const struct dom_sid *, const struct dom_sid *, size_t, uint32_t **, size_t *)
194+pdb_enum_aliasmem: NTSTATUS (const struct dom_sid *, TALLOC_CTX *, struct dom_sid **, size_t *)
195+pdb_enum_group_mapping: bool (const struct dom_sid *, enum lsa_SidType, GROUP_MAP ***, size_t *, bool)
196+pdb_enum_group_members: NTSTATUS (TALLOC_CTX *, const struct dom_sid *, uint32_t **, size_t *)
197+pdb_enum_group_memberships: NTSTATUS (TALLOC_CTX *, struct samu *, struct dom_sid **, gid_t **, uint32_t *)
198+pdb_enum_trusted_domains: NTSTATUS (TALLOC_CTX *, uint32_t *, struct pdb_trusted_domain ***)
199+pdb_enum_trusteddoms: NTSTATUS (TALLOC_CTX *, uint32_t *, struct trustdom_info ***)
200+pdb_enum_upn_suffixes: NTSTATUS (TALLOC_CTX *, uint32_t *, char ***)
201+pdb_find_backend_entry: struct pdb_init_function_entry *(const char *)
202+pdb_get_account_policy: bool (enum pdb_policy_type, uint32_t *)
203+pdb_get_acct_ctrl: uint32_t (const struct samu *)
204+pdb_get_acct_desc: const char *(const struct samu *)
205+pdb_get_aliasinfo: NTSTATUS (const struct dom_sid *, struct acct_info *)
206+pdb_get_backend_private_data: void *(const struct samu *, const struct pdb_methods *)
207+pdb_get_backends: const struct pdb_init_function_entry *(void)
208+pdb_get_bad_password_count: uint16_t (const struct samu *)
209+pdb_get_bad_password_time: time_t (const struct samu *)
210+pdb_get_code_page: uint16_t (const struct samu *)
211+pdb_get_comment: const char *(const struct samu *)
212+pdb_get_country_code: uint16_t (const struct samu *)
213+pdb_get_dir_drive: const char *(const struct samu *)
214+pdb_get_domain: const char *(const struct samu *)
215+pdb_get_domain_info: struct pdb_domain_info *(TALLOC_CTX *)
216+pdb_get_fullname: const char *(const struct samu *)
217+pdb_get_group_rid: uint32_t (struct samu *)
218+pdb_get_group_sid: const struct dom_sid *(struct samu *)
219+pdb_get_homedir: const char *(const struct samu *)
220+pdb_get_hours: const uint8_t *(const struct samu *)
221+pdb_get_hours_len: uint32_t (const struct samu *)
222+pdb_get_init_flags: enum pdb_value_state (const struct samu *, enum pdb_elements)
223+pdb_get_kickoff_time: time_t (const struct samu *)
224+pdb_get_lanman_passwd: const uint8_t *(const struct samu *)
225+pdb_get_logoff_time: time_t (const struct samu *)
226+pdb_get_logon_count: uint16_t (const struct samu *)
227+pdb_get_logon_divs: uint16_t (const struct samu *)
228+pdb_get_logon_script: const char *(const struct samu *)
229+pdb_get_logon_time: time_t (const struct samu *)
230+pdb_get_munged_dial: const char *(const struct samu *)
231+pdb_get_nt_passwd: const uint8_t *(const struct samu *)
232+pdb_get_nt_username: const char *(const struct samu *)
233+pdb_get_pass_can_change: bool (const struct samu *)
234+pdb_get_pass_can_change_time: time_t (const struct samu *)
235+pdb_get_pass_can_change_time_noncalc: time_t (const struct samu *)
236+pdb_get_pass_last_set_time: time_t (const struct samu *)
237+pdb_get_pass_must_change_time: time_t (const struct samu *)
238+pdb_get_plaintext_passwd: const char *(const struct samu *)
239+pdb_get_profile_path: const char *(const struct samu *)
240+pdb_get_pw_history: const uint8_t *(const struct samu *, uint32_t *)
241+pdb_get_secret: NTSTATUS (TALLOC_CTX *, const char *, DATA_BLOB *, NTTIME *, DATA_BLOB *, NTTIME *, struct security_descriptor **)
242+pdb_get_seq_num: bool (time_t *)
243+pdb_get_tevent_context: struct tevent_context *(void)
244+pdb_get_trusted_domain: NTSTATUS (TALLOC_CTX *, const char *, struct pdb_trusted_domain **)
245+pdb_get_trusted_domain_by_sid: NTSTATUS (TALLOC_CTX *, struct dom_sid *, struct pdb_trusted_domain **)
246+pdb_get_trusteddom_pw: bool (const char *, char **, struct dom_sid *, time_t *)
247+pdb_get_unknown_6: uint32_t (const struct samu *)
248+pdb_get_user_rid: uint32_t (const struct samu *)
249+pdb_get_user_sid: const struct dom_sid *(const struct samu *)
250+pdb_get_username: const char *(const struct samu *)
251+pdb_get_workstations: const char *(const struct samu *)
252+pdb_getgrgid: bool (GROUP_MAP *, gid_t)
253+pdb_getgrnam: bool (GROUP_MAP *, const char *)
254+pdb_getgrsid: bool (GROUP_MAP *, struct dom_sid)
255+pdb_gethexhours: bool (const char *, unsigned char *)
256+pdb_gethexpwd: bool (const char *, unsigned char *)
257+pdb_getsampwnam: bool (struct samu *, const char *)
258+pdb_getsampwsid: bool (struct samu *, const struct dom_sid *)
259+pdb_gid_to_sid: bool (gid_t, struct dom_sid *)
260+pdb_group_rid_to_gid: gid_t (uint32_t)
261+pdb_increment_bad_password_count: bool (struct samu *)
262+pdb_is_password_change_time_max: bool (time_t)
263+pdb_is_responsible_for_builtin: bool (void)
264+pdb_is_responsible_for_our_sam: bool (void)
265+pdb_is_responsible_for_unix_groups: bool (void)
266+pdb_is_responsible_for_unix_users: bool (void)
267+pdb_is_responsible_for_wellknown: bool (void)
268+pdb_lookup_rids: NTSTATUS (const struct dom_sid *, int, uint32_t *, const char **, enum lsa_SidType *)
269+pdb_new_rid: bool (uint32_t *)
270+pdb_nop_add_group_mapping_entry: NTSTATUS (struct pdb_methods *, GROUP_MAP *)
271+pdb_nop_delete_group_mapping_entry: NTSTATUS (struct pdb_methods *, struct dom_sid)
272+pdb_nop_enum_group_mapping: NTSTATUS (struct pdb_methods *, enum lsa_SidType, GROUP_MAP **, size_t *, bool)
273+pdb_nop_getgrgid: NTSTATUS (struct pdb_methods *, GROUP_MAP *, gid_t)
274+pdb_nop_getgrnam: NTSTATUS (struct pdb_methods *, GROUP_MAP *, const char *)
275+pdb_nop_getgrsid: NTSTATUS (struct pdb_methods *, GROUP_MAP *, struct dom_sid)
276+pdb_nop_update_group_mapping_entry: NTSTATUS (struct pdb_methods *, GROUP_MAP *)
277+pdb_rename_sam_account: NTSTATUS (struct samu *, const char *)
278+pdb_search_aliases: struct pdb_search *(TALLOC_CTX *, const struct dom_sid *)
279+pdb_search_entries: uint32_t (struct pdb_search *, uint32_t, uint32_t, struct samr_displayentry **)
280+pdb_search_groups: struct pdb_search *(TALLOC_CTX *)
281+pdb_search_init: struct pdb_search *(TALLOC_CTX *, enum pdb_search_type)
282+pdb_search_users: struct pdb_search *(TALLOC_CTX *, uint32_t)
283+pdb_set_account_policy: bool (enum pdb_policy_type, uint32_t)
284+pdb_set_acct_ctrl: bool (struct samu *, uint32_t, enum pdb_value_state)
285+pdb_set_acct_desc: bool (struct samu *, const char *, enum pdb_value_state)
286+pdb_set_aliasinfo: NTSTATUS (const struct dom_sid *, struct acct_info *)
287+pdb_set_backend_private_data: bool (struct samu *, void *, void (*)(void **), const struct pdb_methods *, enum pdb_value_state)
288+pdb_set_bad_password_count: bool (struct samu *, uint16_t, enum pdb_value_state)
289+pdb_set_bad_password_time: bool (struct samu *, time_t, enum pdb_value_state)
290+pdb_set_code_page: bool (struct samu *, uint16_t, enum pdb_value_state)
291+pdb_set_comment: bool (struct samu *, const char *, enum pdb_value_state)
292+pdb_set_country_code: bool (struct samu *, uint16_t, enum pdb_value_state)
293+pdb_set_dir_drive: bool (struct samu *, const char *, enum pdb_value_state)
294+pdb_set_domain: bool (struct samu *, const char *, enum pdb_value_state)
295+pdb_set_fullname: bool (struct samu *, const char *, enum pdb_value_state)
296+pdb_set_group_sid: bool (struct samu *, const struct dom_sid *, enum pdb_value_state)
297+pdb_set_group_sid_from_rid: bool (struct samu *, uint32_t, enum pdb_value_state)
298+pdb_set_homedir: bool (struct samu *, const char *, enum pdb_value_state)
299+pdb_set_hours: bool (struct samu *, const uint8_t *, int, enum pdb_value_state)
300+pdb_set_hours_len: bool (struct samu *, uint32_t, enum pdb_value_state)
301+pdb_set_init_flags: bool (struct samu *, enum pdb_elements, enum pdb_value_state)
302+pdb_set_kickoff_time: bool (struct samu *, time_t, enum pdb_value_state)
303+pdb_set_lanman_passwd: bool (struct samu *, const uint8_t *, enum pdb_value_state)
304+pdb_set_logoff_time: bool (struct samu *, time_t, enum pdb_value_state)
305+pdb_set_logon_count: bool (struct samu *, uint16_t, enum pdb_value_state)
306+pdb_set_logon_divs: bool (struct samu *, uint16_t, enum pdb_value_state)
307+pdb_set_logon_script: bool (struct samu *, const char *, enum pdb_value_state)
308+pdb_set_logon_time: bool (struct samu *, time_t, enum pdb_value_state)
309+pdb_set_munged_dial: bool (struct samu *, const char *, enum pdb_value_state)
310+pdb_set_nt_passwd: bool (struct samu *, const uint8_t *, enum pdb_value_state)
311+pdb_set_nt_username: bool (struct samu *, const char *, enum pdb_value_state)
312+pdb_set_pass_can_change: bool (struct samu *, bool)
313+pdb_set_pass_can_change_time: bool (struct samu *, time_t, enum pdb_value_state)
314+pdb_set_pass_last_set_time: bool (struct samu *, time_t, enum pdb_value_state)
315+pdb_set_plaintext_passwd: bool (struct samu *, const char *)
316+pdb_set_plaintext_pw_only: bool (struct samu *, const char *, enum pdb_value_state)
317+pdb_set_profile_path: bool (struct samu *, const char *, enum pdb_value_state)
318+pdb_set_pw_history: bool (struct samu *, const uint8_t *, uint32_t, enum pdb_value_state)
319+pdb_set_secret: NTSTATUS (const char *, DATA_BLOB *, DATA_BLOB *, struct security_descriptor *)
320+pdb_set_trusted_domain: NTSTATUS (const char *, const struct pdb_trusted_domain *)
321+pdb_set_trusteddom_pw: bool (const char *, const char *, const struct dom_sid *)
322+pdb_set_unix_primary_group: NTSTATUS (TALLOC_CTX *, struct samu *)
323+pdb_set_unknown_6: bool (struct samu *, uint32_t, enum pdb_value_state)
324+pdb_set_upn_suffixes: NTSTATUS (uint32_t, const char **)
325+pdb_set_user_sid: bool (struct samu *, const struct dom_sid *, enum pdb_value_state)
326+pdb_set_user_sid_from_rid: bool (struct samu *, uint32_t, enum pdb_value_state)
327+pdb_set_user_sid_from_string: bool (struct samu *, const char *, enum pdb_value_state)
328+pdb_set_username: bool (struct samu *, const char *, enum pdb_value_state)
329+pdb_set_workstations: bool (struct samu *, const char *, enum pdb_value_state)
330+pdb_sethexhours: void (char *, const unsigned char *)
331+pdb_sethexpwd: void (char *, const unsigned char *, uint32_t)
332+pdb_sid_to_id: bool (const struct dom_sid *, struct unixid *)
333+pdb_sid_to_id_unix_users_and_groups: bool (const struct dom_sid *, struct unixid *)
334+pdb_uid_to_sid: bool (uid_t, struct dom_sid *)
335+pdb_update_autolock_flag: bool (struct samu *, bool *)
336+pdb_update_bad_password_count: bool (struct samu *, bool *)
337+pdb_update_group_mapping_entry: NTSTATUS (GROUP_MAP *)
338+pdb_update_login_attempts: NTSTATUS (struct samu *, bool)
339+pdb_update_sam_account: NTSTATUS (struct samu *)
340+privilege_create_account: NTSTATUS (const struct dom_sid *)
341+privilege_delete_account: NTSTATUS (const struct dom_sid *)
342+privilege_enum_sids: NTSTATUS (enum sec_privilege, TALLOC_CTX *, struct dom_sid **, int *)
343+privilege_enumerate_accounts: NTSTATUS (struct dom_sid **, int *)
344+revoke_all_privileges: bool (const struct dom_sid *)
345+revoke_privilege_by_name: bool (const struct dom_sid *, const char *)
346+revoke_privilege_set: bool (const struct dom_sid *, struct lsa_PrivilegeSet *)
347+samu_alloc_rid_unix: NTSTATUS (struct pdb_methods *, struct samu *, const struct passwd *)
348+samu_new: struct samu *(TALLOC_CTX *)
349+samu_set_unix: NTSTATUS (struct samu *, const struct passwd *)
350+secrets_trusted_domains: NTSTATUS (TALLOC_CTX *, uint32_t *, struct trustdom_info ***)
351+sid_check_is_builtin: bool (const struct dom_sid *)
352+sid_check_is_for_passdb: bool (const struct dom_sid *)
353+sid_check_is_in_builtin: bool (const struct dom_sid *)
354+sid_check_is_in_unix_groups: bool (const struct dom_sid *)
355+sid_check_is_in_unix_users: bool (const struct dom_sid *)
356+sid_check_is_in_wellknown_domain: bool (const struct dom_sid *)
357+sid_check_is_unix_groups: bool (const struct dom_sid *)
358+sid_check_is_unix_users: bool (const struct dom_sid *)
359+sid_check_is_wellknown_builtin: bool (const struct dom_sid *)
360+sid_check_is_wellknown_domain: bool (const struct dom_sid *, const char **)
361+sid_check_object_is_for_passdb: bool (const struct dom_sid *)
362+sid_to_gid: bool (const struct dom_sid *, gid_t *)
363+sid_to_uid: bool (const struct dom_sid *, uid_t *)
364+sids_to_unixids: bool (const struct dom_sid *, uint32_t, struct unixid *)
365+smb_add_user_group: int (const char *, const char *)
366+smb_create_group: int (const char *, gid_t *)
367+smb_delete_group: int (const char *)
368+smb_delete_user_group: int (const char *, const char *)
369+smb_nscd_flush_group_cache: void (void)
370+smb_nscd_flush_user_cache: void (void)
371+smb_register_passdb: NTSTATUS (int, const char *, pdb_init_function)
372+smb_set_primary_group: int (const char *, const char *)
373+uid_to_sid: void (struct dom_sid *, uid_t)
374+uid_to_unix_users_sid: void (uid_t, struct dom_sid *)
375+unix_groups_domain_name: const char *(void)
376+unix_users_domain_name: const char *(void)
377+unixid_from_both: void (struct unixid *, uint32_t)
378+unixid_from_gid: void (struct unixid *, uint32_t)
379+unixid_from_uid: void (struct unixid *, uint32_t)
380+wb_is_trusted_domain: wbcErr (const char *)
381+winbind_allocate_gid: bool (gid_t *)
382+winbind_allocate_uid: bool (uid_t *)
383+winbind_get_groups: bool (TALLOC_CTX *, const char *, uint32_t *, gid_t **)
384+winbind_get_sid_aliases: bool (TALLOC_CTX *, const struct dom_sid *, const struct dom_sid *, size_t, uint32_t **, size_t *)
385+winbind_getpwnam: struct passwd *(const char *)
386+winbind_getpwsid: struct passwd *(const struct dom_sid *)
387+winbind_gid_to_sid: bool (struct dom_sid *, gid_t)
388+winbind_lookup_name: bool (const char *, const char *, struct dom_sid *, enum lsa_SidType *)
389+winbind_lookup_rids: bool (TALLOC_CTX *, const struct dom_sid *, int, uint32_t *, const char **, const char ***, enum lsa_SidType **)
390+winbind_lookup_sid: bool (TALLOC_CTX *, const struct dom_sid *, const char **, const char **, enum lsa_SidType *)
391+winbind_lookup_usersids: bool (TALLOC_CTX *, const struct dom_sid *, uint32_t *, struct dom_sid **)
392+winbind_ping: bool (void)
393+winbind_sid_to_gid: bool (gid_t *, const struct dom_sid *)
394+winbind_sid_to_uid: bool (uid_t *, const struct dom_sid *)
395+winbind_uid_to_sid: bool (struct dom_sid *, uid_t)
396diff --git a/source3/wscript_build b/source3/wscript_build
397index e0432bf..6d6b6aa 100755
398--- a/source3/wscript_build
399+++ b/source3/wscript_build
400@@ -736,7 +736,7 @@ bld.SAMBA3_LIBRARY('pdb',
401 passdb/lookup_sid.h''',
402 abi_match=private_pdb_match,
403 abi_directory='passdb/ABI',
404- vnum='0',
405+ vnum='0.1.0',
406 vars=locals())
407
408 bld.SAMBA3_LIBRARY('smbldaphelper',
409--
4101.8.5.2
411
412
413From 91debcafd196a9e821efddce0a9d75c48f8e168d Mon Sep 17 00:00:00 2001
414From: Andreas Schneider <asn@samba.org>
415Date: Fri, 13 Dec 2013 19:08:34 +0100
416Subject: [PATCH 2/7] s3-auth: Add passwd_to_SamInfo3().
417
418First this function tries to contacts winbind if the user is a domain
419user to get valid information about it. If winbind isn't running it will
420try to create everything from the passwd struct. This is not always
421reliable but works in most cases. It improves the current situation
422which doesn't talk to winbind at all.
423
424Pair-Programmed-With: Guenther Deschner <gd@samba.org>
425Signed-off-by: Guenther Deschner <gd@samba.org>
426Signed-off-by: Andreas Schneider <asn@samba.org>
427Reviewed-by: Andrew Bartlett <abartlet@samba.org>
428(cherry picked from commit 1bb11c7744df6928cb8a096373ab920366b38770)
429---
430 source3/auth/proto.h | 4 ++
431 source3/auth/server_info.c | 116 +++++++++++++++++++++++++++++++++++++++++++++
432 2 files changed, 120 insertions(+)
433
434diff --git a/source3/auth/proto.h b/source3/auth/proto.h
435index 76661fc..8385e66 100644
436--- a/source3/auth/proto.h
437+++ b/source3/auth/proto.h
438@@ -286,6 +286,10 @@ NTSTATUS samu_to_SamInfo3(TALLOC_CTX *mem_ctx,
439 const char *login_server,
440 struct netr_SamInfo3 **_info3,
441 struct extra_auth_info *extra);
442+NTSTATUS passwd_to_SamInfo3(TALLOC_CTX *mem_ctx,
443+ const char *unix_username,
444+ const struct passwd *pwd,
445+ struct netr_SamInfo3 **pinfo3);
446 struct netr_SamInfo3 *copy_netr_SamInfo3(TALLOC_CTX *mem_ctx,
447 struct netr_SamInfo3 *orig);
448 struct netr_SamInfo3 *wbcAuthUserInfo_to_netr_SamInfo3(TALLOC_CTX *mem_ctx,
449diff --git a/source3/auth/server_info.c b/source3/auth/server_info.c
450index d2b7d6e..46d8178 100644
451--- a/source3/auth/server_info.c
452+++ b/source3/auth/server_info.c
453@@ -24,6 +24,7 @@
454 #include "../libcli/security/security.h"
455 #include "rpc_client/util_netlogon.h"
456 #include "nsswitch/libwbclient/wbclient.h"
457+#include "lib/winbind_util.h"
458 #include "passdb.h"
459
460 #undef DBGC_CLASS
461@@ -436,6 +437,121 @@ NTSTATUS samu_to_SamInfo3(TALLOC_CTX *mem_ctx,
462 return NT_STATUS_OK;
463 }
464
465+NTSTATUS passwd_to_SamInfo3(TALLOC_CTX *mem_ctx,
466+ const char *unix_username,
467+ const struct passwd *pwd,
468+ struct netr_SamInfo3 **pinfo3)
469+{
470+ struct netr_SamInfo3 *info3;
471+ NTSTATUS status;
472+ TALLOC_CTX *tmp_ctx;
473+ const char *domain_name = NULL;
474+ const char *user_name = NULL;
475+ struct dom_sid domain_sid;
476+ struct dom_sid user_sid;
477+ struct dom_sid group_sid;
478+ enum lsa_SidType type;
479+ uint32_t num_sids = 0;
480+ struct dom_sid *user_sids = NULL;
481+ bool ok;
482+
483+ tmp_ctx = talloc_stackframe();
484+
485+ ok = lookup_name_smbconf(tmp_ctx,
486+ unix_username,
487+ LOOKUP_NAME_ALL,
488+ &domain_name,
489+ &user_name,
490+ &user_sid,
491+ &type);
492+ if (!ok) {
493+ status = NT_STATUS_NO_SUCH_USER;
494+ goto done;
495+ }
496+
497+ if (type != SID_NAME_USER) {
498+ status = NT_STATUS_NO_SUCH_USER;
499+ goto done;
500+ }
501+
502+ ok = winbind_lookup_usersids(tmp_ctx,
503+ &user_sid,
504+ &num_sids,
505+ &user_sids);
506+ /* Check if winbind is running */
507+ if (ok) {
508+ /*
509+ * Winbind is running and the first element of the user_sids
510+ * is the primary group.
511+ */
512+ if (num_sids > 0) {
513+ group_sid = user_sids[0];
514+ }
515+ } else {
516+ /*
517+ * Winbind is not running, create the group_sid from the
518+ * group id.
519+ */
520+ gid_to_sid(&group_sid, pwd->pw_gid);
521+ }
522+
523+ /* Make sure we have a valid group sid */
524+ ok = !is_null_sid(&group_sid);
525+ if (!ok) {
526+ status = NT_STATUS_NO_SUCH_USER;
527+ goto done;
528+ }
529+
530+ /* Construct a netr_SamInfo3 from the information we have */
531+ info3 = talloc_zero(tmp_ctx, struct netr_SamInfo3);
532+ if (!info3) {
533+ status = NT_STATUS_NO_MEMORY;
534+ goto done;
535+ }
536+
537+ info3->base.account_name.string = talloc_strdup(info3, unix_username);
538+ if (info3->base.account_name.string == NULL) {
539+ status = NT_STATUS_NO_MEMORY;
540+ goto done;
541+ }
542+
543+ ZERO_STRUCT(domain_sid);
544+
545+ sid_copy(&domain_sid, &user_sid);
546+ sid_split_rid(&domain_sid, &info3->base.rid);
547+ info3->base.domain_sid = dom_sid_dup(info3, &domain_sid);
548+
549+ ok = sid_peek_check_rid(&domain_sid, &group_sid,
550+ &info3->base.primary_gid);
551+ if (!ok) {
552+ DEBUG(1, ("The primary group domain sid(%s) does not "
553+ "match the domain sid(%s) for %s(%s)\n",
554+ sid_string_dbg(&group_sid),
555+ sid_string_dbg(&domain_sid),
556+ unix_username,
557+ sid_string_dbg(&user_sid)));
558+ status = NT_STATUS_INVALID_SID;
559+ goto done;
560+ }
561+
562+ info3->base.acct_flags = ACB_NORMAL;
563+
564+ if (num_sids) {
565+ status = group_sids_to_info3(info3, user_sids, num_sids);
566+ if (!NT_STATUS_IS_OK(status)) {
567+ goto done;
568+ }
569+ }
570+
571+ *pinfo3 = talloc_steal(mem_ctx, info3);
572+
573+ status = NT_STATUS_OK;
574+done:
575+ talloc_free(tmp_ctx);
576+
577+ return status;
578+}
579+
580 #undef RET_NOMEM
581
582 #define RET_NOMEM(ptr) do { \
583--
5841.8.5.2
585
586
587From c7b7670dc5cd8dbf727258666b6417d67afafb33 Mon Sep 17 00:00:00 2001
588From: Andreas Schneider <asn@samba.org>
589Date: Fri, 13 Dec 2013 19:11:01 +0100
590Subject: [PATCH 3/7] s3-auth: Pass talloc context to make_server_info_pw().
591
592Pair-Programmed-With: Guenther Deschner <gd@samba.org>
593Signed-off-by: Guenther Deschner <gd@samba.org>
594Signed-off-by: Andreas Schneider <asn@samba.org>
595Reviewed-by: Andrew Bartlett <abartlet@samba.org>
596(cherry picked from commit 1b59c9743cf3fbd66b0b8b52162b2cc8d922e5cf)
597---
598 source3/auth/auth_unix.c | 7 +++++--
599 source3/auth/auth_util.c | 52 +++++++++++++++++++++++++++++-------------------
600 source3/auth/proto.h | 7 ++++---
601 source3/auth/user_krb5.c | 5 +----
602 4 files changed, 42 insertions(+), 29 deletions(-)
603
604diff --git a/source3/auth/auth_unix.c b/source3/auth/auth_unix.c
605index c8b5435..7b483a2 100644
606--- a/source3/auth/auth_unix.c
607+++ b/source3/auth/auth_unix.c
608@@ -67,8 +67,11 @@ static NTSTATUS check_unix_security(const struct auth_context *auth_context,
609 unbecome_root();
610
611 if (NT_STATUS_IS_OK(nt_status)) {
612- if (pass) {
613- make_server_info_pw(server_info, pass->pw_name, pass);
614+ if (pass != NULL) {
615+ nt_status = make_server_info_pw(mem_ctx,
616+ pass->pw_name,
617+ pass,
618+ server_info);
619 } else {
620 /* we need to do somthing more useful here */
621 nt_status = NT_STATUS_NO_SUCH_USER;
622diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
623index ceaa706..b225b0d 100644
624--- a/source3/auth/auth_util.c
625+++ b/source3/auth/auth_util.c
626@@ -639,14 +639,15 @@ NTSTATUS create_local_token(TALLOC_CTX *mem_ctx,
627 to a struct samu
628 ***************************************************************************/
629
630-NTSTATUS make_server_info_pw(struct auth_serversupplied_info **server_info,
631- char *unix_username,
632- struct passwd *pwd)
633+NTSTATUS make_server_info_pw(TALLOC_CTX *mem_ctx,
634+ const char *unix_username,
635+ const struct passwd *pwd,
636+ struct auth_serversupplied_info **server_info)
637 {
638 NTSTATUS status;
639 struct samu *sampass = NULL;
640 char *qualified_name = NULL;
641- TALLOC_CTX *mem_ctx = NULL;
642+ TALLOC_CTX *tmp_ctx;
643 struct dom_sid u_sid;
644 enum lsa_SidType type;
645 struct auth_serversupplied_info *result;
646@@ -664,27 +665,27 @@ NTSTATUS make_server_info_pw(struct auth_serversupplied_info **server_info,
647 * plaintext passwords were used with no SAM backend.
648 */
649
650- mem_ctx = talloc_init("make_server_info_pw_tmp");
651- if (!mem_ctx) {
652+ tmp_ctx = talloc_stackframe();
653+ if (tmp_ctx == NULL) {
654 return NT_STATUS_NO_MEMORY;
655 }
656
657- qualified_name = talloc_asprintf(mem_ctx, "%s\\%s",
658+ qualified_name = talloc_asprintf(tmp_ctx, "%s\\%s",
659 unix_users_domain_name(),
660 unix_username );
661 if (!qualified_name) {
662- TALLOC_FREE(mem_ctx);
663+ TALLOC_FREE(tmp_ctx);
664 return NT_STATUS_NO_MEMORY;
665 }
666
667- if (!lookup_name(mem_ctx, qualified_name, LOOKUP_NAME_ALL,
668+ if (!lookup_name(tmp_ctx, qualified_name, LOOKUP_NAME_ALL,
669 NULL, NULL,
670 &u_sid, &type)) {
671- TALLOC_FREE(mem_ctx);
672+ TALLOC_FREE(tmp_ctx);
673 return NT_STATUS_NO_SUCH_USER;
674 }
675
676- TALLOC_FREE(mem_ctx);
677+ TALLOC_FREE(tmp_ctx);
678
679 if (type != SID_NAME_USER) {
680 return NT_STATUS_NO_SUCH_USER;
681@@ -707,7 +708,7 @@ NTSTATUS make_server_info_pw(struct auth_serversupplied_info **server_info,
682 /* set the user sid to be the calculated u_sid */
683 pdb_set_user_sid(sampass, &u_sid, PDB_SET);
684
685- result = make_server_info(NULL);
686+ result = make_server_info(mem_ctx);
687 if (result == NULL) {
688 TALLOC_FREE(sampass);
689 return NT_STATUS_NO_MEMORY;
690@@ -992,25 +993,36 @@ NTSTATUS make_session_info_from_username(TALLOC_CTX *mem_ctx,
691 struct passwd *pwd;
692 NTSTATUS status;
693 struct auth_serversupplied_info *result;
694+ TALLOC_CTX *tmp_ctx;
695
696- pwd = Get_Pwnam_alloc(talloc_tos(), username);
697- if (pwd == NULL) {
698- return NT_STATUS_NO_SUCH_USER;
699+ tmp_ctx = talloc_stackframe();
700+ if (tmp_ctx == NULL) {
701+ return NT_STATUS_NO_MEMORY;
702 }
703
704- status = make_server_info_pw(&result, pwd->pw_name, pwd);
705+ pwd = Get_Pwnam_alloc(tmp_ctx, username);
706+ if (pwd == NULL) {
707+ status = NT_STATUS_NO_SUCH_USER;
708+ goto done;
709+ }
710
711+ status = make_server_info_pw(tmp_ctx, pwd->pw_name, pwd, &result);
712 if (!NT_STATUS_IS_OK(status)) {
713- return status;
714+ goto done;
715 }
716
717 result->nss_token = true;
718 result->guest = is_guest;
719
720 /* Now turn the server_info into a session_info with the full token etc */
721- status = create_local_token(mem_ctx, result, NULL, pwd->pw_name, session_info);
722- TALLOC_FREE(result);
723- TALLOC_FREE(pwd);
724+ status = create_local_token(mem_ctx,
725+ result,
726+ NULL,
727+ pwd->pw_name,
728+ session_info);
729+
730+done:
731+ talloc_free(tmp_ctx);
732
733 return status;
734 }
735diff --git a/source3/auth/proto.h b/source3/auth/proto.h
736index 8385e66..7abca07 100644
737--- a/source3/auth/proto.h
738+++ b/source3/auth/proto.h
739@@ -206,9 +206,10 @@ bool user_in_group_sid(const char *username, const struct dom_sid *group_sid);
740 bool user_sid_in_group_sid(const struct dom_sid *sid, const struct dom_sid *group_sid);
741 bool user_in_group(const char *username, const char *groupname);
742 struct passwd;
743-NTSTATUS make_server_info_pw(struct auth_serversupplied_info **server_info,
744- char *unix_username,
745- struct passwd *pwd);
746+NTSTATUS make_server_info_pw(TALLOC_CTX *mem_ctx,
747+ const char *unix_username,
748+ const struct passwd *pwd,
749+ struct auth_serversupplied_info **server_info);
750 NTSTATUS make_session_info_from_username(TALLOC_CTX *mem_ctx,
751 const char *username,
752 bool is_guest,
753diff --git a/source3/auth/user_krb5.c b/source3/auth/user_krb5.c
754index 974a8aa..7d44285 100644
755--- a/source3/auth/user_krb5.c
756+++ b/source3/auth/user_krb5.c
757@@ -242,7 +242,7 @@ NTSTATUS make_session_info_krb5(TALLOC_CTX *mem_ctx,
758 */
759 DEBUG(10, ("didn't find user %s in passdb, calling "
760 "make_server_info_pw\n", username));
761- status = make_server_info_pw(&tmp, username, pw);
762+ status = make_server_info_pw(mem_ctx, username, pw, &tmp);
763 }
764
765 TALLOC_FREE(sampass);
766@@ -253,9 +253,6 @@ NTSTATUS make_session_info_krb5(TALLOC_CTX *mem_ctx,
767 return status;
768 }
769
770- /* Steal tmp server info into the server_info pointer. */
771- server_info = talloc_move(mem_ctx, &tmp);
772-
773 /* make_server_info_pw does not set the domain. Without this
774 * we end up with the local netbios name in substitutions for
775 * %D. */
776--
7771.8.5.2
778
779
780From 4fbd13598e8bdc6acf41329f71de806de4265f36 Mon Sep 17 00:00:00 2001
781From: Andreas Schneider <asn@samba.org>
782Date: Fri, 13 Dec 2013 19:19:02 +0100
783Subject: [PATCH 4/7] s3-auth: Add passwd_to_SamInfo3().
784
785Correctly lookup users which come from smb.conf. passwd_to_SamInfo3()
786tries to contact winbind if the user is a domain user to get
787valid information about it. If winbind isn't running it will try to
788create everything from the passwd struct. This is not always reliable
789but works in most cases. It improves the current situation which doesn't
790talk to winbind at all.
791
792BUG: https://bugzilla.samba.org/show_bug.cgi?id=8598
793
794Pair-Programmed-With: Guenther Deschner <gd@samba.org>
795Signed-off-by: Andreas Schneider <asn@samba.org>
796Reviewed-by: Andrew Bartlett <abartlet@samba.org>
797
798Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
799Autobuild-Date(master): Wed Feb 5 01:40:38 CET 2014 on sn-devel-104
800
801(cherry picked from commit 40e6456b5896e934fcd581c2cac2389984256e09)
802---
803 source3/auth/auth_util.c | 87 +++++++++-------------------------------------
804 source3/auth/server_info.c | 22 ++++++++++--
805 2 files changed, 36 insertions(+), 73 deletions(-)
806
807diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
808index b225b0d..24190af 100644
809--- a/source3/auth/auth_util.c
810+++ b/source3/auth/auth_util.c
811@@ -645,98 +645,43 @@ NTSTATUS make_server_info_pw(TALLOC_CTX *mem_ctx,
812 struct auth_serversupplied_info **server_info)
813 {
814 NTSTATUS status;
815- struct samu *sampass = NULL;
816- char *qualified_name = NULL;
817- TALLOC_CTX *tmp_ctx;
818- struct dom_sid u_sid;
819- enum lsa_SidType type;
820+ TALLOC_CTX *tmp_ctx = NULL;
821 struct auth_serversupplied_info *result;
822
823- /*
824- * The SID returned in server_info->sam_account is based
825- * on our SAM sid even though for a pure UNIX account this should
826- * not be the case as it doesn't really exist in the SAM db.
827- * This causes lookups on "[in]valid users" to fail as they
828- * will lookup this name as a "Unix User" SID to check against
829- * the user token. Fix this by adding the "Unix User"\unix_username
830- * SID to the sid array. The correct fix should probably be
831- * changing the server_info->sam_account user SID to be a
832- * S-1-22 Unix SID, but this might break old configs where
833- * plaintext passwords were used with no SAM backend.
834- */
835-
836 tmp_ctx = talloc_stackframe();
837 if (tmp_ctx == NULL) {
838 return NT_STATUS_NO_MEMORY;
839 }
840
841- qualified_name = talloc_asprintf(tmp_ctx, "%s\\%s",
842- unix_users_domain_name(),
843- unix_username );
844- if (!qualified_name) {
845- TALLOC_FREE(tmp_ctx);
846- return NT_STATUS_NO_MEMORY;
847- }
848-
849- if (!lookup_name(tmp_ctx, qualified_name, LOOKUP_NAME_ALL,
850- NULL, NULL,
851- &u_sid, &type)) {
852- TALLOC_FREE(tmp_ctx);
853- return NT_STATUS_NO_SUCH_USER;
854- }
855-
856- TALLOC_FREE(tmp_ctx);
857-
858- if (type != SID_NAME_USER) {
859- return NT_STATUS_NO_SUCH_USER;
860- }
861-
862- if ( !(sampass = samu_new( NULL )) ) {
863- return NT_STATUS_NO_MEMORY;
864- }
865-
866- status = samu_set_unix( sampass, pwd );
867- if (!NT_STATUS_IS_OK(status)) {
868- return status;
869- }
870-
871- /* In pathological cases the above call can set the account
872- * name to the DOMAIN\username form. Reset the account name
873- * using unix_username */
874- pdb_set_username(sampass, unix_username, PDB_SET);
875-
876- /* set the user sid to be the calculated u_sid */
877- pdb_set_user_sid(sampass, &u_sid, PDB_SET);
878-
879- result = make_server_info(mem_ctx);
880+ result = make_server_info(tmp_ctx);
881 if (result == NULL) {
882- TALLOC_FREE(sampass);
883- return NT_STATUS_NO_MEMORY;
884+ status = NT_STATUS_NO_MEMORY;
885+ goto done;
886 }
887
888- status = samu_to_SamInfo3(result, sampass, lp_netbios_name(),
889- &result->info3, &result->extra);
890- TALLOC_FREE(sampass);
891+ status = passwd_to_SamInfo3(result,
892+ unix_username,
893+ pwd,
894+ &result->info3);
895 if (!NT_STATUS_IS_OK(status)) {
896- DEBUG(10, ("Failed to convert samu to info3: %s\n",
897- nt_errstr(status)));
898- TALLOC_FREE(result);
899- return status;
900+ goto done;
901 }
902
903 result->unix_name = talloc_strdup(result, unix_username);
904-
905 if (result->unix_name == NULL) {
906- TALLOC_FREE(result);
907- return NT_STATUS_NO_MEMORY;
908+ status = NT_STATUS_NO_MEMORY;
909+ goto done;
910 }
911
912 result->utok.uid = pwd->pw_uid;
913 result->utok.gid = pwd->pw_gid;
914
915- *server_info = result;
916+ *server_info = talloc_steal(mem_ctx, result);
917+ status = NT_STATUS_OK;
918+done:
919+ talloc_free(tmp_ctx);
920
921- return NT_STATUS_OK;
922+ return status;
923 }
924
925 static NTSTATUS get_system_info3(TALLOC_CTX *mem_ctx,
926diff --git a/source3/auth/server_info.c b/source3/auth/server_info.c
927index 46d8178..43711d5 100644
928--- a/source3/auth/server_info.c
929+++ b/source3/auth/server_info.c
930@@ -489,10 +489,28 @@ NTSTATUS passwd_to_SamInfo3(TALLOC_CTX *mem_ctx,
931 }
932 } else {
933 /*
934- * Winbind is not running, create the group_sid from the
935- * group id.
936+ * Winbind is not running, try to create the group_sid from the
937+ * passwd group id.
938+ */
939+
940+ /*
941+ * This can lead to a primary group of S-1-22-2-XX which
942+ * will be rejected by other Samba code.
943 */
944 gid_to_sid(&group_sid, pwd->pw_gid);
945+
946+ ZERO_STRUCT(domain_sid);
947+
948+ /*
949+ * If we are a unix group, set the group_sid to the
950+ * 'Domain Users' RID of 513 which will always resolve to a
951+ * name.
952+ */
953+ if (sid_check_is_in_unix_groups(&group_sid)) {
954+ sid_compose(&group_sid,
955+ get_global_sam_sid(),
956+ DOMAIN_RID_USERS);
957+ }
958 }
959
960 /* Make sure we have a valid group sid */
961--
9621.8.5.2
963
964
965From 76bb5e0888f4131ab773d90160051a51c401c90d Mon Sep 17 00:00:00 2001
966From: Andreas Schneider <asn@samba.org>
967Date: Tue, 18 Feb 2014 10:02:57 +0100
968Subject: [PATCH 5/7] s3-auth: Pass mem_ctx to make_server_info_sam().
969
970Coverity-Id: 1168009
971BUG: https://bugzilla.samba.org/show_bug.cgi?id=8598
972
973Signed-off-by: Andreas Schneider <asn@samba.org>
974
975Change-Id: Ie614b0654c3a7eec1ebb10dbb9763696eec795bd
976Reviewed-by: Andrew Bartlett <abartlet@samba.org>
977(cherry picked from commit 3dc72266005e87a291f5bf9847257e8c54314d39)
978---
979 source3/auth/check_samsec.c | 2 +-
980 source3/auth/proto.h | 5 ++--
981 source3/auth/server_info_sam.c | 56 +++++++++++++++++++++++++++---------------
982 source3/auth/user_krb5.c | 12 +++++----
983 4 files changed, 47 insertions(+), 28 deletions(-)
984
985diff --git a/source3/auth/check_samsec.c b/source3/auth/check_samsec.c
986index 7ed8cc2..b6cac60 100644
987--- a/source3/auth/check_samsec.c
988+++ b/source3/auth/check_samsec.c
989@@ -482,7 +482,7 @@ NTSTATUS check_sam_security(const DATA_BLOB *challenge,
990 }
991
992 become_root();
993- nt_status = make_server_info_sam(server_info, sampass);
994+ nt_status = make_server_info_sam(mem_ctx, sampass, server_info);
995 unbecome_root();
996
997 TALLOC_FREE(sampass);
998diff --git a/source3/auth/proto.h b/source3/auth/proto.h
999index 7abca07..eac3e54 100644
1000--- a/source3/auth/proto.h
1001+++ b/source3/auth/proto.h
1002@@ -190,8 +190,9 @@ bool make_user_info_guest(const struct tsocket_address *remote_address,
1003 struct auth_usersupplied_info **user_info);
1004
1005 struct samu;
1006-NTSTATUS make_server_info_sam(struct auth_serversupplied_info **server_info,
1007- struct samu *sampass);
1008+NTSTATUS make_server_info_sam(TALLOC_CTX *mem_ctx,
1009+ struct samu *sampass,
1010+ struct auth_serversupplied_info **pserver_info);
1011 NTSTATUS create_local_token(TALLOC_CTX *mem_ctx,
1012 const struct auth_serversupplied_info *server_info,
1013 DATA_BLOB *session_key,
1014diff --git a/source3/auth/server_info_sam.c b/source3/auth/server_info_sam.c
1015index 5d657f9..47087b1 100644
1016--- a/source3/auth/server_info_sam.c
1017+++ b/source3/auth/server_info_sam.c
1018@@ -58,39 +58,51 @@ static bool is_our_machine_account(const char *username)
1019 Make (and fill) a user_info struct from a struct samu
1020 ***************************************************************************/
1021
1022-NTSTATUS make_server_info_sam(struct auth_serversupplied_info **server_info,
1023- struct samu *sampass)
1024+NTSTATUS make_server_info_sam(TALLOC_CTX *mem_ctx,
1025+ struct samu *sampass,
1026+ struct auth_serversupplied_info **pserver_info)
1027 {
1028 struct passwd *pwd;
1029- struct auth_serversupplied_info *result;
1030+ struct auth_serversupplied_info *server_info;
1031 const char *username = pdb_get_username(sampass);
1032+ TALLOC_CTX *tmp_ctx;
1033 NTSTATUS status;
1034
1035- if ( !(result = make_server_info(NULL)) ) {
1036+ tmp_ctx = talloc_stackframe();
1037+ if (tmp_ctx == NULL) {
1038 return NT_STATUS_NO_MEMORY;
1039 }
1040
1041- if ( !(pwd = Get_Pwnam_alloc(result, username)) ) {
1042+ server_info = make_server_info(tmp_ctx);
1043+ if (server_info == NULL) {
1044+ return NT_STATUS_NO_MEMORY;
1045+ }
1046+
1047+ pwd = Get_Pwnam_alloc(tmp_ctx, username);
1048+ if (pwd == NULL) {
1049 DEBUG(1, ("User %s in passdb, but getpwnam() fails!\n",
1050 pdb_get_username(sampass)));
1051- TALLOC_FREE(result);
1052- return NT_STATUS_NO_SUCH_USER;
1053+ status = NT_STATUS_NO_SUCH_USER;
1054+ goto out;
1055 }
1056
1057- status = samu_to_SamInfo3(result, sampass, lp_netbios_name(),
1058- &result->info3, &result->extra);
1059+ status = samu_to_SamInfo3(server_info,
1060+ sampass,
1061+ lp_netbios_name(),
1062+ &server_info->info3,
1063+ &server_info->extra);
1064 if (!NT_STATUS_IS_OK(status)) {
1065- TALLOC_FREE(result);
1066- return status;
1067+ goto out;
1068 }
1069
1070- result->unix_name = pwd->pw_name;
1071- /* Ensure that we keep pwd->pw_name, because we will free pwd below */
1072- talloc_steal(result, pwd->pw_name);
1073- result->utok.gid = pwd->pw_gid;
1074- result->utok.uid = pwd->pw_uid;
1075+ server_info->unix_name = talloc_strdup(server_info, pwd->pw_name);
1076+ if (server_info->unix_name == NULL) {
1077+ status = NT_STATUS_NO_MEMORY;
1078+ goto out;
1079+ }
1080
1081- TALLOC_FREE(pwd);
1082+ server_info->utok.gid = pwd->pw_gid;
1083+ server_info->utok.uid = pwd->pw_uid;
1084
1085 if (IS_DC && is_our_machine_account(username)) {
1086 /*
1087@@ -110,9 +122,13 @@ NTSTATUS make_server_info_sam(struct auth_serversupplied_info **server_info,
1088 }
1089
1090 DEBUG(5,("make_server_info_sam: made server info for user %s -> %s\n",
1091- pdb_get_username(sampass), result->unix_name));
1092+ pdb_get_username(sampass), server_info->unix_name));
1093+
1094+ *pserver_info = talloc_steal(mem_ctx, server_info);
1095
1096- *server_info = result;
1097+ status = NT_STATUS_OK;
1098+out:
1099+ talloc_free(tmp_ctx);
1100
1101- return NT_STATUS_OK;
1102+ return status;
1103 }
1104diff --git a/source3/auth/user_krb5.c b/source3/auth/user_krb5.c
1105index 7d44285..e40c8ac 100644
1106--- a/source3/auth/user_krb5.c
1107+++ b/source3/auth/user_krb5.c
1108@@ -223,9 +223,6 @@ NTSTATUS make_session_info_krb5(TALLOC_CTX *mem_ctx,
1109 * SID consistency with ntlmssp session setup
1110 */
1111 struct samu *sampass;
1112- /* The stupid make_server_info_XX functions here
1113- don't take a talloc context. */
1114- struct auth_serversupplied_info *tmp = NULL;
1115
1116 sampass = samu_new(talloc_tos());
1117 if (sampass == NULL) {
1118@@ -235,14 +232,19 @@ NTSTATUS make_session_info_krb5(TALLOC_CTX *mem_ctx,
1119 if (pdb_getsampwnam(sampass, username)) {
1120 DEBUG(10, ("found user %s in passdb, calling "
1121 "make_server_info_sam\n", username));
1122- status = make_server_info_sam(&tmp, sampass);
1123+ status = make_server_info_sam(mem_ctx,
1124+ sampass,
1125+ &server_info);
1126 } else {
1127 /*
1128 * User not in passdb, make it up artificially
1129 */
1130 DEBUG(10, ("didn't find user %s in passdb, calling "
1131 "make_server_info_pw\n", username));
1132- status = make_server_info_pw(mem_ctx, username, pw, &tmp);
1133+ status = make_server_info_pw(mem_ctx,
1134+ username,
1135+ pw,
1136+ &server_info);
1137 }
1138
1139 TALLOC_FREE(sampass);
1140--
11411.8.5.2
1142
1143
1144From f9c0adb6237c6e60c33ee6af21f55c0cdefa132c Mon Sep 17 00:00:00 2001
1145From: Andreas Schneider <asn@samba.org>
1146Date: Tue, 18 Feb 2014 10:19:57 +0100
1147Subject: [PATCH 6/7] s3-auth: Pass mem_ctx to auth_check_ntlm_password().
1148
1149Coverity-Id: 1168009
1150BUG: https://bugzilla.samba.org/show_bug.cgi?id=8598
1151
1152Signed-off-by: Andreas Schneider <asn@samba.org>
1153
1154Change-Id: Ie01674561a6a75239a13918d3190c2f21c3efc7a
1155Reviewed-by: Andrew Bartlett <abartlet@samba.org>
1156(cherry picked from commit 4d792db03f18aa164b565c7fdc7b446c174fba28)
1157---
1158 source3/auth/auth.c | 50 ++++++++++++++++++-----------
1159 source3/auth/auth_ntlmssp.c | 6 ++--
1160 source3/auth/proto.h | 8 +++--
1161 source3/rpc_server/netlogon/srv_netlog_nt.c | 6 ++--
1162 source3/torture/pdbtest.c | 5 ++-
1163 5 files changed, 48 insertions(+), 27 deletions(-)
1164
1165diff --git a/source3/auth/auth.c b/source3/auth/auth.c
1166index c3797cf..dc9af02 100644
1167--- a/source3/auth/auth.c
1168+++ b/source3/auth/auth.c
1169@@ -160,18 +160,19 @@ static bool check_domain_match(const char *user, const char *domain)
1170 *
1171 **/
1172
1173-NTSTATUS auth_check_ntlm_password(const struct auth_context *auth_context,
1174- const struct auth_usersupplied_info *user_info,
1175- struct auth_serversupplied_info **server_info)
1176+NTSTATUS auth_check_ntlm_password(TALLOC_CTX *mem_ctx,
1177+ const struct auth_context *auth_context,
1178+ const struct auth_usersupplied_info *user_info,
1179+ struct auth_serversupplied_info **pserver_info)
1180 {
1181 /* if all the modules say 'not for me' this is reasonable */
1182 NTSTATUS nt_status = NT_STATUS_NO_SUCH_USER;
1183 const char *unix_username;
1184 auth_methods *auth_method;
1185- TALLOC_CTX *mem_ctx;
1186
1187- if (!user_info || !auth_context || !server_info)
1188+ if (user_info == NULL || auth_context == NULL || pserver_info == NULL) {
1189 return NT_STATUS_LOGON_FAILURE;
1190+ }
1191
1192 DEBUG(3, ("check_ntlm_password: Checking password for unmapped user [%s]\\[%s]@[%s] with the new password interface\n",
1193 user_info->client.domain_name, user_info->client.account_name, user_info->workstation_name));
1194@@ -205,17 +206,27 @@ NTSTATUS auth_check_ntlm_password(const struct auth_context *auth_context,
1195 return NT_STATUS_LOGON_FAILURE;
1196
1197 for (auth_method = auth_context->auth_method_list;auth_method; auth_method = auth_method->next) {
1198+ struct auth_serversupplied_info *server_info;
1199+ TALLOC_CTX *tmp_ctx;
1200 NTSTATUS result;
1201
1202- mem_ctx = talloc_init("%s authentication for user %s\\%s", auth_method->name,
1203- user_info->mapped.domain_name, user_info->client.account_name);
1204+ tmp_ctx = talloc_named(mem_ctx,
1205+ 0,
1206+ "%s authentication for user %s\\%s",
1207+ auth_method->name,
1208+ user_info->mapped.domain_name,
1209+ user_info->client.account_name);
1210
1211- result = auth_method->auth(auth_context, auth_method->private_data, mem_ctx, user_info, server_info);
1212+ result = auth_method->auth(auth_context,
1213+ auth_method->private_data,
1214+ tmp_ctx,
1215+ user_info,
1216+ &server_info);
1217
1218 /* check if the module did anything */
1219 if ( NT_STATUS_V(result) == NT_STATUS_V(NT_STATUS_NOT_IMPLEMENTED) ) {
1220 DEBUG(10,("check_ntlm_password: %s had nothing to say\n", auth_method->name));
1221- talloc_destroy(mem_ctx);
1222+ TALLOC_FREE(tmp_ctx);
1223 continue;
1224 }
1225
1226@@ -229,19 +240,20 @@ NTSTATUS auth_check_ntlm_password(const struct auth_context *auth_context,
1227 auth_method->name, user_info->client.account_name, nt_errstr(nt_status)));
1228 }
1229
1230- talloc_destroy(mem_ctx);
1231-
1232- if ( NT_STATUS_IS_OK(nt_status))
1233- {
1234- break;
1235+ if (NT_STATUS_IS_OK(nt_status)) {
1236+ *pserver_info = talloc_steal(mem_ctx, server_info);
1237+ TALLOC_FREE(tmp_ctx);
1238+ break;
1239 }
1240+
1241+ TALLOC_FREE(tmp_ctx);
1242 }
1243
1244 /* successful authentication */
1245
1246 if (NT_STATUS_IS_OK(nt_status)) {
1247- unix_username = (*server_info)->unix_name;
1248- if (!(*server_info)->guest) {
1249+ unix_username = (*pserver_info)->unix_name;
1250+ if (!(*pserver_info)->guest) {
1251 const char *rhost;
1252
1253 if (tsocket_address_is_inet(user_info->remote_host, "ip")) {
1254@@ -270,9 +282,9 @@ NTSTATUS auth_check_ntlm_password(const struct auth_context *auth_context,
1255 }
1256
1257 if (NT_STATUS_IS_OK(nt_status)) {
1258- DEBUG((*server_info)->guest ? 5 : 2,
1259+ DEBUG((*pserver_info)->guest ? 5 : 2,
1260 ("check_ntlm_password: %sauthentication for user [%s] -> [%s] -> [%s] succeeded\n",
1261- (*server_info)->guest ? "guest " : "",
1262+ (*pserver_info)->guest ? "guest " : "",
1263 user_info->client.account_name,
1264 user_info->mapped.account_name,
1265 unix_username));
1266@@ -286,7 +298,7 @@ NTSTATUS auth_check_ntlm_password(const struct auth_context *auth_context,
1267 DEBUG(2, ("check_ntlm_password: Authentication for user [%s] -> [%s] FAILED with error %s\n",
1268 user_info->client.account_name, user_info->mapped.account_name,
1269 nt_errstr(nt_status)));
1270- ZERO_STRUCTP(server_info);
1271+ ZERO_STRUCTP(pserver_info);
1272
1273 return nt_status;
1274 }
1275diff --git a/source3/auth/auth_ntlmssp.c b/source3/auth/auth_ntlmssp.c
1276index f99bd44..cb7726c 100644
1277--- a/source3/auth/auth_ntlmssp.c
1278+++ b/source3/auth/auth_ntlmssp.c
1279@@ -134,8 +134,10 @@ NTSTATUS auth3_check_password(struct auth4_context *auth4_context,
1280
1281 mapped_user_info->flags = user_info->flags;
1282
1283- nt_status = auth_check_ntlm_password(auth_context,
1284- mapped_user_info, &server_info);
1285+ nt_status = auth_check_ntlm_password(mem_ctx,
1286+ auth_context,
1287+ mapped_user_info,
1288+ &server_info);
1289
1290 if (!NT_STATUS_IS_OK(nt_status)) {
1291 DEBUG(5,("Checking NTLMSSP password for %s\\%s failed: %s\n",
1292diff --git a/source3/auth/proto.h b/source3/auth/proto.h
1293index eac3e54..15b1ba0 100644
1294--- a/source3/auth/proto.h
1295+++ b/source3/auth/proto.h
1296@@ -65,6 +65,8 @@ NTSTATUS auth_get_ntlm_challenge(struct auth_context *auth_context,
1297 * struct. When the return is other than NT_STATUS_OK the contents
1298 * of that structure is undefined.
1299 *
1300+ * @param mem_ctx The memory context to use to allocate server_info
1301+ *
1302 * @param user_info Contains the user supplied components, including the passwords.
1303 * Must be created with make_user_info() or one of its wrappers.
1304 *
1305@@ -79,9 +81,9 @@ NTSTATUS auth_get_ntlm_challenge(struct auth_context *auth_context,
1306 * @return An NTSTATUS with NT_STATUS_OK or an appropriate error.
1307 *
1308 **/
1309-
1310-NTSTATUS auth_check_ntlm_password(const struct auth_context *auth_context,
1311- const struct auth_usersupplied_info *user_info,
1312+NTSTATUS auth_check_ntlm_password(TALLOC_CTX *mem_ctx,
1313+ const struct auth_context *auth_context,
1314+ const struct auth_usersupplied_info *user_info,
1315 struct auth_serversupplied_info **server_info);
1316
1317 /* The following definitions come from auth/auth_builtin.c */
1318diff --git a/source3/rpc_server/netlogon/srv_netlog_nt.c b/source3/rpc_server/netlogon/srv_netlog_nt.c
1319index e5ca474..0c8c9a5 100644
1320--- a/source3/rpc_server/netlogon/srv_netlog_nt.c
1321+++ b/source3/rpc_server/netlogon/srv_netlog_nt.c
1322@@ -1650,8 +1650,10 @@ static NTSTATUS _netr_LogonSamLogon_base(struct pipes_struct *p,
1323 } /* end switch */
1324
1325 if ( NT_STATUS_IS_OK(status) ) {
1326- status = auth_check_ntlm_password(auth_context,
1327- user_info, &server_info);
1328+ status = auth_check_ntlm_password(p->mem_ctx,
1329+ auth_context,
1330+ user_info,
1331+ &server_info);
1332 }
1333
1334 TALLOC_FREE(auth_context);
1335diff --git a/source3/torture/pdbtest.c b/source3/torture/pdbtest.c
1336index 17da455..14d58b9 100644
1337--- a/source3/torture/pdbtest.c
1338+++ b/source3/torture/pdbtest.c
1339@@ -304,7 +304,10 @@ static bool test_auth(TALLOC_CTX *mem_ctx, struct samu *pdb_entry)
1340 return False;
1341 }
1342
1343- status = auth_check_ntlm_password(auth_context, user_info, &server_info);
1344+ status = auth_check_ntlm_password(mem_ctx,
1345+ auth_context,
1346+ user_info,
1347+ &server_info);
1348
1349 if (!NT_STATUS_IS_OK(status)) {
1350 DEBUG(0, ("Failed to test authentication with auth module: %s\n", nt_errstr(status)));
1351--
13521.8.5.2
1353
1354
1355From a48bcd84c59b5b2cb8c3e0f5d68b35065bed81d7 Mon Sep 17 00:00:00 2001
1356From: Andreas Schneider <asn@samba.org>
1357Date: Tue, 18 Feb 2014 13:52:49 +0100
1358Subject: [PATCH 7/7] s3-auth: Pass mem_ctx to do_map_to_guest_server_info().
1359
1360Change-Id: If53117023e3ab37c810193edd00a81d247fdde7a
1361Reviewed-by: Andrew Bartlett <abartlet@samba.org>
1362
1363Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
1364Autobuild-Date(master): Wed Feb 19 01:28:14 CET 2014 on sn-devel-104
1365
1366(cherry picked from commit 79e2725f339e7c5336b4053348c4266268de6ca3)
1367---
1368 source3/auth/auth_ntlmssp.c | 7 ++++---
1369 source3/auth/auth_util.c | 12 +++++++-----
1370 source3/auth/proto.h | 8 +++++---
1371 3 files changed, 16 insertions(+), 11 deletions(-)
1372
1373diff --git a/source3/auth/auth_ntlmssp.c b/source3/auth/auth_ntlmssp.c
1374index cb7726c..d4fe901 100644
1375--- a/source3/auth/auth_ntlmssp.c
1376+++ b/source3/auth/auth_ntlmssp.c
1377@@ -151,10 +151,11 @@ NTSTATUS auth3_check_password(struct auth4_context *auth4_context,
1378 free_user_info(&mapped_user_info);
1379
1380 if (!NT_STATUS_IS_OK(nt_status)) {
1381- nt_status = do_map_to_guest_server_info(nt_status,
1382- &server_info,
1383+ nt_status = do_map_to_guest_server_info(mem_ctx,
1384+ nt_status,
1385 user_info->client.account_name,
1386- user_info->client.domain_name);
1387+ user_info->client.domain_name,
1388+ &server_info);
1389 *server_returned_info = talloc_steal(mem_ctx, server_info);
1390 return nt_status;
1391 }
1392diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
1393index 24190af..8cf5cb7 100644
1394--- a/source3/auth/auth_util.c
1395+++ b/source3/auth/auth_util.c
1396@@ -1536,9 +1536,11 @@ bool is_trusted_domain(const char* dom_name)
1397 on a logon error possibly map the error to success if "map to guest"
1398 is set approriately
1399 */
1400-NTSTATUS do_map_to_guest_server_info(NTSTATUS status,
1401- struct auth_serversupplied_info **server_info,
1402- const char *user, const char *domain)
1403+NTSTATUS do_map_to_guest_server_info(TALLOC_CTX *mem_ctx,
1404+ NTSTATUS status,
1405+ const char *user,
1406+ const char *domain,
1407+ struct auth_serversupplied_info **server_info)
1408 {
1409 user = user ? user : "";
1410 domain = domain ? domain : "";
1411@@ -1548,13 +1550,13 @@ NTSTATUS do_map_to_guest_server_info(NTSTATUS status,
1412 (lp_map_to_guest() == MAP_TO_GUEST_ON_BAD_PASSWORD)) {
1413 DEBUG(3,("No such user %s [%s] - using guest account\n",
1414 user, domain));
1415- return make_server_info_guest(NULL, server_info);
1416+ return make_server_info_guest(mem_ctx, server_info);
1417 }
1418 } else if (NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) {
1419 if (lp_map_to_guest() == MAP_TO_GUEST_ON_BAD_PASSWORD) {
1420 DEBUG(3,("Registered username %s for guest access\n",
1421 user));
1422- return make_server_info_guest(NULL, server_info);
1423+ return make_server_info_guest(mem_ctx, server_info);
1424 }
1425 }
1426
1427diff --git a/source3/auth/proto.h b/source3/auth/proto.h
1428index 15b1ba0..7b8959f 100644
1429--- a/source3/auth/proto.h
1430+++ b/source3/auth/proto.h
1431@@ -264,9 +264,11 @@ NTSTATUS make_user_info(struct auth_usersupplied_info **ret_user_info,
1432 enum auth_password_state password_state);
1433 void free_user_info(struct auth_usersupplied_info **user_info);
1434
1435-NTSTATUS do_map_to_guest_server_info(NTSTATUS status,
1436- struct auth_serversupplied_info **server_info,
1437- const char *user, const char *domain);
1438+NTSTATUS do_map_to_guest_server_info(TALLOC_CTX *mem_ctx,
1439+ NTSTATUS status,
1440+ const char *user,
1441+ const char *domain,
1442+ struct auth_serversupplied_info **server_info);
1443
1444 /* The following definitions come from auth/auth_winbind.c */
1445
1446--
14471.8.5.2
1448