valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

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

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