idmap.h revision 7369:2d92536a8d73
1178825Sdfr/*
2233294Sstas * CDDL HEADER START
3233294Sstas *
4233294Sstas * The contents of this file are subject to the terms of the
5178825Sdfr * Common Development and Distribution License (the "License").
6233294Sstas * You may not use this file except in compliance with the License.
7233294Sstas *
8233294Sstas * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9178825Sdfr * or http://www.opensolaris.org/os/licensing.
10233294Sstas * See the License for the specific language governing permissions
11233294Sstas * and limitations under the License.
12178825Sdfr *
13233294Sstas * When distributing Covered Code, include this CDDL HEADER in each
14233294Sstas * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15233294Sstas * If applicable, add the following below this CDDL HEADER, with the
16178825Sdfr * fields enclosed by brackets "[]" replaced with your own identifying
17233294Sstas * information: Portions Copyright [yyyy] [name of copyright owner]
18233294Sstas *
19233294Sstas * CDDL HEADER END
20178825Sdfr */
21233294Sstas/*
22233294Sstas * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23233294Sstas * Use is subject to license terms.
24233294Sstas */
25233294Sstas
26233294Sstas/*
27233294Sstas * Header File for Clients of Native Identity Mapping Service
28233294Sstas */
29233294Sstas
30233294Sstas#ifndef _IDMAP_H
31233294Sstas#define	_IDMAP_H
32178825Sdfr
33178825Sdfr
34233294Sstas#include <stdlib.h>
35178825Sdfr#include <ctype.h>
36233294Sstas#include <sys/param.h>
37233294Sstas#include <sys/types.h>
38233294Sstas#include <sys/stat.h>
39233294Sstas#include <sys/idmap.h>
40233294Sstas
41178825Sdfr#ifdef __cplusplus
42178825Sdfrextern "C" {
43178825Sdfr#endif
44233294Sstas
45178825Sdfr/* Status */
46178825Sdfrtypedef int32_t	idmap_stat;
47178825Sdfr
48178825Sdfrtypedef uint32_t	idmap_rid_t;
49178825Sdfr
50178825Sdfr/* Opaque client handle */
51178825Sdfrtypedef struct idmap_handle idmap_handle_t;
52178825Sdfr
53178825Sdfr/* Opaque "get-mapping" handle */
54178825Sdfrtypedef struct idmap_get_handle idmap_get_handle_t;
55178825Sdfr
56178825Sdfr
57178825Sdfr
58178825Sdfr/*
59178825Sdfr * Setup API
60178825Sdfr */
61178825Sdfr/* Create/Init handle for userland clients */
62178825Sdfrextern idmap_stat idmap_init(idmap_handle_t **);
63178825Sdfr
64233294Sstas/* Finalize/close handle */
65178825Sdfrextern idmap_stat idmap_fini(idmap_handle_t *);
66233294Sstas
67233294Sstas/* Status code to string */
68178825Sdfrextern const char *idmap_stat2string(idmap_handle_t *, idmap_stat);
69178825Sdfr
70178825Sdfr/* Free memory allocated by the API */
71178825Sdfrextern void idmap_free(void *);
72178825Sdfr
73178825Sdfr
74178825Sdfr/*
75233294Sstas * Supported flag values for mapping requests.
76178825Sdfr * These flag values are applicable to the batch API and the
77178825Sdfr * Windows Name API below.
78 */
79/* Use the libidmap cache */
80#define	IDMAP_REQ_FLG_USE_CACHE	0x00000010
81
82/*
83 * API to batch SID to UID/GID mapping requests
84 */
85/* Create handle */
86extern idmap_stat idmap_get_create(idmap_handle_t *, idmap_get_handle_t **);
87
88/* Given SID, get UID */
89extern idmap_stat idmap_get_uidbysid(idmap_get_handle_t *, char *,
90	idmap_rid_t, int, uid_t *, idmap_stat *);
91
92/* Given SID, get GID */
93extern idmap_stat idmap_get_gidbysid(idmap_get_handle_t *, char *,
94	idmap_rid_t, int, gid_t *, idmap_stat *);
95
96/* Given SID, get UID or GID */
97extern idmap_stat idmap_get_pidbysid(idmap_get_handle_t *, char *,
98	idmap_rid_t, int, uid_t *, int *, idmap_stat *);
99
100/* Given UID, get SID */
101extern idmap_stat idmap_get_sidbyuid(idmap_get_handle_t *, uid_t, int,
102	char **, idmap_rid_t *, idmap_stat *);
103
104/* Given GID, get SID */
105extern idmap_stat idmap_get_sidbygid(idmap_get_handle_t *, gid_t, int,
106	char **, idmap_rid_t *, idmap_stat *);
107
108/* Process the batched requests */
109extern idmap_stat idmap_get_mappings(idmap_get_handle_t *);
110
111/* Destroy the handle */
112extern void idmap_get_destroy(idmap_get_handle_t *);
113
114
115/*
116 * API to get Windows name by UID/GID and vice-versa
117 */
118/* Given UID, get Windows name */
119extern idmap_stat idmap_getwinnamebyuid(uid_t, int, char **, char **);
120
121/* Given GID, get Windows name */
122extern idmap_stat idmap_getwinnamebygid(gid_t, int, char **, char **);
123
124/* Given Windows name, get UID */
125extern idmap_stat idmap_getuidbywinname(const char *, const char *,
126	int, uid_t *);
127
128/* Given Windows name, get GID */
129extern idmap_stat idmap_getgidbywinname(const char *, const char *,
130	int, gid_t *);
131
132
133#ifdef __cplusplus
134}
135#endif
136
137#endif /* _IDMAP_H */
138