diff options
author | Rob Landley <rob@landley.net> | 2021-12-21 20:55:43 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2021-12-21 20:55:43 -0600 |
commit | e1917654af98842cf8e0e3b170565ef3fc97c5fe (patch) | |
tree | 61edf7ca9141647935c3cb49da9b2d712d69b152 /toys/posix/cp.c | |
parent | 887ba4eb7a3f826f3e7c1a9c1de8f9fa71ddee95 (diff) | |
download | toybox-e1917654af98842cf8e0e3b170565ef3fc97c5fe.tar.gz |
Attempt to make --preserve=xattr,context work together and individually.
Note: context should really be using setfscreatecon(), but that involves
scanning (cacheing) xattrs before creating the output file, and what do
you do about overwriting an existing file in non-mv mode?
Diffstat (limited to 'toys/posix/cp.c')
-rw-r--r-- | toys/posix/cp.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/toys/posix/cp.c b/toys/posix/cp.c index fe021cde..cd589c4c 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -257,7 +257,7 @@ static int cp_node(struct dirtree *try) // Copy contents of file. } else { - int fdin; + int fdin, ii; fdin = openat(tfd, try->name, O_RDONLY); if (fdin < 0) { @@ -282,8 +282,9 @@ static int cp_node(struct dirtree *try) xattr_flist(fdin, list, listlen); list[listlen-1] = 0; // I do not trust this API. for (name = list; name-list < listlen; name += strlen(name)+1) { - if (!(TT.pflags&_CP_context) && (strncmp(name, "security.", 9) == 0)) - continue; + // context copies security, xattr copies everything else + ii = strncmp(name, "security.", 9) ? _CP_xattr : _CP_context; + if (!(TT.pflags&ii)) continue; if ((len = xattr_fget(fdin, name, 0, 0))>0) { value = xmalloc(len); if (len == xattr_fget(fdin, name, value, len)) |