]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: evaluate formatting in RUN= key earlier
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 29 Apr 2019 20:24:25 +0000 (22:24 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 2 Jun 2019 23:35:33 +0000 (08:35 +0900)
Closes #12291.

src/udev/udev-event.c
src/udev/udev-rules.c

index 817648ec93f0695007cd1e86b0568871b224d4d8..32788c05e06cf8f6ed13b640bf1c5a2d14b6f4dd 100644 (file)
@@ -937,16 +937,13 @@ int udev_event_execute_rules(UdevEvent *event,
 }
 
 void udev_event_execute_run(UdevEvent *event, usec_t timeout_usec) {
-        const char *cmd;
+        const char *command;
         void *val;
         Iterator i;
         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);
-                char command[UTIL_PATH_SIZE];
-
-                (void) udev_event_apply_format(event, cmd, command, sizeof(command), false);
 
                 if (builtin_cmd != _UDEV_BUILTIN_INVALID) {
                         log_device_debug(event->dev, "Running built-in command \"%s\"", command);
index be4d8aeaa0d9efcf1302c33e4f6097cde950e33a..149d62afb32c2673747ddda1db12be90e8ad086a 100644 (file)
@@ -1832,7 +1832,9 @@ static int udev_rule_apply_token_to_event(
                 if (r < 0)
                         return log_oom();
 
-                cmd = strdup(token->value);
+                (void) udev_event_apply_format(event, token->value, buf, sizeof(buf), false);
+
+                cmd = strdup(buf);
                 if (!cmd)
                         return log_oom();