From 93eec18723a889239b8308516fb6bb70d2b1fb3d Mon Sep 17 00:00:00 2001 From: Anton Reutov Date: Tue, 27 Jul 2021 15:21:52 +0300 Subject: [PATCH] Making sure chmod and chown does not follow symlinks --- func/main.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/func/main.sh b/func/main.sh index 9a7a0a3b4..e359da8fc 100644 --- a/func/main.sh +++ b/func/main.sh @@ -954,3 +954,15 @@ format_aliases() { aliases=$(echo "$aliases" |tr '\n' ',' |sed -e "s/,$//") fi } + +# Simple chmod wrapper that skips symlink files after glob expand +# Taken from HestiaCP +no_symlink_chmod() { + local filemode=$1; shift; + + for i in "$@"; do + [[ -L ${i} ]] && continue + + chmod "${filemode}" "${i}" + done +}