Fix setAutoLogin.sh script (#5298)
This commit is contained in:
@@ -22,15 +22,11 @@ function kcpasswordEncode {
|
|||||||
#converted to hex representation with spaces
|
#converted to hex representation with spaces
|
||||||
local thisStringHex_array=( $(echo -n "${thisString}" | xxd -p -u | sed 's/../& /g') )
|
local thisStringHex_array=( $(echo -n "${thisString}" | xxd -p -u | sed 's/../& /g') )
|
||||||
|
|
||||||
#get padding by subtraction if under 12
|
#get padding by subtraction if under 11
|
||||||
if [ "${#thisStringHex_array[@]}" -lt 12 ]; then
|
local r=$(( ${#thisStringHex_array[@]} % 11 ))
|
||||||
local padding=$(( 12 - ${#thisStringHex_array[@]} ))
|
local padding=0
|
||||||
#get padding by subtracting remainder of modulo 12 if over 12
|
if [ $r -gt 0 ]; then
|
||||||
elif [ "$(( ${#thisStringHex_array[@]} % 12 ))" -ne 0 ]; then
|
local padding=$(( 11 - $r ))
|
||||||
local padding=$(( (12 - ${#thisStringHex_array[@]} % 12) ))
|
|
||||||
#otherwise even multiples of 12 still need 12 padding
|
|
||||||
else
|
|
||||||
local padding=12
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#cycle through each element of the array + padding
|
#cycle through each element of the array + padding
|
||||||
@@ -44,7 +40,7 @@ function kcpasswordEncode {
|
|||||||
#use $(( shell Aritmethic )) to ^ XOR the two 0x## values (extra padding is 0x00)
|
#use $(( shell Aritmethic )) to ^ XOR the two 0x## values (extra padding is 0x00)
|
||||||
#take decimal value and printf convert to two char hex value
|
#take decimal value and printf convert to two char hex value
|
||||||
#use xxd to convert hex to actual value and append to the encodedString variable
|
#use xxd to convert hex to actual value and append to the encodedString variable
|
||||||
local encodedString+=$(printf "%02X" "$(( 0x${charHex_cipher} ^ 0x${charHex:-00} ))" | xxd -r -p)
|
local encodedString+=$(printf "%02X" "$(( 0x${charHex_cipher} ^ 0x${charHex:-00} ))")
|
||||||
done
|
done
|
||||||
|
|
||||||
#return the string without a newline
|
#return the string without a newline
|
||||||
@@ -52,7 +48,7 @@ function kcpasswordEncode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#encode password and write file
|
#encode password and write file
|
||||||
kcpasswordEncode "${PW}" > /etc/kcpassword
|
kcpasswordEncode "${PW}" | xxd -r -p > /etc/kcpassword
|
||||||
|
|
||||||
#ensure ownership and permissions (600)
|
#ensure ownership and permissions (600)
|
||||||
chown root:wheel /etc/kcpassword
|
chown root:wheel /etc/kcpassword
|
||||||
|
|||||||
Reference in New Issue
Block a user