]> git.saurik.com Git - apt.git/blob - test/integration/test-no-fds-leaked-to-maintainer-scripts
do not make PTY slave the controlling terminal
[apt.git] / test / integration / test-no-fds-leaked-to-maintainer-scripts
1 #!/bin/sh
2 set -e
3
4 TESTDIR=$(readlink -f $(dirname $0))
5 . $TESTDIR/framework
6
7 setupenvironment
8 configarchitecture 'amd64' 'i386'
9 configdpkgnoopchroot
10
11 setupsimplenativepackage "fdleaks" 'all' '1.0' 'unstable'
12 BUILDDIR="incoming/fdleaks-1.0"
13 for script in 'preinst' 'postinst' 'prerm' 'postrm'; do
14 echo '#!/bin/sh
15 ls -l /proc/self/fd/' > ${BUILDDIR}/debian/$script
16 done
17 buildpackage "$BUILDDIR" 'unstable' 'main' 'native'
18 rm -rf "$BUILDDIR"
19
20 PKGNAME='fdleaks:all'
21 if ! dpkg-checkbuilddeps -d 'dpkg (>= 1.16.2)' /dev/null >/dev/null 2>&1; then
22 PKGNAME='fdleaks'
23 fi
24
25 setupaptarchive
26
27 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
28 testsuccess aptget install -y fdleaks -qq < /dev/null
29
30 checkfdleak() {
31 msgtest 'Check if fds were not' 'leaked'
32 if [ "$(grep 'root root' rootdir/tmp/testsuccess.output | wc -l)" = "$1" ]; then
33 msgpass
34 else
35 echo
36 cat rootdir/tmp/testsuccess.output
37 msgfail
38 fi
39 }
40 checkinstall() {
41 checkfdleak 8
42
43 cp rootdir/tmp/testsuccess.output terminal.output
44 tail -n +3 rootdir/var/log/apt/term.log | head -n -1 > terminal.log
45 testfileequal 'terminal.log' "$(cat terminal.output)"
46
47 testequal "startup archives unpack
48 install $PKGNAME <none> 1.0
49 status half-installed $PKGNAME 1.0
50 status unpacked $PKGNAME 1.0
51 status unpacked $PKGNAME 1.0
52 startup packages configure
53 configure $PKGNAME 1.0 <none>
54 status unpacked $PKGNAME 1.0
55 status half-configured $PKGNAME 1.0
56 status installed $PKGNAME 1.0" cut -f 3- -d' ' rootdir/var/log/dpkg.log
57 }
58 checkinstall
59
60 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
61 testsuccess aptget purge -y fdleaks -qq
62 checkpurge() {
63 checkfdleak 12
64
65 cp rootdir/tmp/testsuccess.output terminal.output
66 tail -n +3 rootdir/var/log/apt/term.log | head -n -1 > terminal.log
67 testfileequal 'terminal.log' "$(cat terminal.output)"
68
69 testequal "startup packages purge
70 status installed $PKGNAME 1.0
71 remove $PKGNAME 1.0 <none>
72 status half-configured $PKGNAME 1.0
73 status half-installed $PKGNAME 1.0
74 status config-files $PKGNAME 1.0
75 purge $PKGNAME 1.0 <none>
76 status config-files $PKGNAME 1.0
77 status config-files $PKGNAME 1.0
78 status config-files $PKGNAME 1.0
79 status config-files $PKGNAME 1.0
80 status config-files $PKGNAME 1.0
81 status not-installed $PKGNAME <none>" cut -f 3- -d' ' rootdir/var/log/dpkg.log
82 }
83 checkpurge
84
85 msgtest 'setsid provided is new enough to support' '-w'
86 if dpkg-checkbuilddeps -d 'util-linux (>= 2.24.2-1)' /dev/null >/dev/null 2>&1; then
87 msgpass
88 else
89 msgskip "$(command dpkg -l util-linux)"
90 exit
91 fi
92
93 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
94 testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt-get" install -y fdleaks -qq < /dev/null
95 checkinstall
96
97 rm -f rootdir/var/log/dpkg.log rootdir/var/log/apt/term.log
98 testsuccess runapt command setsid -w "${BUILDDIRECTORY}/apt-get" purge -y fdleaks -qq
99 checkpurge