After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 728734 - New g_dbus_warning() API
New g_dbus_warning() API
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gdbus
unspecified
Other All
: Normal enhancement
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on:
Blocks: 728733
 
 
Reported: 2014-04-22 15:21 UTC by Allison Karlitskaya (desrt)
Modified: 2018-05-24 16:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add g_dbus_warning(). (8.62 KB, patch)
2014-04-28 23:43 UTC, Allison Karlitskaya (desrt)
none Details | Review

Description Allison Karlitskaya (desrt) 2014-04-22 15:21:10 UTC
We should add a function like g_dbus_warning() for complaining about D-Bus protocol violations.

You would call this when you fail to validate input from a given sender in a way that means that the sender must be violating the D-Bus protocol that you are implementing (like in bug 728733).

This function would either take extra parameters in the form of (at least) connection and bus name or it would be able to know from context what those are.  For method calls, passing the invocation would make sense.  Too bad we don't have something similar for signals...

The call would print out a warning message, but would also look up the sender of the malformed message by their bus name to get their PID and process name and dump that as well.  This would make it a good deal easier to trace the offending input back to its source.
Comment 1 Allison Karlitskaya (desrt) 2014-04-28 23:43:37 UTC
Created attachment 275394 [details] [review]
Add g_dbus_warning().
Comment 2 Lukasz Skalski 2014-05-09 09:30:35 UTC
Review of attachment 275394 [details] [review]:

Yes I agree, function like g_dbus_warning() will be very useful.

I've only noticed that in g_dbus_log_warning() function, there should be g_string_append_vprintf() instead of g_string_append_printf() - arguments are passed as a va_list.
Comment 3 Lars Karlitski 2015-04-27 06:58:09 UTC
Review of attachment 275394 [details] [review]:

I still think this is a bit too magic, but see the argument that it would not work with signals if we didn't do the source inspection. I think we should document more clearly that you can only call this directly in the handler for the message.

It also makes gdbus harder to maintain gdbus itself: renaming callbacks now also involves dealing with this code and it will crash if we ever change user data on the sources.

If only this weren't so insanely useful…

::: gio/gdbusconnection.c
@@ +7351,3 @@
+ */
+void
+g_dbus_log_warning (const gchar *log_domain,

The doc string above this function is for the macro. I think we should either document this function as well or rename it to match the macro's name.

@@ +7359,3 @@
+  va_list ap;
+
+  string = g_string_new ("Invalid D-Bus message; ");

inside the string: s/;/:/

@@ +7369,3 @@
+
+  va_start (ap, format_string);
+  g_string_append_printf (string, format_string, ap);

vprintf
Comment 4 GNOME Infrastructure Team 2018-05-24 16:28:16 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/862.