]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix get key id from key_idpad
authorMatthijs Mekking <matthijs@isc.org>
Mon, 9 Dec 2019 13:54:04 +0000 (14:54 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Mon, 9 Dec 2019 13:54:04 +0000 (14:54 +0100)
The kasp system test has a call to sed to retrieve the key identifier
without leading zeros.  The sed call could not handle key id 0.
Update the kasp test to also correctly deal with this case.

bin/tests/system/kasp/tests.sh

index 604fd90f535f3b60159a61edcd1cb9ea795b43ee..7bcd68df906acb4439ef5a0de377c245be36a1d8 100644 (file)
@@ -240,13 +240,13 @@ key_states() {
 # KEY_FILE="${BASE_FILE}.key"
 # PRIVATE_FILE="${BASE_FILE}.private"
 # STATE_FILE="${BASE_FILE}.state"
-# KEY_ID=$(echo $1 | sed 's/^0*//')
+# KEY_ID=$(echo $1 | sed 's/^0\{0,4\}//')
 check_key() {
        _dir="$DIR"
        _zone="$ZONE"
        _role=$(key_get "$1" ROLE)
        _key_idpad="$2"
-       _key_id=$(echo "$_key_idpad" | sed 's/^0*//')
+       _key_id=$(echo "$_key_idpad" | sed 's/^0\{0,4\}//')
        _alg_num=$(key_get "$1" ALG_NUM)
        _alg_numpad=$(printf "%03d" "$_alg_num")
        _alg_string=$(key_get "$1" ALG_STR)
@@ -288,7 +288,7 @@ check_key() {
        PRIVATE_FILE="${BASE_FILE}.private"
        STATE_FILE="${BASE_FILE}.state"
        KEY_ID="${_key_id}"
-       
+
        test $_log -eq 1 && echo_i "check key $BASE_FILE"
 
        # Check the public key file.
@@ -409,12 +409,12 @@ check_key() {
 # KEY_FILE="${BASE_FILE}.key"
 # PRIVATE_FILE="${BASE_FILE}.private"
 # STATE_FILE="${BASE_FILE}.state"
-# KEY_ID=$(echo $1 | sed 's/^0*//')
+# KEY_ID=$(echo $1 | sed 's/^0\{0,4\}//')
 key_unused() {
        _dir=$DIR
        _zone=$ZONE
        _key_idpad=$1
-       _key_id=$(echo "$_key_idpad" | sed 's/^0*//')
+       _key_id=$(echo "$_key_idpad" | sed 's/^0\{0,4\}//')
        _alg_num=$(key_get KEY1 ALG_NUM)
         _alg_numpad=$(printf "%03d" "$_alg_num")