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 /* 22*479ac375Sdm199847 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23c5c4113dSnw141292 * Use is subject to license terms. 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 #pragma ident "%Z%%M% %I% %E% SMI" 34c5c4113dSnw141292 35c5c4113dSnw141292 #include <stdlib.h> 36c5c4113dSnw141292 #include <ctype.h> 37c5c4113dSnw141292 #include <sys/param.h> 38c5c4113dSnw141292 #include <sys/types.h> 39c5c4113dSnw141292 #include <sys/stat.h> 40c5c4113dSnw141292 #include <sys/idmap.h> 41c5c4113dSnw141292 42c5c4113dSnw141292 #ifdef __cplusplus 43c5c4113dSnw141292 extern "C" { 44c5c4113dSnw141292 #endif 45c5c4113dSnw141292 46c5c4113dSnw141292 /* Status */ 47c5c4113dSnw141292 typedef int32_t idmap_stat; 48c5c4113dSnw141292 49c5c4113dSnw141292 typedef uint32_t idmap_rid_t; 50c5c4113dSnw141292 51c5c4113dSnw141292 /* Opaque client handle */ 52c5c4113dSnw141292 typedef struct idmap_handle idmap_handle_t; 53c5c4113dSnw141292 54c5c4113dSnw141292 /* Opaque "get-mapping" handle */ 55c5c4113dSnw141292 typedef struct idmap_get_handle idmap_get_handle_t; 56c5c4113dSnw141292 57c5c4113dSnw141292 58*479ac375Sdm199847 59c5c4113dSnw141292 /* 60c5c4113dSnw141292 * Setup API 61c5c4113dSnw141292 */ 62c5c4113dSnw141292 /* Create/Init handle for userland clients */ 63c5c4113dSnw141292 extern idmap_stat idmap_init(idmap_handle_t **); 64c5c4113dSnw141292 65c5c4113dSnw141292 /* Finalize/close handle */ 66c5c4113dSnw141292 extern idmap_stat idmap_fini(idmap_handle_t *); 67c5c4113dSnw141292 68c5c4113dSnw141292 /* Status code to string */ 69c5c4113dSnw141292 extern const char *idmap_stat2string(idmap_handle_t *, idmap_stat); 70c5c4113dSnw141292 71c5c4113dSnw141292 /* Free memory allocated by the API */ 72c5c4113dSnw141292 extern void idmap_free(void *); 73c5c4113dSnw141292 74c5c4113dSnw141292 75c5c4113dSnw141292 /* 76*479ac375Sdm199847 * Directory based name map API 77*479ac375Sdm199847 */ 78*479ac375Sdm199847 79*479ac375Sdm199847 /* Set namemap */ 80*479ac375Sdm199847 extern idmap_stat idmap_set_namemap(char *, char *, char *, 81*479ac375Sdm199847 char *, char *, char *, int, int, int); 82*479ac375Sdm199847 83*479ac375Sdm199847 /* Unset namemap */ 84*479ac375Sdm199847 extern idmap_stat idmap_unset_namemap(char *, char *, char *, 85*479ac375Sdm199847 char *, char *, char *, int, int, int); 86*479ac375Sdm199847 87*479ac375Sdm199847 extern idmap_stat idmap_get_namemap(int *, char **, char **, int *, char **, 88*479ac375Sdm199847 char **); 89*479ac375Sdm199847 90*479ac375Sdm199847 /* 91c5c4113dSnw141292 * API to batch SID to UID/GID mapping requests 92c5c4113dSnw141292 */ 93c5c4113dSnw141292 /* Create handle */ 94c5c4113dSnw141292 extern idmap_stat idmap_get_create(idmap_handle_t *, idmap_get_handle_t **); 95c5c4113dSnw141292 96c5c4113dSnw141292 /* Given SID, get UID */ 97c5c4113dSnw141292 extern idmap_stat idmap_get_uidbysid(idmap_get_handle_t *, char *, 98c5c4113dSnw141292 idmap_rid_t, int, uid_t *, idmap_stat *); 99c5c4113dSnw141292 100c5c4113dSnw141292 /* Given SID, get GID */ 101c5c4113dSnw141292 extern idmap_stat idmap_get_gidbysid(idmap_get_handle_t *, char *, 102c5c4113dSnw141292 idmap_rid_t, int, gid_t *, idmap_stat *); 103c5c4113dSnw141292 104c5c4113dSnw141292 /* Given SID, get UID or GID */ 105c5c4113dSnw141292 extern idmap_stat idmap_get_pidbysid(idmap_get_handle_t *, char *, 106c5c4113dSnw141292 idmap_rid_t, int, uid_t *, int *, idmap_stat *); 107c5c4113dSnw141292 108c5c4113dSnw141292 /* Given UID, get SID */ 109c5c4113dSnw141292 extern idmap_stat idmap_get_sidbyuid(idmap_get_handle_t *, uid_t, int, 110c5c4113dSnw141292 char **, idmap_rid_t *, idmap_stat *); 111c5c4113dSnw141292 112c5c4113dSnw141292 /* Given GID, get SID */ 113c5c4113dSnw141292 extern idmap_stat idmap_get_sidbygid(idmap_get_handle_t *, gid_t, int, 114c5c4113dSnw141292 char **, idmap_rid_t *, idmap_stat *); 115c5c4113dSnw141292 116c5c4113dSnw141292 /* Process the batched requests */ 117c5c4113dSnw141292 extern idmap_stat idmap_get_mappings(idmap_get_handle_t *); 118c5c4113dSnw141292 119c5c4113dSnw141292 /* Destroy the handle */ 120c5c4113dSnw141292 extern void idmap_get_destroy(idmap_get_handle_t *); 121c5c4113dSnw141292 122dd5829d1Sbaban 123dd5829d1Sbaban /* 124dd5829d1Sbaban * API to get Windows name by UID/GID and vice-versa 125dd5829d1Sbaban */ 126dd5829d1Sbaban /* Given UID, get Windows name */ 127dd5829d1Sbaban extern idmap_stat idmap_getwinnamebyuid(uid_t, char **, char **); 128dd5829d1Sbaban 129dd5829d1Sbaban /* Given GID, get Windows name */ 130dd5829d1Sbaban extern idmap_stat idmap_getwinnamebygid(gid_t, char **, char **); 131dd5829d1Sbaban 132dd5829d1Sbaban /* Given Windows name, get UID */ 133dd5829d1Sbaban extern idmap_stat idmap_getuidbywinname(const char *, const char *, uid_t *); 134dd5829d1Sbaban 135dd5829d1Sbaban /* Given Windows name, get GID */ 136dd5829d1Sbaban extern idmap_stat idmap_getgidbywinname(const char *, const char *, gid_t *); 137dd5829d1Sbaban 138dd5829d1Sbaban 139c5c4113dSnw141292 #ifdef __cplusplus 140c5c4113dSnw141292 } 141c5c4113dSnw141292 #endif 142c5c4113dSnw141292 143c5c4113dSnw141292 #endif /* _IDMAP_H */ 144