GNOME Bugzilla – Bug 728734
New g_dbus_warning() API
Last modified: 2018-05-24 16:28:16 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.
Created attachment 275394 [details] [review] Add g_dbus_warning().
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.
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
-- 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.