eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce/*
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce SSSD
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce NSS Responder - Mmap Cache
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce Copyright (C) Simo Sorce <ssorce@redhat.com> 2011
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce This program is free software; you can redistribute it and/or modify
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce it under the terms of the GNU General Public License as published by
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce the Free Software Foundation; either version 3 of the License, or
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce (at your option) any later version.
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce This program is distributed in the hope that it will be useful,
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce but WITHOUT ANY WARRANTY; without even the implied warranty of
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce GNU General Public License for more details.
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce You should have received a copy of the GNU General Public License
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce along with this program. If not, see <http://www.gnu.org/licenses/>.
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce*/
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce#ifndef _NSSSRV_MMAP_CACHE_H_
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce#define _NSSSRV_MMAP_CACHE_H_
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce
99c99e557020775714f028b28a147edda290c783Michal Zidek#define SSS_MC_CACHE_ELEMENTS 50000
99c99e557020775714f028b28a147edda290c783Michal Zidek
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorcestruct sss_mc_ctx;
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorceenum sss_mc_type {
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce SSS_MC_NONE = 0,
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce SSS_MC_PASSWD,
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce SSS_MC_GROUP,
ebf6735dd4f71bf3dc9105e5d04d11e744c64a59Lukas Slebodnik SSS_MC_INITGROUPS,
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce};
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorceerrno_t sss_mmap_cache_init(TALLOC_CTX *mem_ctx, const char *name,
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce enum sss_mc_type type, size_t n_elem,
e9f08ebaba5ec61af74c112f50c7d66257998c97Jan Zeleny time_t valid_time, struct sss_mc_ctx **mcc);
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce
0e6c9d03cacf24de4265ee0f902c216ba5a131c9Simo Sorceerrno_t sss_mmap_cache_pw_store(struct sss_mc_ctx **_mcc,
6cb1a6e7c7517ab4ccb8ad37ade86f95b5c16a01Simo Sorce struct sized_string *name,
6cb1a6e7c7517ab4ccb8ad37ade86f95b5c16a01Simo Sorce struct sized_string *pw,
6cb1a6e7c7517ab4ccb8ad37ade86f95b5c16a01Simo Sorce uid_t uid, gid_t gid,
6cb1a6e7c7517ab4ccb8ad37ade86f95b5c16a01Simo Sorce struct sized_string *gecos,
6cb1a6e7c7517ab4ccb8ad37ade86f95b5c16a01Simo Sorce struct sized_string *homedir,
6cb1a6e7c7517ab4ccb8ad37ade86f95b5c16a01Simo Sorce struct sized_string *shell);
6cb1a6e7c7517ab4ccb8ad37ade86f95b5c16a01Simo Sorce
0e6c9d03cacf24de4265ee0f902c216ba5a131c9Simo Sorceerrno_t sss_mmap_cache_gr_store(struct sss_mc_ctx **_mcc,
c3ef027218fe9a7d16a70ca9d2f53e3d995e369fSimo Sorce struct sized_string *name,
c3ef027218fe9a7d16a70ca9d2f53e3d995e369fSimo Sorce struct sized_string *pw,
c3ef027218fe9a7d16a70ca9d2f53e3d995e369fSimo Sorce gid_t gid, size_t memnum,
c3ef027218fe9a7d16a70ca9d2f53e3d995e369fSimo Sorce char *membuf, size_t memsize);
c3ef027218fe9a7d16a70ca9d2f53e3d995e369fSimo Sorce
ebf6735dd4f71bf3dc9105e5d04d11e744c64a59Lukas Slebodnikerrno_t sss_mmap_cache_initgr_store(struct sss_mc_ctx **_mcc,
ebf6735dd4f71bf3dc9105e5d04d11e744c64a59Lukas Slebodnik struct sized_string *name,
dda0258705de7255e6ec54b7f9adbde83a220996Lukas Slebodnik struct sized_string *unique_name,
39b31427e2d11ca318df11fd48db33a7cc610aa7Lukas Slebodnik uint32_t num_groups,
39b31427e2d11ca318df11fd48db33a7cc610aa7Lukas Slebodnik uint8_t *gids_buf);
ebf6735dd4f71bf3dc9105e5d04d11e744c64a59Lukas Slebodnik
8088274b2389b76f4be581736e55f26a8322fad1Simo Sorceerrno_t sss_mmap_cache_pw_invalidate(struct sss_mc_ctx *mcc,
8088274b2389b76f4be581736e55f26a8322fad1Simo Sorce struct sized_string *name);
8088274b2389b76f4be581736e55f26a8322fad1Simo Sorce
8088274b2389b76f4be581736e55f26a8322fad1Simo Sorceerrno_t sss_mmap_cache_pw_invalidate_uid(struct sss_mc_ctx *mcc, uid_t uid);
8088274b2389b76f4be581736e55f26a8322fad1Simo Sorce
8088274b2389b76f4be581736e55f26a8322fad1Simo Sorceerrno_t sss_mmap_cache_gr_invalidate(struct sss_mc_ctx *mcc,
8088274b2389b76f4be581736e55f26a8322fad1Simo Sorce struct sized_string *name);
8088274b2389b76f4be581736e55f26a8322fad1Simo Sorce
8088274b2389b76f4be581736e55f26a8322fad1Simo Sorceerrno_t sss_mmap_cache_gr_invalidate_gid(struct sss_mc_ctx *mcc, gid_t gid);
8088274b2389b76f4be581736e55f26a8322fad1Simo Sorce
ebf6735dd4f71bf3dc9105e5d04d11e744c64a59Lukas Slebodnikerrno_t sss_mmap_cache_initgr_invalidate(struct sss_mc_ctx *mcc,
ebf6735dd4f71bf3dc9105e5d04d11e744c64a59Lukas Slebodnik struct sized_string *name);
ebf6735dd4f71bf3dc9105e5d04d11e744c64a59Lukas Slebodnik
99c99e557020775714f028b28a147edda290c783Michal Zidekerrno_t sss_mmap_cache_reinit(TALLOC_CTX *mem_ctx, size_t n_elem,
99c99e557020775714f028b28a147edda290c783Michal Zidek time_t timeout, struct sss_mc_ctx **mc_ctx);
99c99e557020775714f028b28a147edda290c783Michal Zidek
9028706a00da1bc48547e74aa872c825ac15adb2Michal Zidekvoid sss_mmap_cache_reset(struct sss_mc_ctx *mc_ctx);
9028706a00da1bc48547e74aa872c825ac15adb2Michal Zidek
eb2e21b764d03544d8161e9956d7f70b07b75f77Simo Sorce#endif /* _NSSSRV_MMAP_CACHE_H_ */