Eliminate the use of eval
`eval` has always been used to process the globs in `.yadm/encrypt`. This is being removed, as there is a risk of executing "dirty" data found in `.yadm/encrypt`. Caveats of this change: * Brace and tilde expansion will no longer work in `.yadm/encrypt` * Paths with spaces must not be quoted anymore
This commit is contained in:
parent
57866714c4
commit
b78bb1eef4
3 changed files with 28 additions and 19 deletions
|
@ -10,7 +10,7 @@ function create_encrypt() {
|
||||||
echo "$efile" >> "$T_YADM_ENCRYPT"
|
echo "$efile" >> "$T_YADM_ENCRYPT"
|
||||||
echo "$efile" >> "$T_DIR_WORK/$efile"
|
echo "$efile" >> "$T_DIR_WORK/$efile"
|
||||||
mkdir -p "$T_DIR_WORK/dir one/$efile"
|
mkdir -p "$T_DIR_WORK/dir one/$efile"
|
||||||
echo "'dir one'/$efile/file1" >> "$T_YADM_ENCRYPT"
|
echo "dir one/$efile/file1" >> "$T_YADM_ENCRYPT"
|
||||||
echo "dir one/$efile/file1" >> "$T_DIR_WORK/dir one/$efile/file1"
|
echo "dir one/$efile/file1" >> "$T_DIR_WORK/dir one/$efile/file1"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,14 +96,16 @@ EOF
|
||||||
while IFS='' read -r glob || [ -n "$glob" ]; do
|
while IFS='' read -r glob || [ -n "$glob" ]; do
|
||||||
if [[ ! $glob =~ ^# && ! $glob =~ ^[[:space:]]*$ ]] ; then
|
if [[ ! $glob =~ ^# && ! $glob =~ ^[[:space:]]*$ ]] ; then
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
for matching_file in $(eval ls -d "$glob" 2>/dev/null); do
|
for matching_file in $glob; do
|
||||||
if [ -d "$matching_file" ]; then
|
if [ -e "$matching_file" ]; then
|
||||||
echo "$matching_file/"
|
if [ -d "$matching_file" ]; then
|
||||||
for subfile in "$matching_file"/*; do
|
echo "$matching_file/"
|
||||||
echo "$subfile"
|
for subfile in "$matching_file"/*; do
|
||||||
done
|
echo "$subfile"
|
||||||
else
|
done
|
||||||
echo "$matching_file"
|
else
|
||||||
|
echo "$matching_file"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -297,7 +299,7 @@ EOF
|
||||||
#; add paths with spaces to YADM_ARCHIVE
|
#; add paths with spaces to YADM_ARCHIVE
|
||||||
local original_encrypt
|
local original_encrypt
|
||||||
original_encrypt=$(cat "$T_YADM_ENCRYPT")
|
original_encrypt=$(cat "$T_YADM_ENCRYPT")
|
||||||
echo -e "'space test'/file*" >> "$T_YADM_ENCRYPT"
|
echo -e "space test/file*" >> "$T_YADM_ENCRYPT"
|
||||||
|
|
||||||
#; run encrypt
|
#; run encrypt
|
||||||
run expect <<EOF
|
run expect <<EOF
|
||||||
|
@ -331,7 +333,7 @@ EOF
|
||||||
#; add directory paths to YADM_ARCHIVE
|
#; add directory paths to YADM_ARCHIVE
|
||||||
local original_encrypt
|
local original_encrypt
|
||||||
original_encrypt=$(cat "$T_YADM_ENCRYPT")
|
original_encrypt=$(cat "$T_YADM_ENCRYPT")
|
||||||
echo -e "'space test'" >> "$T_YADM_ENCRYPT"
|
echo -e "space test" >> "$T_YADM_ENCRYPT"
|
||||||
|
|
||||||
#; run encrypt
|
#; run encrypt
|
||||||
run expect <<EOF
|
run expect <<EOF
|
||||||
|
|
23
yadm
23
yadm
|
@ -178,9 +178,11 @@ function alt() {
|
||||||
if [[ ! $glob =~ ^# && ! $glob =~ ^[[:space:]]*$ ]] ; then
|
if [[ ! $glob =~ ^# && ! $glob =~ ^[[:space:]]*$ ]] ; then
|
||||||
# echo "working on ->$glob<-"
|
# echo "working on ->$glob<-"
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
for matching_file in $(eval "$LS_PROGRAM" -d "$glob" 2>/dev/null); do
|
for matching_file in $glob; do
|
||||||
ENC_FILES[$index]="$matching_file"
|
if [ -e "$matching_file" ]; then
|
||||||
((index++))
|
ENC_FILES[$index]="$matching_file"
|
||||||
|
((index++))
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
done < "$YADM_ENCRYPT"
|
done < "$YADM_ENCRYPT"
|
||||||
|
@ -460,9 +462,11 @@ function encrypt() {
|
||||||
while IFS='' read -r glob || [ -n "$glob" ]; do
|
while IFS='' read -r glob || [ -n "$glob" ]; do
|
||||||
if [[ ! $glob =~ ^# && ! $glob =~ ^[[:space:]]*$ ]] ; then
|
if [[ ! $glob =~ ^# && ! $glob =~ ^[[:space:]]*$ ]] ; then
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
for matching_file in $(eval "$LS_PROGRAM" -d "$glob" 2>/dev/null); do
|
for matching_file in $glob; do
|
||||||
ENC_FILES[$index]="$matching_file"
|
if [ -e "$matching_file" ]; then
|
||||||
((index++))
|
ENC_FILES[$index]="$matching_file"
|
||||||
|
((index++))
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
done < "$YADM_ENCRYPT"
|
done < "$YADM_ENCRYPT"
|
||||||
|
@ -710,8 +714,11 @@ function perms() {
|
||||||
#; include globs found in YADM_ENCRYPT (if present)
|
#; include globs found in YADM_ENCRYPT (if present)
|
||||||
if [ -f "$YADM_ENCRYPT" ] ; then
|
if [ -f "$YADM_ENCRYPT" ] ; then
|
||||||
while IFS='' read -r glob || [ -n "$glob" ]; do
|
while IFS='' read -r glob || [ -n "$glob" ]; do
|
||||||
if [[ ! $glob =~ ^# ]] ; then
|
if [[ ! $glob =~ ^# && ! $glob =~ ^[[:space:]]*$ ]] ; then
|
||||||
GLOBS=("${GLOBS[@]}" $(eval "$LS_PROGRAM" -d "$glob" 2>/dev/null))
|
local IFS=$'\n'
|
||||||
|
for matching_file in $glob; do
|
||||||
|
GLOBS=("${GLOBS[@]}" "$matching_file")
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
done < "$YADM_ENCRYPT"
|
done < "$YADM_ENCRYPT"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue