cl: move the autounlock file to /home/bitcoin/

to fix permission errors in #2812
This commit is contained in:
openoms
2021-12-18 02:29:57 +00:00
parent 1b7f9d51d8
commit 681e8c98bd
3 changed files with 13 additions and 13 deletions

View File

@@ -21,7 +21,7 @@ if [ "$(eval echo \$${netprefix}clEncryptedHSM)" = "off" ];then
elif [ "$(eval echo \$${netprefix}clEncryptedHSM)" = "on" ];then elif [ "$(eval echo \$${netprefix}clEncryptedHSM)" = "on" ];then
OPTIONS+=(PASSWORD_C "Change the hsm_secret encryption password") OPTIONS+=(PASSWORD_C "Change the hsm_secret encryption password")
OPTIONS+=(DECRYPT "Decrypt the hsm_secret") OPTIONS+=(DECRYPT "Decrypt the hsm_secret")
if [ ! -f "/root/.${netprefix}cl.pw" ]; then if [ ! -f "/home/bitcoin/.${netprefix}cl.pw" ]; then
OPTIONS+=(AUTOUNLOCK-ON "Auto-decrypt the hsm_secret after boot") OPTIONS+=(AUTOUNLOCK-ON "Auto-decrypt the hsm_secret after boot")
else else
OPTIONS+=(AUTOUNLOCK-OFF "Do not auto-decrypt the hsm_secret after boot") OPTIONS+=(AUTOUNLOCK-OFF "Do not auto-decrypt the hsm_secret after boot")

View File

@@ -3,7 +3,7 @@
# keeps the password in memory between restarts: /dev/shm/.${netprefix}cl.pw # keeps the password in memory between restarts: /dev/shm/.${netprefix}cl.pw
# see the reasoning: https://github.com/ElementsProject/lightning#hd-wallet-encryption # see the reasoning: https://github.com/ElementsProject/lightning#hd-wallet-encryption
# does not store the password on disk unless auto-unlock is enabled # does not store the password on disk unless auto-unlock is enabled
# autounlock password is in /root/.${netprefix}cl.pw # autounlock password is in /home/bitcoin/.${netprefix}cl.pw
# command info # command info
if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]||\ if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]||\
@@ -41,7 +41,7 @@ hsmSecretPath="/home/bitcoin/.lightning/${CLNETWORK}/hsm_secret"
passwordFile=/dev/shm/.${netprefix}cl.pw passwordFile=/dev/shm/.${netprefix}cl.pw
if grep -Eq "${netprefix}clEncryptedHSM=on" /mnt/hdd/raspiblitz.conf;then if grep -Eq "${netprefix}clEncryptedHSM=on" /mnt/hdd/raspiblitz.conf;then
if grep -Eq "${netprefix}clAutoUnlock=on" /mnt/hdd/raspiblitz.conf;then if grep -Eq "${netprefix}clAutoUnlock=on" /mnt/hdd/raspiblitz.conf;then
passwordFile=/root/${netprefix}cl.pw passwordFile=/home/bitcoin/${netprefix}cl.pw
fi fi
fi fi
@@ -72,7 +72,7 @@ function passwordToFile() {
sudo touch $passwordFile sudo touch $passwordFile
sudo chmod 600 $passwordFile sudo chmod 600 $passwordFile
sudo chown bitcoin:bitcoin $passwordFile sudo chown bitcoin:bitcoin $passwordFile
sudo tee $passwordFile 1>/dev/null < "$data" sudo -u bitcoin tee $passwordFile 1>/dev/null < "$data"
shred "$data";; shred "$data";;
1) 1)
shred "$data" shred "$data"
@@ -94,8 +94,8 @@ function shredPasswordFile() {
if [ -f /dev/shm/.${netprefix}cl.pw ];then if [ -f /dev/shm/.${netprefix}cl.pw ];then
sudo shred -uvz /dev/shm/.${netprefix}cl.pw sudo shred -uvz /dev/shm/.${netprefix}cl.pw
fi fi
if [ -f /root/${netprefix}cl.pw ];then if [ -f /home/bitcoin/${netprefix}cl.pw ];then
sudo shred -uvz /root/${netprefix}cl.pw sudo shred -uvz /home/bitcoin/${netprefix}cl.pw
fi fi
} }
@@ -321,10 +321,10 @@ elif [ "$1" = "decrypt" ]; then
elif [ "$1" = "autounlock-on" ]; then elif [ "$1" = "autounlock-on" ]; then
if grep -Eq "${netprefix}clEncryptedHSM=on" /mnt/hdd/raspiblitz.conf;then if grep -Eq "${netprefix}clEncryptedHSM=on" /mnt/hdd/raspiblitz.conf;then
echo "# Moving the password from $passwordFile to /root/.${netprefix}cl.pw" echo "# Moving the password from $passwordFile to /home/bitcoin/.${netprefix}cl.pw"
sudo -u bitcoin mv /dev/shm/.${netprefix}cl.pw /root/.${netprefix}cl.pw sudo -u bitcoin mv /dev/shm/.${netprefix}cl.pw /home/bitcoin/.${netprefix}cl.pw
else else
passwordFile=/root/.${netprefix}cl.pw passwordFile=/home/bitcoin/.${netprefix}cl.pw
passwordToFile passwordToFile
fi fi
# setting value in raspiblitz config # setting value in raspiblitz config
@@ -333,9 +333,9 @@ elif [ "$1" = "autounlock-on" ]; then
echo "# Autounlock is on for C-lightning $CHAIN" echo "# Autounlock is on for C-lightning $CHAIN"
elif [ "$1" = "autounlock-off" ]; then elif [ "$1" = "autounlock-off" ]; then
if [ -f /root/${netprefix}cl.pw ];then if [ -f /home/bitcoin/${netprefix}cl.pw ];then
sudo cp /root/.${netprefix}cl.pw /dev/shm/.${netprefix}cl.pw sudo cp /home/bitcoin/.${netprefix}cl.pw /dev/shm/.${netprefix}cl.pw
sudo shred -uzv /root/.${netprefix}cl.pw sudo shred -uzv /home/bitcoin/.${netprefix}cl.pw
sudo chmod 600 /dev/shm/.${netprefix}cl.pw sudo chmod 600 /dev/shm/.${netprefix}cl.pw
sudo chown bitcoin:bitcoin /dev/shm/.${netprefix}cl.pw sudo chown bitcoin:bitcoin /dev/shm/.${netprefix}cl.pw
fi fi

View File

@@ -36,7 +36,7 @@ fi
if grep -Eq "${netprefix}clEncryptedHSM=on" /mnt/hdd/raspiblitz.conf;then if grep -Eq "${netprefix}clEncryptedHSM=on" /mnt/hdd/raspiblitz.conf;then
if grep -Eq "${netprefix}clAutoUnlock=on" /mnt/hdd/raspiblitz.conf;then if grep -Eq "${netprefix}clAutoUnlock=on" /mnt/hdd/raspiblitz.conf;then
passwordFile=/root/.${netprefix}cl.pw passwordFile=/home/bitcoin/.${netprefix}cl.pw
else else
passwordFile=/dev/shm/.${netprefix}cl.pw passwordFile=/dev/shm/.${netprefix}cl.pw
fi fi