blob: 7c431aa71aa558a11043f5ef10a2e335c8026a90 [file] [log] [blame]
Dmitry V. Levin1da7c952014-12-13 18:24:13 +00001BEGIN {
2 ok = 0
3 fail = 0
4 r_uid = "(0|[1-9][0-9]*)"
5 r_getuid = "^getuid" suffix "\\(\\)[[:space:]]+= " r_uid "$"
6 r_setuid = "^/$"
7 r_getresuid = "^/$"
8 r_setreuid = "^/$"
9 r_setresuid = "^/$"
10 r_chown = "^/$"
11 s_last = "/"
12}
13
14ok == 1 {
15 fail = 1
16 next
17}
18
19$0 == s_last {
20 ok = 1
21 next
22}
23
24{
25 if (match($0, r_getuid, a)) {
26 r_uid = a[1]
27 r_setuid = "^setuid" suffix "\\(" r_uid "\\)[[:space:]]+= 0$"
28 next
29 }
30 if (match($0, r_setuid)) {
31 r_getresuid = "^getresuid" suffix "\\(\\[" r_uid "\\], \\[" r_uid "\\], \\[" r_uid "\\]\\)[[:space:]]+= 0$"
32 next
33 }
34 if (match($0, r_getresuid)) {
35 r_setreuid = "^setreuid" suffix "\\(-1, -1\\)[[:space:]]+= 0$"
36 next
37 }
38 if (match($0, r_setreuid)) {
39 r_setresuid = "^setresuid" suffix "\\(-1, " r_uid ", -1\\)[[:space:]]+= 0$"
40 next
41 }
42 if (match($0, r_setresuid)) {
43 r_chown = "^chown" suffix "\\(\".\", -1, -1\\)[[:space:]]+= 0$"
44 next
45 }
46 if (match($0, r_chown)) {
47 s_last = "+++ exited with 0 +++"
48 next
49 }
50 next
51}
52
53END {
54 if (fail) {
55 print "Unexpected output after exit"
56 exit 1
57 }
58 if (ok)
59 exit 0
60 if (r_setuid == "^/$") {
61 print "getuid doesn't match"
62 exit 1
63 }
64 if (r_getresuid == "^/$") {
65 print "setuid doesn't match"
66 exit 1
67 }
68 if (r_setreuid == "^/$") {
69 print "getresuid doesn't match"
70 exit 1
71 }
72 if (r_setresuid == "^/$") {
73 print "setreuid doesn't match"
74 exit 1
75 }
76 if (r_chown == "^/$") {
77 print "setresuid doesn't match"
78 exit 1
79 }
80 if (s_last == "/") {
81 print "chown doesn't match"
82 exit 1
83 }
84 print "The last line doesn't match"
85 exit 1
86}