View | Details | Raw Unified | Return to bug 47314
Collapse All | Expand All

(-)a/source3/auth/auth_util.c (-4 / +33 lines)
 Lines 110-115   NTSTATUS make_user_info_map(TALLOC_CTX *mem_ctx, Link Here 
110
	NTSTATUS result;
110
	NTSTATUS result;
111
	bool was_mapped;
111
	bool was_mapped;
112
	char *internal_username = NULL;
112
	char *internal_username = NULL;
113
	bool upn_form = false;
114
	int map_untrusted = lp_map_untrusted_to_domain();
115
116
	if (client_domain[0] == '\0' && strchr(smb_name, '@')) {
117
		upn_form = true;
118
	}
113
119
114
	was_mapped = map_username(talloc_tos(), smb_name, &internal_username);
120
	was_mapped = map_username(talloc_tos(), smb_name, &internal_username);
115
	if (!internal_username) {
121
	if (!internal_username) {
 Lines 119-130   NTSTATUS make_user_info_map(TALLOC_CTX *mem_ctx, Link Here 
119
	DEBUG(5, ("Mapping user [%s]\\[%s] from workstation [%s]\n",
125
	DEBUG(5, ("Mapping user [%s]\\[%s] from workstation [%s]\n",
120
		 client_domain, smb_name, workstation_name));
126
		 client_domain, smb_name, workstation_name));
121
127
122
	/*
123
	 * We let the auth stack canonicalize, username
124
	 * and domain.
125
	 */
126
	domain = client_domain;
128
	domain = client_domain;
127
129
130
	/* If you connect to a Windows domain member using a bogus domain name,
131
	 * the Windows box will map the BOGUS\user to SAMNAME\user.  Thus, if
132
	 * the Windows box is a DC the name will become DOMAIN\user and be
133
	 * authenticated against AD, if the Windows box is a member server but
134
	 * not a DC the name will become WORKSTATION\user.  A standalone
135
	 * non-domain member box will also map to WORKSTATION\user.
136
	 * This also deals with the client passing in a "" domain */
137
138
	if (map_untrusted != Auto && !upn_form &&
139
	    !strequal(domain, my_sam_name()) &&
140
	    !strequal(domain, get_global_sam_name()) &&
141
	    !is_trusted_domain(domain))
142
	{
143
		if (map_untrusted) {
144
			domain = my_sam_name();
145
		} else {
146
			domain = get_global_sam_name();
147
		}
148
		DEBUG(5, ("Mapped domain from [%s] to [%s] for user [%s] from "
149
			  "workstation [%s]\n",
150
			  client_domain, domain, smb_name, workstation_name));
151
	}
152
153
	/* We know that the given domain is trusted (and we are allowing them),
154
	 * it is our global SAM name, or for legacy behavior it is our
155
	 * primary domain name */
156
128
	result = make_user_info(mem_ctx, user_info, smb_name, internal_username,
157
	result = make_user_info(mem_ctx, user_info, smb_name, internal_username,
129
				client_domain, domain, workstation_name,
158
				client_domain, domain, workstation_name,
130
				remote_address, local_address,
159
				remote_address, local_address,
(-)a/docs-xml/smbdotconf/security/mapuntrustedtodomain.xml (+55 lines)
Line 0    Link Here 
1
<samba:parameter name="map untrusted to domain"
2
                 context="G"
3
                 type="enum"
4
                 enumlist="enum_bool_auto"
5
                 deprecated="1"
6
                 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
7
<description>
8
    <para>
9
    By default, and with <smbconfoption name="map untrusted to domain">auto</smbconfoption>
10
    smbd will defer the decision whether the domain name provided by the
11
    client is a valid domain name to the Domain Controller (DC) of
12
    the domain it is a member of, if it is not a DC.  If the DC indicates
13
    that the domain portion is unknown, then a local authentication is performed.
14
    Standalone servers always ignore the domain.  This is basically the same as
15
    the behavior implemented in Windows.
16
    </para>
17
18
    <para>
19
    With <smbconfoption name="map untrusted to domain">no</smbconfoption>,
20
    if a client connects to smbd using an untrusted domain name, such as
21
    BOGUS\user, smbd replaces the BOGUS domain with it's SAM name
22
    (forcing local authentication) before
23
    attempting to authenticate that user.  In the case where smbd is acting as
24
    a NT4 PDC/BDC this will be DOMAIN\user.  In the case where smbd is acting as a
25
    domain member server or a standalone server this will be WORKSTATION\user.
26
    While this appears similar to the behaviour of
27
    <smbconfoption name="map untrusted to domain">auto</smbconfoption>,
28
    the difference is that smbd will use a cached (maybe incomplete) list
29
    of trusted domains in order to classify a domain as "untrusted"
30
    before contacting any DC first.
31
    </para>
32
33
    <para>
34
    With <smbconfoption name="map untrusted to domain">yes</smbconfoption>,
35
    smbd provides the legacy behavior matching that of versions of Samba pre 3.4:
36
    the BOGUS domain name would always be replaced by the
37
    primary domain before attempting to authenticate that user.
38
    This will be DOMAIN\user in all server roles except active directory domain controller.
39
    </para>
40
41
    <para>
42
    <smbconfoption name="map untrusted to domain">no</smbconfoption>,
43
    was the default up to Samba 4.6.
44
    </para>
45
46
    <para>
47
    <smbconfoption name="map untrusted to domain">auto</smbconfoption> was added
48
    and become the default with Samba 4.7.0. As the option is marked as
49
    <constant>deprecated</constant> it will be removed in a future release, while the behavior of
50
    <smbconfoption name="map untrusted to domain">auto</smbconfoption> will be kept.
51
    </para>
52
</description>
53
54
<value type="default">auto</value>
55
</samba:parameter>
(-)a/lib/param/loadparm.c (+2 lines)
 Lines 2840-2845   struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx) Link Here 
2840
2840
2841
	lpcfg_do_global_parameter(lp_ctx, "guest account", GUEST_ACCOUNT);
2841
	lpcfg_do_global_parameter(lp_ctx, "guest account", GUEST_ACCOUNT);
2842
2842
2843
	lpcfg_do_global_parameter(lp_ctx, "map untrusted to domain", "auto");
2844
2843
	lpcfg_do_global_parameter(lp_ctx, "client schannel", "auto");
2845
	lpcfg_do_global_parameter(lp_ctx, "client schannel", "auto");
2844
2846
2845
	lpcfg_do_global_parameter(lp_ctx, "smb encrypt", "default");
2847
	lpcfg_do_global_parameter(lp_ctx, "smb encrypt", "default");
(-)a/source3/param/loadparm.c (+1 lines)
 Lines 867-872   static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals) Link Here 
867
867
868
	Globals.min_receivefile_size = 0;
868
	Globals.min_receivefile_size = 0;
869
869
870
	Globals.map_untrusted_to_domain = Auto;
870
	Globals.multicast_dns_register = true;
871
	Globals.multicast_dns_register = true;
871
872
872
	Globals.smb2_max_read = DEFAULT_SMB2_MAX_READ;
873
	Globals.smb2_max_read = DEFAULT_SMB2_MAX_READ;

Return to bug 47314