File: test.sh

package info (click to toggle)
btrfs-progs 6.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 20,596 kB
  • sloc: ansic: 127,198; sh: 7,836; python: 1,385; makefile: 900; asm: 296
file content (38 lines) | stat: -rwxr-xr-x 976 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Verify "btrfs-image -s" sanitizes the filenames correctly

source "$TEST_TOP/common" || exit
source "$TEST_TOP/common.convert" || exit

setup_root_helper
prepare_test_dev

declare -a filenames=("%%top_secret%%" "@@secret@@" "||confidential||")
tmp=$(_mktemp "image-filename")

run_check_mkfs_test_dev
run_check_mount_test_dev
for i in ${filenames[@]}; do
	run_check $SUDO_HELPER touch "$TEST_MNT/$i"
done
run_check_umount_test_dev

run_check "$TOP/btrfs-image" "$TEST_DEV" "$tmp"
_log "strings found inside the regular dump:"
strings "$tmp" >> "$RESULTS"
for i in ${filenames[@]}; do
	if ! grep -q "$i" "$tmp"; then
		rm -f -- "$tmp"
		_fail "regular dump sanitized the filenames"
	fi
done
run_check "$TOP/btrfs-image" -s "$TEST_DEV" "$tmp"
_log "strings found inside the sanitize dump:"
strings "$tmp" >> "$RESULTS"
for i in ${filenames[@]}; do
	if grep -q "$i" "$tmp"; then
		rm -f -- "$tmp"
		_fail "filenames not properly sanitized"
	fi
done
rm -f -- "$tmp"