From b09c4a7b7deecfee90576c131dcf3e676b3891d1 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 29 Oct 2019 10:36:41 +0100 Subject: [SSPS] Mitm Buschmesser durch! (remove unused code) --- satellit_installer/includes/10-password_helper.inc | 25 +++++++ satellit_installer/includes/10-purge_install.inc | 46 ------------ satellit_installer/includes/10-query_user.inc | 86 ---------------------- .../includes/90-patch_misc_files.inc | 6 ++ satellit_installer/satellit_installer | 17 +---- 5 files changed, 35 insertions(+), 145 deletions(-) create mode 100644 satellit_installer/includes/10-password_helper.inc delete mode 100644 satellit_installer/includes/10-purge_install.inc delete mode 100644 satellit_installer/includes/10-query_user.inc diff --git a/satellit_installer/includes/10-password_helper.inc b/satellit_installer/includes/10-password_helper.inc new file mode 100644 index 0000000..30eece9 --- /dev/null +++ b/satellit_installer/includes/10-password_helper.inc @@ -0,0 +1,25 @@ + +generate_password() { + local password="$(< /dev/urandom tr -dc A-Za-z0-9_ | head -c${1:-16};)" + echo "$password" +} + +# This routine has to be used only in conjunction with the prepare_firstrun-script, which +# will enforce the setting of good passwords on first root login after server start. +set_passwords() { + echo -n "# Setting passwords..." + OPENSLX_PASS="$(generate_password)" + MYSQL_ROOT_PASS="$(generate_password)" + MYSQL_OPENSLX_PASS="$(generate_password)" + MYSQL_SAT_PASS="$(generate_password)" + + # Keep in mind the passwords stored here will be valid only temporary, + # as they will be changed by the dropper script. + # If you need the permanently valid password, you will need to + # decrypt static_files/new_passwords.encrypted. + echo "OPENSLX_PASS=$OPENSLX_PASS" > "$CONFIGDIR"/config + echo "MYSQL_ROOT_PASS=$MYSQL_ROOT_PASS" >> "$CONFIGDIR"/config + echo "MYSQL_OPENSLX_PASS=$MYSQL_OPENSLX_PASS" >> "$CONFIGDIR"/config + echo "MYSQL_SAT_PASS=$MYSQL_SAT_PASS" >> "$CONFIGDIR"/config + echo "ok." +} diff --git a/satellit_installer/includes/10-purge_install.inc b/satellit_installer/includes/10-purge_install.inc deleted file mode 100644 index 0dbdbb6..0000000 --- a/satellit_installer/includes/10-purge_install.inc +++ /dev/null @@ -1,46 +0,0 @@ -read_password() { - MYSQL_ROOT_PASS="$(grep MYSQL_ROOT_PASS "$CONFIGDIR/config"|cut -f 2 -d "=")" 2>/dev/null - MYSQL_ROOT_PASS_OLD="$(grep MYSQL_ROOT_PASS "$CONFIGDIR/config.prerun" | cut -f 2 -d "=")" 2>/dev/null -} - -purge_install() { - echo "# Purging install (This is only to be used within development!)..." - echo "# Purging installed packages..." - uninstall_packages "$PACKAGELIST_SERVER" - uninstall_packages "$PACKAGELIST_SCRIPT" - -# read_password -# echo "# Deleting mysql databases openslx and sat..." -# for db in openslx sat; do -# mysql_delete_db "$db" "$MYSQL_ROOT_PASS" -# if [ "$ERR" -ne 0 ]; then -# echo -n "# Retrying: " -# mysql_delete_db "$user" "$MYSQL_ROOT_PASS_OLD" -# if [ "$ERR" -ne 0 ]; then -# KILLALL=true -# fi -# fi -# done -# -# echo "# Deleting mysql users openslx and sat..." -# for user in openslx sat; do -# mysql_delete_user "$user" "$MYSQL_ROOT_PASS" -# if [ "$ERR" -ne 0 ]; then -# echo -n "# Retrying: " -# mysql_delete_user "$user" "$MYSQL_ROOT_PASS_OLD" -# if [ "$ERR" -ne 0 ]; then -# KILLALL=true -# fi -# fi -# done - -# # Brutalinski user and database dropping: -# if [ "$KILLALL" == "true" ]; then - echo "#" - echo "# Killing databases by force." - echo "#" - rm -rf /var/lib/mysql 2>/dev/null -# fi - - killall mysqld 2>/dev/null 1>&2 -} diff --git a/satellit_installer/includes/10-query_user.inc b/satellit_installer/includes/10-query_user.inc deleted file mode 100644 index 3cad8ad..0000000 --- a/satellit_installer/includes/10-query_user.inc +++ /dev/null @@ -1,86 +0,0 @@ -query_single_password() { - ANSWER_OK=false - while [ "$ANSWER_OK" != "true" ]; do - read -s -p "# Please enter password (Note: Password will not be shown): " PASS1 - echo - read -s -p "# Please enter password again: " PASS2 - echo - if [[ "$PASS1" == "$PASS2" && "$PASS1" != "" ]]; then - ANSWER_OK=true - else - echo "# Password mismatch or password empty!" - echo "#" - fi - echo "#" - echo "# By the way, the cracklib password checker says: $(echo "$PASS1" | cracklib-check | cut -f 2- -d " ")." - done - -} - -query_passwords() { - ANSWER_OK=n - while [ "$ANSWER_OK" != "y" ]; do - echo "#" - echo "# Please enter appropriate passwords." - echo "#" - echo "# We will setup an user called 'openslx', so we need a password." - echo "# This user is just a non-root system user for menial tasks." - query_single_password - OPENSLX_PASS="$PASS1" - echo "#" - echo "# We do also need a password for mysql's root user." - echo "# This user will be needed for database installation etc, but not for daily work." - query_single_password - MYSQL_ROOT_PASS="$PASS1" - echo "#" - echo '# We will setup a mysql user "openslx", so we need another password.' - echo "# This is the database user for the satellite configuration admin interface." - query_single_password - MYSQL_OPENSLX_PASS="$PASS1" - echo "#" - echo "# Now, on to the needed mysql user 'sat' - you guessed it; we need a password." - echo "# This user will be the work horse for the bwLehrpool Suite database." - query_single_password - MYSQL_SAT_PASS="$PASS1" - echo "#" - echo -n "# Everything in order? Please press 'y' to continue; any other key to re-enter passwords: " - read -p "" -n1 -s ANSWER_OK - echo "$ANSWER_OK" - done - # Activate this only for debugging purposes... - # echo "OPENSLX_PASS=$OPENSLX_PASS" >> "$CONFIGDIR"/config - # echo "MYSQL_ROOT_PASS=$MYSQL_ROOT_PASS" >> "$CONFIGDIR"/config - # echo "MYSQL_OPENSLX_PASS=$MYSQL_OPENSLX_PASS" >> "$CONFIGDIR"/config - # echo "MYSQL_SAT_PASS=$MYSQL_SAT_PASS" >> "$CONFIGDIR"/config -} - -generate_password() { - local password="$(< /dev/urandom tr -dc A-Za-z0-9_ | head -c${1:-16};)" - echo "$password" -} - -# This routine has to be used only in conjunction with the prepare_firstrun-script, which -# will enforce the setting of good passwords on first root login after server start. -set_passwords() { - echo -n "# Setting passwords..." - OPENSLX_PASS="$(generate_password)" - MYSQL_ROOT_PASS="$(generate_password)" - MYSQL_OPENSLX_PASS="$(generate_password)" - MYSQL_SAT_PASS="$(generate_password)" - - # Keep in mind the passwords stored here will be valid only temporary, - # as they will be changed by the dropper script. - # If you need the permanently valid password, you will need to - # decrypt static_files/new_passwords.encrypted. - echo "OPENSLX_PASS=$OPENSLX_PASS" > "$CONFIGDIR"/config - echo "MYSQL_ROOT_PASS=$MYSQL_ROOT_PASS" >> "$CONFIGDIR"/config - echo "MYSQL_OPENSLX_PASS=$MYSQL_OPENSLX_PASS" >> "$CONFIGDIR"/config - echo "MYSQL_SAT_PASS=$MYSQL_SAT_PASS" >> "$CONFIGDIR"/config - echo "ok." -} - -set_version_string() { - echo -n "# Setting version string..." - echo 'VERSION="'$VERSION'"' >> "$CONFIGDIR"/config - echo "ok." -} diff --git a/satellit_installer/includes/90-patch_misc_files.inc b/satellit_installer/includes/90-patch_misc_files.inc index bbb3895..45c220f 100644 --- a/satellit_installer/includes/90-patch_misc_files.inc +++ b/satellit_installer/includes/90-patch_misc_files.inc @@ -39,3 +39,9 @@ patch_java() { # java.awt.AWTError: Assistive Technology not found: org.GNOME.Accessibility.AtkWrapper sed -i -e '/^assistive_technologies=/s/^/#/' /etc/java-*-openjdk/accessibility.properties &> /dev/null } + +set_version_string() { + echo -n "# Setting version string..." + echo 'VERSION="'$VERSION'"' >> "$CONFIGDIR"/config + echo "ok." +} diff --git a/satellit_installer/satellit_installer b/satellit_installer/satellit_installer index 5704678..d0cd876 100755 --- a/satellit_installer/satellit_installer +++ b/satellit_installer/satellit_installer @@ -3,22 +3,13 @@ # set -x # This script tries to install a bwLehrpool satellite server in a (hopefully) -# automatic fashion. It is only verified to work on a Debian 8.x distribution. +# automatic fashion. It is only verified to work on the current Debian release. # While it may work on any recent Debian-derived distribution using systemd # this is not guaranteed in any way. # -# If there were any errors in running this script do the following steps to -# re-install: -# 1. Un-outcomment the call to purge_install near the end of this script. -# 2. re-run the script; ignore any errors like "ERROR 1045 (28000): Access -# denied for user 'root'@'localhost'". This is caused by mysql root password -# mismatch; it will vanish on the second run. purge_install will uninstall -# the packages given in PACKAGELIST_SERVER _and_ purge their configuration. -# 3. re-run the script again; then the mysql root password will be set to the -# queried password entry. Then the mysql databases and users will be deleted. -# 4. Out-comment the call to purge_install and run the script again for a clean -# install. -# This cumbersome way will be remedied in the future. +# This installer is destructive and not idempotent. Only run on a clean Debian +# install. Take a snapshot/backup before applying this, so you can start +# over in case of failure. [ -z "$1" ] && exec $(readlink -f "$0 --help") -- cgit v1.2.3-55-g7522