1c5c4113dSnw141292 /* 2c5c4113dSnw141292 * CDDL HEADER START 3c5c4113dSnw141292 * 4c5c4113dSnw141292 * The contents of this file are subject to the terms of the 5c5c4113dSnw141292 * Common Development and Distribution License (the "License"). 6c5c4113dSnw141292 * You may not use this file except in compliance with the License. 7c5c4113dSnw141292 * 8c5c4113dSnw141292 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9c5c4113dSnw141292 * or http://www.opensolaris.org/os/licensing. 10c5c4113dSnw141292 * See the License for the specific language governing permissions 11c5c4113dSnw141292 * and limitations under the License. 12c5c4113dSnw141292 * 13c5c4113dSnw141292 * When distributing Covered Code, include this CDDL HEADER in each 14c5c4113dSnw141292 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15c5c4113dSnw141292 * If applicable, add the following below this CDDL HEADER, with the 16c5c4113dSnw141292 * fields enclosed by brackets "[]" replaced with your own identifying 17c5c4113dSnw141292 * information: Portions Copyright [yyyy] [name of copyright owner] 18c5c4113dSnw141292 * 19c5c4113dSnw141292 * CDDL HEADER END 20c5c4113dSnw141292 */ 21c5c4113dSnw141292 /* 22c5866007SKeyur Desai * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 23*b819cea2SGordon Ross * Copyright 2013 Nexenta Systems, Inc. All rights reserved. 24c5c4113dSnw141292 */ 25c5c4113dSnw141292 26c5c4113dSnw141292 /* 27c5c4113dSnw141292 * Header File for Clients of Native Identity Mapping Service 28c5c4113dSnw141292 */ 29c5c4113dSnw141292 30c5c4113dSnw141292 #ifndef _IDMAP_H 31c5c4113dSnw141292 #define _IDMAP_H 32c5c4113dSnw141292 33c5c4113dSnw141292 34c5c4113dSnw141292 #include <stdlib.h> 35c5c4113dSnw141292 #include <ctype.h> 36c5c4113dSnw141292 #include <sys/param.h> 37c5c4113dSnw141292 #include <sys/types.h> 38c5c4113dSnw141292 #include <sys/stat.h> 39c5c4113dSnw141292 #include <sys/idmap.h> 40c5c4113dSnw141292 41c5c4113dSnw141292 #ifdef __cplusplus 42c5c4113dSnw141292 extern "C" { 43c5c4113dSnw141292 #endif 44c5c4113dSnw141292 45*b819cea2SGordon Ross /* 46*b819cea2SGordon Ross * The ifdef's for these two accomodate duplicate definitions in 47*b819cea2SGordon Ross * lib/smbsrv/libfksmbsrv/common/sys/kidmap.h See notes there. 48*b819cea2SGordon Ross */ 49*b819cea2SGordon Ross 50c5c4113dSnw141292 /* Status */ 51*b819cea2SGordon Ross #ifndef _IDMAP_STAT_TYPE 52*b819cea2SGordon Ross #define _IDMAP_STAT_TYPE 53c5c4113dSnw141292 typedef int32_t idmap_stat; 54*b819cea2SGordon Ross #endif /* _IDMAP_STAT_TYPE */ 55*b819cea2SGordon Ross 56*b819cea2SGordon Ross /* Opaque get handle */ 57*b819cea2SGordon Ross #ifndef _IDMAP_GET_HANDLE_T 58*b819cea2SGordon Ross #define _IDMAP_GET_HANDLE_T 59*b819cea2SGordon Ross typedef struct idmap_get_handle idmap_get_handle_t; 60*b819cea2SGordon Ross #endif /* _IDMAP_GET_HANDLE_T */ 61c5c4113dSnw141292 62c5c4113dSnw141292 typedef uint32_t idmap_rid_t; 63c5c4113dSnw141292 647a8a68f5SJulian Pullen /* Logger prototype which is based on syslog */ 65c5866007SKeyur Desai typedef void (*idmap_logger_t)(int, const char *, ...); 66479ac375Sdm199847 67c5c4113dSnw141292 /* 68c5c4113dSnw141292 * Setup API 69c5c4113dSnw141292 */ 70c5c4113dSnw141292 71c5c4113dSnw141292 /* Status code to string */ 721fdeec65Sjoyce mcintosh extern const char *idmap_stat2string(idmap_stat); 73c5c4113dSnw141292 74c5c4113dSnw141292 /* Free memory allocated by the API */ 75c5c4113dSnw141292 extern void idmap_free(void *); 76c5c4113dSnw141292 77c5c4113dSnw141292 78c5c4113dSnw141292 /* 793ee87bcaSJulian Pullen * Supported flag values for mapping requests. 803ee87bcaSJulian Pullen * These flag values are applicable to the batch API and the 813ee87bcaSJulian Pullen * Windows Name API below. 823ee87bcaSJulian Pullen */ 833ee87bcaSJulian Pullen /* Use the libidmap cache */ 843ee87bcaSJulian Pullen #define IDMAP_REQ_FLG_USE_CACHE 0x00000010 853ee87bcaSJulian Pullen 863ee87bcaSJulian Pullen /* 87c5c4113dSnw141292 * API to batch SID to UID/GID mapping requests 88c5c4113dSnw141292 */ 89c5c4113dSnw141292 /* Create handle */ 901fdeec65Sjoyce mcintosh extern idmap_stat idmap_get_create(idmap_get_handle_t **); 91c5c4113dSnw141292 92c5c4113dSnw141292 /* Given SID, get UID */ 93c5c4113dSnw141292 extern idmap_stat idmap_get_uidbysid(idmap_get_handle_t *, char *, 94c5c4113dSnw141292 idmap_rid_t, int, uid_t *, idmap_stat *); 95c5c4113dSnw141292 96c5c4113dSnw141292 /* Given SID, get GID */ 97c5c4113dSnw141292 extern idmap_stat idmap_get_gidbysid(idmap_get_handle_t *, char *, 98c5c4113dSnw141292 idmap_rid_t, int, gid_t *, idmap_stat *); 99c5c4113dSnw141292 100c5c4113dSnw141292 /* Given SID, get UID or GID */ 101c5c4113dSnw141292 extern idmap_stat idmap_get_pidbysid(idmap_get_handle_t *, char *, 102c5c4113dSnw141292 idmap_rid_t, int, uid_t *, int *, idmap_stat *); 103c5c4113dSnw141292 104c5c4113dSnw141292 /* Given UID, get SID */ 105c5c4113dSnw141292 extern idmap_stat idmap_get_sidbyuid(idmap_get_handle_t *, uid_t, int, 106c5c4113dSnw141292 char **, idmap_rid_t *, idmap_stat *); 107c5c4113dSnw141292 108c5c4113dSnw141292 /* Given GID, get SID */ 109c5c4113dSnw141292 extern idmap_stat idmap_get_sidbygid(idmap_get_handle_t *, gid_t, int, 110c5c4113dSnw141292 char **, idmap_rid_t *, idmap_stat *); 111c5c4113dSnw141292 112c5c4113dSnw141292 /* Process the batched requests */ 113c5c4113dSnw141292 extern idmap_stat idmap_get_mappings(idmap_get_handle_t *); 114c5c4113dSnw141292 115c5c4113dSnw141292 /* Destroy the handle */ 116c5c4113dSnw141292 extern void idmap_get_destroy(idmap_get_handle_t *); 117c5c4113dSnw141292 118dd5829d1Sbaban 119dd5829d1Sbaban /* 120dd5829d1Sbaban * API to get Windows name by UID/GID and vice-versa 121dd5829d1Sbaban */ 122dd5829d1Sbaban /* Given UID, get Windows name */ 1233ee87bcaSJulian Pullen extern idmap_stat idmap_getwinnamebyuid(uid_t, int, char **, char **); 124dd5829d1Sbaban 125dd5829d1Sbaban /* Given GID, get Windows name */ 1263ee87bcaSJulian Pullen extern idmap_stat idmap_getwinnamebygid(gid_t, int, char **, char **); 127dd5829d1Sbaban 1281ed6b69aSGordon Ross /* Given PID, get Windows name */ 1291ed6b69aSGordon Ross extern idmap_stat idmap_getwinnamebypid(uid_t, int, int, char **, char **); 1301ed6b69aSGordon Ross 131dd5829d1Sbaban /* Given Windows name, get UID */ 1323ee87bcaSJulian Pullen extern idmap_stat idmap_getuidbywinname(const char *, const char *, 1333ee87bcaSJulian Pullen int, uid_t *); 134dd5829d1Sbaban 135dd5829d1Sbaban /* Given Windows name, get GID */ 1363ee87bcaSJulian Pullen extern idmap_stat idmap_getgidbywinname(const char *, const char *, 1373ee87bcaSJulian Pullen int, gid_t *); 138dd5829d1Sbaban 139dd5829d1Sbaban 1407a8a68f5SJulian Pullen /* Logger */ 141c5866007SKeyur Desai extern void idmap_set_logger(idmap_logger_t funct); 1427a8a68f5SJulian Pullen 143c5c4113dSnw141292 #ifdef __cplusplus 144c5c4113dSnw141292 } 145c5c4113dSnw141292 #endif 146c5c4113dSnw141292 147c5c4113dSnw141292 #endif /* _IDMAP_H */ 148