42af92a661a06b3cebc88d585aad75064a309d51nd/*
42af92a661a06b3cebc88d585aad75064a309d51nd SSSD
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd ID-mapping plugin for winbind
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd
42af92a661a06b3cebc88d585aad75064a309d51nd Authors:
42af92a661a06b3cebc88d585aad75064a309d51nd Sumit Bose <sbose@redhat.com>
42af92a661a06b3cebc88d585aad75064a309d51nd
42af92a661a06b3cebc88d585aad75064a309d51nd Copyright (C) 2016 Red Hat
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc
42af92a661a06b3cebc88d585aad75064a309d51nd This program is free software; you can redistribute it and/or modify
42af92a661a06b3cebc88d585aad75064a309d51nd it under the terms of the GNU General Public License as published by
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen the Free Software Foundation; either version 3 of the License, or
2e545ce2450a9953665f701bb05350f0d3f26275nd (at your option) any later version.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen This program is distributed in the hope that it will be useful,
42af92a661a06b3cebc88d585aad75064a309d51nd but WITHOUT ANY WARRANTY; without even the implied warranty of
42af92a661a06b3cebc88d585aad75064a309d51nd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42af92a661a06b3cebc88d585aad75064a309d51nd GNU General Public License for more details.
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen
3f08db06526d6901aa08c110b5bc7dde6bc39905nd You should have received a copy of the GNU General Public License
42af92a661a06b3cebc88d585aad75064a309d51nd along with this program. If not, see <http://www.gnu.org/licenses/>.
42af92a661a06b3cebc88d585aad75064a309d51nd*/
42af92a661a06b3cebc88d585aad75064a309d51nd
3f08db06526d6901aa08c110b5bc7dde6bc39905nd#ifndef _WINBIND_SSS_IDMAP_H_
42af92a661a06b3cebc88d585aad75064a309d51nd#define _WINBIND_SSS_IDMAP_H_
42af92a661a06b3cebc88d585aad75064a309d51nd
42af92a661a06b3cebc88d585aad75064a309d51nd#include <stdint.h>
fbad7185dd78ec6e09c5b191693deda9d4bfa08cgryzor#include <stdbool.h>
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung
42af92a661a06b3cebc88d585aad75064a309d51nd#include <core/ntstatus.h>
42af92a661a06b3cebc88d585aad75064a309d51nd#include <ndr.h>
42af92a661a06b3cebc88d585aad75064a309d51nd#include <gen_ndr/security.h>
42af92a661a06b3cebc88d585aad75064a309d51nd
42af92a661a06b3cebc88d585aad75064a309d51nd/* The following definitions are taken from the Samba header files
b09fcdfc59ada4712150e7bcc7b502bb9e4601d8rjung * - winbindd/idmap_proto.h
42af92a661a06b3cebc88d585aad75064a309d51nd * - idmap.d
42af92a661a06b3cebc88d585aad75064a309d51nd * - gen_ndr/idmap.h
886ed39ead0b01f935b148594a871c206ea6e09drbowen * and can be removed if the related Samba header files become public headers
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf * or if this plugin is build inside the Samba source tree. */
42af92a661a06b3cebc88d585aad75064a309d51nd
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsfenum id_type {
42af92a661a06b3cebc88d585aad75064a309d51nd ID_TYPE_NOT_SPECIFIED,
42af92a661a06b3cebc88d585aad75064a309d51nd ID_TYPE_UID,
42af92a661a06b3cebc88d585aad75064a309d51nd ID_TYPE_GID,
42af92a661a06b3cebc88d585aad75064a309d51nd ID_TYPE_BOTH
42af92a661a06b3cebc88d585aad75064a309d51nd};
42af92a661a06b3cebc88d585aad75064a309d51nd
42af92a661a06b3cebc88d585aad75064a309d51ndstruct unixid {
42af92a661a06b3cebc88d585aad75064a309d51nd uint32_t id;
42af92a661a06b3cebc88d585aad75064a309d51nd enum id_type type;
42af92a661a06b3cebc88d585aad75064a309d51nd};
42af92a661a06b3cebc88d585aad75064a309d51nd
42af92a661a06b3cebc88d585aad75064a309d51ndenum id_mapping {
42af92a661a06b3cebc88d585aad75064a309d51nd ID_UNKNOWN,
42af92a661a06b3cebc88d585aad75064a309d51nd ID_MAPPED,
42af92a661a06b3cebc88d585aad75064a309d51nd ID_UNMAPPED,
42af92a661a06b3cebc88d585aad75064a309d51nd ID_EXPIRED
42af92a661a06b3cebc88d585aad75064a309d51nd};
42af92a661a06b3cebc88d585aad75064a309d51nd
42af92a661a06b3cebc88d585aad75064a309d51ndstruct id_map {
42af92a661a06b3cebc88d585aad75064a309d51nd struct dom_sid *sid;
42af92a661a06b3cebc88d585aad75064a309d51nd struct unixid xid;
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri enum id_mapping status;
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri};
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri#define SMB_IDMAP_INTERFACE_VERSION 5
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeristruct idmap_domain {
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri const char *name;
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri struct idmap_methods *methods;
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri uint32_t low_id;
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri uint32_t high_id;
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri bool read_only;
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri void *private_data;
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri};
42af92a661a06b3cebc88d585aad75064a309d51nd
7703bad94964cc64022e08e2d1ae2c5fbfe2d3c6covener/* Filled out by IDMAP backends */
ae600e4660f432839227b71dca0f555a75587177covenerstruct idmap_methods {
42af92a661a06b3cebc88d585aad75064a309d51nd
42af92a661a06b3cebc88d585aad75064a309d51nd /* Called when backend is first loaded */
42af92a661a06b3cebc88d585aad75064a309d51nd NTSTATUS (*init)(struct idmap_domain *dom);
17efe57eb8d88fa0d371f4ac4939dbbbe78fd09bcovener
42af92a661a06b3cebc88d585aad75064a309d51nd /* Map an array of uids/gids to SIDs. The caller specifies
42af92a661a06b3cebc88d585aad75064a309d51nd the uid/gid and type. Gets back the SID. */
42af92a661a06b3cebc88d585aad75064a309d51nd NTSTATUS (*unixids_to_sids)(struct idmap_domain *dom, struct id_map **ids);
42af92a661a06b3cebc88d585aad75064a309d51nd
8068423ee2d80a7c42b2325a71c24ac9485327cecovener /* Map an arry of SIDs to uids/gids. The caller sets the SID
8068423ee2d80a7c42b2325a71c24ac9485327cecovener and type and gets back a uid or gid. */
87b38bd2f8d6e4a914de7aa4a083e2e239a1ba79jim NTSTATUS (*sids_to_unixids)(struct idmap_domain *dom, struct id_map **ids);
bf876fa45c212a18d7aa07504e872cf63a0c247cnd
42af92a661a06b3cebc88d585aad75064a309d51nd /* Allocate a Unix-ID. */
17efe57eb8d88fa0d371f4ac4939dbbbe78fd09bcovener NTSTATUS (*allocate_id)(struct idmap_domain *dom, struct unixid *id);
87b38bd2f8d6e4a914de7aa4a083e2e239a1ba79jim};
87b38bd2f8d6e4a914de7aa4a083e2e239a1ba79jim
42af92a661a06b3cebc88d585aad75064a309d51ndNTSTATUS smb_register_idmap(int version, const char *name,
42af92a661a06b3cebc88d585aad75064a309d51nd struct idmap_methods *methods);
c44eeebd065e2c8cd028016b45c58afb480aaf8fdruggeri#endif /* _WINBIND_SSS_IDMAP_H_ */
42af92a661a06b3cebc88d585aad75064a309d51nd