-
Notifications
You must be signed in to change notification settings - Fork 167
Closed
Description
When I unpack directly into a folder that has existing content, that content also gets chmoded, and I believe that process may also mess with the setuid bit. Is this intended behavior?
cp -v -r --preserve=mode,ownership,timestamps $from/. $to
if [ -n "$owner" ]
then
chown -hR $owner:$owner $to
fiSeems to be the issue.
I am trying this untested workaround, but I do not like it because of the extra disk activity:
function unpack() {
# call like this: unpack /path/to/source /target user -- this will copy
# all files & folders from source to target, preserving mode and timestamps
# and chown to user. If user is not provided, no chown will be performed
from=$1
to=$2
owner=
if [ "$#" -gt 2 ]
then
owner=$3
fi
mkdir -p /tmp/unpack/
# $from/. may look funny, but does exactly what we want, copy _contents_
# from $from to $to, but not $from itself, without the need to glob -- see
# http://stackoverflow.com/a/4645159/2028598
cp -v -r --preserve=mode,timestamps $from/. /tmp/unpack/
if [ -n "$owner" ]
then
chown -hR $owner:$owner $to
fi
cp -v -r --preserve=mode,ownership,timestamps /tmp/unpack/. $to
rm -r /tmp/unpack
}Metadata
Metadata
Assignees
Labels
No labels