923a60
From edaaf538a500811d5457f9c3a8e1ea4c8283806e Mon Sep 17 00:00:00 2001
923a60
From: Jan Synacek <jsynacek@redhat.com>
923a60
Date: Tue, 11 Dec 2018 10:39:01 +0100
923a60
Subject: [PATCH] tmpfiles: 'e' is supposed to operate on directory only
923a60
923a60
(cherry picked from commit d460ba18e777128c19343b067574ecac399f3afc)
923a60
923a60
Related: #1641764
923a60
---
923a60
 src/tmpfiles/tmpfiles.c | 3 +++
923a60
 1 file changed, 3 insertions(+)
923a60
923a60
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
923a60
index f7fa2e40fa..20bc465d23 100644
923a60
--- a/src/tmpfiles/tmpfiles.c
923a60
+++ b/src/tmpfiles/tmpfiles.c
923a60
@@ -621,6 +621,9 @@ static int path_set_perms(Item *i, const char *path) {
923a60
         if (fstatat(fd, "", &st, AT_EMPTY_PATH) < 0)
923a60
                 return log_error_errno(errno, "Failed to fstat() file %s: %m", path);
923a60
 
923a60
+        if (i->type == EMPTY_DIRECTORY && !S_ISDIR(st.st_mode))
923a60
+                return log_error_errno(EEXIST, "'%s' already exists and is not a directory. ", path);
923a60
+
923a60
         if (S_ISLNK(st.st_mode))
923a60
                 log_debug("Skipping mode an owner fix for symlink %s.", path);
923a60
         else {