nsssrv_private.h revision 7a0e6e2b9fc2fffc10f33e90926bb7edb5198dde
f5d30e2864e048a42c4dc1134993ae7efdb5d6c3Mark Andrews/*
a7038d1a0513c8e804937ebc95fc9cb3a46c04f5Mark Andrews SSSD
59563a18b7d83c3de5bb4b57f41fb4c0f9162cd0Andreas Gustafsson
59563a18b7d83c3de5bb4b57f41fb4c0f9162cd0Andreas Gustafsson nsssrv_private.h
59563a18b7d83c3de5bb4b57f41fb4c0f9162cd0Andreas Gustafsson
59563a18b7d83c3de5bb4b57f41fb4c0f9162cd0Andreas Gustafsson Authors:
59563a18b7d83c3de5bb4b57f41fb4c0f9162cd0Andreas Gustafsson Stephen Gallagher <sgallagh@redhat.com>
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews Copyright (C) 2010 Red Hat
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews This program is free software; you can redistribute it and/or modify
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews it under the terms of the GNU General Public License as published by
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews the Free Software Foundation; either version 3 of the License, or
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews (at your option) any later version.
59563a18b7d83c3de5bb4b57f41fb4c0f9162cd0Andreas Gustafsson
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews This program is distributed in the hope that it will be useful,
59563a18b7d83c3de5bb4b57f41fb4c0f9162cd0Andreas Gustafsson but WITHOUT ANY WARRANTY; without even the implied warranty of
59563a18b7d83c3de5bb4b57f41fb4c0f9162cd0Andreas Gustafsson MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
59563a18b7d83c3de5bb4b57f41fb4c0f9162cd0Andreas Gustafsson GNU General Public License for more details.
59563a18b7d83c3de5bb4b57f41fb4c0f9162cd0Andreas Gustafsson
59563a18b7d83c3de5bb4b57f41fb4c0f9162cd0Andreas Gustafsson You should have received a copy of the GNU General Public License
59563a18b7d83c3de5bb4b57f41fb4c0f9162cd0Andreas Gustafsson along with this program. If not, see <http://www.gnu.org/licenses/>.
59563a18b7d83c3de5bb4b57f41fb4c0f9162cd0Andreas Gustafsson*/
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews#ifndef NSSSRV_PRIVATE_H_
b8cfb6c6c8d24b79d6063b358bdf9a33a4b4f3d6Andreas Gustafsson#define NSSSRV_PRIVATE_H_
b8cfb6c6c8d24b79d6063b358bdf9a33a4b4f3d6Andreas Gustafsson
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein#include "dhash.h"
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeinstruct nss_cmd_ctx {
b8cfb6c6c8d24b79d6063b358bdf9a33a4b4f3d6Andreas Gustafsson struct cli_ctx *cctx;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein char *name;
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews uint32_t id;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
b8cfb6c6c8d24b79d6063b358bdf9a33a4b4f3d6Andreas Gustafsson bool immediate;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein bool check_next;
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews bool enum_cached;
b8cfb6c6c8d24b79d6063b358bdf9a33a4b4f3d6Andreas Gustafsson
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews int saved_dom_idx;
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews int saved_cur;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein};
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews
9ae5c33fe47b307db08ff0c437dc6a0deed7b46aAndreas Gustafssonstruct dom_ctx {
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews struct sss_domain_info *domain;
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews struct ldb_result *res;
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews};
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeinstruct setent_req_list {
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein struct setent_req_list *prev;
b8cfb6c6c8d24b79d6063b358bdf9a33a4b4f3d6Andreas Gustafsson struct setent_req_list *next;
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews struct getent_ctx *getent_ctx;
f9f9c47053364ba915d3ef0dbb4f55bd202487daAndreas Gustafsson
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein struct tevent_req *req;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein};
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
f9f9c47053364ba915d3ef0dbb4f55bd202487daAndreas Gustafssonstruct getent_ctx {
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews struct dom_ctx *doms;
f9f9c47053364ba915d3ef0dbb4f55bd202487daAndreas Gustafsson int num;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein bool ready;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein struct setent_req_list *reqs;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews /* Netgroup-specific */
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews hash_table_t *lookup_table;
b5ad6dfea4cc3e7d1d322ac99f1e5a31096837c4Mark Andrews struct sysdb_netgroup_ctx **entries;
char *name;
char *domain;
bool found;
};
struct nss_dom_ctx {
struct nss_cmd_ctx *cmdctx;
struct sss_domain_info *domain;
bool check_provider;
/* cache results */
struct ldb_result *res;
/* Netgroup-specific */
struct getent_ctx *netgr;
};
struct setent_step_ctx {
struct nss_ctx *nctx;
struct nss_dom_ctx *dctx;
struct getent_ctx *getent_ctx;
struct resp_ctx *rctx;
bool check_next;
bool returned_to_mainloop;
/* Netgroup-specific */
char *name;
};
#define NSS_CMD_FATAL_ERROR(cctx) do { \
DEBUG(1,("Fatal error, killing connection!\n")); \
talloc_free(cctx); \
return; \
} while(0)
#define NSS_CMD_FATAL_ERROR_CODE(cctx, ret) do { \
DEBUG(1,("Fatal error, killing connection!\n")); \
talloc_free(cctx); \
return ret; \
} while(0)
/* Find a particular domain object by name */
struct sss_domain_info *nss_get_dom(struct sss_domain_info *doms,
const char *domain);
/* Finish the request */
int nss_cmd_done(struct nss_cmd_ctx *cmdctx, int ret);
/* Respond with no entries */
int fill_empty(struct sss_packet *packet);
int setent_remove_ref(TALLOC_CTX *ctx);
errno_t setent_add_ref(TALLOC_CTX *memctx,
struct getent_ctx *getent_ctx,
struct tevent_req *req);
errno_t check_cache(struct nss_dom_ctx *dctx,
struct nss_ctx *nctx,
struct ldb_result *res,
int req_type,
const char *opt_name,
uint32_t opt_id,
sss_dp_callback_t callback,
void *pvt);
#endif /* NSSSRV_PRIVATE_H_ */