From 436cf306fe05ab4d4805d3fda69660faac8eb4a5 Mon Sep 17 00:00:00 2001 From: Stephane Peter Date: Wed, 21 Dec 2016 01:47:06 -0800 Subject: [PATCH] Added new --needroot option to require root permissions before extracting (bug #73) Bumping version number to 2.3.0 for next release --- makeself-header.sh | 8 ++++++++ makeself.sh | 12 +++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/makeself-header.sh b/makeself-header.sh index a6fccc60..8a55990f 100755 --- a/makeself-header.sh +++ b/makeself-header.sh @@ -253,6 +253,9 @@ do if test x"$copy" = xcopy; then echo "Archive will copy itself to a temporary location" fi + if test x"$NEED_ROOT" = xy; then + echo "Root permissions required for extraction" + fi if test x"$KEEP" = xy; then echo "directory \$targetdir is permanent" else @@ -366,6 +369,11 @@ if test x"\$quiet" = xy -a x"\$verbose" = xy; then exit 1 fi +if test x"$NEED_ROOT" = xy -a \`id -u\` -ne 0; then + echo "Administrative privileges required for this archive (use su or sudo)" >&2 + exit 1 +fi + if test x"\$copy" \!= xphase2; then MS_PrintLicense fi diff --git a/makeself.sh b/makeself.sh index 6e181b7a..f560a6d6 100755 --- a/makeself.sh +++ b/makeself.sh @@ -67,13 +67,13 @@ # Added --target dir to allow extracting directly to a target directory (Guy Baconniere) # - 2.2.0 : Many bugfixes, updates and contributions from users. Check out the project page on Github for the details. # -# (C) 1998-2013 by Stephane Peter +# (C) 1998-2016 by Stephane Peter # # This software is released under the terms of the GNU GPL version 2 and above # Please read the license at http://www.gnu.org/copyleft/gpl.html # -MS_VERSION=2.2.0 +MS_VERSION=2.3.0 MS_COMMAND="$0" unset CDPATH @@ -107,6 +107,7 @@ MS_Usage() echo " --nocomp : Do not compress the data" echo " --notemp : The archive will create archive_dir in the" echo " current directory and uncompress in ./archive_dir" + echo " --needroot : Check that the root user is extracting the archive before proceeding" echo " --copy : Upon extraction, the archive will first copy itself to" echo " a temporary directory" echo " --append : Append more files to an existing Makeself archive" @@ -153,6 +154,7 @@ KEEP_UMASK=n QUIET=n NOPROGRESS=n COPY=none +NEED_ROOT=n TAR_ARGS=cvf TAR_EXTRA="" DU_ARGS=-ks @@ -248,6 +250,10 @@ do NOOVERWRITE=y shift ;; + --needroot) + NEED_ROOT=y + shift + ;; --header) HEADER="$2" if ! shift 2; then MS_Help; exit 1; fi @@ -255,7 +261,7 @@ do --license) LICENSE=`cat $2` if ! shift 2; then MS_Help; exit 1; fi - ;; + ;; --follow) TAR_ARGS=cvhf DU_ARGS=-ksL