Fix #318: only show "[ OK ] Calling foo" progress for runparts ...

For all other run_parts() use-cases we just give the script control over
stdout/stderr to prevent clobbering ANSI color escape codes.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2022-11-23 21:49:30 +01:00
parent c84ababbd4
commit 0498326962
5 changed files with 9 additions and 7 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ static void setup(void *arg)
touch("/etc/resolvconf/run/enable-updates");
chdir("/etc/resolvconf/run/interface");
run_parts("/etc/resolvconf/update.d", "-i");
run_parts("/etc/resolvconf/update.d", "-i", 0);
chdir("/");
}
+5 -3
View File
@@ -441,7 +441,7 @@ pid_t run_sh(char *tty, int noclear, int nowait, struct rlimit rlimit[])
return rc;
}
int run_parts(char *dir, char *cmd)
int run_parts(char *dir, char *cmd, int progress)
{
struct dirent **e;
int i, num;
@@ -490,7 +490,8 @@ int run_parts(char *dir, char *cmd)
strlcat(path, cmd, sizeof(path));
}
print_desc("Calling ", path);
if (progress)
print_desc("Calling ", path);
pid = fork();
if (!pid) {
sig_unblock();
@@ -503,7 +504,8 @@ int run_parts(char *dir, char *cmd)
warnx("%s exited with status %d", path, exit_status);
else if (WIFSIGNALED(status))
warnx("%s terminated by signad %d", path, WTERMSIG(status));
print_result(status);
if (progress)
print_result(status);
}
while (num--)
+1 -1
View File
@@ -602,7 +602,7 @@ static void bootstrap_worker(void *work)
* Run startup scripts in the runparts directory, if any.
*/
if (runparts && fisdir(runparts) && !rescue)
run_parts(runparts, NULL);
run_parts(runparts, NULL, 1);
/*
+1 -1
View File
@@ -86,7 +86,7 @@ int run_interactive (char *cmd, char *fmt, ...) __attribute__ ((format (prin
int exec_runtask (char *cmd, char *args[]);
pid_t run_getty (char *tty, char *cmd, char *args[], int noclear, int nowait, struct rlimit rlimit[]);
pid_t run_sh (char *tty, int noclear, int nowait, struct rlimit rlimit[]);
int run_parts (char *dir, char *cmd);
int run_parts (char *dir, char *cmd, int progress);
static inline int create(char *path, mode_t mode, uid_t uid, gid_t gid)
{
+1 -1
View File
@@ -208,7 +208,7 @@ void plugin_script_run(hook_point_t no)
strlcat(path, PLUGIN_HOOK_SCRIPTS_PATH, sizeof(path));
strlcat(path, hscript_paths[no] + 4, sizeof(path));
run_parts(path, NULL);
run_parts(path, NULL, 0);
}
#else
void plugin_script_run(hook_point_t no)