kidmap_priv.h revision 32ff2b3c67debc0dc66e07986e072d489ea88322
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/*
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * CDDL HEADER START
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * The contents of this file are subject to the terms of the
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * Common Development and Distribution License (the "License").
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * You may not use this file except in compliance with the License.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * or http://www.opensolaris.org/os/licensing.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * See the License for the specific language governing permissions
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * and limitations under the License.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * When distributing Covered Code, include this CDDL HEADER in each
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * If applicable, add the following below this CDDL HEADER, with the
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * fields enclosed by brackets "[]" replaced with your own identifying
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * information: Portions Copyright [yyyy] [name of copyright owner]
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw *
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * CDDL HEADER END
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/*
f7b4b2fefbe31d31fbe1e6a4b494a8fbed3f49b1jp * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * Use is subject to license terms.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw/*
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * Windows to Solaris Identity Mapping kernel API
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw * This header file contains private definitions.
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#ifndef _KIDMAP_PRIV_H
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#define _KIDMAP_PRIV_H
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#include <sys/avl.h>
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#ifdef __cplusplus
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwextern "C" {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#endif
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullentypedef struct sid2pid {
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen avl_node_t avl_link;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen struct sid2pid *flink;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen struct sid2pid *blink;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen const char *sid_prefix;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen uint32_t rid;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen uid_t uid;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen time_t uid_ttl;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen gid_t gid;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen time_t gid_ttl;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen int is_user;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen} sid2pid_t;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullentypedef struct pid2sid {
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen avl_node_t avl_link;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen struct pid2sid *flink;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen struct pid2sid *blink;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen const char *sid_prefix;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen uint32_t rid;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen uid_t pid;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen time_t ttl;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen} pid2sid_t;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp
d15447b6c777a1b2223924443bf36c9c8efb2ea4jptypedef struct idmap_sid2pid_cache {
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp avl_tree_t tree;
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp kmutex_t mutex;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen struct sid2pid head;
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp time_t purge_time;
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp int uid_num;
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp int gid_num;
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp int pid_num;
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp} idmap_sid2pid_cache_t;
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp
d15447b6c777a1b2223924443bf36c9c8efb2ea4jptypedef struct idmap_pid2sid_cache {
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw avl_tree_t tree;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw kmutex_t mutex;
32ff2b3c67debc0dc66e07986e072d489ea88322Julian Pullen struct pid2sid head;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw time_t purge_time;
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp} idmap_pid2sid_cache_t;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
0b10de9fc92843e871f48de87f623808c5913a71jp
0b10de9fc92843e871f48de87f623808c5913a71jp/*
0b10de9fc92843e871f48de87f623808c5913a71jp * There is a cache for every mapping request because a group SID
0b10de9fc92843e871f48de87f623808c5913a71jp * on Windows can be set in a file owner field and versa-visa.
0b10de9fc92843e871f48de87f623808c5913a71jp * To stop this causing problems on Solaris a SID can map to
0b10de9fc92843e871f48de87f623808c5913a71jp * both a UID and a GID.
0b10de9fc92843e871f48de87f623808c5913a71jp */
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwtypedef struct idmap_cache {
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp idmap_sid2pid_cache_t sid2pid;
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp idmap_pid2sid_cache_t uid2sid;
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp idmap_pid2sid_cache_t gid2sid;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw} idmap_cache_t;
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwvoid
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwkidmap_cache_create(idmap_cache_t *cache);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwvoid
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwkidmap_cache_delete(idmap_cache_t *cache);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
0b10de9fc92843e871f48de87f623808c5913a71jpvoid
0b10de9fc92843e871f48de87f623808c5913a71jpkidmap_cache_purge(idmap_cache_t *cache);
0b10de9fc92843e871f48de87f623808c5913a71jp
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwint
0b10de9fc92843e871f48de87f623808c5913a71jpkidmap_cache_lookup_uidbysid(idmap_cache_t *cache, const char *sid_prefix,
0b10de9fc92843e871f48de87f623808c5913a71jp uint32_t rid, uid_t *uid);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwint
0b10de9fc92843e871f48de87f623808c5913a71jpkidmap_cache_lookup_gidbysid(idmap_cache_t *cache, const char *sid_prefix,
0b10de9fc92843e871f48de87f623808c5913a71jp uint32_t rid, gid_t *gid);
0b10de9fc92843e871f48de87f623808c5913a71jp
0b10de9fc92843e871f48de87f623808c5913a71jpint
0b10de9fc92843e871f48de87f623808c5913a71jpkidmap_cache_lookup_pidbysid(idmap_cache_t *cache, const char *sid_prefix,
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw uint32_t rid, uid_t *pid, int *is_user);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
0b10de9fc92843e871f48de87f623808c5913a71jpint
0b10de9fc92843e871f48de87f623808c5913a71jpkidmap_cache_lookup_sidbyuid(idmap_cache_t *cache, const char **sid_prefix,
0b10de9fc92843e871f48de87f623808c5913a71jp uint32_t *rid, uid_t uid);
0b10de9fc92843e871f48de87f623808c5913a71jp
0b10de9fc92843e871f48de87f623808c5913a71jpint
0b10de9fc92843e871f48de87f623808c5913a71jpkidmap_cache_lookup_sidbygid(idmap_cache_t *cache, const char **sid_prefix,
0b10de9fc92843e871f48de87f623808c5913a71jp uint32_t *rid, gid_t gid);
0b10de9fc92843e871f48de87f623808c5913a71jp
0b10de9fc92843e871f48de87f623808c5913a71jp
0b10de9fc92843e871f48de87f623808c5913a71jpvoid
d15447b6c777a1b2223924443bf36c9c8efb2ea4jpkidmap_cache_add_sid2uid(idmap_cache_t *cache, const char *sid_prefix,
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp uint32_t rid, uid_t uid, int direction);
0b10de9fc92843e871f48de87f623808c5913a71jp
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwvoid
d15447b6c777a1b2223924443bf36c9c8efb2ea4jpkidmap_cache_add_sid2gid(idmap_cache_t *cache, const char *sid_prefix,
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp uint32_t rid, gid_t gid, int direction);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwvoid
d15447b6c777a1b2223924443bf36c9c8efb2ea4jpkidmap_cache_add_sid2pid(idmap_cache_t *cache, const char *sid_prefix,
d15447b6c777a1b2223924443bf36c9c8efb2ea4jp uint32_t rid, uid_t pid, int is_user, int direction);
f7b4b2fefbe31d31fbe1e6a4b494a8fbed3f49b1jpvoid
f7b4b2fefbe31d31fbe1e6a4b494a8fbed3f49b1jpkidmap_cache_get_data(idmap_cache_t *cache, size_t *uidbysid, size_t *gidbysid,
f7b4b2fefbe31d31fbe1e6a4b494a8fbed3f49b1jp size_t *pidbysid, size_t *sidbyuid, size_t *sidbygid);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwint
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwkidmap_start(void);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwint
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwkidmap_stop(void);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwvoid
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwkidmap_sid_prefix_store_init(void);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwconst char *
c5c4113dfcabb1eed3d4bdf7609de5170027a794nwkidmap_find_sid_prefix(const char *sid_prefix);
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#ifdef __cplusplus
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw}
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#endif
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw
c5c4113dfcabb1eed3d4bdf7609de5170027a794nw#endif /* _KIDMAP_PRIV_H */