Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'advanced/Scripts/webpage.sh')
-rwxr-xr-xadvanced/Scripts/webpage.sh37
1 files changed, 24 insertions, 13 deletions
diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh
index 7804fc8f..d3ad3032 100755
--- a/advanced/Scripts/webpage.sh
+++ b/advanced/Scripts/webpage.sh
@@ -67,6 +67,13 @@ SetTemperatureUnit(){
}
+HashPassword(){
+ # Compute password hash twice to avoid rainbow table vulnerability
+ return=$(echo -n ${1} | sha256sum | sed 's/\s.*$//')
+ return=$(echo -n ${return} | sha256sum | sed 's/\s.*$//')
+ echo ${return}
+}
+
SetWebPassword(){
if [ "${SUDO_USER}" == "www-data" ]; then
@@ -81,21 +88,25 @@ SetWebPassword(){
exit 1
fi
- read -s -p "Enter New Password (Blank for no password): " PASSWORD
- echo ""
-
- if [ "${PASSWORD}" == "" ]; then
- change_setting "WEBPASSWORD" ""
- echo "Password Removed"
- exit 0
- fi
+ if (( ${#args[2]} > 0 )) ; then
+ readonly PASSWORD="${args[2]}"
+ readonly CONFIRM="${PASSWORD}"
+ else
+ read -s -p "Enter New Password (Blank for no password): " PASSWORD
+ echo ""
+
+ if [ "${PASSWORD}" == "" ]; then
+ change_setting "WEBPASSWORD" ""
+ echo "Password Removed"
+ exit 0
+ fi
+
+ read -s -p "Confirm Password: " CONFIRM
+ echo ""
+ fi
- read -s -p "Confirm Password: " CONFIRM
- echo ""
if [ "${PASSWORD}" == "${CONFIRM}" ] ; then
- # Compute password hash twice to avoid rainbow table vulnerability
- hash=$(echo -n ${PASSWORD} | sha256sum | sed 's/\s.*$//')
- hash=$(echo -n ${hash} | sha256sum | sed 's/\s.*$//')
+ hash=$(HashPassword ${PASSWORD})
# Save hash to file
change_setting "WEBPASSWORD" "${hash}"
echo "New password set"