X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=build%2Fshtool;h=2680d69380a752823343457f3273ce429255beb6;hb=3033741b60eb2cc3af4a6bd30b57e7b4bd85d48e;hp=b17658831e77e01f126086d4033fb8cbd7c8ba63;hpb=752318969382aef07cf41912dd13f7f14b0ce2b2;p=openldap diff --git a/build/shtool b/build/shtool index b17658831e..2680d69380 100755 --- a/build/shtool +++ b/build/shtool @@ -1,12 +1,12 @@ #!/bin/sh ## ## GNU shtool -- The GNU Portable Shell Tool -## Copyright (c) 1994-2004 Ralf S. Engelschall +## Copyright (c) 1994-2005 Ralf S. Engelschall ## ## See http://www.gnu.org/software/shtool/ for more information. ## See ftp://ftp.gnu.org/gnu/shtool/ for latest version. ## -## Version: 2.0.1 (11-Aug-2004) +## Version: 2.0.2 (15-Jun-2005) ## Contents: 6/19 available modules ## @@ -67,8 +67,8 @@ if [ $# -eq 0 ]; then exit 1 fi if [ ".$1" = ".-h" ] || [ ".$1" = ".--help" ]; then - echo "This is GNU shtool, version 2.0.1 (11-Aug-2004)" - echo "Copyright (c) 1994-2004 Ralf S. Engelschall " + echo "This is GNU shtool, version 2.0.2 (15-Jun-2005)" + echo "Copyright (c) 1994-2005 Ralf S. Engelschall " echo "Report bugs to " echo '' echo "Usage: shtool [] [ [] []]" @@ -136,11 +136,11 @@ if [ ".$1" = ".-h" ] || [ ".$1" = ".--help" ]; then exit 0 fi if [ ".$1" = ".-v" ] || [ ".$1" = ".--version" ]; then - echo "GNU shtool 2.0.1 (11-Aug-2004)" + echo "GNU shtool 2.0.2 (15-Jun-2005)" exit 0 fi if [ ".$1" = ".-r" ] || [ ".$1" = ".--recreate" ]; then - shtoolize -obuild/shtool echo move install mkdir mkln subst + shtoolize -oshtool echo move install mkdir mkln subst exit 0 fi if [ ".$1" = ".-d" ] || [ ".$1" = ".--debug" ]; then @@ -404,6 +404,7 @@ esac # establish a temporary file on request if [ ".$gen_tmpfile" = .yes ]; then + # create (explicitly) secure temporary directory if [ ".$TMPDIR" != . ]; then tmpdir="$TMPDIR" elif [ ".$TEMPDIR" != . ]; then @@ -411,10 +412,19 @@ if [ ".$gen_tmpfile" = .yes ]; then else tmpdir="/tmp" fi - tmpfile="$tmpdir/.shtool.$$" - rm -f $tmpfile >/dev/null 2>&1 - touch $tmpfile - chmod 600 $tmpfile + tmpdir="$tmpdir/.shtool.$$" + ( umask 077 + rm -rf "$tmpdir" >/dev/null 2>&1 || true + mkdir "$tmpdir" >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "$msgprefix:Error: failed to create temporary directory \`$tmpdir'" 1>&2 + exit 1 + fi + ) + + # create (implicitly) secure temporary file + tmpfile="$tmpdir/shtool.tmp" + touch "$tmpfile" fi # utility function: map string to lower case @@ -431,7 +441,7 @@ util_upper () { shtool_exit () { rc="$1" if [ ".$gen_tmpfile" = .yes ]; then - rm -f $tmpfile >/dev/null 2>&1 || true + rm -rf "$tmpdir" >/dev/null 2>&1 || true fi exit $rc } @@ -445,7 +455,7 @@ case $tool in echo ) ## ## echo -- Print string with optional construct expansion - ## Copyright (c) 1998-2004 Ralf S. Engelschall + ## Copyright (c) 1998-2005 Ralf S. Engelschall ## text="$*" @@ -743,7 +753,7 @@ echo ) move ) ## ## move -- Move files with simultaneous substitution - ## Copyright (c) 1999-2004 Ralf S. Engelschall + ## Copyright (c) 1999-2005 Ralf S. Engelschall ## src="$1" @@ -835,7 +845,7 @@ move ) install ) ## ## install -- Install a program, script or datafile - ## Copyright (c) 1997-2004 Ralf S. Engelschall + ## Copyright (c) 1997-2005 Ralf S. Engelschall ## # special case: "shtool install -d [...]" internally @@ -998,7 +1008,7 @@ install ) mkdir ) ## ## mkdir -- Make one or more directories - ## Copyright (c) 1996-2004 Ralf S. Engelschall + ## Copyright (c) 1996-2005 Ralf S. Engelschall ## errstatus=0 @@ -1086,7 +1096,7 @@ mkdir ) mkln ) ## ## mkln -- Make link with calculation of relative paths - ## Copyright (c) 1998-2004 Ralf S. Engelschall + ## Copyright (c) 1998-2005 Ralf S. Engelschall ## # determine source(s) and destination @@ -1237,7 +1247,7 @@ mkln ) subst ) ## ## subst -- Apply sed(1) substitution operations - ## Copyright (c) 2001-2004 Ralf S. Engelschall + ## Copyright (c) 2001-2005 Ralf S. Engelschall ## # remember optional list of file(s)