File 0593-dracut-only-copy-xattr-if-root.patch of Package dracut.10716

From 97b36b154ce40f91b1c73a610c796965a569b637 Mon Sep 17 00:00:00 2001
From: Daniel Molkentin <dmolkentin@suse.com>
Date: Mon, 18 Feb 2019 14:21:05 +0100
Subject: [PATCH] dracut: only copy xattr, if root

(Cherry-picked from 076fcd1652af25f57aae063fda3b8c39ef828ac6)
---
 install/dracut-install.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/install/dracut-install.c b/install/dracut-install.c
index a7bfdb8c..381327c2 100644
--- a/install/dracut-install.c
+++ b/install/dracut-install.c
@@ -222,8 +222,13 @@ static int cp(const char *src, const char *dst)
                 if (ret == 0) {
                         struct timeval tv[2];
                         if (fchown(dest_desc, sb.st_uid, sb.st_gid) != 0)
-                                if(fchown(dest_desc, (uid_t) - 1, sb.st_gid) != 0)
-                                    log_error("Failed to chown %s: %m", dst);
+                                if(fchown(dest_desc, (uid_t) - 1, sb.st_gid) != 0) {
+                                        if (geteuid() == 0)
+                                                log_error("Failed to chown %s: %m", dst);
+                                        else
+                                                log_info("Failed to chown %s: %m", dst);
+                                }
+
                         tv[0].tv_sec = sb.st_atime;
                         tv[0].tv_usec = 0;
                         tv[1].tv_sec = sb.st_mtime;
-- 
2.16.4
openSUSE Build Service is sponsored by