valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0596-shared-dropin-ignore-ENAMETOOLONG-when-checking-drop.patch

dd65c9
From 3ce9a9b286825793548ed7a7673dd9674a4e4137 Mon Sep 17 00:00:00 2001
dd65c9
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Nykr=C3=BDn?= <lnykryn@redhat.com>
dd65c9
Date: Fri, 1 Dec 2017 20:34:49 +0100
dd65c9
Subject: [PATCH] shared/dropin: ignore ENAMETOOLONG when checking drop-in
dd65c9
 directories (#7525)
dd65c9
dd65c9
This usually happens for device units with long
dd65c9
path in /sys. But users can't even create such drop-ins,
dd65c9
so lets just ignore the error here.
dd65c9
dd65c9
Fixes #6867
dd65c9
dd65c9
Cherry-picked from: dfeec916b57b593ce07d3751aebdb0cce1d05201
dd65c9
Resolves: #1489095
dd65c9
---
dd65c9
 src/shared/dropin.c | 8 ++++++--
dd65c9
 1 file changed, 6 insertions(+), 2 deletions(-)
dd65c9
dd65c9
diff --git a/src/shared/dropin.c b/src/shared/dropin.c
dd65c9
index d1baad619..b674d307a 100644
dd65c9
--- a/src/shared/dropin.c
dd65c9
+++ b/src/shared/dropin.c
dd65c9
@@ -129,8 +129,12 @@ static int iterate_dir(
dd65c9
 
dd65c9
         d = opendir(path);
dd65c9
         if (!d) {
dd65c9
-                if (errno == ENOENT)
dd65c9
-                        return 0;
dd65c9
+                /* Ignore ENOENT, after all most units won't have a drop-in dir.
dd65c9
+                 * Also ignore ENAMETOOLONG, users are not even able to create
dd65c9
+                 * the drop-in dir in such case. This mostly happens for device units with long /sys path.
dd65c9
+                 * */
dd65c9
+                if (IN_SET(errno, ENOENT, ENAMETOOLONG))
dd65c9
+                            return 0;
dd65c9
 
dd65c9
                 log_error_errno(errno, "Failed to open directory %s: %m", path);
dd65c9
                 return -errno;