]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
add DRACUT_NO_XATTR global environment variable
authorHarald Hoyer <harald@redhat.com>
Thu, 27 Feb 2020 12:21:06 +0000 (13:21 +0100)
committerHarald Hoyer <harald@redhat.com>
Thu, 27 Feb 2020 12:49:21 +0000 (13:49 +0100)
Useful, if you know, that those can't be copied anyway.

dracut-init.sh
install/dracut-install.c

index 0ff9b7e53aeb40836e8ffe93be18ab75a84ec253..a8348b79291fce9a8dd1a0371b7f287834d0ee87 100644 (file)
@@ -19,7 +19,7 @@
 #
 export LC_MESSAGES=C
 
-if [[ "$EUID" = "0" ]]; then
+if [[ "$EUID" = "0" ]] && ! [[ $DRACUT_NO_XATTR ]]; then
     export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,xattr,links -dfr"
 else
     export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr"
index 419385045806a4c819703c5a5e32a0e464e88ad9..5d48e9d56f27205dab61e4bbaa1f2bd7eabf28f3 100644 (file)
@@ -59,6 +59,7 @@ static bool arg_modalias = false;
 static bool arg_resolvelazy = false;
 static bool arg_resolvedeps = false;
 static bool arg_hostonly = false;
+static bool no_xattr = false;
 static char *destrootdir = NULL;
 static char *sysrootdir = NULL;
 static size_t sysrootdirlen = 0;
@@ -310,7 +311,7 @@ static int cp(const char *src, const char *dst)
  normal_copy:
         pid = fork();
         if (pid == 0) {
-                if (geteuid() == 0)
+                if (geteuid() == 0 && no_xattr == false)
                         execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,xattr,timestamps", "-fL", src, dst,
                                NULL);
                 else
@@ -322,7 +323,7 @@ static int cp(const char *src, const char *dst)
         while (waitpid(pid, &ret, 0) < 0) {
                 if (errno != EINTR) {
                         ret = -1;
-                        if (geteuid() == 0)
+                        if (geteuid() == 0 && no_xattr == false)
                                 log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps -fL %s %s", src,
                                           dst);
                         else
@@ -1898,6 +1899,7 @@ int main(int argc, char **argv)
         int r;
         char *i;
         char *path = NULL;
+        char *env_no_xattr = NULL;
 
         r = parse_argv(argc, argv);
         if (r <= 0)
@@ -1945,6 +1947,10 @@ int main(int argc, char **argv)
                 ldd = "ldd";
         log_debug("LDD=%s", ldd);
 
+        env_no_xattr = getenv("DRACUT_NO_XATTR");
+        if (env_no_xattr != NULL)
+                no_xattr = true;
+
         pathdirs = strv_split(path, ":");
 
         umask(0022);