summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2017-09-22 10:47:30 +0200
committerLukas Slebodnik <lslebodn@redhat.com>2017-09-25 21:41:39 +0200
commit1024dbcba0c16fb5df5e6d16894a8c7a36dc75f2 (patch)
tree9cccc19b399a87644fd0044a4d6a0dad40671e73
parent39e300314cb43e534179a6950274e1e9c9a48465 (diff)
downloadsssd-1024dbcba0c16fb5df5e6d16894a8c7a36dc75f2.tar.gz
sssd-1024dbcba0c16fb5df5e6d16894a8c7a36dc75f2.tar.xz
sssd-1024dbcba0c16fb5df5e6d16894a8c7a36dc75f2.zip
IFP: parse ping arguments in codegen
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
-rw-r--r--src/responder/ifp/ifp_iface.xml4
-rw-r--r--src/responder/ifp/ifp_iface_generated.c25
-rw-r--r--src/responder/ifp/ifp_iface_generated.h5
-rw-r--r--src/responder/ifp/ifp_private.h4
-rw-r--r--src/responder/ifp/ifpsrv_cmd.c35
5 files changed, 40 insertions, 33 deletions
diff --git a/src/responder/ifp/ifp_iface.xml b/src/responder/ifp/ifp_iface.xml
index ce071bb99..39385e866 100644
--- a/src/responder/ifp/ifp_iface.xml
+++ b/src/responder/ifp/ifp_iface.xml
@@ -5,8 +5,8 @@
<annotation value="iface_ifp" name="org.freedesktop.DBus.GLib.CSymbol"/>
<method name="Ping">
- <!-- manual argument parsing, raw handler -->
- <annotation name="org.freedesktop.sssd.RawHandler" value="true"/>
+ <arg name="ping" type="s" direction="in" />
+ <arg name="pong" type="s" direction="out" />
</method>
<!-- SSSD components -->
diff --git a/src/responder/ifp/ifp_iface_generated.c b/src/responder/ifp/ifp_iface_generated.c
index 15339698f..6943e38e3 100644
--- a/src/responder/ifp/ifp_iface_generated.c
+++ b/src/responder/ifp/ifp_iface_generated.c
@@ -24,6 +24,25 @@ static int invoke_ss_method(struct sbus_request *dbus_req, void *function_ptr);
/* invokes a handler with a 'ssu' DBus signature */
static int invoke_ssu_method(struct sbus_request *dbus_req, void *function_ptr);
+/* arguments for org.freedesktop.sssd.infopipe.Ping */
+const struct sbus_arg_meta iface_ifp_Ping__in[] = {
+ { "ping", "s" },
+ { NULL, }
+};
+
+/* arguments for org.freedesktop.sssd.infopipe.Ping */
+const struct sbus_arg_meta iface_ifp_Ping__out[] = {
+ { "pong", "s" },
+ { NULL, }
+};
+
+int iface_ifp_Ping_finish(struct sbus_request *req, const char *arg_pong)
+{
+ return sbus_request_return_and_finish(req,
+ DBUS_TYPE_STRING, &arg_pong,
+ DBUS_TYPE_INVALID);
+}
+
/* arguments for org.freedesktop.sssd.infopipe.ListComponents */
const struct sbus_arg_meta iface_ifp_ListComponents__out[] = {
{ "components", "ao" },
@@ -182,10 +201,10 @@ int iface_ifp_ListDomains_finish(struct sbus_request *req, const char *arg_domai
const struct sbus_method_meta iface_ifp__methods[] = {
{
"Ping", /* name */
- NULL, /* no in_args */
- NULL, /* no out_args */
+ iface_ifp_Ping__in,
+ iface_ifp_Ping__out,
offsetof(struct iface_ifp, Ping),
- NULL, /* no invoker */
+ invoke_s_method,
},
{
"ListComponents", /* name */
diff --git a/src/responder/ifp/ifp_iface_generated.h b/src/responder/ifp/ifp_iface_generated.h
index 3dd4355e6..30752bf06 100644
--- a/src/responder/ifp/ifp_iface_generated.h
+++ b/src/responder/ifp/ifp_iface_generated.h
@@ -130,7 +130,7 @@
/* vtable for org.freedesktop.sssd.infopipe */
struct iface_ifp {
struct sbus_vtable vtable; /* derive from sbus_vtable */
- sbus_msg_handler_fn Ping;
+ int (*Ping)(struct sbus_request *req, void *data, const char *arg_ping);
int (*ListComponents)(struct sbus_request *req, void *data);
int (*ListResponders)(struct sbus_request *req, void *data);
int (*ListBackends)(struct sbus_request *req, void *data);
@@ -143,6 +143,9 @@ struct iface_ifp {
int (*ListDomains)(struct sbus_request *req, void *data);
};
+/* finish function for Ping */
+int iface_ifp_Ping_finish(struct sbus_request *req, const char *arg_pong);
+
/* finish function for ListComponents */
int iface_ifp_ListComponents_finish(struct sbus_request *req, const char *arg_components[], int len_components);
diff --git a/src/responder/ifp/ifp_private.h b/src/responder/ifp/ifp_private.h
index ed1b63ad6..13455bbf7 100644
--- a/src/responder/ifp/ifp_private.h
+++ b/src/responder/ifp/ifp_private.h
@@ -48,9 +48,7 @@ errno_t ifp_register_sbus_interface(struct sbus_connection *conn,
void ifp_register_nodes(struct ifp_ctx *ctx, struct sbus_connection *conn);
-/* This is a throwaway method to ease the review of the patch.
- * It will be removed later */
-int ifp_ping(struct sbus_request *dbus_req, void *data);
+int ifp_ping(struct sbus_request *dbus_req, void *data, const char *ping);
int ifp_user_get_attr(struct sbus_request *dbus_req, void *data);
diff --git a/src/responder/ifp/ifpsrv_cmd.c b/src/responder/ifp/ifpsrv_cmd.c
index fc9161e82..38932b7cd 100644
--- a/src/responder/ifp/ifpsrv_cmd.c
+++ b/src/responder/ifp/ifpsrv_cmd.c
@@ -673,20 +673,17 @@ struct cli_protocol_version *register_cli_protocol_version(void)
return ssh_cli_protocol_version;
}
-/* This is a throwaway method to ease the review of the patch.
- * It will be removed later */
-int ifp_ping(struct sbus_request *dbus_req, void *data)
+int ifp_ping(struct sbus_request *dbus_req, void *data, const char *ping)
{
struct ifp_ctx *ifp_ctx = talloc_get_type(data, struct ifp_ctx);
- static const char *pong = "PONG";
- const char *request;
- DBusError dberr;
- errno_t ret;
struct ifp_req *ifp_req;
+ errno_t ret;
if (ifp_ctx == NULL) {
DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
- return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID);
+ sbus_request_reply_error(dbus_req, SBUS_ERROR_INTERNAL,
+ "Invalid infopipe context!");
+ return ERR_SBUS_REQUEST_HANDLED;
}
ret = ifp_req_create(dbus_req, ifp_ctx, &ifp_req);
@@ -694,23 +691,13 @@ int ifp_ping(struct sbus_request *dbus_req, void *data)
return ifp_req_create_handle_failure(dbus_req, ret);
}
- if (!sbus_request_parse_or_finish(dbus_req,
- DBUS_TYPE_STRING, &request,
- DBUS_TYPE_INVALID)) {
- return EOK; /* handled */
- }
-
- DEBUG(SSSDBG_CONF_SETTINGS, "Got request for [%s]\n", request);
+ DEBUG(SSSDBG_CONF_SETTINGS, "Got request for [%s]\n", ping);
- if (strcasecmp(request, "ping") != 0) {
- dbus_error_init(&dberr);
- dbus_set_error_const(&dberr,
- DBUS_ERROR_INVALID_ARGS,
- "Ping() only accepts ping as a param\n");
- return sbus_request_fail_and_finish(dbus_req, &dberr);
+ if (strcasecmp(ping, "ping") != 0) {
+ sbus_request_reply_error(dbus_req, DBUS_ERROR_INVALID_ARGS,
+ "Ping() only accepts \"ping\" as a param\n");
+ return ERR_SBUS_REQUEST_HANDLED;
}
- return sbus_request_return_and_finish(dbus_req,
- DBUS_TYPE_STRING, &pong,
- DBUS_TYPE_INVALID);
+ return iface_ifp_Ping_finish(dbus_req, "PONG");
}