summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico2012-08-15 02:00:35 (GMT)
committerZac Medico2012-08-15 02:00:35 (GMT)
commita343db38d0e4da0126c33d305386b187a6f00205 (patch)
tree8aba2d7a697270b511a27b9d8776b5ac1065f8d6
parent644c0dd5daad47b6392d99c706afaea56e17ee31 (diff)
emerge-webrsync: check permission, bug #142202
-rwxr-xr-xbin/emerge-webrsync20
1 files changed, 18 insertions, 2 deletions
diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index 57e3052..0a036d2 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