udevadm trigger: do not propagate EACCES and ENODEV
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 26 Sep 2019 12:33:59 +0000 (21:33 +0900)
committerMichael Biebl <biebl@debian.org>
Tue, 19 Nov 2019 08:17:12 +0000 (08:17 +0000)
Inside container, writing file returns EACCESS. Moreover, some devices
return ENODEV rather than EACCES. So, let's also ignore these two
error causes.

Closes #13652.

(cherry picked from commit 67acde4869a9505f9721e31fa5167c82445e0e12)
(cherry picked from commit 20438f96c3261e55fabf44c892225efe79dd49d5)

Gbp-Pq: Name udevadm-trigger-do-not-propagate-EACCES-and-ENODEV.patch

src/udev/udevadm-trigger.c

index 77d95e513fb3ae4ddef8ecefcd2494b237bb6e9f..11f2f1c98515d1c813ef923f595b0e8108dbe483 100644 (file)
@@ -45,9 +45,11 @@ static int exec_list(sd_device_enumerator *e, const char *action, Set *settle_se
 
                 r = write_string_file(filename, action, WRITE_STRING_FILE_DISABLE_BUFFER);
                 if (r < 0) {
-                        log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_ERR, r,
+                        bool ignore = IN_SET(r, -ENOENT, -EACCES, -ENODEV);
+
+                        log_full_errno(ignore ? LOG_DEBUG : LOG_ERR, r,
                                        "Failed to write '%s' to '%s': %m", action, filename);
-                        if (ret == 0 && r != -ENOENT)
+                        if (ret == 0 && !ignore)
                                 ret = r;
                         continue;
                 }