diff options
author | Michael Boelen <michael.boelen@cisofy.com> | 2020-07-06 10:26:27 +0300 |
---|---|---|
committer | Michael Boelen <michael.boelen@cisofy.com> | 2020-07-06 10:26:27 +0300 |
commit | 6eae35e564fba2183a1d6a2cddaa656d841756f9 (patch) | |
tree | ffa2b35c28d60bedfdae45d4b8542d4f898c236c /include/helper_generate | |
parent | 7b6624f85dac6b6806495b0dcfff2d5d2b51d75a (diff) |
Fix for too short IDs due to hexdump output missing leading or trailing zeroes
Diffstat (limited to 'include/helper_generate')
-rw-r--r-- | include/helper_generate | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/helper_generate b/include/helper_generate index 67b58b66..f3a8d909 100644 --- a/include/helper_generate +++ b/include/helper_generate @@ -51,8 +51,10 @@ if [ $# -gt 0 ]; then ;; *) # xxd does not exist on FreeBSD - HOSTID=$(head -c20 < /dev/urandom | hexdump -ve '"%.2x"') - HOSTID2=$(head -c32 < /dev/urandom | hexdump -ve '"%.2x"') + # Note: hexdump may omit leading or trailing zeroes. + # Take 100 characters as input, turn to hex, then take first 40/64. + HOSTID=$(head -c100 < /dev/urandom | hexdump -ve '"%.2x"' | head -c40) + HOSTID2=$(head -c100 < /dev/urandom | hexdump -ve '"%.2x"' | head -c64) ;; esac |