1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
14 */
15
16 /*
17 * These replace NODIRECT functions of the same name in
18 * $SRC/lib/smbsrv/libsmb/common/smb_kmod.c including:
19 * smb_kmod_bind, smb_kmod_ioctl, smb_kmod_isbound,
20 * smb_kmod_start, smb_kmod_stop, smb_kmod_unbind.
21 *
22 * For all the other smb_kmod_... functions, we can just use the
23 * libsmb code because those all call smb_kmod_ioctl, for which
24 * we have an override here.
25 *
26 * The replacment functions here just call the libfksmbsrv code
27 * directly where the real (in-kernel) versions would be entered
28 * via the driver framework (open, close, ioctl). Aside from that,
29 * the call sequences are intentionally the same (where possible).
30 * In particular, that makes it possible to debug startup/teardown
31 * problems in the user-space version of this code.
32 */
33
52 boolean_t smbdrv_opened = B_FALSE;
53
54 /*
55 * We want to adjust a few things in the standard configuration
56 * passed to the "fake" version of the smbsrv kernel module.
57 *
58 * Reduce the maximum number of connections and workers, just for
59 * convenience while debugging. (Don't want hundreds of threads.)
60 */
61 static void
62 fksmbd_adjust_config(smb_ioc_header_t *ioc_hdr)
63 {
64 smb_ioc_cfg_t *ioc = (smb_ioc_cfg_t *)ioc_hdr;
65 char *s;
66
67 ioc->maxconnections = 10;
68 ioc->maxworkers = 20;
69 smbd_report("maxconnections=%d, maxworkers=%d",
70 ioc->maxconnections, ioc->maxworkers);
71
72 if ((s = getenv("SMB_SIGNING")) != NULL) {
73 ioc->signing_enable = 0;
74 ioc->signing_required = 0;
75 switch (s[0]) {
76 case 'e':
77 ioc->signing_enable = 1;
78 break;
79 case 'r':
80 ioc->signing_enable = 1;
81 ioc->signing_required = 1;
82 break;
83 default:
84 smbd_report("env SMB_SIGNING invalid");
85 break;
86 }
87 }
88 smbd_report("signing: enable=%d, required=%d",
89 ioc->signing_enable, ioc->signing_required);
90 }
91
|
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
14 */
15
16 /*
17 * These replace NODIRECT functions of the same name in
18 * $SRC/lib/smbsrv/libsmb/common/smb_kmod.c including:
19 * smb_kmod_bind, smb_kmod_ioctl, smb_kmod_isbound,
20 * smb_kmod_start, smb_kmod_stop, smb_kmod_unbind.
21 *
22 * For all the other smb_kmod_... functions, we can just use the
23 * libsmb code because those all call smb_kmod_ioctl, for which
24 * we have an override here.
25 *
26 * The replacment functions here just call the libfksmbsrv code
27 * directly where the real (in-kernel) versions would be entered
28 * via the driver framework (open, close, ioctl). Aside from that,
29 * the call sequences are intentionally the same (where possible).
30 * In particular, that makes it possible to debug startup/teardown
31 * problems in the user-space version of this code.
32 */
33
52 boolean_t smbdrv_opened = B_FALSE;
53
54 /*
55 * We want to adjust a few things in the standard configuration
56 * passed to the "fake" version of the smbsrv kernel module.
57 *
58 * Reduce the maximum number of connections and workers, just for
59 * convenience while debugging. (Don't want hundreds of threads.)
60 */
61 static void
62 fksmbd_adjust_config(smb_ioc_header_t *ioc_hdr)
63 {
64 smb_ioc_cfg_t *ioc = (smb_ioc_cfg_t *)ioc_hdr;
65 char *s;
66
67 ioc->maxconnections = 10;
68 ioc->maxworkers = 20;
69 smbd_report("maxconnections=%d, maxworkers=%d",
70 ioc->maxconnections, ioc->maxworkers);
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
82 if ((s = getenv("SMB_SIGNING")) != NULL) {
83 ioc->signing_enable = 0;
84 ioc->signing_required = 0;
85 switch (s[0]) {
86 case 'e':
87 ioc->signing_enable = 1;
88 break;
89 case 'r':
90 ioc->signing_enable = 1;
91 ioc->signing_required = 1;
92 break;
93 default:
94 smbd_report("env SMB_SIGNING invalid");
95 break;
96 }
97 }
98 smbd_report("signing: enable=%d, required=%d",
99 ioc->signing_enable, ioc->signing_required);
100 }
101
|