mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
scripts: Provide mktemp function for platforms without mktemp command
This is needed for AIX and possibly others. Also provide a cheaper mktemp function is needed in the run_tests script. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit b2b572e9049c7138bd223226475bef8fe3e01f10)
This commit is contained in:
parent
17d7288440
commit
66019e3287
@ -1425,6 +1425,32 @@ iptables()
|
||||
flock -w 30 $CTDB_VARDIR/iptables-ctdb.flock /sbin/iptables "$@"
|
||||
}
|
||||
|
||||
# AIX (and perhaps others?) doesn't have mktemp
|
||||
if ! which mktemp >/dev/null 2>&1 ; then
|
||||
mktemp ()
|
||||
{
|
||||
_dir=false
|
||||
if [ "$1" = "-d" ] ; then
|
||||
_dir=true
|
||||
shift
|
||||
fi
|
||||
_d="${TMPDIR:-/tmp}"
|
||||
_hex10=$(dd if=/dev/urandom count=20 2>/dev/null | \
|
||||
md5sum | \
|
||||
sed -e 's@\(..........\).*@\1@')
|
||||
_t="${_d}/tmp.${_hex10}"
|
||||
(
|
||||
umask 077
|
||||
if $_dir ; then
|
||||
mkdir "$_t"
|
||||
else
|
||||
>"$_t"
|
||||
fi
|
||||
)
|
||||
echo "$_t"
|
||||
}
|
||||
fi
|
||||
|
||||
########################################################
|
||||
# tickle handling
|
||||
########################################################
|
||||
|
@ -143,6 +143,27 @@ summary=""
|
||||
rows=$(if tty -s ; then stty size ; else echo x 80 ; fi | sed -e 's@.* @@' -e 's@^0$@80@')
|
||||
ww=$((rows - 7))
|
||||
|
||||
if ! which mktemp >/dev/null 2>&1 ; then
|
||||
# Not perfect, but it will do...
|
||||
mktemp ()
|
||||
{
|
||||
_dir=false
|
||||
if [ "$1" = "-d" ] ; then
|
||||
_dir=true
|
||||
fi
|
||||
_t="${TMPDIR:-/tmp}/tmp.$$.$RANDOM"
|
||||
(
|
||||
umask 077
|
||||
if $_dir ; then
|
||||
mkdir "$_t"
|
||||
else
|
||||
>"$_t"
|
||||
fi
|
||||
)
|
||||
echo "$_t"
|
||||
}
|
||||
fi
|
||||
|
||||
tf=$(mktemp)
|
||||
sf=$(mktemp)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user