get username from message ?
frederic heem
frederic.heem at telsey.it
Mon Oct 30 06:36:43 PST 2006
Actually, there is a memory leak, dbus_g_method_get_sender allocates memory by
duplicating the output of dbus_message_get_sender. IMHO, duplicated is
useless.
Please find attached a patch that do not duplicate the result, this is done
simply by changing the dbus_g_method_get_sender prototype from
gchar *
dbus_g_method_get_sender (DBusGMethodInvocation *context)
to
const gchar *
dbus_g_method_get_sender (DBusGMethodInvocation *context)
A bug report ha been opened :
https://bugs.freedesktop.org/show_bug.cgi?id=8832
Frederic Heem
Alle 14:52, lunedì 30 ottobre 2006, frederic heem ha scritto:
> Hi,
> Thanks a lot, it works:
> org_freedesktop_DBus_get_connection_unix_user(pSniffer->pProxy,
> dbus_g_method_get_sender(pMethodInvocation), &uiUserId, &pError)
>
> The only problem is that the parameter pMethodInvocation of type
> DBusGMethodInvocation is given only for asynchronous functions, which fine
> for my case.
> What about the group id ?
> Frederic Heem
>
> Alle 11:32, lunedì 30 ottobre 2006, Matthew Johnson ha scritto:
> > On Mon, 30 Oct 2006, frederic heem wrote:
> > > Hi,
> > > Is there a way the get the message sender username ?
> >
> > Yes, get the sending unique bus name (with dbus_message_get_sender, or
> > equivalent in your binding) and call
> > org.freedesktop.DBus.GetConnectionUnixUser
> >
> > Matt
>
> _______________________________________________
> dbus mailing list
> dbus at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dbus
-------------- next part --------------
From 462a95d857b1350eb6af8df31df1f9ddae32a79c Mon Sep 17 00:00:00 2001
From: frederic heem <heefre at heefre.(none)>
Date: Mon, 30 Oct 2006 15:20:12 +0100
Subject: [PATCH] dbus_g_method_get_sender return const char*
---
dbus/dbus-glib-lowlevel.h | 2 +-
dbus/dbus-gobject.c | 10 +++-------
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/dbus/dbus-glib-lowlevel.h b/dbus/dbus-glib-lowlevel.h
index cb015cc..289e716 100644
--- a/dbus/dbus-glib-lowlevel.h
+++ b/dbus/dbus-glib-lowlevel.h
@@ -57,7 +57,7 @@ DBusMessage* dbus_g_message_get_mess
* g-functions anyhow)
*/
-gchar* dbus_g_method_get_sender (DBusGMethodInvocation *context);
+const gchar* dbus_g_method_get_sender (DBusGMethodInvocation *context);
DBusMessage* dbus_g_method_get_reply (DBusGMethodInvocation *context);
diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c
index b51bc7c..d7cf7c4 100644
--- a/dbus/dbus-gobject.c
+++ b/dbus/dbus-gobject.c
@@ -1967,17 +1967,13 @@ dbus_g_object_register_marshaller_array
*
* Returns: the unique name of teh sender
*/
-gchar *
+const gchar *
dbus_g_method_get_sender (DBusGMethodInvocation *context)
{
const gchar *sender;
- sender = dbus_message_get_sender (dbus_g_message_get_message (context->message));
-
- if (sender == NULL)
- return NULL;
-
- return strdup (sender);
+ sender = (const gchar *)dbus_message_get_sender (dbus_g_message_get_message (context->message));
+ return sender;
}
/**
--
1.4.2.4
More information about the dbus
mailing list