dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libidmap / common / idmap.h
blob71cb8042778d4a34833164289b36ab9ad3ec7fae
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
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.
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]
19 * CDDL HEADER END
22 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
27 * Header File for Clients of Native Identity Mapping Service
30 #ifndef _IDMAP_H
31 #define _IDMAP_H
34 #include <stdlib.h>
35 #include <ctype.h>
36 #include <sys/param.h>
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include <sys/idmap.h>
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
45 /* Status */
46 #ifndef _IDMAP_STAT_TYPE
47 #define _IDMAP_STAT_TYPE
48 typedef int32_t idmap_stat;
49 #endif /* _IDMAP_STAT_TYPE */
51 /* Opaque get handle */
52 #ifndef _IDMAP_GET_HANDLE_T
53 #define _IDMAP_GET_HANDLE_T
54 typedef struct idmap_get_handle idmap_get_handle_t;
55 #endif /* _IDMAP_GET_HANDLE_T */
57 typedef uint32_t idmap_rid_t;
59 /* Logger prototype which is based on syslog */
60 typedef void (*idmap_logger_t)(int, const char *, ...);
63 * Setup API
66 /* Status code to string */
67 extern const char *idmap_stat2string(idmap_stat);
69 /* Free memory allocated by the API */
70 extern void idmap_free(void *);
74 * Supported flag values for mapping requests.
75 * These flag values are applicable to the batch API and the
76 * Windows Name API below.
78 /* Use the libidmap cache */
79 #define IDMAP_REQ_FLG_USE_CACHE 0x00000010
82 * API to batch SID to UID/GID mapping requests
84 /* Create handle */
85 extern idmap_stat idmap_get_create(idmap_get_handle_t **);
87 /* Given SID, get UID */
88 extern idmap_stat idmap_get_uidbysid(idmap_get_handle_t *, char *,
89 idmap_rid_t, int, uid_t *, idmap_stat *);
91 /* Given SID, get GID */
92 extern idmap_stat idmap_get_gidbysid(idmap_get_handle_t *, char *,
93 idmap_rid_t, int, gid_t *, idmap_stat *);
95 /* Given SID, get UID or GID */
96 extern idmap_stat idmap_get_pidbysid(idmap_get_handle_t *, char *,
97 idmap_rid_t, int, uid_t *, int *, idmap_stat *);
99 /* Given UID, get SID */
100 extern idmap_stat idmap_get_sidbyuid(idmap_get_handle_t *, uid_t, int,
101 char **, idmap_rid_t *, idmap_stat *);
103 /* Given GID, get SID */
104 extern idmap_stat idmap_get_sidbygid(idmap_get_handle_t *, gid_t, int,
105 char **, idmap_rid_t *, idmap_stat *);
107 /* Process the batched requests */
108 extern idmap_stat idmap_get_mappings(idmap_get_handle_t *);
110 /* Destroy the handle */
111 extern void idmap_get_destroy(idmap_get_handle_t *);
115 * API to get Windows name by UID/GID and vice-versa
117 /* Given UID, get Windows name */
118 extern idmap_stat idmap_getwinnamebyuid(uid_t, int, char **, char **);
120 /* Given GID, get Windows name */
121 extern idmap_stat idmap_getwinnamebygid(gid_t, int, char **, char **);
123 /* Given PID, get Windows name */
124 extern idmap_stat idmap_getwinnamebypid(uid_t, int, int, char **, char **);
126 /* Given Windows name, get UID */
127 extern idmap_stat idmap_getuidbywinname(const char *, const char *,
128 int, uid_t *);
130 /* Given Windows name, get GID */
131 extern idmap_stat idmap_getgidbywinname(const char *, const char *,
132 int, gid_t *);
135 /* Logger */
136 extern void idmap_set_logger(idmap_logger_t funct);
138 #ifdef __cplusplus
140 #endif
142 #endif /* _IDMAP_H */