88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher/*
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher SSSD
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher nsssrv_private.h
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher Authors:
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher Stephen Gallagher <sgallagh@redhat.com>
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher Copyright (C) 2010 Red Hat
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher This program is free software; you can redistribute it and/or modify
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher it under the terms of the GNU General Public License as published by
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher the Free Software Foundation; either version 3 of the License, or
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher (at your option) any later version.
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher This program is distributed in the hope that it will be useful,
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher but WITHOUT ANY WARRANTY; without even the implied warranty of
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher GNU General Public License for more details.
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher You should have received a copy of the GNU General Public License
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher along with this program. If not, see <http://www.gnu.org/licenses/>.
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher*/
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher#ifndef NSSSRV_PRIVATE_H_
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher#define NSSSRV_PRIVATE_H_
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
f7257ab0bcea6c41fab5a4677787f3075ecdcb64Pavel Reichl#include <dhash.h>
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorcestruct nss_state_ent {
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce int dom_idx;
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce int cur;
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce};
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorcestruct nss_state_ctx {
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce struct nss_state_ent pwent;
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce struct nss_state_ent grent;
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce struct nss_state_ent svcent;
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce char *netgr_name;
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce int netgrent_cur;
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce};
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagherstruct nss_cmd_ctx {
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct cli_ctx *cctx;
b3e247cef1f1c81a24ae7759903c11289744e94cSumit Bose enum sss_cli_command cmd;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher char *name;
b9901fe3d6cfe05cd75a2440c0f9c7985aea36c6Lukas Slebodnik const char *normalized_name;
899d1bdc048cd74518170d7d9535d76d3f46d4afSumit Bose bool name_is_upn;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher uint32_t id;
6eadbf9dab2ad9a9463dc23e91c9e2fc804c1e9bSumit Bose char *secid;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher bool immediate;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher bool check_next;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher bool enum_cached;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher int saved_dom_idx;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher int saved_cur;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher};
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagherstruct dom_ctx {
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct sss_domain_info *domain;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct ldb_result *res;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher};
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagherstruct getent_ctx {
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct dom_ctx *doms;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher int num;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher bool ready;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct setent_req_list *reqs;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher /* Netgroup-specific */
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher hash_table_t *lookup_table;
8c64b46e923ec590984325beedb29fcd09aac0e4Sumit Bose struct sysdb_netgroup_ctx **entries;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher char *name;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher char *domain;
7a0e6e2b9fc2fffc10f33e90926bb7edb5198ddeJan Zeleny bool found;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher};
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagherstruct nss_dom_ctx {
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct nss_cmd_ctx *cmdctx;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct sss_domain_info *domain;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
f2d943ee47bb313e0bb7276122587989a3c54fb4Jan Zeleny /* For a case when we are discovering subdomains */
065771c9859df9c4137daa5187be3aa5633b3cd5Jan Zeleny const char *rawname;
f2d943ee47bb313e0bb7276122587989a3c54fb4Jan Zeleny
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher bool check_provider;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher /* cache results */
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct ldb_result *res;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher /* Netgroup-specific */
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct getent_ctx *netgr;
acbc134c063e92a8db1237e1444ad4ada5f54ff8Stephen Gallagher
acbc134c063e92a8db1237e1444ad4ada5f54ff8Stephen Gallagher /* Service-specific */
acbc134c063e92a8db1237e1444ad4ada5f54ff8Stephen Gallagher const char *protocol;
dda0258705de7255e6ec54b7f9adbde83a220996Lukas Slebodnik
dda0258705de7255e6ec54b7f9adbde83a220996Lukas Slebodnik const char *mc_name;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher};
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagherstruct setent_step_ctx {
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct nss_ctx *nctx;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct nss_dom_ctx *dctx;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct getent_ctx *getent_ctx;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct resp_ctx *rctx;
069a5fe72d38f8e15b4416992453ac41a425ce9aStephen Gallagher struct cli_ctx *cctx;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher bool check_next;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
5ea3cfbb8272f5e02f8e9683c0028b3e1a3c9045Sumit Bose bool returned_to_mainloop;
5ea3cfbb8272f5e02f8e9683c0028b3e1a3c9045Sumit Bose
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher /* Netgroup-specific */
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher char *name;
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher};
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher#define NSS_CMD_FATAL_ERROR(cctx) do { \
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE,"Fatal error, killing connection!\n"); \
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher talloc_free(cctx); \
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher return; \
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher} while(0)
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher#define NSS_CMD_FATAL_ERROR_CODE(cctx, ret) do { \
83bf46f4066e3d5e838a32357c201de9bd6ecdfdNikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE,"Fatal error, killing connection!\n"); \
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher talloc_free(cctx); \
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher return ret; \
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher} while(0)
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher/* Finish the request */
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagherint nss_cmd_done(struct nss_cmd_ctx *cmdctx, int ret);
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
98076cabc2a8b8f71dc3bc1263519827f71a5fccJakub Hrozekerrno_t nss_setent_add_ref(TALLOC_CTX *memctx,
98076cabc2a8b8f71dc3bc1263519827f71a5fccJakub Hrozek struct getent_ctx *getent_ctx,
98076cabc2a8b8f71dc3bc1263519827f71a5fccJakub Hrozek struct tevent_req *req);
98076cabc2a8b8f71dc3bc1263519827f71a5fccJakub Hrozek
98076cabc2a8b8f71dc3bc1263519827f71a5fccJakub Hrozekvoid nss_setent_notify_error(struct getent_ctx *getent_ctx, errno_t ret);
98076cabc2a8b8f71dc3bc1263519827f71a5fccJakub Hrozekvoid nss_setent_notify_done(struct getent_ctx *getent_ctx);
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallaghererrno_t check_cache(struct nss_dom_ctx *dctx,
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct nss_ctx *nctx,
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher struct ldb_result *res,
1a818ee8e01136166e7f2b37a441e7e779c6b1f4Lukas Slebodnik enum sss_dp_acct_type req_type,
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher const char *opt_name,
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher uint32_t opt_id,
7d2437adc312d3322d36043ff458fafdb4b7f2cfSumit Bose const char *extra,
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher sss_dp_callback_t callback,
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher void *pvt);
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher
408914f68673f2caa1c82a1a21336fcb7ddd52efSimo Sorcevoid nss_update_initgr_memcache(struct nss_ctx *nctx,
6f0a0ae7599e3947c0b2e4649039f85829e57637Lukas Slebodnik const char *fq_name, const char *domain,
408914f68673f2caa1c82a1a21336fcb7ddd52efSimo Sorce int gnum, uint32_t *groups);
ebba1aa6b9783daa0d530e9f5e307f7be17d3cd3Simo Sorce
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorceint nss_connection_setup(struct cli_ctx *cctx);
4f3a9d837a55b49448eca3c713c85a406207e523Simo Sorce
88a9c6a44b474bff0f7e22f9eb28a9e55df2c0b5Stephen Gallagher#endif /* NSSSRV_PRIVATE_H_ */