lnd.check.sh -> harden rpc user/pass parsing against double entries (#3282)

This commit is contained in:
/rootzoll 2022-09-29 21:03:48 +02:00 committed by GitHub
parent 922ad2ff5a
commit 21616e4ec2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -154,11 +154,25 @@ if [ "$1" == "prestart" ]; then
setting ${lndConfFile} ${insertLine} "${network}d\.zmqpubrawblock" "tcp\:\/\/127\.0\.0\.1\:${zmqprefix}332"
# SET/UPDATE rpcpass
RPCPSW=$(cat /mnt/hdd/${network}/${network}.conf | grep "rpcpassword=" | cut -d "=" -f2)
RPCPSW=$(cat /mnt/hdd/${network}/${network}.conf | grep "^rpcpassword=" | tail -1 | cut -d "=" -f2 | tail -n 1)
if [ "${RPCPSW}" == "" ]; then
RPCPSW=$(cat /mnt/hdd/${network}/${network}.conf | grep "^${network}d.rpcpassword=" | cut -d "=" -f2 | tail -n 1)
fi
if [ "${RPCPSW}" == "" ]; then
1>&2 echo "FAIL: 'rpcpassword' not found in /mnt/hdd/${network}/${network}.conf"
exit 11
fi
setting ${lndConfFile} ${insertLine} "${network}d\.rpcpass" "${RPCPSW}"
# SET/UPDATE rpcuser
RPCUSER=$(cat /mnt/hdd/${network}/${network}.conf | grep "rpcuser=" | cut -d "=" -f2)
RPCUSER=$(cat /mnt/hdd/${network}/${network}.conf | grep "^rpcuser=" | cut -d "=" -f2 | tail -n 1)
if [ "${RPCUSER}" == "" ]; then
RPCUSER=$(cat /mnt/hdd/${network}/${network}.conf | grep "^${network}d.rpcuser=" | cut -d "=" -f2 | tail -n 1)
fi
if [ "${RPCUSER}" == "" ]; then
1>&2 echo "FAIL: 'rpcuser' not found in /mnt/hdd/${network}/${network}.conf"
exit 12
fi
setting ${lndConfFile} ${insertLine} "${network}d\.rpcuser" "${RPCUSER}"
# SET/UPDATE rpchost