Print this page
NEX-19057 All zfs/nfs/smb threads in door calls to idle idmap
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-1638 Updated DC Locator
Includes work by: matt.barden@nexenta.com, kevin.crowe@nexenta.com
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/idmap/idmapd/idmap_lsa.c
+++ new/usr/src/cmd/idmap/idmapd/idmap_lsa.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 - * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
24 + * Copyright 2019 Nexenta Systems, Inc. All rights reserved.
25 25 */
26 26
27 27 /*
28 28 * LSA lookups
29 29 */
30 30
31 31 #include <stdio.h>
32 32 #include <note.h>
33 33 #include <assert.h>
34 34
35 35 #include "idmapd.h"
36 36 #include "libsmb.h"
37 37
38 38 idmap_retcode
39 39 idmap_lsa_xlate_sid_type(const lsa_account_t *acct, idmap_id_type *ret_type)
40 40 {
41 41 switch (acct->a_sidtype) {
42 42 case SidTypeUser:
43 43 case SidTypeComputer:
44 44 case SidTypeDomain:
45 45 case SidTypeDeletedAccount:
46 46 case SidTypeUnknown:
47 47 case SidTypeLabel:
48 48 *ret_type = IDMAP_USID;
49 49 return (IDMAP_SUCCESS);
50 50 case SidTypeGroup:
51 51 case SidTypeAlias:
52 52 case SidTypeWellKnownGroup:
53 53 *ret_type = IDMAP_GSID;
54 54 return (IDMAP_SUCCESS);
55 55 case SidTypeNull:
56 56 case SidTypeInvalid:
57 57 default:
58 58 idmapdlog(LOG_WARNING,
59 59 "LSA lookup: bad type %d for %s@%s",
60 60 acct->a_sidtype, acct->a_name, acct->a_domain);
61 61 return (IDMAP_ERR_OTHER);
62 62 }
63 63 NOTE(NOTREACHED)
64 64 }
65 65
66 66 /* Given SID, look up name and type */
67 67 idmap_retcode
68 68 lookup_lsa_by_sid(
69 69 const char *sidprefix,
70 70 uint32_t rid,
71 71 char **ret_name,
72 72 char **ret_domain,
73 73 idmap_id_type *ret_type)
74 74 {
75 75 lsa_account_t acct;
|
↓ open down ↓ |
41 lines elided |
↑ open up ↑ |
76 76 char sid[SMB_SID_STRSZ + 1];
77 77 idmap_retcode ret;
78 78 int rc;
79 79
80 80 (void) memset(&acct, 0, sizeof (acct));
81 81 *ret_name = NULL;
82 82 *ret_domain = NULL;
83 83
84 84 (void) snprintf(sid, sizeof (sid), "%s-%u", sidprefix, rid);
85 85
86 - rc = smb_lookup_sid(sid, &acct);
86 + rc = smb_lookup_lsid(sid, &acct);
87 87 if (rc != 0) {
88 88 idmapdlog(LOG_ERR, "Error: smb_lookup_sid failed.");
89 89 idmapdlog(LOG_ERR,
90 90 "Check SMB service (svc:/network/smb/server).");
91 91 idmapdlog(LOG_ERR,
92 92 "Check connectivity to Active Directory.");
93 93
94 94 ret = IDMAP_ERR_OTHER;
95 95 goto out;
96 96 }
97 97 if (acct.a_status == NT_STATUS_NONE_MAPPED) {
98 98 ret = IDMAP_ERR_NOTFOUND;
99 99 goto out;
100 100 }
101 101 if (acct.a_status != NT_STATUS_SUCCESS) {
102 102 idmapdlog(LOG_WARNING,
103 103 "Warning: smb_lookup_sid(%s) failed (0x%x)",
104 104 sid, acct.a_status);
105 105 /* Fail soft */
106 106 ret = IDMAP_ERR_NOTFOUND;
107 107 goto out;
108 108 }
109 109
110 110 ret = idmap_lsa_xlate_sid_type(&acct, ret_type);
111 111 if (ret != IDMAP_SUCCESS)
112 112 goto out;
113 113
114 114 *ret_name = strdup(acct.a_name);
115 115 if (*ret_name == NULL) {
116 116 ret = IDMAP_ERR_MEMORY;
117 117 goto out;
118 118 }
119 119
120 120 *ret_domain = strdup(acct.a_domain);
121 121 if (*ret_domain == NULL) {
122 122 ret = IDMAP_ERR_MEMORY;
123 123 goto out;
124 124 }
125 125
126 126 ret = IDMAP_SUCCESS;
127 127
128 128 out:
129 129 if (ret != IDMAP_SUCCESS) {
130 130 free(*ret_name);
131 131 *ret_name = NULL;
132 132 free(*ret_domain);
133 133 *ret_domain = NULL;
134 134 }
135 135 return (ret);
136 136 }
137 137
138 138 /* Given name and optional domain, look up SID, type, and canonical name */
139 139 idmap_retcode
140 140 lookup_lsa_by_name(
141 141 const char *name,
142 142 const char *domain,
143 143 char **ret_sidprefix,
144 144 uint32_t *ret_rid,
145 145 char **ret_name,
146 146 char **ret_domain,
147 147 idmap_id_type *ret_type)
148 148 {
149 149 lsa_account_t acct;
150 150 char *namedom = NULL;
151 151 idmap_retcode ret;
152 152 int rc;
153 153
154 154 (void) memset(&acct, 0, sizeof (acct));
155 155 *ret_sidprefix = NULL;
156 156 if (ret_name != NULL)
157 157 *ret_name = NULL;
158 158 if (ret_domain != NULL)
159 159 *ret_domain = NULL;
|
↓ open down ↓ |
63 lines elided |
↑ open up ↑ |
160 160
161 161 if (domain != NULL)
162 162 (void) asprintf(&namedom, "%s@%s", name, domain);
163 163 else
164 164 namedom = strdup(name);
165 165 if (namedom == NULL) {
166 166 ret = IDMAP_ERR_MEMORY;
167 167 goto out;
168 168 }
169 169
170 - rc = smb_lookup_name(namedom, SidTypeUnknown, &acct);
170 + rc = smb_lookup_lname(namedom, SidTypeUnknown, &acct);
171 171 if (rc != 0) {
172 172 idmapdlog(LOG_ERR, "Error: smb_lookup_name failed.");
173 173 idmapdlog(LOG_ERR,
174 174 "Check SMB service (svc:/network/smb/server).");
175 175 idmapdlog(LOG_ERR,
176 176 "Check connectivity to Active Directory.");
177 177 ret = IDMAP_ERR_OTHER;
178 178 goto out;
179 179 }
180 180 if (acct.a_status == NT_STATUS_NONE_MAPPED) {
181 181 ret = IDMAP_ERR_NOTFOUND;
182 182 goto out;
183 183 }
184 184 if (acct.a_status != NT_STATUS_SUCCESS) {
185 185 idmapdlog(LOG_WARNING,
186 186 "Warning: smb_lookup_name(%s) failed (0x%x)",
187 187 namedom, acct.a_status);
188 188 /* Fail soft */
189 189 ret = IDMAP_ERR_NOTFOUND;
190 190 goto out;
191 191 }
192 192
193 193 rc = smb_sid_splitstr(acct.a_sid, ret_rid);
194 194 assert(rc == 0);
195 195 *ret_sidprefix = strdup(acct.a_sid);
196 196 if (*ret_sidprefix == NULL) {
197 197 ret = IDMAP_ERR_MEMORY;
198 198 goto out;
199 199 }
200 200
201 201 ret = idmap_lsa_xlate_sid_type(&acct, ret_type);
202 202 if (ret != IDMAP_SUCCESS)
203 203 goto out;
204 204
205 205 if (ret_name != NULL) {
206 206 *ret_name = strdup(acct.a_name);
207 207 if (*ret_name == NULL) {
208 208 ret = IDMAP_ERR_MEMORY;
209 209 goto out;
210 210 }
211 211 }
212 212
213 213 if (ret_domain != NULL) {
214 214 *ret_domain = strdup(acct.a_domain);
215 215 if (*ret_domain == NULL) {
216 216 ret = IDMAP_ERR_MEMORY;
217 217 goto out;
218 218 }
219 219 }
220 220
221 221 ret = IDMAP_SUCCESS;
222 222
223 223 out:
224 224 free(namedom);
225 225 if (ret != IDMAP_SUCCESS) {
226 226 if (ret_name != NULL) {
227 227 free(*ret_name);
228 228 *ret_name = NULL;
229 229 }
230 230 if (ret_domain != NULL) {
231 231 free(*ret_domain);
232 232 *ret_domain = NULL;
233 233 }
234 234 free(*ret_sidprefix);
235 235 *ret_sidprefix = NULL;
236 236 }
237 237 return (ret);
238 238 }
239 239
240 240 /*
241 241 * This exists just so we can avoid exposing all of idmapd to libsmb.h.
242 242 * Like the above functions, it's a door call over to smbd.
243 243 */
244 244 void
245 245 notify_dc_changed(void)
246 246 {
247 247 smb_notify_dc_changed();
248 248 }
|
↓ open down ↓ |
68 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX