add DRACUT_NO_XATTR global environment variable

Useful, if you know, that those can't be copied anyway.
master
Harald Hoyer 2020-02-27 13:21:06 +01:00
parent a8ba1c4e25
commit 93be2bc6ab
2 changed files with 9 additions and 3 deletions

View File

@ -19,7 +19,7 @@
# #
export LC_MESSAGES=C 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" export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,xattr,links -dfr"
else else
export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr" export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr"

View File

@ -59,6 +59,7 @@ static bool arg_modalias = false;
static bool arg_resolvelazy = false; static bool arg_resolvelazy = false;
static bool arg_resolvedeps = false; static bool arg_resolvedeps = false;
static bool arg_hostonly = false; static bool arg_hostonly = false;
static bool no_xattr = false;
static char *destrootdir = NULL; static char *destrootdir = NULL;
static char *sysrootdir = NULL; static char *sysrootdir = NULL;
static size_t sysrootdirlen = 0; static size_t sysrootdirlen = 0;
@ -310,7 +311,7 @@ static int cp(const char *src, const char *dst)
normal_copy: normal_copy:
pid = fork(); pid = fork();
if (pid == 0) { 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, execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,xattr,timestamps", "-fL", src, dst,
NULL); NULL);
else else
@ -322,7 +323,7 @@ static int cp(const char *src, const char *dst)
while (waitpid(pid, &ret, 0) < 0) { while (waitpid(pid, &ret, 0) < 0) {
if (errno != EINTR) { if (errno != EINTR) {
ret = -1; 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, log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps -fL %s %s", src,
dst); dst);
else else
@ -1898,6 +1899,7 @@ int main(int argc, char **argv)
int r; int r;
char *i; char *i;
char *path = NULL; char *path = NULL;
char *env_no_xattr = NULL;


r = parse_argv(argc, argv); r = parse_argv(argc, argv);
if (r <= 0) if (r <= 0)
@ -1945,6 +1947,10 @@ int main(int argc, char **argv)
ldd = "ldd"; ldd = "ldd";
log_debug("LDD=%s", 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, ":"); pathdirs = strv_split(path, ":");


umask(0022); umask(0022);