Tell sed to follow symlinks

This commit is contained in:
Jérémy Lecour 2022-03-22 15:33:00 +01:00 committed by Jérémy Lecour
parent 959077327a
commit 960dd97d68
6 changed files with 8 additions and 8 deletions

4
Vagrantfile vendored
View File

@ -28,8 +28,8 @@ DEBIAN_FRONTEND=noninteractive apt-get -yq install openssh-server btrfs-progs rs
SCRIPT
$pre_part = <<SCRIPT
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
sed -i -e 's/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' /etc/locale.gen && \
sed --follow-symlinks --in-place -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
sed --follow-symlinks --in-place -e 's/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' /etc/locale.gen && \
echo 'LANG="fr_FR.UTF-8"'>/etc/default/locale && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=fr_FR.UTF-8

View File

@ -25,7 +25,7 @@ iptables_input_accept() {
if [ -n "${FIREWALL_RULES}" ]; then
# remove existing rules for this jail
[ -f "${FIREWALL_RULES}" ] && sed -i "/#${jail_name}$/d" "${FIREWALL_RULES}"
[ -f "${FIREWALL_RULES}" ] && sed --follow-symlinks --in-place "/#${jail_name}$/d" "${FIREWALL_RULES}"
if [ -d "${jail_path}" ]; then
port=$("${LIBDIR}/bkctld-port" "${jail_name}")
# Add a rule for each IP

View File

@ -38,7 +38,7 @@ else
allow_users="${allow_users} root@${new_ip}"
done
if grep -q -E "^AllowUsers" "${jail_sshd_config}"; then
sed -i "s~^AllowUsers .*~${allow_users}~" "${jail_sshd_config}"
sed --follow-symlinks --in-place "s~^AllowUsers .*~${allow_users}~" "${jail_sshd_config}"
else
error "No \`AllowUsers' directive found in \`${jail_sshd_config}'"
fi

View File

@ -27,7 +27,7 @@ else
port=$((port+1))
[ "${port}" -le 1 ] && port=2222
fi
sed -i "s/^Port .*/Port ${port}/" "${jail_sshd_config}"
sed --follow-symlinks --in-place "s/^Port .*/Port ${port}/" "${jail_sshd_config}"
notice "Update SSH port \`${port}' for jail \`${jail_name}' : OK"

View File

@ -61,7 +61,7 @@ load test_helper
@test "Missing AllowUsers" {
# Remove AllowUsers directive in SSH config
sed -i '/^AllowUsers/d' "${JAILPATH}/etc/ssh/sshd_config"
sed --follow-symlinks --in-place '/^AllowUsers/d' "${JAILPATH}/etc/ssh/sshd_config"
# An error should be raised when trying to add an IP restriction
run /usr/lib/bkctld/bkctld-ip "${JAILNAME}" "10.0.0.1"
assert_failure

View File

@ -40,7 +40,7 @@ set_variable() {
var_value=${3:-}
if grep -qE "^\s*${var_name}=" "${file}"; then
sed -i "s|^\s*${var_name}=.*|${var_name}=${var_value}|" "${file}"
sed --follow-symlinks --in-place "s|^\s*${var_name}=.*|${var_name}=${var_value}|" "${file}"
else
echo "${var_name}=${var_value}" >> "${file}"
fi
@ -49,7 +49,7 @@ remove_variable() {
file=${1:?}
var_name=${2:?}
sed -i "s|^\s*${var_name}=.*|d" "${file}"
sed --follow-symlinks --in-place "s|^\s*${var_name}=.*|d" "${file}"
}
is_btrfs() {