]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
ply-input-device: Add new plymouth.debug-input-devices kernel option
authorRay Strode <rstrode@redhat.com>
Mon, 4 Dec 2023 12:59:38 +0000 (07:59 -0500)
committerRay Strode <halfline@gmail.com>
Mon, 4 Dec 2023 23:11:05 +0000 (23:11 +0000)
Right now we don't have a lot of debugging information when processing
keyboard events.  I mean we don't want passwords to show up in logs
after all.

Still, it would be useful to have a way to turn the valve on to the
firehose.

This commit adds a plymouth.debug-input-devices kernel option.

src/libply-splash-core/ply-input-device.c

index 19daa394df47d4dec85a744df7ced5f4b8f28aa8..db826ab9a2ff8ef430086eae17dfa5695fa5dcd9 100644 (file)
@@ -161,6 +161,19 @@ on_input (ply_input_device_t *input_device)
         int rc;
         unsigned int flags;
         ply_buffer_t *input_buffer = ply_buffer_new ();
+        static enum { PLY_INPUT_DEVICE_DEBUG_UNKNOWN = -1,
+                      PLY_INPUT_DEVICE_DEBUG_DISABLED,
+                      PLY_INPUT_DEVICE_DEBUG_ENABLED } debug_key_events = PLY_INPUT_DEVICE_DEBUG_UNKNOWN;
+
+        if (debug_key_events == PLY_INPUT_DEVICE_DEBUG_UNKNOWN) {
+                if (ply_kernel_command_line_has_argument ("plymouth.debug-input-devices")) {
+                        ply_trace ("WARNING: Input device debugging enabled. Passwords will be in log!");
+                        debug_key_events = PLY_INPUT_DEVICE_DEBUG_ENABLED;
+                } else {
+                        ply_trace ("Input device debugging disabled");
+                        debug_key_events = PLY_INPUT_DEVICE_DEBUG_DISABLED;
+                }
+        }
 
         flags = LIBEVDEV_READ_FLAG_NORMAL;
         for (;;) {
@@ -183,6 +196,14 @@ on_input (ply_input_device_t *input_device)
                         break;
                 }
 
+                if (debug_key_events == PLY_INPUT_DEVICE_DEBUG_ENABLED) {
+                        ply_trace ("Received event from input device %s, type=%s code=%s value=%d.",
+                                   libevdev_get_name (input_device->dev),
+                                   libevdev_event_type_get_name (ev.type),
+                                   libevdev_event_code_get_name (ev.type, ev.code),
+                                   ev.value);
+                }
+
                 if (!libevdev_event_is_type (&ev, EV_KEY))
                         continue;