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 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * Windows to Solaris Identity Mapping kernel API
29 * This module provides an API to map Windows SIDs to
30 * Solaris UID and GIDs.
31 */
32
33
34 #include <sys/types.h>
35 #include <sys/ksynch.h>
36 #include <sys/door.h>
37 #include <rpc/rpc_msg.h>
38 #include <rpc/xdr.h>
39 #include <rpc/auth.h>
40 #include <rpc/rpc_sztypes.h>
41 #ifdef DEBUG
42 #include <sys/cmn_err.h>
43 #endif /* DEBUG */
44 #include <sys/proc.h>
1290 request->id1.idmap_id_u.sid.rid,
1291 id->idmap_id_u.gid,
1292 direction);
1293 else if (*result->stat == IDMAP_SUCCESS && result->pid)
1294 kidmap_cache_add_sid2pid(
1295 cache, sid_prefix,
1296 request->id1.idmap_id_u.sid.rid,
1297 id->idmap_id_u.gid, 0,
1298 direction);
1299 break;
1300
1301 case IDMAP_SID:
1302 case IDMAP_USID:
1303 case IDMAP_GSID:
1304 sid_prefix = kidmap_find_sid_prefix(
1305 id->idmap_id_u.sid.prefix);
1306 if (result->sid_prefix && result->rid) {
1307 *result->sid_prefix = sid_prefix;
1308 *result->rid = id->idmap_id_u.sid.rid;
1309 }
1310 if (*result->stat == IDMAP_SUCCESS &&
1311 request->id1.idtype == IDMAP_UID)
1312 kidmap_cache_add_sid2uid(
1313 cache, sid_prefix,
1314 id->idmap_id_u.sid.rid,
1315 request->id1.idmap_id_u.uid,
1316 direction);
1317 else if (*result->stat == IDMAP_SUCCESS &&
1318 request->id1.idtype == IDMAP_GID)
1319 kidmap_cache_add_sid2gid(
1320 cache, sid_prefix,
1321 id->idmap_id_u.sid.rid,
1322 request->id1.idmap_id_u.gid,
1323 direction);
1324 break;
1325
1326 default:
1327 *result->stat = IDMAP_ERR_NORESULT;
1328 if (result->uid)
1329 *result->uid = UID_NOBODY;
|
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 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 *
26 * Copyright 2018 Nexenta Systems, Inc.
27 */
28
29 /*
30 * Windows to Solaris Identity Mapping kernel API
31 * This module provides an API to map Windows SIDs to
32 * Solaris UID and GIDs.
33 */
34
35
36 #include <sys/types.h>
37 #include <sys/ksynch.h>
38 #include <sys/door.h>
39 #include <rpc/rpc_msg.h>
40 #include <rpc/xdr.h>
41 #include <rpc/auth.h>
42 #include <rpc/rpc_sztypes.h>
43 #ifdef DEBUG
44 #include <sys/cmn_err.h>
45 #endif /* DEBUG */
46 #include <sys/proc.h>
1292 request->id1.idmap_id_u.sid.rid,
1293 id->idmap_id_u.gid,
1294 direction);
1295 else if (*result->stat == IDMAP_SUCCESS && result->pid)
1296 kidmap_cache_add_sid2pid(
1297 cache, sid_prefix,
1298 request->id1.idmap_id_u.sid.rid,
1299 id->idmap_id_u.gid, 0,
1300 direction);
1301 break;
1302
1303 case IDMAP_SID:
1304 case IDMAP_USID:
1305 case IDMAP_GSID:
1306 sid_prefix = kidmap_find_sid_prefix(
1307 id->idmap_id_u.sid.prefix);
1308 if (result->sid_prefix && result->rid) {
1309 *result->sid_prefix = sid_prefix;
1310 *result->rid = id->idmap_id_u.sid.rid;
1311 }
1312 if (*result->stat == IDMAP_ERR_NOTFOUND &&
1313 sid_prefix != NULL) {
1314 /* IDMAP generated a local SID. Use it. */
1315 *result->stat = IDMAP_SUCCESS;
1316 }
1317
1318 if (*result->stat == IDMAP_SUCCESS &&
1319 request->id1.idtype == IDMAP_UID)
1320 kidmap_cache_add_sid2uid(
1321 cache, sid_prefix,
1322 id->idmap_id_u.sid.rid,
1323 request->id1.idmap_id_u.uid,
1324 direction);
1325 else if (*result->stat == IDMAP_SUCCESS &&
1326 request->id1.idtype == IDMAP_GID)
1327 kidmap_cache_add_sid2gid(
1328 cache, sid_prefix,
1329 id->idmap_id_u.sid.rid,
1330 request->id1.idmap_id_u.gid,
1331 direction);
1332 break;
1333
1334 default:
1335 *result->stat = IDMAP_ERR_NORESULT;
1336 if (result->uid)
1337 *result->uid = UID_NOBODY;
|