2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-03 15:55:40 +00:00

Just ignore the -c option, it is the default

Add support for -d option
This commit is contained in:
Todd C. Miller
2010-07-13 08:31:01 -04:00
parent 5b9e39ac87
commit 69400709d7

View File

@@ -49,7 +49,7 @@ CHMODIT=false
STRIPIT=false STRIPIT=false
BACKIT=false BACKIT=false
TOUCHIT=true TOUCHIT=true
SAVESRC=false DIRMODE=false
case `${WHOAMI}` in case `${WHOAMI}` in
root) root)
@@ -74,7 +74,10 @@ while ${MORETODO} ; do
BACKUP=`expr "$1" : '-b\(.*\)'` BACKUP=`expr "$1" : '-b\(.*\)'`
;; ;;
X-c) X-c)
SAVESRC=true # backwards compatibility
;;
X-d)
DIRMODE=true
;; ;;
X-g) X-g)
GROUP="$2" GROUP="$2"
@@ -155,15 +158,10 @@ while ${MORETODO} ; do
${MORETODO} && shift ${MORETODO} && shift
done done
## Process arguments.
if [ $# -ne 2 ] ; then
echo "Usage: ${PROGNAME} [flags] source destination"
exit 1
fi
## Making a directory? ## Making a directory?
if [ X"$1" = X. ] ; then if ${DIRMODE} ; then
DEST="$2" while test $# != 0; do
DEST="$1"
if [ ! -d "${DEST}" ] ; then if [ ! -d "${DEST}" ] ; then
${MKDIR} "${DEST}" || exit 1 ${MKDIR} "${DEST}" || exit 1
fi fi
@@ -174,12 +172,19 @@ if [ X"$1" = X. ] ; then
${CHGRP} "${GROUP}" "${DEST}" || exit 1 ${CHGRP} "${GROUP}" "${DEST}" || exit 1
fi fi
if ${CHMODIT} ; then if ${CHMODIT} ; then
umask 0
${CHMOD} "${MODE}" "${DEST}" || exit 1 ${CHMOD} "${MODE}" "${DEST}" || exit 1
fi fi
shift;
done
exit 0 exit 0
fi fi
## Process arguments.
if [ $# -ne 2 ] ; then
echo "Usage: ${PROGNAME} [flags] source destination"
exit 1
fi
## Get the destination and a temp file in the destination diretory. ## Get the destination and a temp file in the destination diretory.
if [ -d "$2" ] ; then if [ -d "$2" ] ; then
DEST="$2/`basename $1`" DEST="$2/`basename $1`"
@@ -190,7 +195,7 @@ else
fi fi
## If not given the same name, we must try to copy. ## If not given the same name, we must try to copy.
if [ X"$1" != X"$2" -o $SAVESRC ] ; then if [ X"$1" != X"$2" ] ; then
if cmp -s "$1" "${DEST}" ; then if cmp -s "$1" "${DEST}" ; then
## Files are same; touch or not. ## Files are same; touch or not.
${TOUCHIT} && touch "${DEST}" ${TOUCHIT} && touch "${DEST}"
@@ -221,7 +226,6 @@ if ${CHGROUPIT} ; then
${CHGRP} "${GROUP}" "${DEST}" || exit 1 ${CHGRP} "${GROUP}" "${DEST}" || exit 1
fi fi
if ${CHMODIT} ; then if ${CHMODIT} ; then
umask 0
${CHMOD} "${MODE}" "${DEST}" || exit 1 ${CHMOD} "${MODE}" "${DEST}" || exit 1
fi fi
exit 0 exit 0