From: Zac Medico Date: Wed, 15 Aug 2012 02:00:35 +0000 (-0700) Subject: emerge-webrsync: check permission, bug #142202 X-Git-Tag: v2.2.0_alpha122~35 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a343db38d0e4da0126c33d305386b187a6f00205;p=portage.git emerge-webrsync: check permission, bug #142202 --- diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index 57e305288..0a036d29e 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -22,9 +22,9 @@ vvecho() { [[ ${do_verbose} -eq 1 ]] && echo "$@" ; } # Only echo if not in verbose mode nvecho() { [[ ${do_verbose} -eq 0 ]] && echo "$@" ; } # warning echos -wecho() { echo "${argv0}: warning: $*" 1>&2 ; } +wecho() { echo "${argv0##*/}: warning: $*" 1>&2 ; } # error echos -eecho() { echo "${argv0}: error: $*" 1>&2 ; } +eecho() { echo "${argv0##*/}: error: $*" 1>&2 ; } argv0=$0 @@ -445,6 +445,12 @@ main() { esac done + [[ -d ${PORTDIR} ]] || mkdir -p "${PORTDIR}" + if [[ ! -w ${PORTDIR} ]] ; then + eecho "PORTDIR is not writable: ${PORTDIR}" + exit 1 + fi + TMPDIR=${PORTAGE_TMPDIR}/emerge-webrsync ${keep} || DISTDIR=${TMPDIR} @@ -452,6 +458,16 @@ main() { [ ! -d "${DISTDIR}" ] && mkdir -p "${DISTDIR}" cd "${TMPDIR}" || exit 1 + if ${keep} && [[ ! -w ${DISTDIR} ]] ; then + eecho "DISTDIR is not writable: ${DISTDIR}" + exit 1 + fi + + if [[ ! -w ${TMPDIR} ]] ; then + eecho "TMPDIR is not writable: ${TMPDIR}" + exit 1 + fi + # This is a sanity check to help prevent people like funtoo users # from accidentally wiping out their git tree. if [[ -n $SYNC && ${SYNC#rsync:} = $SYNC ]] ; then