Changing app passwords

This commit is contained in:
Bob Mottram 2016-11-20 12:37:13 +00:00
parent 0147cadc53
commit b4971017c2
24 changed files with 139 additions and 113 deletions

View File

@ -41,10 +41,6 @@ function install_interactive_batman {
APP_INSTALLED=1 APP_INSTALLED=1
} }
function change_password_batman {
echo -n ''
}
function configure_firewall_for_batman { function configure_firewall_for_batman {
if [[ $(is_completed $FUNCNAME) == "1" ]]; then if [[ $(is_completed $FUNCNAME) == "1" ]]; then
return return

View File

@ -66,10 +66,6 @@ function install_interactive_dlna {
APP_INSTALLED=1 APP_INSTALLED=1
} }
function change_password_dlna {
echo -n ''
}
function reconfigure_dlna { function reconfigure_dlna {
echo '' echo ''
} }

View File

@ -61,7 +61,8 @@ function install_interactive_dokuwiki {
} }
function change_password_dokuwiki { function change_password_dokuwiki {
${PROJECT_NAME}-pass -u $1 -a dokuwiki -p "$2" echo -n ''
#${PROJECT_NAME}-pass -u $1 -a dokuwiki -p "$2"
} }
function reconfigure_dokuwiki { function reconfigure_dokuwiki {

View File

@ -106,15 +106,13 @@ function install_interactive_ghost {
} }
function change_password_ghost { function change_password_ghost {
set_completion_param "ghost domain" "$GHOST_DOMAIN_NAME"
GHOST_DOMAIN_NAME=$(get_completion_param "ghost domain")
GHOST_USERNAME="$1" GHOST_USERNAME="$1"
GHOST_PASSWORD="$2" GHOST_PASSWORD="$2"
if [ ${#GHOST_PASSWORD} -lt 8 ]; then if [ ${#GHOST_PASSWORD} -lt 8 ]; then
echo $'Ghost password is too short' echo $'Ghost password is too short'
return return
fi fi
#${PROJECT_NAME}-pass -u $GHOST_USERNAME -a ghost -p "$GHOST_PASSWORD"
} }
function reconfigure_ghost { function reconfigure_ghost {

View File

@ -189,7 +189,15 @@ function install_interactive_gnusocial {
} }
function change_password_gnusocial { function change_password_gnusocial {
${PROJECT_NAME}-pass -u $1 -a gnusocial -p "$2" curr_username="$1"
new_user_password="$2"
read_config_param ${GNUSOCIAL_DOMAIN_NAME}
cd /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs
./scripts/setpassword "$curr_username" "$new_user_password"
${PROJECT_NAME}-pass -u "$curr_username" -a gnusocial -p "$new_user_password"
} }
function gnusocial_create_database { function gnusocial_create_database {

View File

@ -53,6 +53,11 @@ gogs_variables=(ONION_ONLY
DDNS_PROVIDER DDNS_PROVIDER
ARCHITECTURE) ARCHITECTURE)
function change_password_gogs {
curr_username="$1"
new_user_password="$2"
}
function install_interactive_gogs { function install_interactive_gogs {
if [[ $ONION_ONLY != "no" ]]; then if [[ $ONION_ONLY != "no" ]]; then
GIT_DOMAIN_NAME='gogs.local' GIT_DOMAIN_NAME='gogs.local'
@ -84,10 +89,6 @@ function configure_interactive_gogs {
systemctl restart gogs systemctl restart gogs
} }
function change_password_gogs {
echo -n ''
}
function gogs_parameters { function gogs_parameters {
if [[ ${ARCHITECTURE} == *"386" || ${ARCHITECTURE} == *"686" ]]; then if [[ ${ARCHITECTURE} == *"386" || ${ARCHITECTURE} == *"686" ]]; then
CURR_ARCH=386 CURR_ARCH=386

View File

@ -179,7 +179,7 @@ function change_password_htmly {
echo $'Htmly password is too short' echo $'Htmly password is too short'
return return
fi fi
${PROJECT_NAME}-pass -u $HTMLY_USERNAME -a htmly -p "$HTMLY_PASSWORD" ${PROJECT_NAME}-pass -u "$HTMLY_USERNAME" -a htmly -p "$HTMLY_PASSWORD"
HTMLY_PASSWORD_HASH=$(${PROJECT_NAME}-sec --htmlyhash "$HTMLY_PASSWORD") HTMLY_PASSWORD_HASH=$(${PROJECT_NAME}-sec --htmlyhash "$HTMLY_PASSWORD")
if [ ${#HTMLY_PASSWORD_HASH} -lt 8 ]; then if [ ${#HTMLY_PASSWORD_HASH} -lt 8 ]; then
echo $'Htmly admin password could not be hashed' echo $'Htmly admin password could not be hashed'

View File

@ -167,7 +167,14 @@ function install_interactive_hubzilla {
} }
function change_password_hubzilla { function change_password_hubzilla {
${PROJECT_NAME}-pass -u $1 -a hubzilla -p "$2" HUBZILLA_USERNAME="$1"
HUBZILLA_PASSWORD="$2"
if [ ${#HUBZILLA_PASSWORD} -lt 8 ]; then
echo $'Hubzilla password is too short'
return
fi
# TODO: This doesn't actually change the password
#${PROJECT_NAME}-pass -u $HUBZILLA_USERNAME -a hubzilla -p "$HUBZILLA_PASSWORD"
} }
function hubzilla_create_database { function hubzilla_create_database {

View File

@ -53,10 +53,6 @@ function install_interactive_ipfs {
APP_INSTALLED=1 APP_INSTALLED=1
} }
function change_password_ipfs {
echo -n ''
}
function reconfigure_ipfs { function reconfigure_ipfs {
echo -n '' echo -n ''
} }

View File

@ -172,6 +172,73 @@ function remove_user_irc {
fi fi
} }
function irc_get_global_password {
echo $(cat /etc/ngircd/ngircd.conf | grep "Password =" | head -n 1 | awk -F '=' '{print $2}')
}
function irc_set_global_password_base {
NEW_IRC_PASSWORD="$1"
EXISTING_IRC_PASSWORD=$(irc_get_global_password)
sed -i "0,/RE/s/Password =.*/Password =$NEW_IRC_PASSWORD/" /etc/ngircd/ngircd.conf
# replace the password for all users
for d in /home/*/ ; do
IRC_USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $(is_valid_user "$IRC_USERNAME") == "1" ]]; then
if [ -f /home/${IRC_USERNAME}/.irssi/config ]; then
sed -i "s|$EXISTING_IRC_PASSWORD|$NEW_IRC_PASSWORD|g" /home/${IRC_USERNAME}/.irssi/config
chown -R ${IRC_USERNAME}:${IRC_USERNAME} /home/${IRC_USERNAME}/.irssi
fi
fi
done
read_config_param DEFAULT_DOMAIN_NAME
read_config_param IRC_PORT
read_config_param MY_USERNAME
stop_irc_bouncer
sleep 2
# change the hashes. There are multiple users, but since we're using a global
# password this doesn't matter
ZNC_SALT="$(dd if=/dev/urandom bs=16c count=1 | md5sum | awk -F ' ' '{print $1}' | cut -c1-20)"
new_user_hash=$(echo -n "${NEW_IRC_PASSWORD}${ZNC_SALT}" | sha256sum | awk -F ' ' '{print $1}')
sed -i "s|Hash = .*|Hash = ${new_user_hash}|g" /home/znc/.znc/configs/znc.conf
sed -i "s|Salt = .*|Salt = ${ZNC_SALT}|g" /home/znc/.znc/configs/znc.conf
# change the server password
sed -i "s|Server = 127.0.0.1.*|Server = 127.0.0.1 ${IRC_PORT} ${NEW_IRC_PASSWORD}|g" /home/znc/.znc/configs/znc.conf
# Update the password
${PROJECT_NAME}-pass -u $MY_USERNAME -a irc -p "$NEW_IRC_PASSWORD"
# matrix bridge to irc
if [ -f $INSTALL_DIR/matrix_irc_bridge/config.yaml ]; then
sed -i "s|password: .*|password: \"$NEW_IRC_PASSWORD\"|g" $INSTALL_DIR/matrix_irc_bridge/config.yaml
systemctl restart matrix_irc_bridge
fi
write_config_param "IRC_PASSWORD" "$NEW_IRC_PASSWORD"
# restart the daemon for the new password to take effect
systemctl restart ngircd
start_irc_bouncer
}
function change_password_irc {
new_global_password="$2"
# Change the password for all users
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
${PROJECT_NAME}-pass -u "$USERNAME" -a irc -p "$new_global_password"
fi
done
irc_set_global_password_base "$new_global_password"
}
function add_user_irc_bouncer { function add_user_irc_bouncer {
new_username="$1" new_username="$1"
new_user_password="$2" new_user_password="$2"
@ -180,12 +247,13 @@ function add_user_irc_bouncer {
is_admin='false' is_admin='false'
fi fi
${PROJECT_NAME}-pass -u $new_username -a irc -p "$new_user_password"
if [[ $(is_valid_user "$new_username") == "0" ]]; then if [[ $(is_valid_user "$new_username") == "0" ]]; then
return return
fi fi
${PROJECT_NAME}-pass -u $new_username -a irc -p "$new_user_password"
read_config_param IRC_PORT read_config_param IRC_PORT
read_config_param DEFAULT_DOMAIN_NAME read_config_param DEFAULT_DOMAIN_NAME
if [ ! $2 ]; then if [ ! $2 ]; then
@ -284,7 +352,7 @@ function add_user_irc {
new_username="$1" new_username="$1"
new_user_password="$2" new_user_password="$2"
IRC_PASSWORD=$(cat /etc/ngircd/ngircd.conf | grep "Password =" | head -n 1 | awk -F '=' '{print $2}') IRC_PASSWORD=$(irc_get_global_password)
if [ ${#IRC_PASSWORD} -lt 2 ]; then if [ ${#IRC_PASSWORD} -lt 2 ]; then
IRC_PASSWORD= IRC_PASSWORD=
fi fi
@ -303,66 +371,22 @@ function run_client_irc {
} }
function irc_show_password { function irc_show_password {
IRC_PASSWORD=$(cat /etc/ngircd/ngircd.conf | grep "Password =" | head -n 1 | awk -F '=' '{print $2}') IRC_PASSWORD=$(irc_get_global_password)
dialog --title $"IRC Password" \ dialog --title $"IRC Password" \
--msgbox "$IRC_PASSWORD" 6 40 --msgbox "$IRC_PASSWORD" 6 40
} }
function irc_set_global_password { function irc_set_global_password {
EXISTING_IRC_PASSWORD=$(irc_get_global_password)
dialog --title $"IRC Password" \ dialog --title $"IRC Password" \
--clear \ --clear \
--backtitle $"Freedombone Control Panel" \ --backtitle $"Freedombone Control Panel" \
--passwordbox $"Password for all IRC users, or press Enter for no password" 10 60 2> $data --passwordbox $"Password for all IRC users, or press Enter for no password" 10 60 "$EXISTING_IRC_PASSWORD" 2> $data
sel=$? sel=$?
case $sel in case $sel in
0) 0)
EXISTING_IRC_PASSWORD=$(cat /etc/ngircd/ngircd.conf | grep "Password =" | head -n 1 | awk -F '=' '{print $2}')
NEW_IRC_PASSWORD=$(<$data) NEW_IRC_PASSWORD=$(<$data)
sed -i "0,/RE/s/Password =.*/Password =$NEW_IRC_PASSWORD/" /etc/ngircd/ngircd.conf irc_set_global_password_base "$NEW_IRC_PASSWORD"
# replace the password for all users
for d in /home/*/ ; do
IRC_USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $(is_valid_user "$IRC_USERNAME") == "1" ]]; then
if [ -f /home/${IRC_USERNAME}/.irssi/config ]; then
sed -i "s|$EXISTING_IRC_PASSWORD|$NEW_IRC_PASSWORD|g" /home/${IRC_USERNAME}/.irssi/config
chown -R ${IRC_USERNAME}:${IRC_USERNAME} /home/${IRC_USERNAME}/.irssi
fi
fi
done
read_config_param DEFAULT_DOMAIN_NAME
read_config_param IRC_PORT
read_config_param MY_USERNAME
stop_irc_bouncer
sleep 2
# change the hashes. There are multiple users, but since we're using a global
# password this doesn't matter
ZNC_SALT="$(dd if=/dev/urandom bs=16c count=1 | md5sum | awk -F ' ' '{print $1}' | cut -c1-20)"
new_user_hash=$(echo -n "${NEW_IRC_PASSWORD}${ZNC_SALT}" | sha256sum | awk -F ' ' '{print $1}')
sed -i "s|Hash = .*|Hash = ${new_user_hash}|g" /home/znc/.znc/configs/znc.conf
sed -i "s|Salt = .*|Salt = ${ZNC_SALT}|g" /home/znc/.znc/configs/znc.conf
# change the server password
sed -i "s|Server = 127.0.0.1.*|Server = 127.0.0.1 ${IRC_PORT} ${NEW_IRC_PASSWORD}|g" /home/znc/.znc/configs/znc.conf
# Update the password
${PROJECT_NAME}-pass -u $MY_USERNAME -a irc -p "$NEW_IRC_PASSWORD"
if [ -f $INSTALL_DIR/matrix_irc_bridge/config.yaml ]; then
sed -i "s|password: .*|password: \"$NEW_IRC_PASSWORD\"|g" $INSTALL_DIR/matrix_irc_bridge/config.yaml
systemctl restart matrix_irc_bridge
fi
write_config_param "IRC_PASSWORD" "$NEW_IRC_PASSWORD"
# restart the daemon for the new password to take effect
systemctl restart ngircd
start_irc_bouncer
dialog --title $"IRC Password" \ dialog --title $"IRC Password" \
--msgbox $"The IRC password was changed" 6 40 --msgbox $"The IRC password was changed" 6 40
;; ;;

View File

@ -73,10 +73,6 @@ function jitsi_disable_google_spyware {
fi fi
} }
function change_password_jitsi {
echo -n ''
}
function can_install_videobridge { function can_install_videobridge {
check_architecture=$(uname -a) check_architecture=$(uname -a)
if [[ "$check_architecture" == *"amd64"* || "$check_architecture" == *"i386"* ]]; then if [[ "$check_architecture" == *"amd64"* || "$check_architecture" == *"i386"* ]]; then

View File

@ -50,10 +50,6 @@ function install_interactive_librevault {
APP_INSTALLED=1 APP_INSTALLED=1
} }
function change_password_librevault {
echo -n ''
}
function reconfigure_librevault { function reconfigure_librevault {
echo -n '' echo -n ''
# TODO # TODO

View File

@ -100,16 +100,14 @@ function install_interactive_lychee {
} }
function change_password_lychee { function change_password_lychee {
set_completion_param "lychee domain" "$LYCHEE_DOMAIN_NAME"
LYCHEE_DOMAIN_NAME=$(get_completion_param "lychee domain")
LYCHEE_USERNAME="$1" LYCHEE_USERNAME="$1"
LYCHEE_PASSWORD="$2" LYCHEE_PASSWORD="$2"
if [ ${#LYCHEE_PASSWORD} -lt 8 ]; then if [ ${#LYCHEE_PASSWORD} -lt 8 ]; then
echo $'Lychee password is too short' echo $'Lychee password is too short'
return return
fi fi
${PROJECT_NAME}-pass -u $LYCHEE_USERNAME -a lychee -p "$LYCHEE_PASSWORD" # TODO: This doesn't actually change the password
#${PROJECT_NAME}-pass -u $LYCHEE_USERNAME -a lychee -p "$LYCHEE_PASSWORD"
} }
function reconfigure_lychee { function reconfigure_lychee {

View File

@ -73,7 +73,8 @@ function install_interactive_mailpile {
} }
function change_password_mailpile { function change_password_mailpile {
${PROJECT_NAME}-pass -u $1 -a mailpile -p "$2" echo -n ''
#${PROJECT_NAME}-pass -u $1 -a mailpile -p "$2"
} }
function reconfigure_mailpile { function reconfigure_mailpile {

View File

@ -54,7 +54,18 @@ function install_interactive_mumble {
} }
function change_password_mumble { function change_password_mumble {
${PROJECT_NAME}-pass -u $1 -a mumble -p "$2" new_mumble_password="$2"
# Change the password for all users
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
${PROJECT_NAME}-pass -u "$USERNAME" -a mumble -p "$new_mumble_password"
fi
done
sed -i "s|serverpassword=.*|serverpassword=$new_mumble_password|g" /etc/mumble-server.ini
systemctl restart mumble-server
} }
function reconfigure_mumble { function reconfigure_mumble {
@ -108,7 +119,7 @@ function restore_local_mumble {
cp /etc/ssl/certs/mumble* /var/lib/mumble-server cp /etc/ssl/certs/mumble* /var/lib/mumble-server
cp /etc/ssl/private/mumble* /var/lib/mumble-server cp /etc/ssl/private/mumble* /var/lib/mumble-server
chown -R mumble-server:mumble-server /var/lib/mumble-server chown -R mumble-server:mumble-server /var/lib/mumble-server
service mumble-server restart systemctl restart mumble-server
fi fi
} }
@ -150,7 +161,7 @@ function restore_remote_mumble {
cp /etc/ssl/certs/mumble* /var/lib/mumble-server cp /etc/ssl/certs/mumble* /var/lib/mumble-server
cp /etc/ssl/private/mumble* /var/lib/mumble-server cp /etc/ssl/private/mumble* /var/lib/mumble-server
chown -R mumble-server:mumble-server /var/lib/mumble-server chown -R mumble-server:mumble-server /var/lib/mumble-server
service mumble-server restart systemctl restart mumble-server
echo $"Restore of Mumble complete" echo $"Restore of Mumble complete"
fi fi
} }

View File

@ -49,10 +49,6 @@ function install_interactive_pelican {
APP_INSTALLED=1 APP_INSTALLED=1
} }
function change_password_pelican {
echo -n ''
}
function reconfigure_pelican { function reconfigure_pelican {
echo -n '' echo -n ''
} }

View File

@ -268,10 +268,6 @@ function install_interactive_pihole {
APP_INSTALLED=1 APP_INSTALLED=1
} }
function change_password_pihole {
echo -n ''
}
function reconfigure_pihole { function reconfigure_pihole {
echo -n '' echo -n ''
} }

View File

@ -146,7 +146,15 @@ function install_interactive_postactiv {
} }
function change_password_postactiv { function change_password_postactiv {
echo -n '' curr_username="$1"
new_user_password="$2"
read_config_param ${POSTACTIV_DOMAIN_NAME}
cd /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs
./scripts/setpassword "$curr_username" "$new_user_password"
${PROJECT_NAME}-pass -u "$curr_username" -a postactiv -p "$new_user_password"
} }
function postactiv_create_database { function postactiv_create_database {

View File

@ -60,7 +60,10 @@ function install_interactive_rss {
} }
function change_password_rss { function change_password_rss {
${PROJECT_NAME}-pass -u $1 -a rss -p "$2" curr_username="$1"
new_user_password="$2"
#${PROJECT_NAME}-pass -u "$curr_username" -a rss -p "$new_user_password"
} }
function rss_create_database { function rss_create_database {

View File

@ -97,7 +97,10 @@ function install_interactive_sip {
} }
function change_password_sip { function change_password_sip {
${PROJECT_NAME}-pass -u $1 -a sip -p "$2" curr_username="$1"
new_user_password="$2"
#${PROJECT_NAME}-pass -u "$curr_username" -a sip -p "$new_user_password"
} }
function reconfigure_sip { function reconfigure_sip {

View File

@ -212,7 +212,10 @@ function install_interactive_synapse {
} }
function change_password_synapse { function change_password_synapse {
${PROJECT_NAME}-pass -u $1 -a synapse -p "$2" curr_username="$1"
new_user_password="$2"
#${PROJECT_NAME}-pass -u "$curr_username" -a synapse -p "$new_user_password"
} }
function reconfigure_synapse { function reconfigure_synapse {

View File

@ -51,10 +51,6 @@ function install_interactive_tahoelafs {
APP_INSTALLED=1 APP_INSTALLED=1
} }
function change_password_tahoelafs {
echo -n ''
}
function reconfigure_tahoelafs { function reconfigure_tahoelafs {
for d in /home/*/ ; do for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}') USERNAME=$(echo "$d" | awk -F '/' '{print $3}')

View File

@ -37,10 +37,6 @@ function install_interactive_vpn {
APP_INSTALLED=1 APP_INSTALLED=1
} }
function change_password_vpn {
echo -n ''
}
function reconfigure_vpn { function reconfigure_vpn {
echo -n '' echo -n ''
} }

View File

@ -66,10 +66,6 @@ function install_interactive_zeronet {
APP_INSTALLED=1 APP_INSTALLED=1
} }
function change_password_zeronet {
echo -n ''
}
function reconfigure_zeronet { function reconfigure_zeronet {
echo -n '' echo -n ''
} }