Print this page
NEX-10019 SMB server min_protocol setting
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-4083 Upstream changes from illumos 5917 and 5995
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-3591 SMB3 signing (fix fksmbd)
NEX-3610 CLONE NEX-3591 SMB3 signing
Reviewed by: Gordon Ross <gwr@nexenta.com>
Reviewed by: Dan Fields <dan.fields@nexenta.com>
NEX-1050 enable_smb2 should be smb2_enable (nit)
NEX-1050 enable_smb2 should be smb2_enable
SMB-11 SMB2 message parse & dispatch
SMB-12 SMB2 Negotiate Protocol
SMB-13 SMB2 Session Setup
SMB-14 SMB2 Logoff
SMB-15 SMB2 Tree Connect
SMB-16 SMB2 Tree Disconnect
SMB-17 SMB2 Create
SMB-18 SMB2 Close
SMB-19 SMB2 Flush
SMB-20 SMB2 Read
SMB-21 SMB2 Write
SMB-22 SMB2 Lock/Unlock
SMB-23 SMB2 Ioctl
SMB-24 SMB2 Cancel
SMB-25 SMB2 Echo
SMB-26 SMB2 Query Dir
SMB-27 SMB2 Change Notify
SMB-28 SMB2 Query Info
SMB-29 SMB2 Set Info
SMB-30 SMB2 Oplocks
SMB-53 SMB2 Create Context options
(SMB2 code review cleanup 1, 2, 3)
SMB-72 Improve startup/shudown debug features
SMB-39 Use AF_UNIX pipes for RPC
SMB-50 User-mode SMB server
Includes work by these authors:
Thomas Keiser <thomas.keiser@nexenta.com>
Albert Lee <trisk@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/smbsrv/fksmbd/fksmbd_kmod.c
+++ new/usr/src/cmd/smbsrv/fksmbd/fksmbd_kmod.c
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
|
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 - * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
13 + * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
14 14 */
15 15
16 16 /*
17 17 * These replace NODIRECT functions of the same name in
18 18 * $SRC/lib/smbsrv/libsmb/common/smb_kmod.c including:
19 19 * smb_kmod_bind, smb_kmod_ioctl, smb_kmod_isbound,
20 20 * smb_kmod_start, smb_kmod_stop, smb_kmod_unbind.
21 21 *
22 22 * For all the other smb_kmod_... functions, we can just use the
23 23 * libsmb code because those all call smb_kmod_ioctl, for which
24 24 * we have an override here.
25 25 *
26 26 * The replacment functions here just call the libfksmbsrv code
27 27 * directly where the real (in-kernel) versions would be entered
28 28 * via the driver framework (open, close, ioctl). Aside from that,
29 29 * the call sequences are intentionally the same (where possible).
30 30 * In particular, that makes it possible to debug startup/teardown
31 31 * problems in the user-space version of this code.
32 32 */
33 33
34 34 #include <sys/types.h>
35 35 #include <sys/stat.h>
36 36 #include <sys/ioccom.h>
37 37 #include <sys/param.h>
38 38 #include <stddef.h>
39 39 #include <stdio.h>
40 40 #include <string.h>
41 41 #include <strings.h>
42 42 #include <stdlib.h>
43 43 #include <unistd.h>
44 44 #include <fcntl.h>
45 45 #include <errno.h>
46 46 #include <note.h>
47 47
48 48 #include <smbsrv/smbinfo.h>
49 49 #include <smbsrv/smb_ioctl.h>
50 50 #include "smbd.h"
51 51
52 52 boolean_t smbdrv_opened = B_FALSE;
53 53
54 54 /*
55 55 * We want to adjust a few things in the standard configuration
56 56 * passed to the "fake" version of the smbsrv kernel module.
57 57 *
58 58 * Reduce the maximum number of connections and workers, just for
59 59 * convenience while debugging. (Don't want hundreds of threads.)
60 60 */
61 61 static void
|
↓ open down ↓ |
38 lines elided |
↑ open up ↑ |
62 62 fksmbd_adjust_config(smb_ioc_header_t *ioc_hdr)
63 63 {
64 64 smb_ioc_cfg_t *ioc = (smb_ioc_cfg_t *)ioc_hdr;
65 65 char *s;
66 66
67 67 ioc->maxconnections = 10;
68 68 ioc->maxworkers = 20;
69 69 smbd_report("maxconnections=%d, maxworkers=%d",
70 70 ioc->maxconnections, ioc->maxworkers);
71 71
72 + if ((s = getenv("SMB_MAX_PROTOCOL")) != NULL) {
73 + ioc->max_protocol = strtol(s, NULL, 16);
74 + smbd_report("max_protocol=0x%x", ioc->max_protocol);
75 + }
76 +
77 + if ((s = getenv("SMB_MIN_PROTOCOL")) != NULL) {
78 + ioc->min_protocol = strtol(s, NULL, 16);
79 + smbd_report("min_protocol=0x%x", ioc->min_protocol);
80 + }
81 +
72 82 if ((s = getenv("SMB_SIGNING")) != NULL) {
73 83 ioc->signing_enable = 0;
74 84 ioc->signing_required = 0;
75 85 switch (s[0]) {
76 86 case 'e':
77 87 ioc->signing_enable = 1;
78 88 break;
79 89 case 'r':
80 90 ioc->signing_enable = 1;
81 91 ioc->signing_required = 1;
82 92 break;
83 93 default:
84 94 smbd_report("env SMB_SIGNING invalid");
85 95 break;
86 96 }
87 97 }
88 98 smbd_report("signing: enable=%d, required=%d",
89 99 ioc->signing_enable, ioc->signing_required);
90 100 }
91 101
92 102 boolean_t
93 103 smb_kmod_isbound(void)
94 104 {
95 105 return (smbdrv_opened);
96 106 }
97 107
98 108 int
99 109 smb_kmod_bind(void)
100 110 {
101 111 int rc;
102 112
103 113 if (smbdrv_opened) {
104 114 smbdrv_opened = B_FALSE;
105 115 (void) fksmbsrv_drv_close();
106 116 }
107 117
108 118 rc = fksmbsrv_drv_open();
109 119 if (rc == 0)
110 120 smbdrv_opened = B_TRUE;
111 121
112 122 return (rc);
113 123 }
114 124
115 125 void
116 126 smb_kmod_unbind(void)
117 127 {
118 128 if (smbdrv_opened) {
119 129 smbdrv_opened = B_FALSE;
120 130 (void) fksmbsrv_drv_close();
121 131 }
122 132 }
123 133
124 134 int
125 135 smb_kmod_ioctl(int cmd, smb_ioc_header_t *ioc, uint32_t len)
126 136 {
127 137 int rc;
128 138
129 139 _NOTE(ARGUNUSED(len));
130 140
131 141 if (!smbdrv_opened)
132 142 return (EBADF);
133 143
134 144 if (cmd == SMB_IOC_CONFIG)
135 145 fksmbd_adjust_config(ioc);
136 146
137 147 rc = fksmbsrv_drv_ioctl(cmd, ioc);
138 148 return (rc);
139 149 }
140 150
141 151 /* ARGSUSED */
142 152 int
143 153 smb_kmod_start(int opipe, int lmshr, int udoor)
144 154 {
145 155 smb_ioc_start_t ioc;
146 156 int rc;
147 157
148 158 bzero(&ioc, sizeof (ioc));
149 159
150 160 /* These three are unused */
151 161 ioc.opipe = -1;
152 162 ioc.lmshrd = -1;
153 163 ioc.udoor = -1;
154 164
155 165 /* These are the "door" dispatch callbacks */
156 166 ioc.lmshr_func = NULL; /* not used */
157 167 ioc.opipe_func = NULL; /* not used */
158 168 ioc.udoor_func = (void *)fksmbd_door_dispatch;
159 169
160 170 rc = smb_kmod_ioctl(SMB_IOC_START, &ioc.hdr, sizeof (ioc));
161 171 return (rc);
162 172 }
163 173
164 174 void
165 175 smb_kmod_stop(void)
166 176 {
167 177 smb_ioc_header_t ioc;
168 178
169 179 bzero(&ioc, sizeof (ioc));
170 180 (void) smb_kmod_ioctl(SMB_IOC_STOP, &ioc, sizeof (ioc));
171 181 }
|
↓ open down ↓ |
90 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX