diff options
Diffstat (limited to 'bin/mkrc.in')
-rwxr-xr-x | bin/mkrc.in | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/bin/mkrc.in b/bin/mkrc.in index 5d6af7e..5628f14 100755 --- a/bin/mkrc.in +++ b/bin/mkrc.in @@ -20,6 +20,28 @@ destination() { fi } +exit_if_dangerous() { + local file="$1" + + if [ -L "$file" ]; then + $ERROR 1 "'$file' is a symlink. Cannot process file." + elif is_nested "$file"; then + # Remove DEST_DIR in case $HOME is under a symlink + saved_ifs="$IFS" + IFS=/ + set -- $(dirname "$file" | sed "s|$DEST_DIR/||") + IFS="$saved_ifs" + + built_dir="$DEST_DIR" + for dir in $@; do + built_dir="$built_dir/$dir" + if [ -L "$built_dir" ]; then + $ERROR 1 "'$file' path contains a symlink ($dir). Cannot process file." + fi + done + fi +} + show_help() { local exit_code=${1:-0} @@ -64,7 +86,7 @@ while getopts :ChSsUuVvqot:d:B: opt; do B) in_host=1 hostname="$OPTARG" - install_args="-B $hostname" + install_args=$(append_variable "$install_args" "-B $hostname") ;; ?) show_help 64 ;; esac @@ -84,6 +106,7 @@ fi files="" for i; do + exit_if_dangerous "$i" files="$(printf "$files\n$i")" done |