process-util: rework wait_for_terminate_and_warn() to take a flags parameter
This renames wait_for_terminate_and_warn() to wait_for_terminate_and_check(), and adds a flags parameter, that controls how much to log: there's one flag that means we log about abnormal stuff, and another one that controls whether we log about non-zero exit codes. Finally, there's a shortcut flag value for logging in both cases, as that's what we usually use. All callers are accordingly updated. At three occasions duplicate logging is removed, i.e. where the old function was called but logged in the caller, too.
This commit is contained in:
@@ -133,7 +133,7 @@ int change_uid_gid(const char *user, char **_home) {
|
||||
|
||||
truncate_nl(line);
|
||||
|
||||
wait_for_terminate_and_warn("getent passwd", pid, true);
|
||||
(void) wait_for_terminate_and_check("getent passwd", pid, WAIT_LOG);
|
||||
|
||||
x = strchr(line, ':');
|
||||
if (!x) {
|
||||
@@ -216,7 +216,7 @@ int change_uid_gid(const char *user, char **_home) {
|
||||
|
||||
truncate_nl(line);
|
||||
|
||||
wait_for_terminate_and_warn("getent initgroups", pid, true);
|
||||
(void) wait_for_terminate_and_check("getent initgroups", pid, WAIT_LOG);
|
||||
|
||||
/* Skip over the username and subsequent separator whitespace */
|
||||
x = line;
|
||||
|
||||
+1
-1
@@ -3516,7 +3516,7 @@ static int run(int master,
|
||||
}
|
||||
|
||||
/* Wait for the outer child. */
|
||||
r = wait_for_terminate_and_warn("namespace helper", *pid, NULL);
|
||||
r = wait_for_terminate_and_check("namespace helper", *pid, WAIT_LOG_ABNORMAL);
|
||||
if (r != 0)
|
||||
return r < 0 ? r : -EIO;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user