diff --git a/README.md b/README.md index d45c270..d340dd2 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,10 @@ Nested container test drive * CONTAINER=nested * lxc-miaou-create $CONTAINER -o sameuser,nesting * lxc sameuser $CONTAINER +* # EITHER: * /opt/miaou/lib/install.sh dev + * # OR + * EMAIL= /opt/miaou/lib/install.sh dev Hardening server ---------------- diff --git a/lib/functions.sh b/lib/functions.sh index 25b4b61..ecf5c64 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -641,6 +641,7 @@ function prepare_toolbox() { function install_mandatory_commands() { local PREFIX="mandatory:commands" + echo "installing various mandatory commands" sudo /opt/miaou-bash/tools/idem_apt_install dnsutils build-essential curl mariadb-client postgresql-client if ! exist_command tera; then diff --git a/lib/harden.sh b/lib/harden.sh index 9b524bf..ee57ada 100755 --- a/lib/harden.sh +++ b/lib/harden.sh @@ -217,7 +217,7 @@ function disable_systemd_resolved() { sudo systemctl stop systemd-resolved.service sudo systemctl disable systemd-resolved.service sudo rm /etc/resolv.conf - cat </dev/null </dev/null; then @@ -178,14 +180,14 @@ EOF echo -n "set environment container_hostname to <$env_container_hostname> ... " sg $NEW_GROUP -c "lxc profile set default environment.container_hostname \"$env_container_hostname\"" - PREFIX="" echoinfo OK + PREFIX="" echoinfo DONE else echo "environment container_hostname <$env_container_hostname> already defined!" fi if ! grep -q "root:$(id -u):1" /etc/subuid; then - echo -n "subuid, subgid allowing <$(whoami)> ..." - printf "root:$(id -u):1\n" | sudo tee -a /etc/subuid /etc/subgid + echo -n "saving subuid, subgid permissions for <$(whoami)> ..." + printf "root:$(id -u):1\n" | sudo tee -a /etc/subuid /etc/subgid &>/dev/null PREFIX="" echoinfo DONE else echo "subuid, subgid allowing <$(whoami)> already done!" @@ -215,7 +217,7 @@ function set_alias { if ! lxc alias list -f csv | grep -q "^$name,"; then echo -n "defining new lxc alias <$name> ..." lxc alias add "$name" "$command" - PREFIX="" echoinfo OK + PREFIX="" echoinfo DONE else echo "lxc alias <$name> already defined!" fi @@ -226,7 +228,7 @@ function miaou_evalfrombashrc() { local PREFIX="miaou:bashrc" output=$( /opt/miaou-bash/tools/append_or_replace \ - "^eval \"\\$\($MIAOU_BASEDIR/lib/install.sh shellenv\)\"$" \ + "^eval \"\\$\(.*miaou/lib/install.sh shellenv\)\"$" \ "eval \"\$($MIAOU_BASEDIR/lib/install.sh shellenv)\"" \ "$HOME/.bashrc" ) @@ -353,12 +355,13 @@ function miaou_resolver() { fi else if ! grep -q "nameserver $bridge" /etc/resolv.conf; then - echo "customize resolv.conf from scratch (SERVER)..." + echo -n "customize resolv.conf from scratch with bridge=<$bridge>, gatewary=<$gateway> ..." sudo tee /etc/resolv.conf &>/dev/null </dev/null <" + resolver=$(grep nameserver /etc/resolv.conf | tail -n1 | cut -d ' ' -f2) PREFIX="resolver:check" echo "container resolver is <$resolver>" - PREFIX="resolver:check" echo "container bridge is <$bridge_gw>" + [[ "$bridge_gw" != "$resolver" ]] && return 21 return 0 }