Ray Strode [Fri, 5 May 2023 20:22:11 +0000 (16:22 -0400)]
wip! Add ply-terminal-buffer object
We're going to need to do at least basic parsing of terminal text
so we can show the console to the user in color when they hit
escape and VTs are disabled.
This commit adds the start of a class to do this basic parsing.
The way it works is the terminal text is inject into the object
and all escape sequences are filtered out. When a color control
sequence is found, the current color is noted, along with which
characters it applies to. A list of the text spans and their
color attributes is then iteratable using a an api.
n3rdopolis [Mon, 2 Jan 2023 16:57:21 +0000 (11:57 -0500)]
ply-input-device: Ensure that the LED state is updated on the keyboard of which the lock key was pressed on
When a lock modifier is pressed, plymouth goes through some gymnastics
to ensure the LEDs on all attached keyboards are appropriately updated.
Unfortunately, an optimization in the code used to avoid redundant
updates of keyboards that already have the correct state is actually
preventing the initiating keyboard from getting its LEDs turned on.
This is because the initiating keyboard gets its state updated at
key press time before the LED handling code runs, thus making it
seem like that run is redundant.
This commit introduces a new state variable `leds_state_invalid`
on the input device to mark this situation and updates the optimization
check to also check the new variable.
Ray Strode [Wed, 30 Nov 2022 14:51:17 +0000 (09:51 -0500)]
device-manager: Actually fall back to reading from tty if no xkb layout specified
Commit 7fcfcdf2d63025151a160f7948ee7406f0f16843 tried to fall back to
reading from a tty if no xkb layout was specified, but neglected to
actually check if no xkb layout was specified and force fall back to
reading from a tty in that case.
This commit changes device manager to actually disable reading from
/dev/input if the user doesn't specify a layout to use in vconsole.conf.
Ray Strode [Wed, 30 Nov 2022 14:51:17 +0000 (09:51 -0500)]
device-manager: Fall back to reading from tty if no xkb layout specified
At the moment if a user doesn't specify a xkb layout in vconsole.conf we
just fall back to assuming a us qwerty layout.
This isn't really optimal, since it might not match the keyboard.
Furthermore, the tty does have a usable layout, so it makes more sense
to fall back to it.
This commit changes device manager to disable reading from /dev/input
if the user doesn't specify a layout to use in vconsole.conf.
Close https://gitlab.freedesktop.org/plymouth/plymouth/-/issues/199
Ray Strode [Tue, 29 Nov 2022 19:46:08 +0000 (14:46 -0500)]
ci: Fix check-format
In commit bb6580212d45f9ab0a459a9335aec2ff20818a6e we tried to stop
running check-format on debian. We did this by moving the check-format
details to its own map and then adding a "<<" merge key to only pull
it in on Fedora.
The Fedora map already has a "<<" merge key however for doing the actual
build.
It's not allowed for their to be two, and gitlab's ci just ignores
the second one.
Ray Strode [Tue, 29 Nov 2022 18:08:59 +0000 (13:08 -0500)]
input-device: Only allow one renderer to consume input at a time
Right now if there are two graphics cards, there ends up with two
renderers active at the same time. Both process keyboard inputs
and both end up sending those events to plymouthd, resulting in
duplicate input.
This commit changes the input handlers so the first one wins, and
the rest don't get input.
Ray Strode [Fri, 21 Oct 2022 15:33:41 +0000 (11:33 -0400)]
src: Hide console text when splash is requested
plymouthd may not be able to show the splash screen as soon as the
boot process wants it shown (if e.g. the driver isn't fully loaded
yet)
In that case, we sit tight and wait. Unfortunately, we aren't
logging boot messages while waiting.
This commit sets KD_GRAPHICS mode early to hide text from hitting
the console, but still tells systemd to print messages. This way
we get boot logging but don't display the text while we wait on
the splash.
Ray Strode [Fri, 25 Nov 2022 16:27:24 +0000 (11:27 -0500)]
device-manager: Only wait for device timeout for framebuffer devices
At the moment we ignore any udev events that come in before the
device timeout that are not drm devices.
That is because we don't want to use framebuffer devices as anything
but a last resort fallback option.
In the near future we're going to be handling input events from udev
as well. Those will obviously need to be handled right away, just like
drm devices.
This commit makes the check only defer framebuffer devices and not
anything that isn't a drm device.
Ray Strode [Fri, 25 Nov 2022 16:25:37 +0000 (11:25 -0500)]
ply-device-manager: Add != 0 to strcmp calls
strcmp is kind of a confusing function in that it returns
non-zero when the strings are not equal. That is
especially counterintuitive when this non-zero value is
treated as a TRUE boolean.
This commit just adds some != 0's to a couple of strcmp
calls for clarity.
Ray Strode [Sat, 26 Nov 2022 16:15:59 +0000 (11:15 -0500)]
buffer: Support length == 0 for ply_buffer_append_bytes
Right now callers of ply_buffer_append_bytes have to be
very careful to make sure the data they're appending is
non-zero in length. This is kind of inconvenient, since
it's not unusual for data to come in that's zero bytes
long.
For simplicity, this commit just makes
ply_buffer_append_bytes support that use case.
Ray Strode [Thu, 17 Nov 2022 15:01:34 +0000 (10:01 -0500)]
terminal: Add API for flushing input buffer
In the future we're going to start reading keyboard input from
/dev/input instead of the tty. When that happens, input will
still be sent by the kernel to the tty.
This input would eventually back up and overflow.
To address that problem before it exists, this commit adds a new
API, ply_terminal_flush_input, that will drain the input buffer
on demand.
We can later use that API to keep the tty from backing up.
Ray Strode [Wed, 16 Nov 2022 18:57:56 +0000 (13:57 -0500)]
trigger: Add the ability to trigger data with an associated instance
Right now triggers can only fire off handlers that have one piece
of data associated with them, but sometimes it's useful to have
an object associated with the data too.
This commit adds new api for adding "instance handlers" that have
an additional parameter and a new method `ply_trigger_set_instance`
that allows an object to be associated with the trigger and get
used for the additional parameter of the instance handlers.
n3rdopolis [Tue, 18 Oct 2022 17:06:28 +0000 (13:06 -0400)]
device-manager: Support kernels with CONFIG_VT=n
At the moment, plymouth requires VT support be enabled in the kernel
to show graphical splashes.
This is because:
1. it relies on the tty to show details
2. when VT support is disabled the kernel will use ttyS0 as the default
console which makes plymouth disable graphical splashes since it assumes
the machine is a server with a serial console.
This commit addresses the first problem by disabling the
escape-to-toggle-details feature and addresses the second problem by
introducing a new kernel parameter plymouth.graphical that is like
the "splash" option and "plymouth.ignore-serial-consoles" option
combined.
plugins: label-freetype: Fixes calculation of line width
label-freetype was giving a wrong line width for two reasons:
* Unproper handling of negative left bearings as it was using it as normal
while in fact the plugin draws full character boxes.
* Loading of the character used different flags when calculating width
and when actually printing the characters.
label->width is used to calculate wrapping of lines and it is by
default -1. We need to use label->area.width instead when aligning a
line, as label->width might not have been set.
Ray Strode [Tue, 30 Aug 2022 18:41:36 +0000 (14:41 -0400)]
details: Don't replay boot buffer on serial consoles
commit 0e59dde8 changed the details plugin to clear the terminal when
first opening it. This was done to prevent duplicate messages from
showing up when toggling back and forth between details and graphical
splashes.
That has the negative side effect of purging serial console output too
though. Furthermore, it makes little sense to replay the boot buffer
on serial consoles, since serial consoles don't aggressively purge
scrollback like VTs do.
This commit adds a check to make sure the terminal is a VT before trying
to clear and replay the scrollback buffer.
shiptux [Sat, 27 Aug 2022 07:09:57 +0000 (15:09 +0800)]
ply-device-manager: Add plymouth.force-frame-buffer-on-boot parameter, allow to choose force framebuffer mode.
Some hardware vendor may not open source display driver. (Such as pangu
M900). They load drm driver via kernel modules. On such devices, drm driver
load more slowly then other devices, which may cause logo show later and no
seem to get the Plymouth decryption screen to show. To avoid this problem,
add a bootargs for people who want to forced use fb in plymouth.
When found "plymouth.force-frame-buffer-on-boot flags" in kernel parameter,
During the system start, PLY_DEVICE_MANAGER_FLAGS_FORCE_FRAM_BUFFER will be
add to device_manager_flags. Then "force_fb" mode will enable, and the
renderer_type set as framebuffer.
systemd: Add mkinitcpio support to plymouth-switch-root-initramfs.service
plymouth-switch-root-initramfs.service commands plymouth to release
rootfs to allow the shutdown ramfs to unmount rootfs. However, it only
integrates with dracut. Arch Linux uses mkinitcpio by default, and it
uses shutdown ramfs when layered block storage (e.g. LUKS) is used for
rootfs. Therefore, it fails to unmount rootfs on shutdown if LUKS and
plymouth are used together.
Add a new trigger for plymouth-switch-root-initramfs.service to start
when /run/initramfs/shutdown exists (/run/initramfs/bin/sh may not exist
with mkinitcpio when systemd-based initramfs is used), and add a
dependency to start it after mkinitcpio generates the shutdown ramfs.
Hans de Goede [Wed, 28 Sep 2022 13:16:15 +0000 (15:16 +0200)]
ply-device-manager: Also ignore SimpleDRM devs in coldplug enumeration path
Plymouth has 2 hw discovery paths:
1. Enumerating devices already known by udev at plymouth startup
2. Devices which are hotplugged after startup
At boot we have udevd which is enumerating hw and plymouthd racing
with each other, which means that plymouthd may discover the new
SimpleDRM device through either 1. or 2.
Before this patch a check for SimpleDRM was missing from path 1, causing
it to be treated as a normal device instead of being ignored as intended:
plymouth-debug.log for the simpledrm being enumerated in path 1:
ply-device-manager.c:344: create_devices_for_subsystem:
found device /sys/devices/platform/simple-framebuffer.0/drm/card0
ply-device-manager.c:351: create_devices_for_subsystem:
device is initialized
ply-device-manager.c:360: create_devices_for_subsystem:
found node /dev/dri/card0
ply-device-manager.c:283: create_devices_for_udev_device:
found DRM device /dev/dri/card0
ply-device-manager.c:885: create_devices_for_terminal_and_rende:
creating devices for /dev/dri/card0 (renderer type: 1)
plymouth-debug.log for the simpledrm *not* being enumerated in path 1:
ply-device-manager.c:344: create_devices_for_subsystem:
found device /sys/devices/platform/simple-framebuffer.0/drm/card0
ply-device-manager.c:367: create_devices_for_subsystem:
it's not initialized
followed by path 2 enumerating the device very shortly after this:
ply-device-manager.c:532: on_udev_event:
got add event for device /dev/dri/card0
ply-device-manager.c:462: verify_add_or_change:
ignoring since we only handle SimpleDRM devices after timeout
Note how path 2 does correctly ignore SimpleDRM devices, where as
path 1 does not. This commit fixes this by moving the verify_drm_device()
check in to create_devices_for_udev_device() which runs in both paths.
Kate Hsuan [Fri, 10 Jun 2022 05:52:37 +0000 (13:52 +0800)]
plugins: splash: two-step: Secure boot check and a warning image
Secure boot is used against several security threats when malware tries to
infect the firmware of the system. Users may inadvertently disable or
software may intentionally disable the secure boot. Consequently, the
system is running on an insecure platform with incorrect configuration. If
Plymouth could offer a warning to the user, the user could reboot and
reconfigure their system or asks for help immediately.
This work can be used to check the secure boot configuration and put a red
warning image on the screen if the secure boot is disabled. Also, this
check can be utterly disabled through the kernel parameter for testing.
If the parameter "secure_boot.warn_if_disabled=false" appears in the
kernel parameter, the secure boot check will be disabled.
This checks the secure boot status. If the secure boot are enabled,
return true. Otherwise, return false.
The system secure boot settings is at
/sys/firmware/efi/efivars/SecureBoot* and the fifth byte should be
0x1 which means the system secure boot is enabled.