eudev-project / eudev

Repository for eudev development
GNU General Public License v2.0
529 stars 144 forks source link

Operator `:=` not preventing further assignments to `RUN` #256

Closed akselaase closed 1 year ago

akselaase commented 1 year ago

Using RUN:="/my_script.sh" in a rule doesn't inhibit later rules from appending RUN commands.

This seems to be due to missing handling of event->run_final here: https://github.com/eudev-project/eudev/blob/4758e346a14126fc3a964de5831e411c27ebe487/src/udev/udev-rules.c#L2592

Happens with eudev 3.2.7 (udevd --version shows 220), but the missing code isn't present on master either.

Seems to be resolved with the following patch, although this is only lightly tested.

--- a/src/udev/udev-rules.c 2023-08-29 14:39:36.249571381 +0200
+++ b/src/udev/udev-rules.c 2023-08-29 14:41:01.689303563 +0200
@@ -2589,6 +2589,10 @@
                 case TK_A_RUN_PROGRAM: {
                         struct udev_list_entry *entry;

+                        if (event->run_final)
+                                break;
+                        if (cur->key.op == OP_ASSIGN_FINAL)
+                                event->run_final = true;
                         if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL)
                                 udev_list_cleanup(&event->run_list);
                         log_debug("RUN '%s' %s:%u",