From 5ef3c5f9538acd753b2b6715c8fc4a4f0e083254 Mon Sep 17 00:00:00 2001 From: Bob Mottram <bob@freedombone.net> Date: Thu, 5 Jul 2018 21:36:53 +0100 Subject: [PATCH] Restart prosody after sending notification --- src/freedombone-app-xmpp | 28 +++++++++++++++++----------- src/freedombone-notification | 1 + 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/freedombone-app-xmpp b/src/freedombone-app-xmpp index 5b88308c6..05d1113dd 100755 --- a/src/freedombone-app-xmpp +++ b/src/freedombone-app-xmpp @@ -94,15 +94,20 @@ function xmpp_update_e2e_policy { sed -i 's|e2e_policy_muc.*|e2e_policy_muc = "none"|g' "$filename" fi if ! grep -q "e2e_policy_chat" "$filename"; then - echo "e2e_policy_chat = \"required\"" >> "$filename" + echo "e2e_policy_chat = \"optional\"" >> "$filename" else - sed -i 's|e2e_policy_chat.*|e2e_policy_chat = "required"|g' "$filename" + sed -i 's|e2e_policy_chat.*|e2e_policy_chat = "optional"|g' "$filename" fi if ! grep -q "e2e_policy_message_required_chat" "$filename"; then echo "e2e_policy_message_required_chat = \"$xmpp_encryption_warning\"" >> "$filename" else sed -i "s|e2e_policy_message_required_chat.*|e2e_policy_message_required_chat = \"$xmpp_encryption_warning\"|g" "$filename" fi + if ! grep -q "e2e_policy_whitelist" "$filename"; then + echo "e2e_policy_whitelist = { \"notification@$HOSTNAME\" };" >> "$filename" + else + sed -i "s|e2e_policy_whitelist.*|e2e_policy_whitelist = { \"notification@$HOSTNAME\" };|g" "$filename" + fi if [[ "$ONION_ONLY" != 'no' ]]; then XMPP_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_xmpp/hostname) @@ -897,12 +902,13 @@ function xmpp_create_config { { echo '}'; echo ''; - echo 'c2s_require_encryption = true'; - echo 's2s_require_encryption = true'; + echo 'c2s_require_encryption = false'; + echo 's2s_require_encryption = false'; echo ''; echo 'e2e_policy_muc = "none"'; - echo 'e2e_policy_chat = "required"'; + echo 'e2e_policy_chat = "optional"'; echo "e2e_policy_message_required_chat = \"$xmpp_encryption_warning\""; + echo "e2e_policy_whitelist = { \"notification@${HOSTNAME}\" };"; echo ''; echo 's2s_secure_auth = false'; echo ''; @@ -1145,14 +1151,14 @@ function install_xmpp { fi echo '' >> /etc/prosody/conf.avail/xmpp.cfg.lua if ! grep -q "c2s_require_encryption" /etc/prosody/conf.avail/xmpp.cfg.lua; then - echo 'c2s_require_encryption = true' >> /etc/prosody/conf.avail/xmpp.cfg.lua + echo 'c2s_require_encryption = false' >> /etc/prosody/conf.avail/xmpp.cfg.lua else - sed -i 's|c2s_require_encryption.*|c2s_require_encryption = true|g' /etc/prosody/conf.avail/xmpp.cfg.lua + sed -i 's|c2s_require_encryption.*|c2s_require_encryption = false|g' /etc/prosody/conf.avail/xmpp.cfg.lua fi if ! grep -q "s2s_require_encryption" /etc/prosody/conf.avail/xmpp.cfg.lua; then - echo 's2s_require_encryption = true' >> /etc/prosody/conf.avail/xmpp.cfg.lua + echo 's2s_require_encryption = false' >> /etc/prosody/conf.avail/xmpp.cfg.lua else - sed -i 's|s2s_require_encryption.*|s2s_require_encryption = true|g' /etc/prosody/conf.avail/xmpp.cfg.lua + sed -i 's|s2s_require_encryption.*|s2s_require_encryption = false|g' /etc/prosody/conf.avail/xmpp.cfg.lua fi if [[ "$ONION_ONLY" != 'no' ]]; then @@ -1163,9 +1169,9 @@ function install_xmpp { xmpp_update_e2e_policy /etc/prosody/conf.avail/xmpp.cfg.lua if ! grep -q "allow_unencrypted_plain_auth" /etc/prosody/conf.avail/xmpp.cfg.lua; then - echo 'allow_unencrypted_plain_auth = false' >> /etc/prosody/conf.avail/xmpp.cfg.lua + echo 'allow_unencrypted_plain_auth = true' >> /etc/prosody/conf.avail/xmpp.cfg.lua else - sed -i 's|allow_unencrypted_plain_auth.*|allow_unencrypted_plain_auth = false|g' /etc/prosody/conf.avail/xmpp.cfg.lua + sed -i 's|allow_unencrypted_plain_auth.*|allow_unencrypted_plain_auth = true|g' /etc/prosody/conf.avail/xmpp.cfg.lua fi ln -sf /etc/prosody/conf.avail/xmpp.cfg.lua /etc/prosody/conf.d/xmpp.cfg.lua diff --git a/src/freedombone-notification b/src/freedombone-notification index eae1dddcd..5d3cb9dba 100755 --- a/src/freedombone-notification +++ b/src/freedombone-notification @@ -105,6 +105,7 @@ if [ -d /etc/prosody ]; then chmod +x /tmp/xsend echo "$MESSAGE" | python2 /tmp/xsend "$ADMIN_EMAIL_ADDRESS" + systemctl restart prosody rm /tmp/xsend fi prosodyctl deluser "notification@$HOSTNAME" -- GitLab