ryantimwilson / rpms / systemd

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