Hi,
New user here, many months reading, first time posting (actually just made an account).
I'm using an Asus RT-AC68U HW rev. A1 router using firmware AsusWRT-Merlin 384.14_beta1 with AMTM, Diversion, Skynet, uiDivStats and uiScribe scripts, all installed from amtm. Thank you to all of the coders whose code I've been using!
After installing Diversion, I've configured its email settings for it to be able to send notifications and the file backups. I've used a gmail account, but hit a few problems along the way (one of which was to
enable Less secure app access in the gmail account settings).
The other however was that I am using a password with many non alphanumeric characters in it, one of them being $ . However, this is a special character in the linux shell, thus the password did not get stored correctly (it only stored the password up to this character). After escaping the character with \ , it worked. But this still bothered me, along with the message that the character " cannot be used, but it should with the same method of escaping the character.
I've then started to check which other non alphanumeric characters should be escaped (from the 32 ones easily accessible with an US style keyboard) and proceeded to modify the script to escape the characters by itself. The result is that the password is stored with the special characters escaped and also works in sending the emails. I've then decided to share it here, so here we go:
This is the file that should be edited:
Code:
/opt/share/diversion/file/functions.div
1. Add a new procedure (it doesn't really matter where as long as it's between
#BOF and
#EOF and not wihin another procedure or the main procedure itself; a good place would be to add it before the first procedure, which for the current 4.1.6 version is
au_function() at line 63):
Code:
escape_password_special_characters(){
i=0
PASSWORD=
while [ $i -lt `expr length "$value"` ]
do
case ${value:$i:1} in
[\`\'\$\\\"])
PASSWORD="$PASSWORD\\"
;;
%)
PASSWORD="$PASSWORD%"
;;
esac
PASSWORD="$PASSWORD${value:$i:1}"
i=`expr $i + 1`
done
}
2. Modify line where the password is read directly in the
PASSWORD variable by reading it in the
value variable and calling the newly created procedure, from:
Code:
printf "\\n${RED_BG} Enter Password: ${NC} ";read -r PASSWORD
to
Code:
printf "\\n${RED_BG} Enter Password: ${NC} ";read -r value;escape_password_special_characters
3. Modify lines where the password is stored in the
PASSWORD variable by calling the newly created procedure, from:
Code:
6) printf "\\n Note: Password may NOT contain \" character.\\n"
printf "\\n $PASSWORD${RED} <-- current password${NC}\\n"
printf "${RED_BG} Enter Password: ${NC} [e=Exit] ";read -r value
PASSWORD=$value;break;;
to
Code:
6) printf "\\n $PASSWORD${RED} <-- current password${NC}\\n"
printf "${RED_BG} Enter Password: ${NC} [e=Exit] ";read -r value
escape_password_special_characters;break;;
Save the changes made to the file and this should be it until a reinstall or upgrade of Diversion which will overwrite the file.
Maybe
@thelonelycoder could add something similar in the next releases if he sees value in it or maybe not if there's something wrong in doing this that I'm not seeing.