summaryrefslogtreecommitdiffstats
path: root/src/responder/common/iface
diff options
context:
space:
mode:
Diffstat (limited to 'src/responder/common/iface')
-rw-r--r--src/responder/common/iface/responder_domain.c73
-rw-r--r--src/responder/common/iface/responder_iface.c36
-rw-r--r--src/responder/common/iface/responder_iface.h37
-rw-r--r--src/responder/common/iface/responder_iface.xml13
-rw-r--r--src/responder/common/iface/responder_iface_generated.c78
-rw-r--r--src/responder/common/iface/responder_iface_generated.h63
6 files changed, 300 insertions, 0 deletions
diff --git a/src/responder/common/iface/responder_domain.c b/src/responder/common/iface/responder_domain.c
new file mode 100644
index 000000000..2e7f78855
--- /dev/null
+++ b/src/responder/common/iface/responder_domain.c
@@ -0,0 +1,73 @@
+/*
+ Copyright (C) 2016 Red Hat
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <string.h>
+#include <errno.h>
+
+#include "util/util.h"
+#include "sbus/sssd_dbus.h"
+#include "responder/common/responder.h"
+#include "responder/common/iface/responder_iface.h"
+
+static void set_domain_state_by_name(struct resp_ctx *rctx,
+ const char *domain_name,
+ enum sss_domain_state state)
+{
+ struct sss_domain_info *dom;
+
+ if (domain_name == NULL) {
+ DEBUG(SSSDBG_MINOR_FAILURE, "BUG: NULL domain name\n");
+ return;
+ }
+
+ DEBUG(SSSDBG_TRACE_LIBS, "Setting state of domain %s\n", domain_name);
+
+ for (dom = rctx->domains;
+ dom != NULL;
+ dom = get_next_domain(dom, SSS_GND_ALL_DOMAINS)) {
+
+ if (strcasecmp(dom->name, domain_name) == 0) {
+ break;
+ }
+ }
+
+ if (dom != NULL) {
+ sss_domain_set_state(dom, state);
+ }
+}
+
+int sss_resp_domain_active(struct sbus_request *req,
+ void *data,
+ const char *domain_name)
+{
+ struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
+
+ DEBUG(SSSDBG_TRACE_LIBS, "Enabling domain %s\n", domain_name);
+ set_domain_state_by_name(rctx, domain_name, DOM_ACTIVE);
+ return iface_responder_domain_SetActive_finish(req);
+}
+
+int sss_resp_domain_inconsistent(struct sbus_request *req,
+ void *data,
+ const char *domain_name)
+{
+ struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
+
+ DEBUG(SSSDBG_TRACE_LIBS, "Disabling domain %s\n", domain_name);
+ set_domain_state_by_name(rctx, domain_name, DOM_INCONSISTENT);
+ return iface_responder_domain_SetInconsistent_finish(req);
+}
diff --git a/src/responder/common/iface/responder_iface.c b/src/responder/common/iface/responder_iface.c
new file mode 100644
index 000000000..f1e618b65
--- /dev/null
+++ b/src/responder/common/iface/responder_iface.c
@@ -0,0 +1,36 @@
+/*
+ Copyright (C) 2016 Red Hat
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "sbus/sssd_dbus.h"
+#include "responder/common/iface/responder_iface.h"
+#include "responder/common/responder.h"
+
+struct iface_responder_domain iface_responder_domain = {
+ { &iface_responder_domain_meta, 0 },
+ .SetActive = sss_resp_domain_active,
+ .SetInconsistent = sss_resp_domain_inconsistent,
+};
+
+static struct sbus_iface_map iface_map[] = {
+ { RESPONDER_PATH, &iface_responder_domain.vtable },
+ { NULL, NULL }
+};
+
+struct sbus_iface_map *responder_get_sbus_interface()
+{
+ return iface_map;
+}
diff --git a/src/responder/common/iface/responder_iface.h b/src/responder/common/iface/responder_iface.h
new file mode 100644
index 000000000..abd7c83ce
--- /dev/null
+++ b/src/responder/common/iface/responder_iface.h
@@ -0,0 +1,37 @@
+/*
+ Copyright (C) 2016 Red Hat
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _RESPONDER_IFACE_H_
+#define _RESPONDER_IFACE_H_
+
+#include "responder/common/iface/responder_iface_generated.h"
+
+#define RESPONDER_PATH "/org/freedesktop/sssd/responder"
+
+struct sbus_iface_map *responder_get_sbus_interface(void);
+
+/* org.freedesktop.sssd.Responder.Domain */
+
+int sss_resp_domain_active(struct sbus_request *req,
+ void *data,
+ const char *domain_name);
+
+int sss_resp_domain_inconsistent(struct sbus_request *req,
+ void *data,
+ const char *domain_name);
+
+#endif /* _RESPONDER_IFACE_H_ */
diff --git a/src/responder/common/iface/responder_iface.xml b/src/responder/common/iface/responder_iface.xml
new file mode 100644
index 000000000..d3d0ff40e
--- /dev/null
+++ b/src/responder/common/iface/responder_iface.xml
@@ -0,0 +1,13 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.freedesktop.sssd.Responder.Domain">
+ <annotation value="iface_responder_domain" name="org.freedesktop.DBus.GLib.CSymbol"/>
+ <method name="SetActive">
+ <arg name="name" type="s" direction="in" />
+ </method>
+ <method name="SetInconsistent">
+ <arg name="name" type="s" direction="in" />
+ </method>
+ </interface>
+</node>
diff --git a/src/responder/common/iface/responder_iface_generated.c b/src/responder/common/iface/responder_iface_generated.c
new file mode 100644
index 000000000..1d59eafed
--- /dev/null
+++ b/src/responder/common/iface/responder_iface_generated.c
@@ -0,0 +1,78 @@
+/* The following definitions are auto-generated from responder_iface.xml */
+
+#include "util/util.h"
+#include "sbus/sssd_dbus.h"
+#include "sbus/sssd_dbus_meta.h"
+#include "sbus/sssd_dbus_invokers.h"
+#include "responder_iface_generated.h"
+
+/* invokes a handler with a 's' DBus signature */
+static int invoke_s_method(struct sbus_request *dbus_req, void *function_ptr);
+
+/* arguments for org.freedesktop.sssd.Responder.Domain.SetActive */
+const struct sbus_arg_meta iface_responder_domain_SetActive__in[] = {
+ { "name", "s" },
+ { NULL, }
+};
+
+int iface_responder_domain_SetActive_finish(struct sbus_request *req)
+{
+ return sbus_request_return_and_finish(req,
+ DBUS_TYPE_INVALID);
+}
+
+/* arguments for org.freedesktop.sssd.Responder.Domain.SetInconsistent */
+const struct sbus_arg_meta iface_responder_domain_SetInconsistent__in[] = {
+ { "name", "s" },
+ { NULL, }
+};
+
+int iface_responder_domain_SetInconsistent_finish(struct sbus_request *req)
+{
+ return sbus_request_return_and_finish(req,
+ DBUS_TYPE_INVALID);
+}
+
+/* methods for org.freedesktop.sssd.Responder.Domain */
+const struct sbus_method_meta iface_responder_domain__methods[] = {
+ {
+ "SetActive", /* name */
+ iface_responder_domain_SetActive__in,
+ NULL, /* no out_args */
+ offsetof(struct iface_responder_domain, SetActive),
+ invoke_s_method,
+ },
+ {
+ "SetInconsistent", /* name */
+ iface_responder_domain_SetInconsistent__in,
+ NULL, /* no out_args */
+ offsetof(struct iface_responder_domain, SetInconsistent),
+ invoke_s_method,
+ },
+ { NULL, }
+};
+
+/* interface info for org.freedesktop.sssd.Responder.Domain */
+const struct sbus_interface_meta iface_responder_domain_meta = {
+ "org.freedesktop.sssd.Responder.Domain", /* name */
+ iface_responder_domain__methods,
+ NULL, /* no signals */
+ NULL, /* no properties */
+ sbus_invoke_get_all, /* GetAll invoker */
+};
+
+/* invokes a handler with a 's' DBus signature */
+static int invoke_s_method(struct sbus_request *dbus_req, void *function_ptr)
+{
+ const char * arg_0;
+ int (*handler)(struct sbus_request *, void *, const char *) = function_ptr;
+
+ if (!sbus_request_parse_or_finish(dbus_req,
+ DBUS_TYPE_STRING, &arg_0,
+ DBUS_TYPE_INVALID)) {
+ return EOK; /* request handled */
+ }
+
+ return (handler)(dbus_req, dbus_req->intf->handler_data,
+ arg_0);
+}
diff --git a/src/responder/common/iface/responder_iface_generated.h b/src/responder/common/iface/responder_iface_generated.h
new file mode 100644
index 000000000..e7f5c64fe
--- /dev/null
+++ b/src/responder/common/iface/responder_iface_generated.h
@@ -0,0 +1,63 @@
+/* The following declarations are auto-generated from responder_iface.xml */
+
+#ifndef __RESPONDER_IFACE_XML__
+#define __RESPONDER_IFACE_XML__
+
+#include "sbus/sssd_dbus.h"
+
+/* ------------------------------------------------------------------------
+ * DBus Constants
+ *
+ * Various constants of interface and method names mostly for use by clients
+ */
+
+/* constants for org.freedesktop.sssd.Responder.Domain */
+#define IFACE_RESPONDER_DOMAIN "org.freedesktop.sssd.Responder.Domain"
+#define IFACE_RESPONDER_DOMAIN_SETACTIVE "SetActive"
+#define IFACE_RESPONDER_DOMAIN_SETINCONSISTENT "SetInconsistent"
+
+/* ------------------------------------------------------------------------
+ * DBus handlers
+ *
+ * These structures are filled in by implementors of the different
+ * dbus interfaces to handle method calls.
+ *
+ * Handler functions of type sbus_msg_handler_fn accept raw messages,
+ * other handlers are typed appropriately. If a handler that is
+ * set to NULL is invoked it will result in a
+ * org.freedesktop.DBus.Error.NotSupported error for the caller.
+ *
+ * Handlers have a matching xxx_finish() function (unless the method has
+ * accepts raw messages). These finish functions the
+ * sbus_request_return_and_finish() with the appropriate arguments to
+ * construct a valid reply. Once a finish function has been called, the
+ * @dbus_req it was called with is freed and no longer valid.
+ */
+
+/* vtable for org.freedesktop.sssd.Responder.Domain */
+struct iface_responder_domain {
+ struct sbus_vtable vtable; /* derive from sbus_vtable */
+ int (*SetActive)(struct sbus_request *req, void *data, const char *arg_name);
+ int (*SetInconsistent)(struct sbus_request *req, void *data, const char *arg_name);
+};
+
+/* finish function for SetActive */
+int iface_responder_domain_SetActive_finish(struct sbus_request *req);
+
+/* finish function for SetInconsistent */
+int iface_responder_domain_SetInconsistent_finish(struct sbus_request *req);
+
+/* ------------------------------------------------------------------------
+ * DBus Interface Metadata
+ *
+ * These structure definitions are filled in with the information about
+ * the interfaces, methods, properties and so on.
+ *
+ * The actual definitions are found in the accompanying C file next
+ * to this header.
+ */
+
+/* interface info for org.freedesktop.sssd.Responder.Domain */
+extern const struct sbus_interface_meta iface_responder_domain_meta;
+
+#endif /* __RESPONDER_IFACE_XML__ */