Add NetBSD and SunOS (SmartOS) support to _stack_lib.sh.

This commit is contained in:
Travis Paul
2018-11-29 14:01:54 +08:00
parent b3b0604be7
commit 3a491aad01

View File

@@ -57,7 +57,7 @@ function create_self_deleting_tempfile() {
: "${TMPDIR:=/tmp}" ; : "${TMPDIR:=/tmp}" ;
filename=$(mktemp -t _stacklib_.XXXXXXXX ) filename=$(mktemp -t _stacklib_.XXXXXXXX )
;; ;;
Linux | CYGWIN* | MINGW* ) Linux | CYGWIN* | MINGW* | NetBSD | SunOS )
filename=$(mktemp) filename=$(mktemp)
;; ;;
* ) * )
@@ -78,7 +78,7 @@ function create_self_deleting_tempdir() {
: "${TMPDIR:=/tmp}" ; : "${TMPDIR:=/tmp}" ;
filename=$(mktemp -d -t _stacklib_.XXXXXXXX ) filename=$(mktemp -d -t _stacklib_.XXXXXXXX )
;; ;;
Linux | CYGWIN* | MINGW* ) Linux | CYGWIN* | MINGW* | NetBSD | SunOS )
filename=$(mktemp -d) filename=$(mktemp -d)
;; ;;
* ) * )
@@ -102,7 +102,7 @@ function make_self_deleting_tempfile() {
: "${TMPDIR:=/tmp}" ; : "${TMPDIR:=/tmp}" ;
name=$(mktemp -t _stacklib_.XXXXXXXX ) name=$(mktemp -t _stacklib_.XXXXXXXX )
;; ;;
Linux | CYGWIN* | MINGW* ) Linux | CYGWIN* | MINGW* | NetBSD | SunOS )
name=$(mktemp) name=$(mktemp)
;; ;;
* ) * )
@@ -127,7 +127,7 @@ function make_tempdir() {
# which needs to fit within sockaddr_un.sun_path (see unix(7)). # which needs to fit within sockaddr_un.sun_path (see unix(7)).
name=$(mktemp -d -t SO ) name=$(mktemp -d -t SO )
;; ;;
Linux | CYGWIN* | MINGW* ) Linux | CYGWIN* | MINGW* | NetBSD | SunOS )
name=$(mktemp -d) name=$(mktemp -d)
;; ;;
* ) * )
@@ -160,14 +160,14 @@ function fail_if_not_running_as_root() {
function fail_if_in_root_directory() { function fail_if_in_root_directory() {
# Verify nobody has tricked us into being in "/". # Verify nobody has tricked us into being in "/".
case $(uname -s) in case $(uname -s) in
Darwin | FreeBSD ) Darwin | FreeBSD | NetBSD )
if [[ $(stat -f'%i' / ) == $(stat -f'%i' . ) ]] ; then if [[ $(stat -f'%i' / ) == $(stat -f'%i' . ) ]] ; then
echo 'SECURITY ALERT: The current directory is the root directory.' echo 'SECURITY ALERT: The current directory is the root directory.'
echo 'Exiting...' echo 'Exiting...'
exit 1 exit 1
fi fi
;; ;;
Linux | CYGWIN* | MINGW* ) Linux | CYGWIN* | MINGW* | SunOS )
if [[ $(stat -c'%i' / ) == $(stat -c'%i' . ) ]] ; then if [[ $(stat -c'%i' / ) == $(stat -c'%i' . ) ]] ; then
echo 'SECURITY ALERT: The current directory is the root directory.' echo 'SECURITY ALERT: The current directory is the root directory.'
echo 'Exiting...' echo 'Exiting...'