590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek/*
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek Authors:
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek Jakub Hrozek <jhrozek@redhat.com>
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek Pavel Březina <pbrezina@redhat.com>
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek Copyright (C) 2014 Red Hat
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek This program is free software; you can redistribute it and/or modify
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek it under the terms of the GNU General Public License as published by
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek the Free Software Foundation; either version 3 of the License, or
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek (at your option) any later version.
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek This program is distributed in the hope that it will be useful,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek GNU General Public License for more details.
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek You should have received a copy of the GNU General Public License
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek*/
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek#include <talloc.h>
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina#include <tevent.h>
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina#include <string.h>
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek#include "db/sysdb.h"
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek#include "util/util.h"
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek#include "confdb/confdb.h"
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek#include "responder/common/responder.h"
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek#include "responder/ifp/ifp_domains.h"
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina#include "responder/common/data_provider/rdp.h"
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina#include "sbus/sssd_dbus_errors.h"
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina#include "providers/data_provider/dp_responder_iface.h"
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina#define RETURN_DOM_PROP_AS_STRING(dbus_req, pvt_data, out, property) do { \
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina struct sss_domain_info *__dom; \
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina \
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *(out) = NULL; \
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina \
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina __dom = get_domain_info_from_req((dbus_req), (pvt_data)); \
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (__dom == NULL) { \
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina return; \
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina } \
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina \
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *(out) = __dom->property; \
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina} while (0)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozekstatic void ifp_list_domains_process(struct tevent_req *req);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozekint ifp_list_domains(struct sbus_request *dbus_req,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek void *data)
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek{
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek struct ifp_ctx *ifp_ctx;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek struct ifp_req *ireq;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek struct tevent_req *req;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek DBusError *error;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek errno_t ret;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek ifp_ctx = talloc_get_type(data, struct ifp_ctx);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (ifp_ctx == NULL) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "Invalid ifp context!\n");
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek error = sbus_error_new(dbus_req, DBUS_ERROR_FAILED,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek "Invalid ifp context!");
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return sbus_request_fail_and_finish(dbus_req, error);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek ret = ifp_req_create(dbus_req, ifp_ctx, &ireq);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (ret != EOK) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek error = sbus_error_new(dbus_req, DBUS_ERROR_FAILED,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek "%s", sss_strerror(ret));
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return sbus_request_fail_and_finish(dbus_req, error);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek req = sss_dp_get_domains_send(ireq, ifp_ctx->rctx, false, NULL);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (req == NULL) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return sbus_request_finish(ireq->dbus_req, NULL);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek tevent_req_set_callback(req, ifp_list_domains_process, ireq);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return EOK;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek}
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozekstatic void ifp_list_domains_process(struct tevent_req *req)
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek{
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek struct sss_domain_info *dom;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek struct ifp_req *ireq;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek const char **paths;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek char *p;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek DBusError *error;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek size_t num_domains;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek size_t pi;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek errno_t ret;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek ireq = tevent_req_callback_data(req, struct ifp_req);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek ret = sss_dp_get_domains_recv(req);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek talloc_free(req);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (ret != EOK) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek error = sbus_error_new(ireq->dbus_req, DBUS_ERROR_FAILED,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek "Failed to refresh domain objects\n");
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek sbus_request_fail_and_finish(ireq->dbus_req, error);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek ret = sysdb_master_domain_update(ireq->ifp_ctx->rctx->domains);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (ret != EOK) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek error = sbus_error_new(ireq->dbus_req, DBUS_ERROR_FAILED,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek "Failed to refresh subdomain list\n");
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek sbus_request_fail_and_finish(ireq->dbus_req, error);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek num_domains = 0;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek for (dom = ireq->ifp_ctx->rctx->domains;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek dom != NULL;
877b92e80bde510d5cd9f03dbf01e2bcf73ab072Michal Židek dom = get_next_domain(dom, SSS_GND_DESCEND)) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek num_domains++;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek paths = talloc_zero_array(ireq, const char *, num_domains);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (paths == NULL) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek sbus_request_finish(ireq->dbus_req, NULL);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek pi = 0;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek for (dom = ireq->ifp_ctx->rctx->domains;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek dom != NULL;
877b92e80bde510d5cd9f03dbf01e2bcf73ab072Michal Židek dom = get_next_domain(dom, SSS_GND_DESCEND)) {
62ebed8582285bd24efba92b9a06366511507946Pavel Březina p = sbus_opath_compose(ireq, IFP_PATH_DOMAINS, dom->name);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (p == NULL) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek DEBUG(SSSDBG_MINOR_FAILURE,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek "Could not create path for dom %s, skipping\n", dom->name);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek continue;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek paths[pi] = p;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek pi++;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
beeef7f627a5ed9264de25ee4c76eb9620c1c984Pavel Březina ret = iface_ifp_ListDomains_finish(ireq->dbus_req, paths, num_domains);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (ret != EOK) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek DEBUG(SSSDBG_OP_FAILURE, "Could not finish request!\n");
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek}
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozekstruct ifp_get_domain_state {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek const char *name;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek struct ifp_req *ireq;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek};
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozekstatic void ifp_find_domain_by_name_process(struct tevent_req *req);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozekint ifp_find_domain_by_name(struct sbus_request *dbus_req,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek void *data,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek const char *arg_name)
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek{
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek struct ifp_ctx *ifp_ctx;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek struct ifp_req *ireq;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek struct tevent_req *req;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek struct ifp_get_domain_state *state;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek DBusError *error;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek errno_t ret;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek ifp_ctx = talloc_get_type(data, struct ifp_ctx);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (ifp_ctx == NULL) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek error = sbus_error_new(dbus_req, DBUS_ERROR_FAILED,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek "Invalid ifp context!");
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return sbus_request_fail_and_finish(dbus_req, error);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek ret = ifp_req_create(dbus_req, ifp_ctx, &ireq);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (ret != EOK) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek error = sbus_error_new(dbus_req, DBUS_ERROR_FAILED,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek "%s", sss_strerror(ret));
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return sbus_request_fail_and_finish(dbus_req, error);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek state = talloc_zero(ireq, struct ifp_get_domain_state);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (state == NULL) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return sbus_request_finish(dbus_req, NULL);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek state->name = arg_name;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek state->ireq = ireq;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek req = sss_dp_get_domains_send(ireq, ifp_ctx->rctx, false, NULL);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (req == NULL) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return sbus_request_finish(dbus_req, NULL);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek tevent_req_set_callback(req, ifp_find_domain_by_name_process, state);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return EOK;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek}
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozekstatic void ifp_find_domain_by_name_process(struct tevent_req *req)
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek{
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek errno_t ret;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek struct ifp_req *ireq;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek struct ifp_get_domain_state *state;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek struct sss_domain_info *iter;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek const char *path;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek DBusError *error;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek state = tevent_req_callback_data(req, struct ifp_get_domain_state);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek ireq = state->ireq;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek ret = sss_dp_get_domains_recv(req);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek talloc_free(req);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (ret != EOK) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek error = sbus_error_new(ireq->dbus_req, DBUS_ERROR_FAILED,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek "Failed to refresh domain objects\n");
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek sbus_request_fail_and_finish(ireq->dbus_req, error);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek ret = sysdb_master_domain_update(ireq->ifp_ctx->rctx->domains);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (ret != EOK) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek error = sbus_error_new(ireq->dbus_req, DBUS_ERROR_FAILED,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek "Failed to refresh subdomain list\n");
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek sbus_request_fail_and_finish(ireq->dbus_req, error);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek /* Reply with the domain that was asked for */
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek for (iter = ireq->ifp_ctx->rctx->domains;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek iter != NULL;
877b92e80bde510d5cd9f03dbf01e2bcf73ab072Michal Židek iter = get_next_domain(iter, SSS_GND_DESCEND)) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (strcasecmp(iter->name, state->name) == 0) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek break;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (iter == NULL) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek error = sbus_error_new(ireq->dbus_req, DBUS_ERROR_FAILED,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek "No such domain\n");
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek sbus_request_fail_and_finish(ireq->dbus_req, error);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
62ebed8582285bd24efba92b9a06366511507946Pavel Březina path = sbus_opath_compose(ireq, IFP_PATH_DOMAINS, iter->name);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (path == NULL) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek DEBUG(SSSDBG_MINOR_FAILURE,
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek "Could not create path for domain %s, skipping\n", iter->name);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek sbus_request_finish(ireq->dbus_req, NULL);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek return;
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek
beeef7f627a5ed9264de25ee4c76eb9620c1c984Pavel Březina ret = iface_ifp_FindDomainByName_finish(ireq->dbus_req, path);
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek if (ret != EOK) {
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek DEBUG(SSSDBG_OP_FAILURE, "Could not finish request!\n");
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek }
590582be38cdbfde387fcc57df92903d48c5a083Jakub Hrozek}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinastatic struct sss_domain_info *
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinaget_domain_info_from_req(struct sbus_request *dbus_req, void *data)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina struct ifp_ctx *ctx = NULL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina struct sss_domain_info *domains = NULL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina struct sss_domain_info *iter = NULL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina char *name = NULL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina ctx = talloc_get_type(data, struct ifp_ctx);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (ctx == NULL) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina return NULL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
ca6dd8e7ac91c7f8e3b4d55206d4f39791ab7149Pavel Březina name = sbus_opath_get_object_name(dbus_req, dbus_req->path,
62ebed8582285bd24efba92b9a06366511507946Pavel Březina IFP_PATH_DOMAINS);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (name == NULL) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina return NULL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina DEBUG(SSSDBG_TRACE_INTERNAL, "Looking for domain %s\n", name);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina domains = ctx->rctx->domains;
877b92e80bde510d5cd9f03dbf01e2bcf73ab072Michal Židek for (iter = domains; iter != NULL;
877b92e80bde510d5cd9f03dbf01e2bcf73ab072Michal Židek iter = get_next_domain(iter, SSS_GND_DESCEND)) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (strcasecmp(iter->name, name) == 0) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina break;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina talloc_free(name);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina return iter;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinastatic void get_server_list(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina const char ***_out,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina int *_out_len,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina bool backup)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina static const char *srv[] = {"_srv_"};
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina struct sss_domain_info *dom = NULL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina struct ifp_ctx *ctx = NULL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina const char *conf_path = NULL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina const char *option = NULL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina const char **out = NULL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina char **servers = NULL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina int num_servers;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina errno_t ret;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina int i;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = NULL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out_len = 0;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina dom = get_domain_info_from_req(dbus_req, data);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (dom == NULL) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina return;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (dom->parent != NULL) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina /* subdomains are not present in configuration */
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina ret = ENOENT;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina goto done;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina ctx = talloc_get_type(data, struct ifp_ctx);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (ctx == NULL) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid ifp context!\n");
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina ret = ENOMEM;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina goto done;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina conf_path = talloc_asprintf(dbus_req, CONFDB_DOMAIN_PATH_TMPL, dom->name);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (conf_path == NULL) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina ret = ENOMEM;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina goto done;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina /* TODO: replace hardcoded values with option names from the provider */
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (strcasecmp(dom->provider, "ldap") == 0) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina option = backup == false ? "ldap_uri" : "ldap_backup_uri";
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina } else if (strcasecmp(dom->provider, "ipa") == 0) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina option = backup == false ? "ipa_server" : "ipa_backup_server";
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina } else if (strcasecmp(dom->provider, "ad") == 0) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina option = backup == false ? "ad_server" : "ad_backup_server";
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina } else {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina ret = EINVAL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina goto done;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina ret = confdb_get_string_as_list(ctx->rctx->cdb, dbus_req, conf_path,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina option, &servers);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (ret != EOK) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina goto done;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina for (num_servers = 0; servers[num_servers] != NULL; num_servers++);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (num_servers == 0) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina ret = ENOENT;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina goto done;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina out = talloc_zero_array(dbus_req, const char*, num_servers);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (out == NULL) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina ret = ENOMEM;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina goto done;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina for (i = 0; i < num_servers; i++) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina out[i] = talloc_steal(out, servers[i]);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = out;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out_len = num_servers;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina ret = EOK;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinadone:
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (ret == ENOENT) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = srv;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out_len = 1;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina return;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinavoid ifp_dom_get_name(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina const char **_out)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina RETURN_DOM_PROP_AS_STRING(dbus_req, data, _out, name);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinavoid ifp_dom_get_provider(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina const char **_out)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina RETURN_DOM_PROP_AS_STRING(dbus_req, data, _out, provider);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinavoid ifp_dom_get_primary_servers(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina const char ***_out,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina int *_out_len)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina get_server_list(dbus_req, data, _out, _out_len, false);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinavoid ifp_dom_get_backup_servers(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina const char ***_out,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina int *_out_len)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina get_server_list(dbus_req, data, _out, _out_len, true);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinavoid ifp_dom_get_min_id(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina uint32_t *_out)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina struct sss_domain_info *dom;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = 1;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina dom = get_domain_info_from_req(dbus_req, data);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (dom == NULL) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina return;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = dom->id_min;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinavoid ifp_dom_get_max_id(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina uint32_t *_out)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina struct sss_domain_info *dom;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = 0;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina dom = get_domain_info_from_req(dbus_req, data);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (dom == NULL) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina return;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = dom->id_max;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinavoid ifp_dom_get_realm(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina const char **_out)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina RETURN_DOM_PROP_AS_STRING(dbus_req, data, _out, realm);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinavoid ifp_dom_get_forest(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina const char **_out)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina RETURN_DOM_PROP_AS_STRING(dbus_req, data, _out, forest);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinavoid ifp_dom_get_login_format(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina const char **_out)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina RETURN_DOM_PROP_AS_STRING(dbus_req, data, _out, names->re_pattern);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinavoid ifp_dom_get_fqdn_format(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina const char **_out)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina RETURN_DOM_PROP_AS_STRING(dbus_req, data, _out, names->fq_fmt);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinavoid ifp_dom_get_enumerable(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina bool *_out)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina struct sss_domain_info *dom;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = false;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina dom = get_domain_info_from_req(dbus_req, data);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (dom == NULL) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina return;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = dom->enumerate;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinavoid ifp_dom_get_use_fqdn(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina bool *_out)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina struct sss_domain_info *dom;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = false;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina dom = get_domain_info_from_req(dbus_req, data);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (dom == NULL) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina return;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = dom->fqnames;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinavoid ifp_dom_get_subdomain(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina bool *_out)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina struct sss_domain_info *dom;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = false;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina dom = get_domain_info_from_req(dbus_req, data);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (dom == NULL) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina return;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = dom->parent ? true : false;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březinavoid ifp_dom_get_parent_domain(struct sbus_request *dbus_req,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina void *data,
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina const char **_out)
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina{
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina struct sss_domain_info *dom;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = NULL;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina dom = get_domain_info_from_req(dbus_req, data);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (dom == NULL) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina return;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina if (dom->parent == NULL) {
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina *_out = "/";
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina return;
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina }
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina
62ebed8582285bd24efba92b9a06366511507946Pavel Březina *_out = sbus_opath_compose(dbus_req, IFP_PATH_DOMAINS,
3a8f6b575f4019f21c9425a26f1b346c08a197aePavel Březina dom->parent->name);
d387c4608dbd3ca056e18e85313ef51aac146fd2Pavel Březina}
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březinaint ifp_domains_domain_is_online(struct sbus_request *sbus_req,
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina void *data)
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina{
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina struct ifp_ctx *ifp_ctx;
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina struct sss_domain_info *dom;
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina ifp_ctx = talloc_get_type(data, struct ifp_ctx);
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina dom = get_domain_info_from_req(sbus_req, data);
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina if (dom == NULL) {
a06e23c0bcf0c8669a29b801876aca8aac422931Pavel Březina sbus_request_reply_error(sbus_req, SBUS_ERROR_UNKNOWN_DOMAIN,
a06e23c0bcf0c8669a29b801876aca8aac422931Pavel Březina "Unknown domain");
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina return EOK;
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina }
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina
a40d9cc11d17d9c3c22a0462cd8c419d1e79ffb8Pavel Březina rdp_message_send_and_reply(sbus_req, ifp_ctx->rctx, dom, DP_PATH,
a40d9cc11d17d9c3c22a0462cd8c419d1e79ffb8Pavel Březina IFACE_DP_BACKEND, IFACE_DP_BACKEND_ISONLINE,
a40d9cc11d17d9c3c22a0462cd8c419d1e79ffb8Pavel Březina DBUS_TYPE_STRING, &dom->name);
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina return EOK;
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina}
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březinaint ifp_domains_domain_list_services(struct sbus_request *sbus_req,
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina void *data)
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina{
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina struct ifp_ctx *ifp_ctx;
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina struct sss_domain_info *dom;
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina ifp_ctx = talloc_get_type(data, struct ifp_ctx);
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina dom = get_domain_info_from_req(sbus_req, data);
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina if (dom == NULL) {
a06e23c0bcf0c8669a29b801876aca8aac422931Pavel Březina sbus_request_reply_error(sbus_req, SBUS_ERROR_UNKNOWN_DOMAIN,
a06e23c0bcf0c8669a29b801876aca8aac422931Pavel Březina "Unknown domain");
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina return EOK;
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina }
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina
a40d9cc11d17d9c3c22a0462cd8c419d1e79ffb8Pavel Březina rdp_message_send_and_reply(sbus_req, ifp_ctx->rctx, dom, DP_PATH,
a40d9cc11d17d9c3c22a0462cd8c419d1e79ffb8Pavel Březina IFACE_DP_FAILOVER,
a40d9cc11d17d9c3c22a0462cd8c419d1e79ffb8Pavel Březina IFACE_DP_FAILOVER_LISTSERVICES,
a40d9cc11d17d9c3c22a0462cd8c419d1e79ffb8Pavel Březina DBUS_TYPE_STRING, &dom->name);
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina return EOK;
9e9ad4cb181c6c0ec70caacfb31319753f889e98Pavel Březina}
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březinaint ifp_domains_domain_active_server(struct sbus_request *sbus_req,
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina void *data,
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina const char *service)
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina{
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina struct ifp_ctx *ifp_ctx;
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina struct sss_domain_info *dom;
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina ifp_ctx = talloc_get_type(data, struct ifp_ctx);
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina dom = get_domain_info_from_req(sbus_req, data);
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina if (dom == NULL) {
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina sbus_request_reply_error(sbus_req, SBUS_ERROR_UNKNOWN_DOMAIN,
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina "Unknown domain");
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina return EOK;
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina }
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina rdp_message_send_and_reply(sbus_req, ifp_ctx->rctx, dom, DP_PATH,
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina IFACE_DP_FAILOVER,
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina IFACE_DP_FAILOVER_ACTIVESERVER,
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina DBUS_TYPE_STRING, &service);
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina return EOK;
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina}
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březinaint ifp_domains_domain_list_servers(struct sbus_request *sbus_req,
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina void *data,
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina const char *service)
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina{
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina struct ifp_ctx *ifp_ctx;
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina struct sss_domain_info *dom;
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina ifp_ctx = talloc_get_type(data, struct ifp_ctx);
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina dom = get_domain_info_from_req(sbus_req, data);
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina if (dom == NULL) {
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina sbus_request_reply_error(sbus_req, SBUS_ERROR_UNKNOWN_DOMAIN,
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina "Unknown domain");
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina return EOK;
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina }
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina rdp_message_send_and_reply(sbus_req, ifp_ctx->rctx, dom, DP_PATH,
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina IFACE_DP_FAILOVER,
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina IFACE_DP_FAILOVER_LISTSERVERS,
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina DBUS_TYPE_STRING, &service);
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina return EOK;
bd4c2ed5aec7f57ea04500f0e43f151eedfdde45Pavel Březina}
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březinaint ifp_domains_domain_refresh_access_rules(struct sbus_request *sbus_req,
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina void *data)
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina{
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina struct ifp_ctx *ifp_ctx;
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina struct sss_domain_info *dom;
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina ifp_ctx = talloc_get_type(data, struct ifp_ctx);
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina dom = get_domain_info_from_req(sbus_req, data);
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina if (dom == NULL) {
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina sbus_request_reply_error(sbus_req, SBUS_ERROR_UNKNOWN_DOMAIN,
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina "Unknown domain");
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina return EOK;
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina }
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina rdp_message_send_and_reply(sbus_req, ifp_ctx->rctx, dom, DP_PATH,
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina IFACE_DP_ACCESS_CONTROL,
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina IFACE_DP_ACCESS_CONTROL_REFRESHRULES);
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina return EOK;
c6cf752337f5977ce3753b7113dc1a2342c86319Pavel Březina}