anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0688-tmpfiles-e-is-supposed-to-operate-on-directory-only.patch

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