daandemeyer / rpms / systemd

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