summaryrefslogtreecommitdiffstats
path: root/src/responder/nss/nsssrv.c
diff options
context:
space:
mode:
authorStef Walter <stefw@redhat.com>2014-02-21 16:59:48 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-06-02 19:03:26 +0200
commit462592812dc67a49fa41a46626ebff3d48e20f19 (patch)
tree9f3d4e6b1649ce22c2dfee2279fa595e483cf15e /src/responder/nss/nsssrv.c
parentc672fc52ff2bade73ad735162af9b4eb6fcccdfb (diff)
downloadsssd-462592812dc67a49fa41a46626ebff3d48e20f19.tar.gz
sssd-462592812dc67a49fa41a46626ebff3d48e20f19.tar.xz
sssd-462592812dc67a49fa41a46626ebff3d48e20f19.zip
sbus: Add the sbus_request_parse_or_finish() method
Some DBus types returned from dbus_message_get_args() require memory to be released when done. We automatically attach these to the talloc struct sbus_request memory context in this function. This accepts varargs similar to dbus_message_get_args(), which are rather awkward. However instead of reworking them completely, future generated marshalling code will replace most uses of these varargs. If parsing the dbus message fails, then it responds to the DBus caller with an appropriate error such as o.f.D.Error.InvalidArgs. In these cases (ie: when it returns FALSE) the sbus_request is finished. Migrated some, but not all, uses of dbus_message_get_args() to the new function. Some instances have uncommon semantics such as terminating the connection upon failure to parse a message. Reviewed-by: Jakub Hrozek <jhrozek@redhat.com> Reviewed-by: Pavel Březina <pbrezina@redhat.com> Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com> (cherry picked from commit 06b7bc8ca2e005ed510210d3b8dee16afbabbcc9)
Diffstat (limited to 'src/responder/nss/nsssrv.c')
-rw-r--r--src/responder/nss/nsssrv.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c
index 5e6237722..c6e7cb402 100644
--- a/src/responder/nss/nsssrv.c
+++ b/src/responder/nss/nsssrv.c
@@ -311,28 +311,17 @@ static int nss_memcache_initgr_check(struct sbus_request *dbus_req, void *data)
{
struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
struct nss_ctx *nctx = talloc_get_type(rctx->pvt_ctx, struct nss_ctx);
- DBusError dbus_error;
- dbus_bool_t dbret;
char *user;
char *domain;
uint32_t *groups;
int gnum;
- dbus_error_init(&dbus_error);
-
- dbret = dbus_message_get_args(dbus_req->message, &dbus_error,
- DBUS_TYPE_STRING, &user,
- DBUS_TYPE_STRING, &domain,
- DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32,
- &groups, &gnum,
- DBUS_TYPE_INVALID);
-
- if (!dbret) {
- DEBUG(SSSDBG_CRIT_FAILURE, "Failed, to parse message!\n");
- if (dbus_error_is_set(&dbus_error)) {
- dbus_error_free(&dbus_error);
- }
- return EIO;
+ if (!sbus_request_parse_or_finish(dbus_req,
+ DBUS_TYPE_STRING, &user,
+ DBUS_TYPE_STRING, &domain,
+ DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &groups, &gnum,
+ DBUS_TYPE_INVALID)) {
+ return EOK; /* handled */
}
DEBUG(SSSDBG_TRACE_LIBS,