1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

udev: do not propagate error in executing PROGRAM and IMPORT{program}

Also, this adds more logs.

Fixes #14027.
This commit is contained in:
Yu Watanabe 2019-11-18 20:56:33 +09:00 committed by Lennart Poettering
parent 25f9288e31
commit 08de195825
2 changed files with 14 additions and 8 deletions

View File

@ -1014,7 +1014,9 @@ void udev_event_execute_run(UdevEvent *event, usec_t timeout_usec) {
log_device_debug(event->dev, "Running command \"%s\"", command);
r = udev_event_spawn(event, timeout_usec, false, command, NULL, 0);
if (r > 0) /* returned value is positive when program fails */
if (r < 0)
log_device_warning_errno(event->dev, r, "Failed to execute '%s', ignoring: %m", command);
else if (r > 0) /* returned value is positive when program fails */
log_device_debug(event->dev, "Command \"%s\" returned %d (error), ignoring.", command, r);
}
}

View File

@ -1665,10 +1665,13 @@ static int udev_rule_apply_token_to_event(
log_rule_debug(dev, rules, "Running PROGRAM '%s'", buf);
r = udev_event_spawn(event, timeout_usec, true, buf, result, sizeof(result));
if (r < 0)
return log_rule_error_errno(dev, rules, r, "Failed to execute '%s': %m", buf);
if (r > 0)
if (r != 0) {
if (r < 0)
log_rule_warning_errno(dev, rules, r, "Failed to execute '%s', ignoring: %m", buf);
else /* returned value is positive when program fails */
log_rule_debug(dev, rules, "Command \"%s\" returned %d (error), ignoring", buf, r);
return token->op == OP_NOMATCH;
}
delete_trailing_chars(result, "\n");
count = util_replace_chars(result, UDEV_ALLOWED_CHARS_INPUT);
@ -1732,10 +1735,11 @@ static int udev_rule_apply_token_to_event(
log_rule_debug(dev, rules, "Importing properties from results of '%s'", buf);
r = udev_event_spawn(event, timeout_usec, true, buf, result, sizeof result);
if (r < 0)
return log_rule_error_errno(dev, rules, r, "Failed to execute '%s': %m", buf);
if (r > 0) {
log_rule_debug(dev, rules, "Command \"%s\" returned %d (error), ignoring", buf, r);
if (r != 0) {
if (r < 0)
log_rule_warning_errno(dev, rules, r, "Failed to execute '%s', ignoring: %m", buf);
else /* returned value is positive when program fails */
log_rule_debug(dev, rules, "Command \"%s\" returned %d (error), ignoring", buf, r);
return token->op == OP_NOMATCH;
}