Skip to content

Commit 69a2fb4

Browse files
committed
wip: address feedback
1 parent 726e529 commit 69a2fb4

2 files changed

Lines changed: 15 additions & 24 deletions

File tree

plugins/plymouth.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Plymouth boot splash plugin for Finit
22
*
3-
* Copyright (c) 2012-2026 Joachim Wiberg <troglobit@gmail.com>
3+
* Copyright (c) 2012-2026 Aaron Andersen <troglobit@gmail.com>
44
*
55
* Permission is hereby granted, free of charge, to any person obtaining a copy
66
* of this software and associated documentation files (the "Software"), to deal
@@ -37,19 +37,15 @@
3737
* splash during poweroff/reboot.
3838
*
3939
* The plugin is only activated when "splash" is present on the kernel
40-
* command line. Plymouth requires devpts for VT takeover, which may
41-
* not be mounted yet at HOOK_BANNER time (before fs_finalize), so the
42-
* plugin mounts it if needed.
40+
* command line. Plymouth requires devpts for VT takeover; fs_init()
41+
* mounts it early enough for HOOK_BANNER.
4342
*
4443
* NOTE: The initramfs must include /etc/initrd-release. Plymouth
4544
* checks for this file and, when present, prefixes its argv[0] with
4645
* '@' so that the process is not killed during switch_root. Without
4746
* it, plymouthd will not survive the initramfs-to-rootfs transition.
4847
*/
4948

50-
#include <sys/mount.h>
51-
#include <sys/stat.h>
52-
5349
#include "config.h"
5450
#include "finit.h"
5551
#include "helpers.h"
@@ -99,13 +95,7 @@ static int plymouth_alive(void)
9995
return daemon_pid > 0 && pid_alive(daemon_pid);
10096
}
10197

102-
/*
103-
* Start plymouthd in the given mode ("boot" or "shutdown").
104-
*
105-
* Mounts devpts if needed -- HOOK_BANNER fires before fs_finalize(),
106-
* so /dev/pts may not exist yet. Plymouth needs it for --attach-to-session
107-
* which gives it control of the VT for rendering.
108-
*/
98+
/* Start plymouthd in the given mode ("boot" or "shutdown"). */
10999
static void plymouth_start(const char *mode)
110100
{
111101
char cmd[256];
@@ -114,13 +104,6 @@ static void plymouth_start(const char *mode)
114104
if (plymouth_alive())
115105
return;
116106

117-
/* Mount devpts if not already mounted (needed for --attach-to-session) */
118-
if (!fismnt("/dev/pts")) {
119-
mkdir("/dev/pts", 0755);
120-
mount("devpts", "/dev/pts", "devpts",
121-
MS_NOSUID | MS_NOEXEC, "ptmxmode=0666,mode=0620");
122-
}
123-
124107
snprintf(cmd, sizeof(cmd),
125108
PLYMOUTHD_PATH " --attach-to-session --mode %s --pid-file %s",
126109
mode, PLYMOUTH_PIDFILE);

src/finit.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ static void fs_finalize(void)
370370
fs_mount("shm", "/dev/shm", "tmpfs", flags | MS_NODEV, "mode=1777");
371371
}
372372

373-
/* Modern systems use /dev/pts */
374-
if (!fismnt("/dev/pts")) {
373+
/* Remount devpts with proper gid/mode now that /etc/group is available */
374+
{
375375
char opts[32];
376376
int gid;
377377

@@ -383,7 +383,8 @@ static void fs_finalize(void)
383383
snprintf(opts, sizeof(opts), "gid=%d,mode=0620,ptmxmode=0666", gid);
384384

385385
makedir("/dev/pts", 0755);
386-
fs_mount("devpts", "/dev/pts", "devpts", flags, opts);
386+
fs_mount("devpts", "/dev/pts", "devpts",
387+
flags | MS_REMOUNT, opts);
387388
}
388389

389390
/* Needed on systems like Alpine Linux */
@@ -529,6 +530,13 @@ static void fs_init(void)
529530

530531
fs_mount(fs[i].spec, fs[i].file, fs[i].type, 0, NULL);
531532
}
533+
534+
/* Early devpts mount for plugins that need PTY access (e.g. plymouth) */
535+
if (!fismnt("/dev/pts")) {
536+
makedir("/dev/pts", 0755);
537+
fs_mount("devpts", "/dev/pts", "devpts",
538+
MS_NOSUID | MS_NOEXEC, "ptmxmode=0666");
539+
}
532540
}
533541

534542

0 commit comments

Comments
 (0)