Usually we place things in /opt
so they are owned by root but normal users can execute them. This prevents normal users modifying the binaries so they cannot execute arbitrary stuff. However, to put things there using sudo unzip something.zip -d /opt
is a little bit dangerous as an exploit in unzip
could then do anything with sudo capabilities. I created a temp folder instead and then extract there and sudo mv folder /opt
, is this the safest solution?
from
RUN curl -sSL "${GRADLE_SDK_URL}" -o gradle.zip \
&& echo "${GRADLE_ZIP_SHA256_HASH} *gradle.zip" | shasum -a 256 --check \
&& sudo unzip gradle.zip -d /opt \
&& rm -rf $TEMPD \
&& rm -rf gradle.zip
to
RUN curl -sSL "${GRADLE_SDK_URL}" -o gradle.zip \
&& echo "${GRADLE_ZIP_SHA256_HASH} *gradle.zip" | shasum -a 256 --check \
&& TEMPD=$(mktemp -d) \
&& unzip gradle.zip -d ${TEMPD} \
&& sudo mv ${TEMPD} /opt \
&& rm -rf $TEMPD \
&& rm -rf gradle.zip