]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev_rules_parse_file: do not skip ENOENT
authorDmitry V. Levin <ldv@strace.io>
Tue, 28 Feb 2023 08:00:00 +0000 (08:00 +0000)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 6 Mar 2023 08:42:12 +0000 (17:42 +0900)
Starting with commit ed88bcfb7c15029f9fc95ee2380759a9eb782d46,
udev_rules_parse_file() silently skips files it fails to open with
ENOENT error, e.g. when they are broken symlinks.  As this behavior is
undocumented and it seems to be unintended, let's treat ENOENT like any
other error.  This change would also simplify the implementation of the
udev rules syntax checker mentioned in #26606.

udev_rules_load(), the only user of udev_rules_parse_file(), is not
affected by this change because it essentially ignores the value
returned by the latter, the only visible difference would be a log
message issued for every udev rules file that couldn't be open because
of ENOENT.

Fixes: ed88bcfb7c15 ("Be more careful when checking for empty files")
src/udev/udev-rules.c

index 5bd09a64d1d268e5a5cf89b656eb10ef0e4347b6..68c4bc903ce34993504dcf81e5bf1b96541972c9 100644 (file)
@@ -1178,12 +1178,8 @@ int udev_rules_parse_file(UdevRules *rules, const char *filename) {
         int r;
 
         f = fopen(filename, "re");
-        if (!f) {
-                if (errno == ENOENT)
-                        return 0;
-
+        if (!f)
                 return log_warning_errno(errno, "Failed to open %s, ignoring: %m", filename);
-        }
 
         if (fstat(fileno(f), &st) < 0)
                 return log_warning_errno(errno, "Failed to stat %s, ignoring: %m", filename);