2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A/*
2N/A * Additional API for Identity Mapping Service
2N/A */
2N/A
2N/A#ifndef _IDMAP_PRIV_H
2N/A#define _IDMAP_PRIV_H
2N/A
2N/A
2N/A#include <libscf.h>
2N/A#include <resolv.h>
2N/A
2N/A#include "idmap.h"
2N/A#include <rpcsvc/idmap_prot.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#define IDMAP_MAX_NAME_LEN 512
2N/A
2N/A#define IDMAP_ERROR(rc) (rc != IDMAP_SUCCESS && rc != IDMAP_NEXT)
2N/A#define IDMAP_FATAL_ERROR(rc) (rc == IDMAP_ERR_MEMORY ||\
2N/A rc == IDMAP_ERR_DB)
2N/A
2N/A
2N/A/* is_user values */
2N/A
2N/A#define IDMAP_YES 1
2N/A#define IDMAP_NO 0
2N/A#define IDMAP_UNKNOWN -1
2N/A
2N/A#define CHECK_NULL(s) (s != NULL ? s : "null")
2N/A#define EMPTY_STRING(str) (str == NULL || *str == '\0')
2N/A
2N/A/* Opaque handle to batch config add/remove operations */
2N/Atypedef struct idmap_udt_handle idmap_udt_handle_t;
2N/A
2N/A/* Opaque iterator */
2N/Atypedef struct idmap_iter idmap_iter_t;
2N/A
2N/A
2N/A/*
2N/A * Update API
2N/A */
2N/A
2N/A/* Create handle for updates */
2N/Aextern idmap_stat idmap_udt_create(idmap_udt_handle_t **);
2N/A
2N/A/* Commit */
2N/Aextern idmap_stat idmap_udt_commit(idmap_udt_handle_t *);
2N/A
2N/A/* Get index of the failed batch element */
2N/Aextern idmap_stat idmap_udt_get_error_index(idmap_udt_handle_t *, int64_t *);
2N/A
2N/A/* Get the rule which caused the batch to failed */
2N/Aextern idmap_stat idmap_udt_get_error_rule(idmap_udt_handle_t *, char **,
2N/A char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
2N/A
2N/A/* Get the rule which caused a conflict */
2N/Aextern idmap_stat idmap_udt_get_conflict_rule(idmap_udt_handle_t *, char **,
2N/A char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
2N/A
2N/A/* Destroy the update handle */
2N/Aextern void idmap_udt_destroy(idmap_udt_handle_t *);
2N/A
2N/A/* Add name-based mapping rule */
2N/Aextern idmap_stat idmap_udt_add_namerule(idmap_udt_handle_t *, const char *,
2N/A boolean_t, boolean_t, const char *, const char *, boolean_t, int);
2N/A
2N/A/* Remove name-based mapping rule */
2N/Aextern idmap_stat idmap_udt_rm_namerule(idmap_udt_handle_t *, boolean_t,
2N/A boolean_t, const char *, const char *, const char *, int);
2N/A
2N/A/* Flush name-based mapping rules */
2N/Aextern idmap_stat idmap_udt_flush_namerules(idmap_udt_handle_t *);
2N/A
2N/A/* Flush caches */
2N/Aextern idmap_stat idmap_flush(idmap_flush_op);
2N/A
2N/A/*
2N/A * Iterator API
2N/A */
2N/A
2N/A/* Create a iterator to get SID to UID/GID mappings */
2N/Aextern idmap_stat idmap_iter_mappings(idmap_iter_t **, int flag);
2N/A
2N/A/* Iterate through the SID to UID/GID mappings */
2N/Aextern idmap_stat idmap_iter_next_mapping(idmap_iter_t *, char **,
2N/A idmap_rid_t *, uid_t *, char **, char **, char **, boolean_t *,
2N/A boolean_t *, int *, idmap_info *);
2N/A
2N/A/* Create a iterator to get name-based mapping rules */
2N/Aextern idmap_stat idmap_iter_namerules(const char *,
2N/A boolean_t, boolean_t, const char *, const char *, idmap_iter_t **);
2N/A
2N/A/* Iterate through the name-based mapping rules */
2N/Aextern idmap_stat idmap_iter_next_namerule(idmap_iter_t *, char **,
2N/A char **, char **, boolean_t *, boolean_t *, boolean_t *, int *);
2N/A
2N/A/* Set the number of entries requested per batch */
2N/Aextern idmap_stat idmap_iter_set_limit(idmap_iter_t *, uint64_t);
2N/A
2N/A/* Destroy the iterator */
2N/Aextern void idmap_iter_destroy(idmap_iter_t *);
2N/A
2N/A
2N/A/*
2N/A * Get mapping
2N/A */
2N/Aextern idmap_stat idmap_get_w2u_mapping(const char *,
2N/A idmap_rid_t *, const char *, const char *, int, int *, int *,
2N/A uid_t *, char **, int *, idmap_info *);
2N/A
2N/Aextern idmap_stat idmap_get_u2w_mapping(uid_t *,
2N/A const char *, int, int, int *, char **, idmap_rid_t *, char **,
2N/A char **, int *, idmap_info *);
2N/A
2N/A
2N/A/*
2N/A * Miscellaneous
2N/A */
2N/A
2N/A/* string to status */
2N/Aextern idmap_stat idmap_string2stat(const char *);
2N/A
2N/A/* internal status to protocol status */
2N/Aextern idmap_stat idmap_stat4prot(idmap_stat);
2N/A
2N/A/* copy idmap_namerule including strings */
2N/Aextern idmap_stat idmap_namerule_cpy(idmap_namerule *, idmap_namerule *);
2N/A
2N/A/* Move idmap_info info including strings */
2N/Aextern void idmap_info_mov(idmap_info *to, idmap_info *from);
2N/A
2N/A/* free idmap_info info from user supplied struct */
2N/Aextern void idmap_info_free(idmap_info *);
2N/Aextern void idmap_how_clear(idmap_how *);
2N/A
2N/A
2N/A/*
2N/A * Extended API to batch SID to UID/GID mapping requests
2N/A */
2N/A
2N/A/* Given SID, get UID */
2N/Aextern idmap_stat idmap_getext_uidbysid(idmap_get_handle_t *, char *,
2N/A idmap_rid_t, int, uid_t *, idmap_info *, idmap_stat *);
2N/A
2N/A/* Given SID, get GID */
2N/Aextern idmap_stat idmap_getext_gidbysid(idmap_get_handle_t *, char *,
2N/A idmap_rid_t, int, gid_t *, idmap_info *, idmap_stat *);
2N/A
2N/A/* Given SID, get UID or GID */
2N/Aextern idmap_stat idmap_getext_pidbysid(idmap_get_handle_t *, char *,
2N/A idmap_rid_t, int, uid_t *, int *, idmap_info *, idmap_stat *);
2N/A
2N/A/* Given UID, get SID */
2N/Aextern idmap_stat idmap_getext_sidbyuid(idmap_get_handle_t *, uid_t, int,
2N/A char **, idmap_rid_t *, idmap_info *, idmap_stat *);
2N/A
2N/A/* Given GID, get SID */
2N/Aextern idmap_stat idmap_getext_sidbygid(idmap_get_handle_t *, gid_t, int,
2N/A char **, idmap_rid_t *, idmap_info *, idmap_stat *);
2N/A
2N/A/* Properties */
2N/Aextern idmap_stat idmap_get_prop_ds(idmap_prop_type, idmap_ad_disc_ds_t *);
2N/Aextern idmap_stat idmap_get_prop_str(idmap_prop_type, char **);
2N/A
2N/A/*
2N/A * Trace
2N/A *
2N/A * These are the names of the trace parameters that may be returned
2N/A * when tracing is requested.
2N/A */
2N/A#define IDMAP_TRACE_NAME_MAX 100 /* max length of a trace param name */
2N/A#define IDMAP_TRACE_TYPE "-type" /* prefix with "from" or "to" */
2N/A#define IDMAP_TRACE_NAME "-name" /* prefix with "from" or "to" */
2N/A#define IDMAP_TRACE_SID "-sid" /* prefix with "from" or "to" */
2N/A#define IDMAP_TRACE_UNIXID "-unixid" /* prefix with "from" or "to" */
2N/A#define IDMAP_TRACE_ERROR "error"
2N/A#define IDMAP_TRACE_MESSAGE "message"
2N/A
2N/Aextern void idmap_trace_print_1(FILE *out, char *prefix, nvlist_t *entry);
2N/Aextern void idmap_trace_print(FILE *out, char *prefix, nvlist_t *trace);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _IDMAP_PRIV_H */