From 31f35295d984d4fae5d8d62a625173d482505461 Mon Sep 17 00:00:00 2001 From: Jakub Dzikowski Date: Sat, 7 Dec 2024 12:42:46 +0100 Subject: [PATCH] Use less strict permissions for channel genesis Signed-off-by: Jakub Dzikowski --- ...ig-hlf3-1orgs-1chaincode.json.test.ts.snap | 20 ++++++++++++++---- ...lf3-bft-1orgs-1chaincode.json.test.ts.snap | 20 ++++++++++++++---- .../scripts/cli/channel_fns-v3.sh | 21 ++++++++++++++----- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/e2e/__snapshots__/fablo-config-hlf3-1orgs-1chaincode.json.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf3-1orgs-1chaincode.json.test.ts.snap index 800134ea..2c870b41 100644 --- a/e2e/__snapshots__/fablo-config-hlf3-1orgs-1chaincode.json.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf3-1orgs-1chaincode.json.test.ts.snap @@ -3181,11 +3181,14 @@ createChannelAndJoin() { echo " CORE_PEER_ADDRESS: $CORE_PEER_ADDRESS" echo " CORE_PEER_MSPCONFIGPATH: $CORE_PEER_MSPCONFIGPATH" - mkdir "$DIR_NAME" && cd "$DIR_NAME" + mkdir -p "$DIR_NAME" && cd "$DIR_NAME" + chmod -R a+rw "$DIR_NAME" cp /var/hyperledger/cli/config/"$CHANNEL_NAME".pb . + chmod a+rw "$CHANNEL_NAME".pb osnadmin channel join --channelID "\${CHANNEL_NAME}" --config-block ./"$CHANNEL_NAME".pb -o "\${ORDERER_URL}" + cd .. rm -rf "$DIR_NAME" } @@ -3207,8 +3210,10 @@ createChannelAndJoinTls() { echo " TLS_CA_CERT_PATH: $TLS_CA_CERT_PATH" if [ ! -d "$DIR_NAME" ]; then - mkdir "$DIR_NAME" + mkdir -p "$DIR_NAME" + chmod -R a+rw "$DIR_NAME" cp /var/hyperledger/cli/config/"$CHANNEL_NAME".pb "$DIR_NAME" + chmod a+rw "$DIR_NAME/$CHANNEL_NAME.pb" fi osnadmin channel join \\ @@ -3219,6 +3224,7 @@ createChannelAndJoinTls() { --client-key "\${ADMIN_TLS_PRIVATE_KEY}" \\ --ca-file "\${TLS_CA_CERT_PATH}" + cd .. rm -rf "$DIR_NAME" } @@ -3239,11 +3245,14 @@ fetchChannelAndJoin() { echo " CORE_PEER_ADDRESS: $CORE_PEER_ADDRESS" echo " CORE_PEER_MSPCONFIGPATH: $CORE_PEER_MSPCONFIGPATH" - mkdir "$DIR_NAME" && cd "$DIR_NAME" + mkdir -p "$DIR_NAME" && cd "$DIR_NAME" + chmod -R a+rw "$DIR_NAME" peer channel fetch newest -c "\${CHANNEL_NAME}" --orderer "\${ORDERER_URL}" + chmod a+rw "\${CHANNEL_NAME}"_newest.block peer channel join -b "\${CHANNEL_NAME}"_newest.block + cd .. rm -rf "$DIR_NAME" } @@ -3273,11 +3282,14 @@ fetchChannelAndJoinTls() { echo " CORE_PEER_TLS_KEY_FILE: $CORE_PEER_TLS_KEY_FILE" echo " CORE_PEER_TLS_ROOTCERT_FILE: $CORE_PEER_TLS_ROOTCERT_FILE" - mkdir "$DIR_NAME" && cd "$DIR_NAME" + mkdir -p "$DIR_NAME" && cd "$DIR_NAME" + chmod -R a+rw "$DIR_NAME" peer channel fetch newest -c "\${CHANNEL_NAME}" --orderer "\${ORDERER_URL}" --tls --cafile "$TLS_CA_CERT_PATH" + chmod a+rw "\${CHANNEL_NAME}"_newest.block peer channel join -b "\${CHANNEL_NAME}"_newest.block --tls --cafile "$TLS_CA_CERT_PATH" + cd .. rm -rf "$DIR_NAME" } " diff --git a/e2e/__snapshots__/fablo-config-hlf3-bft-1orgs-1chaincode.json.test.ts.snap b/e2e/__snapshots__/fablo-config-hlf3-bft-1orgs-1chaincode.json.test.ts.snap index ca807e36..a35fa976 100644 --- a/e2e/__snapshots__/fablo-config-hlf3-bft-1orgs-1chaincode.json.test.ts.snap +++ b/e2e/__snapshots__/fablo-config-hlf3-bft-1orgs-1chaincode.json.test.ts.snap @@ -3206,11 +3206,14 @@ createChannelAndJoin() { echo " CORE_PEER_ADDRESS: $CORE_PEER_ADDRESS" echo " CORE_PEER_MSPCONFIGPATH: $CORE_PEER_MSPCONFIGPATH" - mkdir "$DIR_NAME" && cd "$DIR_NAME" + mkdir -p "$DIR_NAME" && cd "$DIR_NAME" + chmod -R a+rw "$DIR_NAME" cp /var/hyperledger/cli/config/"$CHANNEL_NAME".pb . + chmod a+rw "$CHANNEL_NAME".pb osnadmin channel join --channelID "\${CHANNEL_NAME}" --config-block ./"$CHANNEL_NAME".pb -o "\${ORDERER_URL}" + cd .. rm -rf "$DIR_NAME" } @@ -3232,8 +3235,10 @@ createChannelAndJoinTls() { echo " TLS_CA_CERT_PATH: $TLS_CA_CERT_PATH" if [ ! -d "$DIR_NAME" ]; then - mkdir "$DIR_NAME" + mkdir -p "$DIR_NAME" + chmod -R a+rw "$DIR_NAME" cp /var/hyperledger/cli/config/"$CHANNEL_NAME".pb "$DIR_NAME" + chmod a+rw "$DIR_NAME/$CHANNEL_NAME.pb" fi osnadmin channel join \\ @@ -3244,6 +3249,7 @@ createChannelAndJoinTls() { --client-key "\${ADMIN_TLS_PRIVATE_KEY}" \\ --ca-file "\${TLS_CA_CERT_PATH}" + cd .. rm -rf "$DIR_NAME" } @@ -3264,11 +3270,14 @@ fetchChannelAndJoin() { echo " CORE_PEER_ADDRESS: $CORE_PEER_ADDRESS" echo " CORE_PEER_MSPCONFIGPATH: $CORE_PEER_MSPCONFIGPATH" - mkdir "$DIR_NAME" && cd "$DIR_NAME" + mkdir -p "$DIR_NAME" && cd "$DIR_NAME" + chmod -R a+rw "$DIR_NAME" peer channel fetch newest -c "\${CHANNEL_NAME}" --orderer "\${ORDERER_URL}" + chmod a+rw "\${CHANNEL_NAME}"_newest.block peer channel join -b "\${CHANNEL_NAME}"_newest.block + cd .. rm -rf "$DIR_NAME" } @@ -3298,11 +3307,14 @@ fetchChannelAndJoinTls() { echo " CORE_PEER_TLS_KEY_FILE: $CORE_PEER_TLS_KEY_FILE" echo " CORE_PEER_TLS_ROOTCERT_FILE: $CORE_PEER_TLS_ROOTCERT_FILE" - mkdir "$DIR_NAME" && cd "$DIR_NAME" + mkdir -p "$DIR_NAME" && cd "$DIR_NAME" + chmod -R a+rw "$DIR_NAME" peer channel fetch newest -c "\${CHANNEL_NAME}" --orderer "\${ORDERER_URL}" --tls --cafile "$TLS_CA_CERT_PATH" + chmod a+rw "\${CHANNEL_NAME}"_newest.block peer channel join -b "\${CHANNEL_NAME}"_newest.block --tls --cafile "$TLS_CA_CERT_PATH" + cd .. rm -rf "$DIR_NAME" } " diff --git a/src/setup-docker/templates/fabric-docker/scripts/cli/channel_fns-v3.sh b/src/setup-docker/templates/fabric-docker/scripts/cli/channel_fns-v3.sh index 1b51468a..5aed16f1 100644 --- a/src/setup-docker/templates/fabric-docker/scripts/cli/channel_fns-v3.sh +++ b/src/setup-docker/templates/fabric-docker/scripts/cli/channel_fns-v3.sh @@ -19,12 +19,14 @@ createChannelAndJoin() { echo " CORE_PEER_ADDRESS: $CORE_PEER_ADDRESS" echo " CORE_PEER_MSPCONFIGPATH: $CORE_PEER_MSPCONFIGPATH" - mkdir "$DIR_NAME" && cd "$DIR_NAME" - + mkdir -p "$DIR_NAME" && cd "$DIR_NAME" + chmod -R a+rw "$DIR_NAME" cp /var/hyperledger/cli/config/"$CHANNEL_NAME".pb . + chmod a+rw "$CHANNEL_NAME".pb osnadmin channel join --channelID "${CHANNEL_NAME}" --config-block ./"$CHANNEL_NAME".pb -o "${ORDERER_URL}" + cd .. rm -rf "$DIR_NAME" } @@ -46,8 +48,10 @@ createChannelAndJoinTls() { echo " TLS_CA_CERT_PATH: $TLS_CA_CERT_PATH" if [ ! -d "$DIR_NAME" ]; then - mkdir "$DIR_NAME" + mkdir -p "$DIR_NAME" + chmod -R a+rw "$DIR_NAME" cp /var/hyperledger/cli/config/"$CHANNEL_NAME".pb "$DIR_NAME" + chmod a+rw "$DIR_NAME/$CHANNEL_NAME.pb" fi osnadmin channel join \ @@ -58,6 +62,7 @@ createChannelAndJoinTls() { --client-key "${ADMIN_TLS_PRIVATE_KEY}" \ --ca-file "${TLS_CA_CERT_PATH}" + cd .. rm -rf "$DIR_NAME" } @@ -78,11 +83,14 @@ fetchChannelAndJoin() { echo " CORE_PEER_ADDRESS: $CORE_PEER_ADDRESS" echo " CORE_PEER_MSPCONFIGPATH: $CORE_PEER_MSPCONFIGPATH" - mkdir "$DIR_NAME" && cd "$DIR_NAME" + mkdir -p "$DIR_NAME" && cd "$DIR_NAME" + chmod -R a+rw "$DIR_NAME" peer channel fetch newest -c "${CHANNEL_NAME}" --orderer "${ORDERER_URL}" + chmod a+rw "${CHANNEL_NAME}"_newest.block peer channel join -b "${CHANNEL_NAME}"_newest.block + cd .. rm -rf "$DIR_NAME" } @@ -112,10 +120,13 @@ fetchChannelAndJoinTls() { echo " CORE_PEER_TLS_KEY_FILE: $CORE_PEER_TLS_KEY_FILE" echo " CORE_PEER_TLS_ROOTCERT_FILE: $CORE_PEER_TLS_ROOTCERT_FILE" - mkdir "$DIR_NAME" && cd "$DIR_NAME" + mkdir -p "$DIR_NAME" && cd "$DIR_NAME" + chmod -R a+rw "$DIR_NAME" peer channel fetch newest -c "${CHANNEL_NAME}" --orderer "${ORDERER_URL}" --tls --cafile "$TLS_CA_CERT_PATH" + chmod a+rw "${CHANNEL_NAME}"_newest.block peer channel join -b "${CHANNEL_NAME}"_newest.block --tls --cafile "$TLS_CA_CERT_PATH" + cd .. rm -rf "$DIR_NAME" }