4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
26 #include <sys/types.h>
37 #include <nss_dbdefs.h>
38 #include <sys/idmap.h>
42 * Invoked at user logon due to SmbSessionSetupX.
44 * On error, returns NULL, and status in user_info->lg_status
47 smbd_user_auth_logon(smb_logon_t
*user_info
)
49 smb_token_t
*token
= NULL
;
54 if (user_info
->lg_username
== NULL
||
55 user_info
->lg_domain
== NULL
||
56 user_info
->lg_workstation
== NULL
) {
57 user_info
->lg_status
= NT_STATUS_INVALID_PARAMETER
;
62 * Avoid modifying the caller-provided struct because it
63 * may or may not point to allocated strings etc.
64 * Copy to tmp_user, auth, then copy the (out) lg_status
65 * member back to the caller-provided struct.
67 tmp_user
= *user_info
;
68 if (tmp_user
.lg_username
[0] == '\0') {
69 tmp_user
.lg_flags
|= SMB_ATF_ANON
;
70 tmp_user
.lg_e_username
= "anonymous";
72 tmp_user
.lg_e_username
= tmp_user
.lg_username
;
75 /* Handle user@domain format. */
76 if (tmp_user
.lg_domain
[0] == '\0' &&
77 (p
= strchr(tmp_user
.lg_e_username
, '@')) != NULL
) {
78 buf
= strdup(tmp_user
.lg_e_username
);
81 p
= buf
+ (p
- tmp_user
.lg_e_username
);
83 tmp_user
.lg_e_domain
= p
+ 1;
84 tmp_user
.lg_e_username
= buf
;
86 tmp_user
.lg_e_domain
= tmp_user
.lg_domain
;
89 token
= smb_logon(&tmp_user
);
90 user_info
->lg_status
= tmp_user
.lg_status
;
96 smb_token_destroy(token
);