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.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
25 */
26
27 /*
28 * There used to be a "redirector" library, which has been replaced,
29 * leaving only the "glue" functions in this file that adapt this
30 * library to the interface provided by libsmbfs.
31 */
32
33 #include <errno.h>
34 #include <string.h>
35 #include <strings.h>
36 #include <unistd.h>
37 #include <priv.h>
38
39 #include <netsmb/smbfs_api.h>
40 #include <smbsrv/libsmb.h>
41 #include <smbsrv/libmlsvc.h>
42 #include <libsmbrdr.h>
43 #include <mlsvc.h>
44
141 /* Send NTLM */
142 authflags = SMB_AT_NTLM1;
143 } else {
144 /* Send NTLMv2 */
145 authflags = SMB_AT_NTLM2;
146 }
147 smb_ipc_get_passwd(nthash, sizeof (nthash));
148 (void) smb_ctx_setpwhash(ctx, nthash, NULL);
149 }
150 (void) smb_ctx_setauthflags(ctx, authflags);
151
152 /*
153 * Do lookup, connect, session setup, tree connect.
154 * Or find and reuse a session/tree, if one exists.
155 */
156 if ((err = smb_ctx_resolve(ctx)) != 0) {
157 err = NT_STATUS_BAD_NETWORK_PATH;
158 goto errout;
159 }
160 if ((err = smb_ctx_get_ssn(ctx)) != 0) {
161 err = NT_STATUS_NETWORK_ACCESS_DENIED;
162 goto errout;
163 }
164 if ((err = smb_ctx_get_tree(ctx)) != 0) {
165 err = NT_STATUS_BAD_NETWORK_NAME;
166 goto errout;
167 }
168
169 /* Success! */
170 *ctx_p = ctx;
171 return (0);
172
173 errout:
174 smb_ctx_free(ctx);
175 return (err);
176 }
|
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.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
25 */
26
27 /*
28 * There used to be a "redirector" library, which has been replaced,
29 * leaving only the "glue" functions in this file that adapt this
30 * library to the interface provided by libsmbfs.
31 */
32
33 #include <errno.h>
34 #include <string.h>
35 #include <strings.h>
36 #include <unistd.h>
37 #include <priv.h>
38
39 #include <netsmb/smbfs_api.h>
40 #include <smbsrv/libsmb.h>
41 #include <smbsrv/libmlsvc.h>
42 #include <libsmbrdr.h>
43 #include <mlsvc.h>
44
141 /* Send NTLM */
142 authflags = SMB_AT_NTLM1;
143 } else {
144 /* Send NTLMv2 */
145 authflags = SMB_AT_NTLM2;
146 }
147 smb_ipc_get_passwd(nthash, sizeof (nthash));
148 (void) smb_ctx_setpwhash(ctx, nthash, NULL);
149 }
150 (void) smb_ctx_setauthflags(ctx, authflags);
151
152 /*
153 * Do lookup, connect, session setup, tree connect.
154 * Or find and reuse a session/tree, if one exists.
155 */
156 if ((err = smb_ctx_resolve(ctx)) != 0) {
157 err = NT_STATUS_BAD_NETWORK_PATH;
158 goto errout;
159 }
160 if ((err = smb_ctx_get_ssn(ctx)) != 0) {
161 switch (err) {
162 case EAUTH:
163 err = NT_STATUS_NETWORK_ACCESS_DENIED;
164 break;
165 default:
166 err = NT_STATUS_BAD_NETWORK_PATH;
167 break;
168 }
169 goto errout;
170 }
171 if ((err = smb_ctx_get_tree(ctx)) != 0) {
172 err = NT_STATUS_BAD_NETWORK_NAME;
173 goto errout;
174 }
175
176 /* Success! */
177 *ctx_p = ctx;
178 return (0);
179
180 errout:
181 smb_ctx_free(ctx);
182 return (err);
183 }
|