File: functions

package info (click to toggle)
crack 5.0a-19
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,248 kB
  • sloc: ansic: 7,445; perl: 1,375; sh: 1,066; makefile: 216
file content (35 lines) | stat: -rw-r--r-- 807 bytes parent folder | download
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
# -*- shell-script -*-

match_or_exit () {
	file_to_match="$1"
	pattern_file="$2"

	while read line_to_match <&3 && read pattern_line <&4 ; do
		if [ "${line_to_match##$pattern_line}" ]; then
			echo '!!! MISMATCH !!!' >&2
			echo "   Line: »${line_to_match}«" >&2
			echo "Pattern: »${pattern_line}«" >&2
			exit 1
		fi;
	done 3<"${file_to_match}" 4<"${pattern_file}"
}

create_empty_dict () {
	mkdir -p /var/lib/Crack/dict
	date >/var/lib/Crack/dict/.dictmade
}

remove_artefacts () {
	rm /var/lib/Crack/?*.?*
}

run_crack_and_check_the_result () {
	cp debian/tests/resources/$1-passwd /tmp/passwd
	Crack /tmp/passwd 2>&1
	sleep 5
	Crack-Reporter >/tmp/crack-reporter.out
    cat /tmp/crack-reporter.out
	match_or_exit \
		/tmp/crack-reporter.out \
		debian/tests/resources/expected-result.patterns
}