Commit graph

2100 commits

Author SHA1 Message Date
Ray Strode
3945071e39 boot-server: free the argument and triggers
coverity found some pervasive leaking of the argument
and triggers.

This commit mops them up.
2018-10-15 21:56:03 -04:00
Ray Strode
5badb95b8e script: fix various memory leaks
coverity found a few leaks.

this commit mops them up.
2018-10-15 21:44:10 -04:00
Ray Strode
322a3635fa key-file: ply_key_file_get_value returns duplicated memory, don't leak
For some reason I made the same api misdesign with ply_key_file_t
that I made when writing GKeyFile...it returns duplicated memory for
no good reason.

This commit sprinkles frees around.
2018-10-15 21:13:58 -04:00
Ray Strode
656444ed26 event-loop: fix leak in error path
ply_event_loop_new fails to clean itself up if it's unable to
create a pipe for dispatching signals.

This commit fixes that.
2018-10-15 21:07:01 -04:00
Ray Strode
310b63cd15 boot-splash: fix memory leak in error path
If the splash key file fails to load, we don't free
the associated key file object.

This commit fixes that.
2018-10-15 21:04:47 -04:00
Ray Strode
4ff6d59d10 populate-initrd: drop unused local variable
the inst_library function declares a variable `_lib`
that's completely unused.

This commit removes the declaration.
2018-10-15 21:02:50 -04:00
Iain Lane
89283f38b0 Merge branch 'fix-deactivate-udev-race' into 'master'
device-manager: don't watch for udev events when deactivated

See merge request plymouth/plymouth!5
2018-10-10 20:42:27 +00:00
Ray Strode
85d843af84
device-manager: don't watch for udev events when deactivated
If a device gets added when we're already deactivated, plymouth shouldn't
process the device, since processing it effectively activates plymouth.

This commit pulls the udev monitor fd out of the event loop while
plymouth is deactivated so new events are deferred until reactivation.

Modified by Iain Lane <iain.lane@canonical.com>: Also deactivate the
timer that finds all devices known to udev after an interval, when
paused.
2018-10-10 20:09:52 +01:00
Ray Strode
0a66272326 Merge branch 'wip/dont-muck-with-login-screen-tty' into 'master'
main: ensure tty is closed on deactivate

See merge request plymouth/plymouth!2
2018-08-27 19:19:41 +00:00
Ray Strode
28ee4012c9 main: ensure tty is closed on deactivate
If plymouth doesn't get explicitly "activated" then when
GDM tries to deactivate it, the deactivation request is
a noop.

One aspect of being active, though is having ownership and
control of the terminal.  This happens immediately, even
before a splash is shown.

The `deactivate` request needs to relinguish such control,
unconditionally, since some display server is about to use
the tty.

This commit fixes that.
2018-08-27 15:16:18 -04:00
Ray Strode
7663b0c587 Merge branch 'wip/container-condition-check' into 'master'
systemd-units: Add "ConditionVirtualization=!container"

Closes #27

See merge request plymouth/plymouth!1
2018-08-07 15:41:15 +00:00
Hans de Goede
9ed2a0c55b systemd-units: Add "ConditionVirtualization=!container"
When running in a container with plymouth installed, plymouth is started
unnecessarily and systemd prints warnings:

[  OK  ] Reached target Shutdown.
Sending SIGTERM to remaining processes...
Sending SIGKILL to remaining processes...
Process 253 (plymouthd) has been been marked to be excluded from killing. It is running from the root file system, and thus likely to block re-mounting of the root file system to read-only. Please consider moving it into an initrd file system instead.

It makes little sense to start plymouth in contains, so add
'ConditionVirtualization=!container' everywhere where
ConditionKernelCommandLine=!plymouth.enable=0 appears to disable plymouth
in containers.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1337611
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Closes: https://gitlab.freedesktop.org/plymouth/plymouth/issues/27
2018-08-07 09:58:58 -04:00
Ray Strode
81055ace5b README: add link to Code of Conduct 2018-08-06 14:58:18 -04:00
Ray Strode
f151b22e62 two-step: add unhandled splash mode case to switch
This fixes a compiler warning.
2018-07-10 16:00:18 -04:00
Ray Strode
75ef8ee24b main: fix build
I slightly modified Hans patch in commit 129b4a50 before pushing it
and broke the build.

This fixes the build by adding a forward declaration.
2018-07-10 15:58:04 -04:00
Hans de Goede
b145b25dbe Fix miscellaneous compiler warnings
Fix all compiler warnings (and one type) except for the deprectation warnings
for the gdk_screen_get_monitor_* functions used in the x11 renderer.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-07-10 15:53:57 -04:00
Hans de Goede
7fdfeecd32 configure: Pass -Wno-cast-function-type if available
plymouth uses function type casts for callbacks in quite a few places, fixing
these needlessly complicates the code, so lets pass -Wno-cast-function-type.

This fixes 218 warnings like this one:

ply-command-parser.c: In function ‘ply_command_parser_stop_parsing_arguments’:
ply-command-parser.c:680:48: warning: cast between incompatible function types from ‘void (*)(ply_command_parser_t *)’ {aka ‘void (*)(struct _ply_command_parser *)’} to ‘void (*)(void *, int,  ply_event_loop_t *)’ {aka ‘void (*)(void *, int,  struct _ply_event_loop *)’} [-Wcast-function-type]
                                                (ply_event_loop_exit_handler_t)

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-07-10 15:47:14 -04:00
Hans de Goede
6a1fdabf34 main: Fix getting detailed logs from systemd
This are 3 issues with the detailed logs handling:

1) plymouth attaches to the session directly on a show-splash command
(in on_show_splash()), but it does not tell systemd to start printing
details until the splash is actually shown after the splash_delay.

2) If the splash is actually shown during the initrd (e.g. a diskcript
password is necessary) then we tell the initrd systemd instance to
print details, but we don't tell the regular initrd instance which takes
over as pid 1 after the switch-root to print details.

This leads to rather inconsistent logging/printing behavior, e.g.:

* If a diskcrypt password is asked for, we only log details from
the initrd phase.

* If the boot is shorter then splash_delay no details are logged

* If the user presses ESC during boot during the initrd, only initrd
  messages are printed

* If the user presses ESC during boot after the initrd, only normal
  messages are printed

This commit fixes both these issues by:

1) Telling systemd to print details as soon as we have attached to the session;
   and to stop printing details when we detach from the session (*)
2) Telling systemd to print details after the rootfs has been remounted rw

*) This is necessary to have a smooth transition to e.g. gdm if the splash
has not shown because the boot is shorter then splash_delay

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-07-10 15:40:29 -04:00
Hans de Goede
129b4a5004 main: Show details when ESC is pressed during splash_delay
Start listening for keypresses on the first show_splash() call, so that
pressing ESC while we're delaying show the non-details splash will show
the details splash.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-07-10 15:34:28 -04:00
Hans de Goede
b527834c88 drm: Remove unnecessary reset_scan_out_buffer_if_needed() call from ply_renderer_head_map()
ply_renderer_head_map() gets only called from map_to_device() which
calls activate() directly afterwards which calls
ply_renderer_head_set_scan_out_buffer(), so there is no need for the
reset_scan_out_buffer_if_needed() call.

Not only is it not needed, but it is actually harmful, there are 2 problems
woth it:

1) Normally the drm plugin gets instantiated by ply-renderer.c with
   rendered->is_active=true, backend->is_active=false. The
   rendered->is_active=true causes the first ply_renderer_activate call
   to be a no-op without calling backend->activate(). So when the first
   map_to_device() calls happen activate() has not been called yet and we've
   not yet claimed master rights, so ply_renderer_head_set_scan_out_buffer()
   calls will always fail, resulting in this in a ply-trace:

   Mapping buffer for 1920x1080 renderer head
   Redrawing 1920x1080 renderer head
   Setting scan out buffer of 1920x1080 head to our buffer
   Couldn't set scan out buffer for head with controller id 41

   This is harmless, but also shows that the reset_scan_out_buffer_if_needed()
   is really not needed.

2. If deactivate_renderer() gets called before the first show-splash then
   rendered->is_active will become false, so renderer_activate() done before
   map_to_device() will now actually call backend->activate() claiming
   drm master rights and setting backend->is_active=true.

   The map_to_device() -> ply_renderer_head_map() call done after this, calls
   ply_renderer_head_redraw() -> flush_head() which under 1. was a no-op
   as it exits directly when backend->is_active=false. But now it actually
   flushes the buffers by calling reset_scan_out_buffer_if_needed(). This
   itself is fine.

   But since reset_scan_out_buffer_if_needed() has already happened in
   ply_renderer_head_redraw() the reset_scan_out_buffer_if_needed() call this
   commit removes would always return false (no reset necessary) causing
   ply_renderer_head_map() to destroy the buffer and return an error.

   This results in the splash briefly showing, followed by the core soon after
   trying another map_to_device(), which again briefly shows the splash, etc.
   With the end result being a badly flickering display.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-07-10 15:32:04 -04:00
Hans de Goede
447c783046 main: Only activate renderers if the splash uses pixel-displays
Since commit eb147e52b1 ("renderer: support reactivating renderer without
closing it first"), the show_theme() call done by
toggle_between_splash_and_details() will reactivate the renderers after
switching to details mode, causing the drm renderer to switch the screen
from text to graphics mode hiding the details being logged on the console.

This commit fixes this by only calling ply_device_manager_activate_renderers()
and ply_device_manager_deactivate_renderers if the splash uses pixel-displays.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

https://bugs.freedesktop.org/show_bug.cgi?id=107047
2018-07-10 09:28:55 -04:00
Hans de Goede
778e0fb77a main: move ply_device_manager_deactivate_renderers() into hide_splash()
hide_splash() should be the counter-part of show_splash(). show_splash()
calls ply_device_manager_activate_renderers() (through show_theme()).

2 of the 3 callers of hide_splash() are already calling
ply_device_manager_deactivate_renderers() directly before calling
hide_splash(). This commit moves the deactivate call into hide_splash()
so that it also gets called from the 3th code-path, which is when
the user hits the escape to key to toggle from the splash to details.

It's important that plymouth deactivates its renderers before going
to details, because those renderers can block the kernel from
initializing fbcon, which the kernel will start doing lazily in the
future:

https://lkml.org/lkml/2018/6/26/489.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

https://bugs.freedesktop.org/show_bug.cgi?id=107047
2018-06-29 16:25:42 -04:00
Hans de Goede
eb147e52b1 renderer: support reactivating renderer without closing it first
At the moment, ply_renderer_activate() doesn't work immediately following
ply_renderer_deactivate().  This is because the renderer isn't marked
inactive until it's closed.

This commit marks the renderer inactive when it's deactivated.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

https://bugs.freedesktop.org/show_bug.cgi?id=107047
2018-06-29 16:18:42 -04:00
Adam Williamson
014c215889 device-manager: skip graphical renderer setup when details forced
If neither "rhgb" nor "splash" is on the kernel cmdline, then
plymouth forces the "details" splash. This splash is merely
a passthrough plugin, where it makes boot looks like plymouth
isn't even running.

In this case, the code sets PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV.
The idea is to not bother waiting for udev events notifying
plymouth when graphics devices show up, since it doesn't need
to use the grpahics devices directly anyway.

Unfortunately, it does still erroneously try to setup graphical
renderers in this case, including the /dev/fb renderer.

Before commit e4f86e3c, these graphical renderers failed because
they were given the wrong device name, but since that fix, they're
suceeding.  We definitely don't want the /dev/fb renderer to
load if we're ignoring udev on efi systems, since during very
early boot /dev/fb is backed by efifb, something we never want to
use.  efifb is supposed to get replaced during the boot process
by other fb implementations like say radeondrmfb, virtiodrmfb or
bochsdrmfb, and some of those implementations can't handle the
transition if /dev/fb is open at switchover time.

This commit adds a new flag to tell the device manager to
not bother trying to setup graphical renderers when details are
forced.

http://bugzilla.redhat.com/1518464
2018-06-07 10:12:25 -04:00
qiangzhao
179ba1e0d8 docs: fix some typos
There are few word spelling errors in the documentation.

This commit addresses those problems.
2018-06-06 13:29:09 -04:00
Ray Strode
43cfbb2a8b Revert "wip! plymouth: stub out drm escrow program"
This reverts commit 12b03bf60e.
2018-05-31 10:52:34 -04:00
Ray Strode
8edd4c36f8 Revert "wip! systemd-units: add unit to switch back to initrd at shutdown"
This reverts commit 82b2b09639.
2018-05-31 10:52:34 -04:00
Ray Strode
f6549d8fb1 Revert "main: don't load cache or treat root as mounted on shutdown"
This reverts commit 55186d76ab.
2018-05-31 10:52:34 -04:00
Ray Strode
7627f93959 Revert "utils: add function for running program"
This reverts commit 0faf4c82bf.
2018-05-31 10:52:34 -04:00
Ray Strode
b5a613b14c Revert "main: reap zombies"
This reverts commit c59b031980.
2018-05-31 10:52:34 -04:00
Ray Strode
2969ed5161 Revert "wip! main: run plymouth-drm-escrow when switching to initrd"
This reverts commit f083f0a150.
2018-05-31 10:52:34 -04:00
Ray Strode
b4955ce1f0 Revert "fixup! utils: add function for running program"
This reverts commit 78cf571066.
2018-05-31 10:52:34 -04:00
Ray Strode
eb03dd7048 Revert "wip! renderer: add disown method"
This reverts commit 0c006993a4.
2018-05-31 10:52:34 -04:00
Ulrich Ölmann
2b5b27cbdc client: fix typo in help text
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
2018-05-17 15:24:43 -04:00
Ulrich Ölmann
99dc44e212 configure: fix help text
The used name for the feature "drm" results in the configure option
"--enable-drm" and not "--enable-drm-renderer".

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
2018-05-17 15:24:08 -04:00
Ray Strode
0c006993a4 wip! renderer: add disown method 2018-05-08 16:44:46 -04:00
Ray Strode
78cf571066 fixup! utils: add function for running program 2018-05-01 16:33:48 -04:00
Ray Strode
f083f0a150 wip! main: run plymouth-drm-escrow when switching to initrd 2018-04-26 13:22:27 -04:00
Ray Strode
c59b031980 main: reap zombies
Now that we have the ability to run a child we should make sure
that zombie children get reaped.
2018-04-26 12:42:20 -04:00
Ray Strode
0faf4c82bf utils: add function for running program
In order to hand off the drm fd to another program we need
to be able to run that other program.

This commit adds an API for running a program with no arguments,
in the background.
2018-04-26 12:36:31 -04:00
Ray Strode
55186d76ab main: don't load cache or treat root as mounted on shutdown
Right now, anytime we update the root fs in the daemon we treat
it like we switched from initramfs to the main root filesystem.

We shoudn't do that when shutting down since we're going to go
the other direction.

This commit changes on_newroot to look at the current mode to
decide what to do.

For the moment it doesn't do anything in the shutdown case, but
that will change shortly.
2018-04-26 10:45:39 -04:00
Ray Strode
82b2b09639 wip! systemd-units: add unit to switch back to initrd at shutdown
plymouthd currently sticks around on the main filesystem during
shutdown, while shutdown proceeds on the initramfs.

This commit adds a unit to make it jump into the initramfs too.

This is important, so we can run the drm escrow binary from
the initramfs.
2018-04-26 10:41:22 -04:00
Ray Strode
12b03bf60e wip! plymouth: stub out drm escrow program
Right now plymouthd forces itself to stay alive for the duration of
shutdown, so the splash screen can stay up until the power is killed.

This causes unclean mounts in some situations following system updates.

Rather than keep plymouthd around, all we really need to do is keep
the drm fd around.  That can be down with a separate program executed
just in time from the initramfs.

As a first step toward acheiving that goal, this commit creates a
simple new program "plymouth-drm-escrow" that doesn't do anything
at all but try to stay alive.

A future commit will change plymouthd to run plymouth-drm-escrow,
and pass it the drm fd.
2018-04-26 10:15:14 -04:00
Ray Strode
555257c74f pixel-buffer: switch device rotation to an enum
Right now device rotation is stored in a bare integer.

For clarity, switch that to an enum.
2018-04-10 16:40:06 -04:00
Hans de Goede
4992f06138 branch-merge: support device rotation
On some devices the LCD panel is mounted in the casing in such a way
that the up/top side of the panel does not match with the top side of
the device.

Examples of this are:
-Tablets where the LCD panel is mounted upside-down (various models)
-Clamshell design devices use portrait tablet screens in a landscape fashion /
 a landscape case, e.g. the GPD pocket, GPD win, Asus T100HA and the VIOS LTH17
 (so the didplay is mounted rotated 90 degrees clock-wise or counter-clock-wise).

Starting with kernel 4.16 there is code in the kernel to:
-Detect affected devices
-Automatically rotate the fbconsole to compensate
-Let userspace know about this with a new "panel orientation" property on the drm connector of the panel

The patch series I'm attaching to this bug adds support for this to
plymouth, so that the boot-splash and diskcrypt-ask-password are shown
with the correct orientation / the right way up on these devices.
2018-04-10 11:35:42 -04:00
Hans de Goede
d769f1194c drm: Reset primary plane rotation to DRM_MODE_ROTATE_0
On devices where the (LCD) panel is mounted upside-down in the case
the kernel's drm_fb_helper code may have set up rotation on the primary
plane to make the text-console (and other fbdev using apps) show the right
way up.

We inherit this rotation from the text-mode and since we do our own rotation
where necessary we end up rotating twice and showing the boot-splash
upside-down again.

Dealing with hardware rotation may require using a specific framebuffer
tiling which we do not support, so we should just disable the hardware
rotation and keep using our own software rotation.

This commit adds code to find the primary plane and its rotation property
and if it is not DRM_MODE_ROTATE_0 then sets it to DRM_MODE_ROTATE_0. fixing
the double rotation issue.

https://bugs.freedesktop.org/show_bug.cgi?id=104714
2018-04-10 11:32:59 -04:00
Hans de Goede
a6f25b7276 drm: Check for "panel orientation" connector property
On some devices the LCD panel is mounted in the casing in such a way
that the up/top side of the panel does not match with the top side of
the device (e.g. it is mounted upside-down).

Kernel 4.16 introduces a new "panel-orientation" property on the drm
connector which allows modesetting applications / code to check for
such LCD panels.

This commit adds support for this new property and passes this to the
pixel_buffer code using the new ply_pixel_buffer_new_with_device_rotation
method, so that the pixel_buffer code will automatically rotate the
image to correct for the panel orientation.

https://bugs.freedesktop.org/show_bug.cgi?id=104714
2018-04-10 11:32:58 -04:00
Hans de Goede
0e4e268844 pixel-buffer: Add the concept of device rotation
On some devices the LCD panel is mounted in the casing in such a way
that the up/top side of the panel does not match with the top side of
the device (e.g. it is mounted upside-down).

This commit adds support to the ply-pixel-buffer code to create
buffers which take device rotation into account and which will rotate
the picture to compensate.

https://bugs.freedesktop.org/show_bug.cgi?id=104714
2018-04-10 11:32:55 -04:00
Hans de Goede
da27e42316 main: Do not update the display on backspace when there is no input to remove
On machines with a slow CPU (Atom) and a highres screen drawing the
diskcrypt dialog may take longer then the keyrepeat speed, this leads to
a long delay before showing keypresses when doing the following:

1) Type long password
2) Realize it is wrong, press + hold backspace
   the key-repeat will now generate backspace key presses faster then we
   process them as main.c does an update_display for each press
3) Users releases backspace when we've processed input-length backspace
   key-presses, but since we were drawing slower then key-presses were
   coming in many more backspace keypresses are in the keyboard buffer
4) User types first character of the right password, this shows up up to
   a couple of seconds later because first we are still processing all
   the queued up backspace presses and doing a redraw for each.

This commit fixes this by skipping the redraws in on_backspace when there
is no more input left in the input buffer.

https://bugs.freedesktop.org/show_bug.cgi?id=104714
2018-04-10 11:32:52 -04:00
Ray Strode
6e9e95dc0f device-manager: drop superfluous create_pixel_displays_for_renderer call
commit 29e2763769 tried to move
create_pixel_displays_for_renderer down a couple of lines, but it
inadvertently copied it instead of moved it.

This commit fixes that.

https://bugs.freedesktop.org/show_bug.cgi?id=104353
2017-12-20 10:51:10 -05:00