mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 14:55:00 +00:00
Check if gbase64 (GNU) is available on Mac and use it in preference to BSD base64 @marcjay
Check if gbase64 (GNU) is available on Mac and use it in preference to BSD base64
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
# specific language governing permissions and limitations under the License.
|
# specific language governing permissions and limitations under the License.
|
||||||
|
|
||||||
DATE_CMD="date"
|
DATE_CMD="date"
|
||||||
|
BASE64_CMD="base64"
|
||||||
|
|
||||||
gnu_how_older_from_today() {
|
gnu_how_older_from_today() {
|
||||||
DATE_TO_COMPARE=$1
|
DATE_TO_COMPARE=$1
|
||||||
@@ -44,10 +45,10 @@ bsd_timestamp_to_date() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gnu_decode_report() {
|
gnu_decode_report() {
|
||||||
base64 -d
|
"$BASE64_CMD" -d
|
||||||
}
|
}
|
||||||
bsd_decode_report() {
|
bsd_decode_report() {
|
||||||
base64 -D
|
"$BASE64_CMD" -D
|
||||||
}
|
}
|
||||||
|
|
||||||
gnu_how_many_days_from_today() {
|
gnu_how_many_days_from_today() {
|
||||||
@@ -146,12 +147,16 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|||||||
# It is possible that the user has installed GNU coreutils on OS X. By default, this will make GNU commands
|
# It is possible that the user has installed GNU coreutils on OS X. By default, this will make GNU commands
|
||||||
# available with a 'g' prefix, e.g. 'gdate'. Test if this is present, and use it if so, as it supports more features.
|
# available with a 'g' prefix, e.g. 'gdate'. Test if this is present, and use it if so, as it supports more features.
|
||||||
# The user also may have replaced the default Mac OS X BSD tools with the GNU coreutils equivalents.
|
# The user also may have replaced the default Mac OS X BSD tools with the GNU coreutils equivalents.
|
||||||
# Only GNU date allows --version as a valid argument, so use the validity of this argument
|
# Only GNU date/base64 allows --version as a valid argument, so use the validity of this argument
|
||||||
# as a means to detect that coreutils is installed and is overriding the default tools
|
# as a means to detect that coreutils is installed and is overriding the default tools
|
||||||
GDATE=$(which gdate)
|
GDATE=$(which gdate)
|
||||||
if [ -n "${GDATE}" ]; then
|
if [ -n "${GDATE}" ]; then
|
||||||
DATE_CMD="gdate"
|
DATE_CMD="gdate"
|
||||||
fi
|
fi
|
||||||
|
GBASE64=$(which gbase64)
|
||||||
|
if [ -n "${GBASE64}" ]; then
|
||||||
|
BASE64_CMD="gbase64"
|
||||||
|
fi
|
||||||
if "$DATE_CMD" --version >/dev/null 2>&1 ; then
|
if "$DATE_CMD" --version >/dev/null 2>&1 ; then
|
||||||
how_older_from_today() {
|
how_older_from_today() {
|
||||||
gnu_how_older_from_today "$1"
|
gnu_how_older_from_today "$1"
|
||||||
@@ -159,9 +164,6 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|||||||
timestamp_to_date() {
|
timestamp_to_date() {
|
||||||
gnu_timestamp_to_date "$1"
|
gnu_timestamp_to_date "$1"
|
||||||
}
|
}
|
||||||
decode_report() {
|
|
||||||
gnu_decode_report
|
|
||||||
}
|
|
||||||
how_many_days_from_today() {
|
how_many_days_from_today() {
|
||||||
gnu_how_many_days_from_today "$1"
|
gnu_how_many_days_from_today "$1"
|
||||||
}
|
}
|
||||||
@@ -181,9 +183,6 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|||||||
timestamp_to_date() {
|
timestamp_to_date() {
|
||||||
bsd_timestamp_to_date "$1"
|
bsd_timestamp_to_date "$1"
|
||||||
}
|
}
|
||||||
decode_report() {
|
|
||||||
bsd_decode_report
|
|
||||||
}
|
|
||||||
how_many_days_from_today() {
|
how_many_days_from_today() {
|
||||||
bsd_how_many_days_from_today "$1"
|
bsd_how_many_days_from_today "$1"
|
||||||
}
|
}
|
||||||
@@ -197,6 +196,15 @@ elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|||||||
bsd_get_iso8601_timestamp
|
bsd_get_iso8601_timestamp
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
if "$BASE64_CMD" --version >/dev/null 2>&1 ; then
|
||||||
|
decode_report() {
|
||||||
|
gnu_decode_report
|
||||||
|
}
|
||||||
|
else
|
||||||
|
decode_report() {
|
||||||
|
bsd_decode_report
|
||||||
|
}
|
||||||
|
fi
|
||||||
test_tcp_connectivity() {
|
test_tcp_connectivity() {
|
||||||
bsd_test_tcp_connectivity "$1" "$2" "$3"
|
bsd_test_tcp_connectivity "$1" "$2" "$3"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user