Skip to content

Commit

Permalink
Consistently create the temporary directory with the correct mode
Browse files Browse the repository at this point in the history
Fixes #107.
  • Loading branch information
CyberShadow committed Jul 29, 2021
1 parent 34f3fbe commit bc81184
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ function AconfCompileOutput() {
return
fi

# shellcheck disable=SC2174
mkdir --mode=700 --parents "$tmp_dir"

rm -rf "$output_dir"
mkdir --parents "$output_dir"
mkdir "$output_dir"/files
Expand Down Expand Up @@ -248,6 +251,9 @@ function AconfCompileSystem() {
return
fi

# shellcheck disable=SC2174
mkdir --mode=700 --parents "$tmp_dir"

rm -rf "$system_dir"
mkdir --parents "$system_dir"
mkdir "$system_dir"/files
Expand Down Expand Up @@ -276,8 +282,7 @@ function AconfCompileSystem() {
AconfCreateFindIgnoreArgs ignore_args "${ignore_paths[@]}"

LogEnter 'Enumerating owned files...\n'
# shellcheck disable=SC2174
mkdir -m 700 --parents "$tmp_dir"
mkdir --parents "$tmp_dir"
( "$PACMAN" --query --list --quiet || true ) | sed 's#\/$##' | sort --unique > "$tmp_dir"/owned-files
LogLeave

Expand Down Expand Up @@ -791,8 +796,7 @@ function AconfAnalyzeFiles() {
LogEnter 'Examining files...\n'

LogEnter 'Loading data...\n'
# shellcheck disable=SC2174
mkdir -m 700 --parents "$tmp_dir"
mkdir --parents "$tmp_dir"
( cd "$output_dir"/files && find . -mindepth 1 -print0 ) | cut --zero-terminated -c 2- | sort --zero-terminated > "$tmp_dir"/output-files
( cd "$system_dir"/files && find . -mindepth 1 -print0 ) | cut --zero-terminated -c 2- | sort --zero-terminated > "$tmp_dir"/system-files
LogLeave
Expand Down
11 changes: 11 additions & 0 deletions test/t/lib-funcs-common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ function TestDone() {
| diff /dev/null /dev/stdin
) || FatalError 'Unknown stray global variables found!\n'

# Check that the temporary directory is created with the correct permissions
local tmp_dir_mode
if [[ -d "$tmp_dir" ]]
then
tmp_dir_mode=$(stat --format=%a "$tmp_dir")
if [[ "$tmp_dir_mode" != 700 ]]
then
FatalError '%q has mode %s, not 700!\n' "$tmp_dir" "$tmp_dir_mode"
fi
fi

LogLeave 'Test %s: %s!\n' "$(Color C "$test_name")" "$(Color G success)"
printf '\n' 1>&2 # Leave a blank line between tests
Exit 0
Expand Down
1 change: 1 addition & 0 deletions test/t/lib.bash
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ do
mkdir -p "$dir"
done
unset dir
rmdir "$tmp_dir" # Allow AconfCompile... to create it with the correct mode

source ./lib-funcs-common.bash
if ((${ACONFMGR_INTEGRATION:-0}))
Expand Down

0 comments on commit bc81184

Please sign in to comment.