Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Boelen <michael.boelen@cisofy.com>2019-07-14 13:18:05 +0300
committerMichael Boelen <michael.boelen@cisofy.com>2019-07-14 13:18:05 +0300
commitba32b1a001b703fe99fcf74da80816ac31245a74 (patch)
treec18312badae4c55f10813e8b042b425f0042b83b /include/helper_generate
parent4829ae97221336f10ef2369b6cbf7929a62a8fb8 (diff)
Use xxd or hexdump, depending on OS
Diffstat (limited to 'include/helper_generate')
-rw-r--r--include/helper_generate14
1 files changed, 12 insertions, 2 deletions
diff --git a/include/helper_generate b/include/helper_generate
index 31dba7ec..30044705 100644
--- a/include/helper_generate
+++ b/include/helper_generate
@@ -43,8 +43,18 @@ if [ $# -gt 0 ]; then
fi
# Generate random host IDs
- HOSTID=$(head -c20 < /dev/urandom | xxd -c 20 -p)
- HOSTID2=$(head -c32 < /dev/urandom | xxd -c 32 -p)
+ case "${OS}" in
+ "AIX")
+ # hexdump does not exist on AIX
+ HOSTID=$(head -c20 < /dev/urandom | xxd -c 20 -p)
+ HOSTID2=$(head -c32 < /dev/urandom | xxd -c 32 -p)
+ ;;
+ *)
+ # xxd does not exist on FreeBSD
+ HOSTID=$(head -c20 < /dev/urandom | hexdump -ve '"%.2x"')
+ HOSTID2=$(head -c32 < /dev/urandom | hexdump -ve '"%.2x"')
+ ;;
+ esac
${ECHOCMD} "Generated host identifiers"
${ECHOCMD} "- hostid: ${HOSTID}"