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