From c170ebccd8ea303d689689e654652925fcbc5323 Mon Sep 17 00:00:00 2001 From: John Klug Date: Thu, 10 Mar 2022 17:48:39 -0600 Subject: Guard against circular symlinks --- recipes-core/multitech/config/config.init | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/recipes-core/multitech/config/config.init b/recipes-core/multitech/config/config.init index 282b0bb..2a1e0b5 100644 --- a/recipes-core/multitech/config/config.init +++ b/recipes-core/multitech/config/config.init @@ -145,6 +145,11 @@ function copydir { ln -sf "$to/$newdir" "$from" else mkdir "$to/$newdir" >/dev/null 2>&1 || true + if [[ -L $from ]] ; then + # If we have a symlink to a directory, + # skip copying any files. + return 0 + fi savedir=$(pwd) cd "$from" for f in * ; do @@ -285,8 +290,10 @@ case $1 in rm -rf /etc/$file ln -sf ${CONFIG_DIR}/$file /etc/$file else - rm -f "/etc/${file}/*" - linkdir "${CONFIG_DIR}/${file}" "/etc/${file}" + if ! [[ -L "/etc/${file}" ]] ; then + rm -f "/etc/${file}/*" + linkdir "${CONFIG_DIR}/${file}" "/etc/${file}" + fi fi done ;; -- cgit v1.2.3