on master help sign in
utils/morty.sh: set morty key to avoid service abuse

- https://github.com/asciimoo/searx/issues/1871#issuecomment-592459798 make install all generates random MORTY_KEY, install service with that key and sets option in the searx settingy.yml file. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>

commitea3255835a259516c7a8b62eb319a338cebf7e9f authorMarkus Heiser <markus.heiser@darmarit.de> dateTue 28 Apr 2020, 16:21 (6 years ago) parent26a3a7d
3 files changed+7−4
utils/morty.sh+4−1 utils/searx.sh+2−2 utils/templates/lib/systemd/system/morty.service+1−1
utils/morty.sh+4−1
@@ -208,6 +208,9 @@ main() {
208208}
209209
210210install_all() {
211+
212+ MORTY_KEY="$(head -c 32 /dev/urandom | base64)"
213+
211214 rst_title "Install $SERVICE_NAME (service)"
212215 assert_user
213216 wait_key
@@ -233,7 +236,7 @@ install_all() {
233236 fi
234237 info_searx
235238 if ask_yn "Add image and result proxy to searx settings.yml?" Yn; then
236− "${REPO_ROOT}/utils/searx.sh" option result-proxy "${PUBLIC_URL_MORTY}"
239+ "${REPO_ROOT}/utils/searx.sh" option result-proxy "${PUBLIC_URL_MORTY}" "${MORTY_KEY}"
237240 "${REPO_ROOT}/utils/searx.sh" option image-proxy-on
238241 fi
239242
utils/searx.sh+2−2
@@ -584,7 +584,7 @@ set_result_proxy() {
584584
585585 # usage: set_result_proxy <URL> [<key>]
586586
587− info_msg "try to set result proxy: $1"
587+ info_msg "try to set result proxy: '$1' ($2)"
588588 cp "${SEARX_SETTINGS_PATH}" "${SEARX_SETTINGS_PATH}.bak"
589589 _set_result_proxy "$1" "$2" > "${SEARX_SETTINGS_PATH}"
590590}
@@ -593,7 +593,7 @@ _set_result_proxy() {
593593 local line
594594 local stage=0
595595 local url=" url: $1"
596− local key=" key: $2"
596+ local key=" key: !!binary \"$2\""
597597 if [[ -z $2 ]]; then
598598 key=
599599 fi
utils/templates/lib/systemd/system/morty.service+1−1
@@ -10,7 +10,7 @@ Type=simple
1010User=${SERVICE_USER}
1111Group=${SERVICE_GROUP}
1212WorkingDirectory=${SERVICE_HOME}
13−ExecStart=${SERVICE_HOME}/go-apps/bin/morty -key '' -listen '${MORTY_LISTEN}' -timeout ${MORTY_TIMEOUT}
13+ExecStart=${SERVICE_HOME}/go-apps/bin/morty -key '${MORTY_KEY}' -listen '${MORTY_LISTEN}' -timeout ${MORTY_TIMEOUT}
1414
1515Restart=always
1616Environment=USER=${SERVICE_USER} HOME=${SERVICE_HOME} DEBUG=${SERVICE_ENV_DEBUG}