plugins: skip plugin in rescue mode

These plugins should not run in rescue mode, because the system may be
in a very bad state and we do not want to make the situation any worse
than it already is.

Essentially, only services in rescue.conf should run in rescue mode.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2021-04-24 19:46:43 +02:00
parent 799e992542
commit 26128dd788
7 changed files with 53 additions and 0 deletions
+10
View File
@@ -30,6 +30,11 @@
static void save(void *arg)
{
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
if (whichp(ALSACTL)) {
_d("Saving sound settings ...");
run_interactive(ALSACTL " -g store", "Saving sound settings");
@@ -38,6 +43,11 @@ static void save(void *arg)
static void restore(void *arg)
{
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
if (whichp(ALSACTL)) {
_d("Restoring sound settings ...");
run_interactive(ALSACTL " -g restore", "Restoring sound settings");
+5
View File
@@ -43,6 +43,11 @@ static void setup(void *arg)
mode_t prev;
char *cmd;
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
cmd = which(DAEMON);
if (!cmd) {
_d("Skipping plugin, %s is not installed.", DAEMON);
+5
View File
@@ -34,6 +34,11 @@ static void setup(void *arg)
char cmd[256];
char *path;
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
/*
* Populate /dev and prepare for runtime events from kernel.
* Prefer udev if mdev is also available on the system.
+8
View File
@@ -23,6 +23,9 @@
#include <glob.h>
#include <lite/lite.h>
#include "finit.h"
#include "helpers.h"
#include "plugin.h"
static void setup(void *arg)
@@ -31,6 +34,11 @@ static void setup(void *arg)
glob_t gl;
char buf[160];
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
glob("/run/sysctl.d/*.conf", 0, NULL, &gl);
glob("/etc/sysctl.d/*.conf", GLOB_APPEND, NULL, &gl);
glob("/usr/local/lib/sysctl.d/*.conf", GLOB_APPEND, NULL, &gl);
+10
View File
@@ -84,6 +84,11 @@ static void rtc_save(void *arg)
int fd, rc = 0;
char tz[128];
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
fd = rtc_open();
if (fd < 0)
return;
@@ -121,6 +126,11 @@ static void rtc_restore(void *arg)
int fd, rc = 0;
char tz[128];
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
fd = rtc_open();
if (fd < 0)
return;
+10
View File
@@ -35,6 +35,11 @@
static void setup(void *arg)
{
#ifdef RANDOMSEED
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
if (!fexist(RANDOMSEED)) {
int ret = 1;
mode_t prev;
@@ -71,6 +76,11 @@ static void save(void *arg)
#ifdef RANDOMSEED
mode_t prev;
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
prev = umask(077);
print_desc("Saving random seed", NULL);
+5
View File
@@ -39,6 +39,11 @@ static void setup(void *arg)
int fd;
#endif
if (rescue) {
_d("Skipping %s plugin in rescue mode.", __FILE__);
return;
}
prev = umask(0);
makedir("/var/run/console", 01777);