udev: evaluate formatting in RUN= key earlier

Closes #12291.
This commit is contained in:
Yu Watanabe 2019-04-29 22:24:25 +02:00
parent 7280153364
commit 1448820aad
2 changed files with 5 additions and 6 deletions

View file

@ -937,16 +937,13 @@ int udev_event_execute_rules(UdevEvent *event,
} }
void udev_event_execute_run(UdevEvent *event, usec_t timeout_usec) { void udev_event_execute_run(UdevEvent *event, usec_t timeout_usec) {
const char *cmd; const char *command;
void *val; void *val;
Iterator i; Iterator i;
int r; int r;
ORDERED_HASHMAP_FOREACH_KEY(val, cmd, event->run_list, i) { ORDERED_HASHMAP_FOREACH_KEY(val, command, event->run_list, i) {
UdevBuiltinCommand builtin_cmd = PTR_TO_UDEV_BUILTIN_CMD(val); UdevBuiltinCommand builtin_cmd = PTR_TO_UDEV_BUILTIN_CMD(val);
char command[UTIL_PATH_SIZE];
(void) udev_event_apply_format(event, cmd, command, sizeof(command), false);
if (builtin_cmd != _UDEV_BUILTIN_INVALID) { if (builtin_cmd != _UDEV_BUILTIN_INVALID) {
log_device_debug(event->dev, "Running built-in command \"%s\"", command); log_device_debug(event->dev, "Running built-in command \"%s\"", command);

View file

@ -1832,7 +1832,9 @@ static int udev_rule_apply_token_to_event(
if (r < 0) if (r < 0)
return log_oom(); return log_oom();
cmd = strdup(token->value); (void) udev_event_apply_format(event, token->value, buf, sizeof(buf), false);
cmd = strdup(buf);
if (!cmd) if (!cmd)
return log_oom(); return log_oom();