b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose/*
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose SSSD
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose ID-mapping library - private headers
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose Authors:
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose Sumit Bose <sbose@redhat.com>
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose Copyright (C) 2012 Red Hat
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose This program is free software; you can redistribute it and/or modify
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose it under the terms of the GNU General Public License as published by
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose the Free Software Foundation; either version 3 of the License, or
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose (at your option) any later version.
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose This program is distributed in the hope that it will be useful,
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose but WITHOUT ANY WARRANTY; without even the implied warranty of
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose GNU General Public License for more details.
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose You should have received a copy of the GNU General Public License
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose along with this program. If not, see <http://www.gnu.org/licenses/>.
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose*/
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose#ifndef SSS_IDMAP_PRIVATE_H_
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose#define SSS_IDMAP_PRIVATE_H_
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek#define SSS_IDMAP_DEFAULT_LOWER 200000
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek#define SSS_IDMAP_DEFAULT_UPPER 2000200000
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek#define SSS_IDMAP_DEFAULT_RANGESIZE 200000
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek#define SSS_IDMAP_DEFAULT_AUTORID false
8babbeee01e67893af4828ddfc922ecac0be4197Pavel Reichl#define SSS_IDMAP_DEFAULT_EXTRA_SLICE_INIT 10
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose#define CHECK_IDMAP_CTX(ctx, ret) do { \
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose if (ctx == NULL || ctx->alloc_func == NULL || ctx->free_func == NULL) { \
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose return ret; \
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose } \
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose} while(0)
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidekstruct sss_idmap_opts {
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek /* true if autorid compatibility mode is used */
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek bool autorid_mode;
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek /* smallest available id (for all domains) */
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek id_t idmap_lower;
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek /* highest available id (for all domains) */
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek id_t idmap_upper;
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek /* number of available UIDs (for single domain) */
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek id_t rangesize;
8babbeee01e67893af4828ddfc922ecac0be4197Pavel Reichl
8babbeee01e67893af4828ddfc922ecac0be4197Pavel Reichl /* maximal number of secondary slices */
8babbeee01e67893af4828ddfc922ecac0be4197Pavel Reichl int extra_slice_init;
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek};
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bosestruct sss_idmap_ctx {
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose idmap_alloc_func *alloc_func;
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose void *alloc_pvt;
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose idmap_free_func *free_func;
46222e5191473f9a46aec581273eb2eef22e23beMichal Zidek struct sss_idmap_opts idmap_opts;
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose struct idmap_domain_info *idmap_domain_info;
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose};
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose/* This is a copy of the definition in the samba gen_ndr/security.h header
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose * file. We use it here to be able to offer conversions form struct dom_sid to
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose * string or binary representation since those are not made available by
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose * public samba libraries.
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose *
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose * If the definition ever changes on the samba side we have to adopt the
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose * change. But chances are very low that this will ever happen since e.g. this
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose * struct is also defined in public documentation from Microsoft. See e.g.
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose * section 2.4.2.3 of "[MS-DTYP]: Windows Data Types"
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose * http://msdn.microsoft.com/en-us/library/cc230364(v=prot.10)
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose */
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose
2998435fcc95857b73049b3955af9889ab595f24Sumit Bosestruct dom_sid {
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose uint8_t sid_rev_num;
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose int8_t num_auths;
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose uint8_t id_auth[6];
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose uint32_t sub_auths[15];
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose};
2998435fcc95857b73049b3955af9889ab595f24Sumit Bose
b6dfbf81c61d4431aaa81687ec53e892f8b71edbSumit Bose#endif /* SSS_IDMAP_PRIVATE_H_ */