idmap_priv.h revision 48258c6b4e17f36ab09fba0bd6307d1fec9dcbce
a72f7ea693101cc48bafbb4db6bb437d828011c4ql/*
9aa73b6813b3fd35e78fcc44fd17535e765e504cQin Michael Li * CDDL HEADER START
a72f7ea693101cc48bafbb4db6bb437d828011c4ql *
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * The contents of this file are subject to the terms of the
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * Common Development and Distribution License (the "License").
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * You may not use this file except in compliance with the License.
a72f7ea693101cc48bafbb4db6bb437d828011c4ql *
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * or http://www.opensolaris.org/os/licensing.
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * See the License for the specific language governing permissions
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * and limitations under the License.
a72f7ea693101cc48bafbb4db6bb437d828011c4ql *
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * When distributing Covered Code, include this CDDL HEADER in each
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * If applicable, add the following below this CDDL HEADER, with the
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * fields enclosed by brackets "[]" replaced with your own identifying
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * information: Portions Copyright [yyyy] [name of copyright owner]
a72f7ea693101cc48bafbb4db6bb437d828011c4ql *
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * CDDL HEADER END
a72f7ea693101cc48bafbb4db6bb437d828011c4ql */
a72f7ea693101cc48bafbb4db6bb437d828011c4ql/*
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * Use is subject to license terms.
a72f7ea693101cc48bafbb4db6bb437d828011c4ql */
a72f7ea693101cc48bafbb4db6bb437d828011c4ql
a72f7ea693101cc48bafbb4db6bb437d828011c4ql/*
a72f7ea693101cc48bafbb4db6bb437d828011c4ql * Additional API for Identity Mapping Service
a72f7ea693101cc48bafbb4db6bb437d828011c4ql */
a72f7ea693101cc48bafbb4db6bb437d828011c4ql
a72f7ea693101cc48bafbb4db6bb437d828011c4ql#ifndef _IDMAP_PRIV_H
a72f7ea693101cc48bafbb4db6bb437d828011c4ql#define _IDMAP_PRIV_H
a72f7ea693101cc48bafbb4db6bb437d828011c4ql
a72f7ea693101cc48bafbb4db6bb437d828011c4ql#pragma ident "%Z%%M% %I% %E% SMI"
a72f7ea693101cc48bafbb4db6bb437d828011c4ql
a72f7ea693101cc48bafbb4db6bb437d828011c4ql#include "idmap.h"
a72f7ea693101cc48bafbb4db6bb437d828011c4ql#include "idmap_prot.h"
a72f7ea693101cc48bafbb4db6bb437d828011c4ql
9aa73b6813b3fd35e78fcc44fd17535e765e504cQin Michael Li#ifdef __cplusplus
9aa73b6813b3fd35e78fcc44fd17535e765e504cQin Michael Liextern "C" {
9aa73b6813b3fd35e78fcc44fd17535e765e504cQin Michael Li#endif
9aa73b6813b3fd35e78fcc44fd17535e765e504cQin Michael Li
a72f7ea693101cc48bafbb4db6bb437d828011c4ql#define IDMAP_MAX_NAME_LEN 512
a72f7ea693101cc48bafbb4db6bb437d828011c4ql
a72f7ea693101cc48bafbb4db6bb437d828011c4ql#define IDMAP_ERROR(rc) (rc != IDMAP_SUCCESS && rc != IDMAP_NEXT)
a72f7ea693101cc48bafbb4db6bb437d828011c4ql#define IDMAP_FATAL_ERROR(rc) (rc == IDMAP_ERR_MEMORY ||\
a72f7ea693101cc48bafbb4db6bb437d828011c4ql rc == IDMAP_ERR_DB)
9aa73b6813b3fd35e78fcc44fd17535e765e504cQin Michael Li
9aa73b6813b3fd35e78fcc44fd17535e765e504cQin Michael Li/* Direction in which mapping is valid */
9aa73b6813b3fd35e78fcc44fd17535e765e504cQin Michael Li#define IDMAP_DIRECTION_UNDEF -1 /* not defined */
a72f7ea693101cc48bafbb4db6bb437d828011c4ql#define IDMAP_DIRECTION_BI 0 /* bi-directional */
a72f7ea693101cc48bafbb4db6bb437d828011c4ql#define IDMAP_DIRECTION_W2U 1 /* windows to unix only */
#define IDMAP_DIRECTION_U2W 2 /* unix to windows only */
/* Opaque handle to batch config add/remove operations */
typedef struct idmap_udt_handle idmap_udt_handle_t;
/* Opaque iterator */
typedef struct idmap_iter idmap_iter_t;
/*
* Update API
*/
/* Create handle for updates */
extern idmap_stat idmap_udt_create(idmap_handle_t *,
idmap_udt_handle_t **);
/* Commit */
extern idmap_stat idmap_udt_commit(idmap_udt_handle_t *);
/* Get index of the failed batch element */
extern idmap_stat idmap_udt_get_error_index(idmap_udt_handle_t *, int64_t *);
/* Get the rule which caused the batch to failed */
extern idmap_stat idmap_udt_get_error_rule(idmap_udt_handle_t *, char **,
char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
/* Get the rule which caused a conflict */
extern idmap_stat idmap_udt_get_conflict_rule(idmap_udt_handle_t *, char **,
char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
/* Destroy the update handle */
extern void idmap_udt_destroy(idmap_udt_handle_t *);
/* Add name-based mapping rule */
extern idmap_stat idmap_udt_add_namerule(idmap_udt_handle_t *, const char *,
boolean_t, boolean_t, const char *, const char *, boolean_t, int);
/* Remove name-based mapping rule */
extern idmap_stat idmap_udt_rm_namerule(idmap_udt_handle_t *, boolean_t,
boolean_t, const char *, const char *, const char *, int);
/* Flush name-based mapping rules */
extern idmap_stat idmap_udt_flush_namerules(idmap_udt_handle_t *);
/*
* Iterator API
*/
/* Create a iterator to get SID to UID/GID mappings */
extern idmap_stat idmap_iter_mappings(idmap_handle_t *, idmap_iter_t **,
int flag);
/* Iterate through the SID to UID/GID mappings */
extern idmap_stat idmap_iter_next_mapping(idmap_iter_t *, char **,
idmap_rid_t *, uid_t *, char **, char **, char **, boolean_t *,
boolean_t *, int *, idmap_info *);
/* Create a iterator to get name-based mapping rules */
extern idmap_stat idmap_iter_namerules(idmap_handle_t *, const char *,
boolean_t, boolean_t, const char *, const char *, idmap_iter_t **);
/* Iterate through the name-based mapping rules */
extern idmap_stat idmap_iter_next_namerule(idmap_iter_t *, char **,
char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
/* Set the number of entries requested per batch */
extern idmap_stat idmap_iter_set_limit(idmap_iter_t *, uint64_t);
/* Destroy the iterator */
extern void idmap_iter_destroy(idmap_iter_t *);
/*
* Get mapping
*/
extern idmap_stat idmap_get_w2u_mapping(idmap_handle_t *, const char *,
idmap_rid_t *, const char *, const char *, int, int *, int *,
uid_t *, char **, int *, idmap_info *);
extern idmap_stat idmap_get_u2w_mapping(idmap_handle_t *, uid_t *,
const char *, int, int, int *, char **, idmap_rid_t *, char **,
char **, int *, idmap_info *);
/*
* Miscellaneous
*/
/* string to status */
extern idmap_stat idmap_string2stat(const char *);
/* internal status to protocol status */
extern idmap_stat idmap_stat4prot(idmap_stat);
/* copy idmap_namerule including strings */
extern idmap_stat idmap_namerule_cpy(idmap_namerule *, idmap_namerule *);
/* copy idmap_info info including strings */
extern idmap_stat idmap_info_cpy(idmap_info *to, idmap_info *from);
/* Move idmap_info info including strings */
extern idmap_stat idmap_info_mov(idmap_info *to, idmap_info *from);
/* free idmap_info info from user supplied struct */
extern void idmap_info_free(idmap_info *);
/*
* Extended API to batch SID to UID/GID mapping requests
*/
/* Given SID, get UID */
extern idmap_stat idmap_getext_uidbysid(idmap_get_handle_t *, char *,
idmap_rid_t, int, uid_t *, idmap_info *, idmap_stat *);
/* Given SID, get GID */
extern idmap_stat idmap_getext_gidbysid(idmap_get_handle_t *, char *,
idmap_rid_t, int, gid_t *, idmap_info *, idmap_stat *);
/* Given SID, get UID or GID */
extern idmap_stat idmap_getext_pidbysid(idmap_get_handle_t *, char *,
idmap_rid_t, int, uid_t *, int *, idmap_info *, idmap_stat *);
/* Given UID, get SID */
extern idmap_stat idmap_getext_sidbyuid(idmap_get_handle_t *, uid_t, int,
char **, idmap_rid_t *, idmap_info *, idmap_stat *);
/* Given GID, get SID */
extern idmap_stat idmap_getext_sidbygid(idmap_get_handle_t *, gid_t, int,
char **, idmap_rid_t *, idmap_info *, idmap_stat *);
#ifdef __cplusplus
}
#endif
#endif /* _IDMAP_PRIV_H */