From 776b4f4cec5f0c9f163bf8f6cc38711ca81197b2 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Mon, 2 Dec 2019 15:38:10 +0100 Subject: [PATCH] device: Log offending API user if DeleteEnrolledFinger is used When the DeleteEnrolledFinger API is used, log an additional warning with the command that made the call. --- src/device.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/device.c b/src/device.c index 5d5bd26..e5f5c4c 100644 --- a/src/device.c +++ b/src/device.c @@ -1297,6 +1297,44 @@ static void delete_enrolled_fingers(FprintDevice *rdev, const char *user) } } +#ifdef __linux__ +static void log_offending_client(DBusGMethodInvocation *context) +{ + g_autofree char *sender = NULL; + g_autofree char *path = NULL; + g_autofree char *content = NULL; + DBusGProxy *proxy = NULL; + guint pid = 0; + + sender = dbus_g_method_get_sender(context); + proxy = dbus_g_proxy_new_for_name (fprintd_dbus_conn, + "org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus"); + + if (!dbus_g_proxy_call(proxy, + "GetConnectionUnixProcessID", + NULL, + G_TYPE_STRING, + sender, + G_TYPE_INVALID, + G_TYPE_UINT, + &pid, + G_TYPE_INVALID)) { + goto out; + } + + path = g_strdup_printf ("/proc/%u/comm", pid); + if (g_file_get_contents (path, &content, NULL, NULL)) { + g_strchomp (content); + g_warning ("Offending API user is %s", content); + } + +out: + g_clear_object (&proxy); +} +#endif + static void fprint_device_delete_enrolled_fingers(FprintDevice *rdev, const char *username, DBusGMethodInvocation *context) @@ -1307,6 +1345,9 @@ static void fprint_device_delete_enrolled_fingers(FprintDevice *rdev, gboolean opened; g_warning ("The API user should be updated to use DeleteEnrolledFingers2 method!"); +#ifdef __linux__ + log_offending_client(context); +#endif user = _fprint_device_check_for_username (rdev, context,