4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher/*
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher SSSD
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher Authors:
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher Stephen Gallagher <sgallagh@redhat.com>
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher Copyright (C) 2012 Red Hat
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher This program is free software; you can redistribute it and/or modify
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher it under the terms of the GNU General Public License as published by
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher the Free Software Foundation; either version 3 of the License, or
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher (at your option) any later version.
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher This program is distributed in the hope that it will be useful,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher but WITHOUT ANY WARRANTY; without even the implied warranty of
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher GNU General Public License for more details.
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher You should have received a copy of the GNU General Public License
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher along with this program. If not, see <http://www.gnu.org/licenses/>.
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher*/
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher#ifndef SYSDB_SERVICES_H_
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher#define SYSDB_SERVICES_H_
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
50310d617e25abf118fbd867cbdc0fbc866277b5Pavel Březina#include "db/sysdb.h"
50310d617e25abf118fbd867cbdc0fbc866277b5Pavel Březina
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher#define SYSDB_SVC_CLASS "service"
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher#define SYSDB_SVC_CONTAINER "cn=services"
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher#define SYSDB_SC "objectclass="SYSDB_SVC_CLASS
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher#define SYSDB_SVC_PORT "servicePort"
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher#define SYSDB_SVC_PROTO "serviceProtocol"
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher#define SYSDB_TMPL_SVC_BASE SYSDB_SVC_CONTAINER",cn=%s,"SYSDB_BASE
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher#define SYSDB_TMPL_SVC SYSDB_NAME"=%s,"SYSDB_TMPL_SVC_BASE
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
fd555d130dc733509347fa096a2cb858b014a196Simo Sorce#define SYSDB_SVC_BYNAME_FILTER "(&("SYSDB_SVC_PROTO"=%s)(|("SYSDB_NAME_ALIAS"=%s)("SYSDB_NAME"=%s)))"
fd555d130dc733509347fa096a2cb858b014a196Simo Sorce#define SYSDB_SVC_BYPORT_FILTER "(&("SYSDB_SVC_PROTO"=%s)("SYSDB_SVC_PORT"=%u))"
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher#define SYSDB_SVC_ATTRS { \
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher SYSDB_NAME, \
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher SYSDB_NAME_ALIAS, \
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher SYSDB_SVC_PORT, \
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher SYSDB_SVC_PROTO, \
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher SYSDB_DEFAULT_ATTRS, \
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher NULL }
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallaghererrno_t
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallaghersysdb_getservbyname(TALLOC_CTX *mem_ctx,
681742138b2afbbefa7f14de937beb438409208eSimo Sorce struct sss_domain_info *domain,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher const char *name,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher const char *proto,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher struct ldb_result **_res);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallaghererrno_t
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallaghersysdb_getservbyport(TALLOC_CTX *mem_ctx,
681742138b2afbbefa7f14de937beb438409208eSimo Sorce struct sss_domain_info *domain,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher int port,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher const char *proto,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher struct ldb_result **_res);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
1e7c355a2d36eb7b942b5111c96eb2a2285d49ccStephen Gallaghererrno_t
1e7c355a2d36eb7b942b5111c96eb2a2285d49ccStephen Gallaghersysdb_enumservent(TALLOC_CTX *mem_ctx,
681742138b2afbbefa7f14de937beb438409208eSimo Sorce struct sss_domain_info *domain,
1e7c355a2d36eb7b942b5111c96eb2a2285d49ccStephen Gallagher struct ldb_result **_res);
1e7c355a2d36eb7b942b5111c96eb2a2285d49ccStephen Gallagher
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallaghererrno_t
4fcc50e133f90cd4c5931a3ac48c84cb628b16fcMichal Zideksysdb_store_service(struct sss_domain_info *domain,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher const char *primary_name,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher int port,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher const char **aliases,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher const char **protocols,
e299638926171e0e92a36122aeff6611cd52418dStephen Gallagher struct sysdb_attrs *extra_attrs,
e299638926171e0e92a36122aeff6611cd52418dStephen Gallagher char **remove_attrs,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher uint64_t cache_timeout,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher time_t now);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagherstruct ldb_dn *
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallaghersysdb_svc_dn(struct sysdb_ctx *sysdb, TALLOC_CTX *mem_ctx,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher const char *domain, const char *name);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
681742138b2afbbefa7f14de937beb438409208eSimo Sorceerrno_t
681742138b2afbbefa7f14de937beb438409208eSimo Sorcesysdb_svc_add(TALLOC_CTX *mem_ctx,
681742138b2afbbefa7f14de937beb438409208eSimo Sorce struct sss_domain_info *domain,
681742138b2afbbefa7f14de937beb438409208eSimo Sorce const char *primary_name,
681742138b2afbbefa7f14de937beb438409208eSimo Sorce int port,
681742138b2afbbefa7f14de937beb438409208eSimo Sorce const char **aliases,
681742138b2afbbefa7f14de937beb438409208eSimo Sorce const char **protocols,
681742138b2afbbefa7f14de937beb438409208eSimo Sorce struct ldb_dn **dn);
681742138b2afbbefa7f14de937beb438409208eSimo Sorce
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallaghererrno_t
4fcc50e133f90cd4c5931a3ac48c84cb628b16fcMichal Zideksysdb_svc_delete(struct sss_domain_info *domain,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher const char *name,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher int port,
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher const char *proto);
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher
eb29ae58117ca88868491fe2240e27393c7a9068Jakub Hrozekerrno_t
4fcc50e133f90cd4c5931a3ac48c84cb628b16fcMichal Zideksysdb_set_service_attr(struct sss_domain_info *domain,
eb29ae58117ca88868491fe2240e27393c7a9068Jakub Hrozek const char *name,
eb29ae58117ca88868491fe2240e27393c7a9068Jakub Hrozek struct sysdb_attrs *attrs,
eb29ae58117ca88868491fe2240e27393c7a9068Jakub Hrozek int mod_op);
eb29ae58117ca88868491fe2240e27393c7a9068Jakub Hrozek
d0483eefc41ac295ed4c56e08ad76ca7b5fb3b2cSimo Sorceerrno_t sysdb_search_services(TALLOC_CTX *mem_ctx,
681742138b2afbbefa7f14de937beb438409208eSimo Sorce struct sss_domain_info *domain,
d0483eefc41ac295ed4c56e08ad76ca7b5fb3b2cSimo Sorce const char *sub_filter,
d0483eefc41ac295ed4c56e08ad76ca7b5fb3b2cSimo Sorce const char **attrs,
d0483eefc41ac295ed4c56e08ad76ca7b5fb3b2cSimo Sorce size_t *msgs_count,
d0483eefc41ac295ed4c56e08ad76ca7b5fb3b2cSimo Sorce struct ldb_message ***msgs);
d0483eefc41ac295ed4c56e08ad76ca7b5fb3b2cSimo Sorce
4c1bf6607060cea867fccf667063c028dfd51e96Stephen Gallagher#endif /* SYSDB_SERVICES_H_ */