diff --git a/rootfs/standard/usr/bin/mynode_chpasswd.sh b/rootfs/standard/usr/bin/mynode_chpasswd.sh index 3e3e9214..cd02518c 100755 --- a/rootfs/standard/usr/bin/mynode_chpasswd.sh +++ b/rootfs/standard/usr/bin/mynode_chpasswd.sh @@ -1,18 +1,34 @@ #!/bin/bash PASSWORD=$1 -HASH=$(echo -n "$PASSWORD" | sha256sum | awk '{print $1}') + +HASH_SHA256=$(echo -n "$PASSWORD" | sha256sum | awk '{print $1}') +HASH_BCRYPT=$(python3.7 -c "import bcrypt; print(bcrypt.hashpw(b\"$PASSWORD\", bcrypt.gensalt()).decode(\"ascii\"))") + +# If pass did not change, exit success +if [ -f /home/bitcoin/.mynode/.hashedpw ]; then + OLD_HASH_SHA256=$(cat /home/bitcoin/.mynode/.hashedpw) + if [ "$OLD_HASH_SHA256" = "$HASH_SHA256" ]; then + exit 0; + fi +fi + # Change Linux Password echo "admin:$PASSWORD" | chpasswd # Save hashed password -echo "$HASH" > /home/bitcoin/.mynode/.hashedpw +echo "$HASH_SHA256" > /home/bitcoin/.mynode/.hashedpw +echo "$HASH_BCRYPT" > /home/bitcoin/.mynode/.hashedpw_bcrypt # Change RTL password -sed -i "s/\"multiPassHashed\":.*/\"multiPassHashed\": \"$HASH\",/g" /mnt/hdd/mynode/rtl/RTL-Config.json -systemctl restart rtl & +if [ -f /mnt/hdd/mynode/rtl/RTL-Config.json ]; then + sed -i "s/\"multiPassHashed\":.*/\"multiPassHashed\": \"$HASH_SHA256\",/g" /mnt/hdd/mynode/rtl/RTL-Config.json + systemctl restart rtl & +fi # Change Thunderhub password -#sed -i "s/???/???/g" /mnt/hdd/mynode/rtl/RTL-Config.json -#systemctl restart thunderhub & +if [ -f /mnt/hdd/mynode/thunderhub/thub_config.yaml ]; then + sed -i "s/masterPassword:.*/masterPassword: 'thunderhub-$HASH_BCRYPT'/g" /mnt/hdd/mynode/thunderhub/thub_config.yaml + systemctl restart thunderhub & +fi \ No newline at end of file diff --git a/rootfs/standard/usr/bin/mynode_post_upgrade.sh b/rootfs/standard/usr/bin/mynode_post_upgrade.sh index 791f9b30..c34989ab 100755 --- a/rootfs/standard/usr/bin/mynode_post_upgrade.sh +++ b/rootfs/standard/usr/bin/mynode_post_upgrade.sh @@ -103,6 +103,7 @@ pip3 install gnureadline --no-cache-dir pip3 install lndmanage==0.10.0 --no-cache-dir # Install LND Manage (keep up to date with LND) pip3 install docker-compose --no-cache-dir pip3 install pipenv --no-cache-dir +pip3 install bcrypt --no-cache-dir # Install Docker @@ -515,7 +516,7 @@ fi # Upgrade Thunderhub -THUNDERHUB_UPGRADE_URL=https://github.com/apotdevin/thunderhub/archive/v0.8.8.tar.gz +THUNDERHUB_UPGRADE_URL=https://github.com/apotdevin/thunderhub/archive/v0.8.13.tar.gz THUNDERHUB_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.thunderhub_url CURRENT="" if [ -f $THUNDERHUB_UPGRADE_URL_FILE ]; then diff --git a/rootfs/standard/usr/bin/mynode_startup.sh b/rootfs/standard/usr/bin/mynode_startup.sh index 197bc1cc..e3d45655 100755 --- a/rootfs/standard/usr/bin/mynode_startup.sh +++ b/rootfs/standard/usr/bin/mynode_startup.sh @@ -282,6 +282,14 @@ if [ ! -L /home/bitcoin/.specter ]; then sudo -u bitcoin ln -s /mnt/hdd/mynode/specter /home/bitcoin/.specter fi +# Setup Thunderhub +if [ -f /mnt/hdd/mynode/thunderhub/thub_config.yaml ]; then + if [ -f /home/bitcoin/.mynode/.hashedpw_bcrypt ]; then + HASH_BCRYPT=$(cat /home/bitcoin/.mynode/.hashedpw_bcrypt) + sed -i "s/masterPassword:.*/masterPassword: 'thunderhub-$HASH_BCRYPT'/g" /mnt/hdd/mynode/thunderhub/thub_config.yaml + fi +fi + # Setup udev chown root:root /etc/udev/rules.d/* || true udevadm trigger diff --git a/rootfs/standard/usr/share/mynode/thub_config.yaml b/rootfs/standard/usr/share/mynode/thub_config.yaml index 5f785744..1bb0ac45 100644 --- a/rootfs/standard/usr/share/mynode/thub_config.yaml +++ b/rootfs/standard/usr/share/mynode/thub_config.yaml @@ -1,4 +1,4 @@ -masterPassword: 'bolt' # Default password unless defined in account +masterPassword: 'thunderhub-$2b$12$IMmGa2C29byHS7TkaAzMcuptaAQgthisisgarbage' # Invalid password unless defined in account accounts: - name: 'localhost' serverUrl: '127.0.0.1:10009' diff --git a/rootfs/standard/var/www/mynode/user_management.py b/rootfs/standard/var/www/mynode/user_management.py index 9f942087..8a719c5b 100644 --- a/rootfs/standard/var/www/mynode/user_management.py +++ b/rootfs/standard/var/www/mynode/user_management.py @@ -40,8 +40,13 @@ def login(password): increase_recent_invalid_login_attempts() return False else: + # Setup settion info session["logged_in"] = True session.permanent = True + + # Call change password to ensure hash files are up to date + subprocess.call(['/usr/bin/mynode_chpasswd.sh', password]) + return True def logout():