Merge ~ahasenack/ubuntu/+source/squid3:artful-squid3-merge-1712653 into ~usd-import-team/ubuntu/+source/squid3:debian/sid

Proposed by Andreas Hasenack on 2017-08-24
Status: Merged
Merge reported by: Nish Aravamudan
Merged at revision: 66a53e162dfc8c55739c145bd34a49b047dbdae1
Proposed branch: ~ahasenack/ubuntu/+source/squid3:artful-squid3-merge-1712653
Merge into: ~usd-import-team/ubuntu/+source/squid3:debian/sid
Diff against target: 2942 lines (+2640/-30)
21 files modified
debian/NEWS.debian (+11/-0)
debian/changelog (+711/-1)
debian/control (+5/-6)
debian/patches/90-cf.data.ubuntu.patch (+12/-0)
debian/patches/99-ubuntu-ssl-cert-snakeoil.patch (+22/-0)
debian/patches/gcc7-assert-wants-boolean.patch (+23/-0)
debian/patches/gcc7-squidpurge-4695.patch (+29/-0)
debian/patches/series (+4/-0)
debian/rules (+8/-1)
debian/squid.install (+3/-0)
debian/squid.preinst (+15/-0)
debian/squid.rc (+0/-2)
debian/squid3.postinst (+0/-11)
debian/squid3.preinst (+0/-8)
debian/tests/control (+4/-0)
debian/tests/squid (+11/-0)
debian/tests/test-squid.py (+221/-0)
debian/tests/testlib.py (+1133/-0)
debian/tests/testlib_httpd.py (+352/-0)
debian/tests/upstream-test-suite (+1/-1)
debian/usr.sbin.squid (+75/-0)
Reviewer Review Type Date Requested Status
Nish Aravamudan 2017-08-24 Approve on 2017-08-24
Canonical Server Team 2017-08-24 Pending
Review via email: mp+329541@code.launchpad.net

Description of the Change

Debian merge of 3.5.23-5

This merge only got complicated due to the gcc7 FTBFS errors (#1712668). Upstream has fixes for all but one of them in 3.5.27, and their v3.5 git branch. The remaining one is a failure on 32bits that they deemed too intrusive to fix in v3.5. Therefore, we decided to not include the upstream existing v3.5 fixes and just disable the respective gcc7 errors, i.e., make them a warning.

Here is a list of the gcc7 changes: https://gcc.gnu.org/gcc-7/changes.html

The two errors that we turned back into warnings are:
* "deprecated": happens like this during build:
../include/SquidNew.h:29:54: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
 _SQUID_EXTERNNEW_ void *operator new[] (size_t size) throw (std::bad_alloc)
                                                      ^~~~
* "format-truncation": very common, and hard to fix in the case of the remaining build failure in 32 bits, happens when a snprintf() family function is used and whatever it is writing to the target buffer gets truncated because it did not fit. There is no overflow, but a truncation happens. It's a bit more complicated when the precision specifier is a variable ("*" in the format string), so its value is not known at compile time, in which case gcc assumes the worst possible case and outputs something like:
"""
Format.cc: In member function ‘void Format::Format::assemble(MemBuf&, const Pointer&, int) const’:
Format.cc:345:1: error: ‘%0*lld’ directive output may be truncated writing between 1 and 2147483646 bytes into a region of size 1024 [-Werror=format-truncation=]
"""

The above were the most common problems with gcc7. A couple of others happened but these were easy to fix with a patch which was deemed safe enough, and a better approach to disabling the error. Both patches are either direct copies from upstream, or a cherry pick of just the interesting hunk (the DEP3 header clarifies which is which):

- debian/patches/gcc7-squidpurge-4695.patch: this fixes a warning about an uninitialized variable being used, temp.refcount. The memcpy() was just using the incorrect variable in the sizeof(). Additionally, this was a case where a simple bump in the size of a buffer was enough to silence the format-truncation error.

- debian/patches/gcc7-assert-wants-boolean.patch: extracted from a bigger upstream change, this deals with the new "int-in-bool-context" warning from GCC7 which was hit in an assert() call.

DEP8 tests passed, upgrade from previous artful package worked, and I have this running as my local squid at home. What I did not test was an upgrade from zesty or xenial.

Test packages are available in this PPA for artful:

https://launchpad.net/~ahasenack/+archive/ubuntu/squid-merge-ftbfs-1712668-1712653/

IMPORTANT

Note for sponsorship: the #ubuntu-release team was asked for a FFe for this upload on IRC, but it's a busy day :)
<rbasak> Mini FFe request: ahasenack has been working on a squid3 merge but held up by a gcc7 related FTBFS. He's almost ready for sponsorship and upload. The merge would only include one very minor functional change: https://anonscm.debian.org/git/pkg-squid/pkg-squid3.git/commit/?id=710982a8fb26a4a949f48812847cc13b1c17a3ca
<rbasak> But we don't think we'll manage the upload today.
<rbasak> Could a release team member please ack this to upload if within the next week or so?
<rbasak> All other changes that would land are bugfixes.
<rbasak> So this is really a technicality IMHO, but one that requires ~ubuntu-release to ack.
<rbasak> All other changes coming from Debian are at: https://anonscm.debian.org/git/pkg-squid/pkg-squid3.git/log/
<rbasak> From 3.5.23-1 through 3.5.23-5.

If this MP is deemed correct and ready for upload, please ping me or Robie so we can ask the release team one more time and probably make it formal via the bug we have for this merge, and the FTBFS bug as well.

To post a comment you must log in.
Andreas Hasenack (ahasenack) wrote :

I did a build on amd64 with artful-proposed enabled on diglett, it built fine:
# only call dh_scour for packages in main
if grep -q '^Component:[[:space:]]*main' /CurrentlyBuilding 2>/dev/null; then dh_scour -psquid-purge ; fi
dh_md5sums -psquid-purge
dh_builddeb -psquid-purge
dpkg-deb: building package 'squid-purge' in '../squid-purge_3.5.23-5ubuntu1_amd64.deb'.
 dpkg-genbuildinfo
 dpkg-genchanges >../squid3_3.5.23-5ubuntu1_amd64.changes
dpkg-genchanges: info: not including original source code in upload
 dpkg-source --after-build squid3-3.5.23
dpkg-buildpackage: info: binary and diff upload (original source NOT included)

real 15m48.910s
user 13m47.816s
sys 1m20.360s
ubuntu@andreas-artful:~/squid3-3.5.23⟫ l ..
squid3-3.5.23/ squid3_3.5.23-5ubuntu1.debian.tar.xz squid-cgi_3.5.23-5ubuntu1_amd64.deb squid-purge_3.5.23-5ubuntu1_amd64.deb
squid3_3.5.23-5ubuntu1_all.deb squid3_3.5.23-5ubuntu1.dsc squidclient_3.5.23-5ubuntu1_amd64.deb
squid3_3.5.23-5ubuntu1_amd64.buildinfo squid3_3.5.23.orig.tar.gz squid-common_3.5.23-5ubuntu1_all.deb
squid3_3.5.23-5ubuntu1_amd64.changes squid_3.5.23-5ubuntu1_amd64.deb squid-dbg_3.5.23-5ubuntu1_amd64.deb

Andreas Hasenack (ahasenack) wrote :

ubuntu@andreas-artful:~/squid3-3.5.23⟫ apt-cache policy binutils
binutils:
  Installed: 2.29-6ubuntu3
  Candidate: 2.29-6ubuntu3
  Version table:
 *** 2.29-6ubuntu3 500
        500 http://archive.ubuntu.com/ubuntu artful-proposed/main amd64 Packages
        100 /var/lib/dpkg/status
     2.29-5ubuntu1 500
        500 http://archive.ubuntu.com/ubuntu artful/main amd64 Packages

Nish Aravamudan (nacc) :
review: Approve
Nish Aravamudan (nacc) wrote :

Upload tagged and sponsored.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/NEWS.debian b/debian/NEWS.debian
2index 3987e99..7a738d5 100644
3--- a/debian/NEWS.debian
4+++ b/debian/NEWS.debian
5@@ -26,6 +26,17 @@ squid3 (3.5.6-1) unstable; urgency=medium
6 that cache store format changed from squid 2.x and cannot be reused with
7 squid 3.x
8
9+ [ Robie Basak ]
10+ In Ubuntu, data in /var/spool/squid3 *was* moved automatically on upgrade to
11+ Xenial (3.5.12-1ubuntu7). Upgrades from before Xenial to after Xenial are not
12+ supported; you must upgrade through Xenial. Details of the historic migration
13+ path are in Steve's note below.
14+
15+ [ Steve Langasek ]
16+ An attempt will be made to move the data in /var/spool/squid3 automatically.
17+ If this is a mountpoint, the move will fail and you will need to migrate
18+ your mount configuration by hand.
19+
20 -- Luigi Gangitano <luigi@debian.org> Wed, 22 Jul 2015 15:48:13 +0200
21
22 squid3 (3.0.STABLE15-1) unstable; urgency=low
23diff --git a/debian/changelog b/debian/changelog
24index f38058d..c4d02eb 100644
25--- a/debian/changelog
26+++ b/debian/changelog
27@@ -1,3 +1,36 @@
28+squid3 (3.5.23-5ubuntu1) artful; urgency=medium
29+
30+ * Merge with Debian unstable (LP: #1712653). Remaining changes:
31+ - Add additional dep8 tests.
32+ - Use snakeoil certificates.
33+ - Add an example refresh pattern for debs.
34+ - Add disabled by default AppArmor profile.
35+ - Enable autoreconf. This is no longer required for the security updates,
36+ but is needed for the seddery of test-suite/Makefile.am in
37+ d/t/upstream-test-suite.
38+ - Correct attribution and add explanatory note in d/NEWS.debian.
39+ - Drop Conflicts/Replaces of squid against squid3. In Ubuntu, the migration
40+ happened in Xenial, so no upgrade path still requires this code. This
41+ reduces upgrade ordering difficulty.
42+ - Adjust seddery for upstream test squid binary location.
43+ - Revert "Set pidfile for systemd's sysv-generator" from Debian.
44+ - Drop wrong short-circuiting of various invocations; we always want to
45+ call the debhelper block.
46+ * Drop:
47+ - Add missing Pre-Depends on adduser.
48+ [Fixed in Debian 3.5.23-2]
49+ * GCC7 FTBFS fixes (LP: #1712668):
50+ - d/rules: don't error when hitting the "deprecated" and
51+ "format-truncation" gcc7 warnings. Upstream 3.5.27 has fixes for these,
52+ but one in Format.cc that affects 32bit builds was deemed too intrusive
53+ for the 3.5 stable series and is only in squid 4.x
54+ - debian/patches/gcc7-squidpurge-4695.patch: GCC 7 build errors.
55+ Thanks to Lubos Uhliarik <luhliari@redhat.com>.
56+ - debian/patches/gcc7-assert-wants-boolean.patch: assert() takes a
57+ boolean. Thanks to Amos Jeffries <squid3@treenet.co.nz>
58+
59+ -- Andreas Hasenack <andreas@canonical.com> Thu, 24 Aug 2017 16:04:35 -0300
60+
61 squid3 (3.5.23-5) unstable; urgency=medium
62
63 * Reload squid so that it uses modified config, not default one.
64@@ -52,6 +85,55 @@ squid3 (3.5.23-2) unstable; urgency=medium
65
66 -- Santiago Garcia Mantinan <manty@debian.org> Sun, 19 Mar 2017 23:23:57 +0100
67
68+squid3 (3.5.23-1ubuntu1) zesty; urgency=medium
69+
70+ * Merge from Debian (LP: #1644538). Remaining changes:
71+ - Add additional dep8 tests.
72+ - Use snakeoil certificates.
73+ - Add an example refresh pattern for debs.
74+ - Add disabled by default AppArmor profile.
75+ - Revert "Set pidfile for systemd's sysv-generator" from Debian.
76+ - Drop wrong short-circuiting of various invocations; we always want to
77+ call the debhelper block.
78+ - Add missing Pre-Depends on adduser.
79+ - Enable autoreconf. This is no longer required for the security updates,
80+ but is needed for the seddery of test-suite/Makefile.am in
81+ d/t/upstream-test-suite.
82+ * Drop changes (adopted in Debian):
83+ - Run sarg-reports if present before rotating logs.
84+ - Add lsb-release build dep.
85+ * Drop changes that no longer make a functional difference in Ubuntu, but may
86+ still be relevant to send to Debian:
87+ - d/squid3.postinst: don't try to stop squid3 again.
88+ - d/squid3.postrm: don't rm -f conffiles in purge.
89+ - Drop squid3 dependencies on ${shlib:Depends} and lsb-base.
90+ - Drop creation of /etc/squid.
91+ * Drop unnecessary changes:
92+ - Add executable bits to d/squid.preinst.
93+ * Drop changes relating to the upgrade path from prior to Xenial, so no
94+ longer required:
95+ - /var/spool/squid3 upgrade path handling.
96+ - Conffile upgrade path handling.
97+ - Remove redundant version-guarded restart code from squid postinst.
98+ - Clean up apparmor links for usr.sbin.squid3 on upgrade.
99+ - Attempt to migrate /var/log/squid3 -> /var/log/squid on upgrade.
100+ - Add Breaks on older ufw to fix upgrade path.
101+ - Use Breaks instead of Conflicts. Instead, drop the Conflicts/Replaces
102+ entirely (see below).
103+ * Drop security fixes: all included in 3.5.23 upstream.
104+ * Drop Conflicts/Replaces of squid against squid3. In Ubuntu, the migration
105+ happened in Xenial, so no upgrade path still requires this code. This
106+ reduces upgrade ordering difficulty.
107+ * Fix failing autopkgtests:
108+ - Adjust Python module dependencies.
109+ - Correctly handle the squid3 -> squid rename.
110+ - Adjust seddery for upstream test squid binary location.
111+ * Drop dependency on init-system-helpers. This was introduced in LP 1432683.
112+ Since we no longer ship an upstart job, it is no longer required.
113+ * Correct attribution and add explanatory note in d/NEWS.debian.
114+
115+ -- Robie Basak <robie.basak@ubuntu.com> Tue, 24 Jan 2017 15:47:44 +0000
116+
117 squid3 (3.5.23-1) unstable; urgency=high
118
119 [ Amos Jeffries <amosjeffries@squid-cache.org> ]
120@@ -173,6 +255,186 @@ squid3 (3.5.14-1) unstable; urgency=medium
121
122 -- Luigi Gangitano <luigi@debian.org> Tue, 16 Feb 2016 23:14:00 +0100
123
124+squid3 (3.5.12-1ubuntu9) zesty; urgency=medium
125+
126+ * SECURITY UPDATE: cookie data leak via If-Not-Modified HTTP conditional
127+ - debian/patches/CVE-2016-10002.patch: properly handle combination of
128+ If-Match and a Cache Hit in src/LogTags.h, src/client_side.cc,
129+ src/client_side_reply.cc, src/client_side_reply.h.
130+ - CVE-2016-10002
131+ * SECURITY UPDATE: incorrect HTTP Request header comparison
132+ - debian/patches/CVE-2016-10003.patch: don't share private responses
133+ with collapsed client in src/client_side_reply.cc.
134+ - CVE-2016-10003
135+
136+ -- Marc Deslauriers <marc.deslauriers@ubuntu.com> Fri, 03 Feb 2017 13:07:31 -0500
137+
138+squid3 (3.5.12-1ubuntu8) yakkety; urgency=medium
139+
140+ * SECURITY UPDATE: denial of service via pinger and ICMPv6 packet
141+ - debian/patches/CVE-2016-3947.patch: fix sizes in src/icmp/Icmp6.cc.
142+ - CVE-2016-3947
143+ * SECURITY UPDATE: denial of service and possible code execution via
144+ seeding manager reporter with crafted data
145+ - debian/patches/CVE-2016-4051.patch: use dynamic MemBuf for internal
146+ content generation in tools/cachemgr.cc, src/tests/stub_cbdata.cc,
147+ src/tests/stub_mem.cc, tools/Makefile.am.
148+ - CVE-2016-4051
149+ * SECURITY UPDATE: denial of service or arbitrary code execution via
150+ crafted ESI responses
151+ - debian/patches/CVE-2016-4052.patch: perform bounds checking and
152+ remove asserts in src/esi/Esi.cc.
153+ - CVE-2016-4052
154+ - CVE-2016-4053
155+ - CVE-2016-4054
156+ * SECURITY UPDATE: cache-poisoning attacks via an HTTP request with an
157+ absolute-URI
158+ - debian/patches/CVE-2016-4553.patch: properly handle condition in
159+ src/client_side.cc
160+ - CVE-2016-4553
161+ * SECURITY UPDATE: same-origin bypass and cache-poisoning attack via
162+ crafted HTTP host header
163+ - debian/patches/CVE-2016-4554.patch: properly handle whitespace in
164+ src/mime_header.cc.
165+ - CVE-2016-4554
166+ * SECURITY UPDATE: denial of service via ESI responses
167+ - debian/patches/CVE-2016-4555.patch: fix segfaults in
168+ src/client_side_request.cc, src/esi/Context.h, src/esi/Esi.cc.
169+ - CVE-2016-4555
170+ - CVE-2016-4556
171+ * debian/rules: include autoreconf.mk.
172+ * debian/control: add dh-autoreconf to BuildDepends.
173+
174+ -- Marc Deslauriers <marc.deslauriers@ubuntu.com> Wed, 08 Jun 2016 08:05:32 -0400
175+
176+squid3 (3.5.12-1ubuntu7.1) xenial; urgency=medium
177+
178+ * Add Breaks on older ufw to fix upgrade path (LP: #1571174).
179+
180+ -- Robie Basak <robie.basak@ubuntu.com> Thu, 12 May 2016 11:03:06 +0000
181+
182+squid3 (3.5.12-1ubuntu7) xenial; urgency=medium
183+
184+ * Update apparmor profile to be correct for maas-proxy.
185+
186+ -- LaMont Jones <lamont@ubuntu.com> Tue, 12 Apr 2016 13:05:00 -0600
187+
188+squid3 (3.5.12-1ubuntu6) xenial; urgency=medium
189+
190+ * Attempt to migrate /var/log/squid3 -> /var/log/squid on upgrade.
191+ * Update apparmor profile for s/squid3/squid/ and /dev/shm access.
192+
193+ -- Adam Conrad <adconrad@ubuntu.com> Sun, 03 Apr 2016 21:34:50 -0600
194+
195+squid3 (3.5.12-1ubuntu5) xenial; urgency=medium
196+
197+ * Use versioned Breaks/Replaces instead of an unversioned Conflicts, to
198+ further clean up the upgrade ordering.
199+
200+ -- Steve Langasek <steve.langasek@ubuntu.com> Fri, 01 Apr 2016 21:05:38 +0000
201+
202+squid3 (3.5.12-1ubuntu4) xenial; urgency=medium
203+
204+ * Remove redundant version-guarded restart code from squid postinst, which
205+ doesn't do the right thing on Ubuntu upgrades.
206+ * Remove duplicated conffile handling from the squid3 dummy package with
207+ extreme prejudice. The conffile moving absolutely *must* be done
208+ exclusively in the squid package; trying to do it in the squid3 package
209+ causes pristine conffiles to be silently overwritten with any
210+ locally-modified version from the squid3 package, with hilarious effect.
211+ * Adjust squid.{pre,post}inst to trick dpkg-maintscript-helper into
212+ believing we had a previously installed version of this package even if
213+ we did not, which appears to be a requirement for mv_conffile to DTRT.
214+ This is certainly a dpkg bug that needs to be filed.
215+ * Move all Ubuntu-specific dpkg-maintscript-helper delta into
216+ debian/squid.maintscript for clarity/sanity. Among other things,
217+ this uncovers a bug where we're trying to call both mv_conffile and
218+ rm_conffile for /etc/init.d/squid3.
219+ * debian/squid3.{pre,post}inst: drop wrong short-circuiting of various
220+ invocations; we always want to call the debhelper block.
221+ * debian/squid3.postinst: don't try to stop squid3 again, this is
222+ redundant.
223+ * debian/squid3.postrm: don't rm -f conffiles in purge when dpkg already
224+ handles these.
225+ * Add missing pre-depends on adduser
226+ * Anchor the Conflicts/Replaces to the version of the package that
227+ introduced the name change in Ubuntu, to avoid upgrade ordering problems
228+ later.
229+ * Include upgrade migration handling for /var/spool/squid3 ->
230+ /var/spool/squid. This won't work if /var/spool/squid3 is a mount point,
231+ so fail gracefully, but leaving two full squid cache directories around
232+ after upgrade is a nuisance.
233+ * Remove empty /etc/squid3 dir on upgrade.
234+ * Clean up apparmor links for usr.sbin.squid3 on upgrade. We don't migrate
235+ these apparmor settings over, so at least don't leave stale links behind.
236+
237+ -- Steve Langasek <steve.langasek@ubuntu.com> Thu, 31 Mar 2016 19:01:47 -0700
238+
239+squid3 (3.5.12-1ubuntu3) xenial; urgency=medium
240+
241+ * Revert last postinst change as it's buggy.
242+ * Remove /etc/init.d/squid3 from preinst on upgrade.
243+
244+ -- Stéphane Graber <stgraber@ubuntu.com> Tue, 29 Mar 2016 22:46:16 -0400
245+
246+squid3 (3.5.12-1ubuntu2) xenial; urgency=medium
247+
248+ * debian/squid.postinst: Fix dist-upgrade of squid by detecting service
249+ name (/etc/init.d/squid vs. squid3).
250+
251+ -- Ryan Harper <ryan.harper@canonical.com> Mon, 28 Mar 2016 11:20:35 -0500
252+
253+squid3 (3.5.12-1ubuntu1) xenial; urgency=medium
254+
255+ * Merge from Debian (LP: #1473691). Remaining changes:
256+ - Add dep8 tests.
257+ - Use snakeoil certificates.
258+ - Run sarg-reports if present before rotating logs
259+ - debian/patches/90-cf.data.ubuntu.dpatch: add an example refresh
260+ pattern for debs.
261+ - Add disabled by default AppArmor profile. Versioned dependency on
262+ init-system-helpers (>> 1.22ubuntu5) to ensure we have the
263+ apparmor-profile-load script at boot time.
264+ * Drop changes:
265+ - No longer needed:
266+ + Upstart job.
267+ + Dependency package for squid -> squid3: depcrecated; the transitional package now runs the other way.
268+ + Fix perl & pod2man config.tests.
269+ + fix-logical-not-parentheses-warning.patch.
270+ + fix-pod2name-pipe-failure.patch.
271+ + --disable-strict-error-checking to fix FTBFS.
272+ - NEWS.Debian: no longer relevant.
273+ - Hardening options: deprecated.
274+ - Add patch to show distribution: fixed in Debian (but see
275+ lsb-release B-D).
276+ - Enable parallel build: makes no difference to build time.
277+ - Force -O2 to work around build failure with -O3: presumed no
278+ longer needed.
279+ - Fixed upstream:
280+ + CVE-2014-3609.patch: confirmed fixed since 3.4.7 from upstream
281+ advisory.
282+ + Fix various ICMP handling issues in Squid pinger: confirmed
283+ fixed since 3.4.7 from upstream advisory.
284+ + fix-caching-vary-header.patch.
285+ + netfilter_fix.patch.
286+ * Drop Testsuite: header from dep8 tests: no longer required since
287+ dpkg-source >= 1.17.11 does it.
288+ * Revert "Set pidfile for systemd's sysv-generator" from Debian.
289+ systemd races the squid daemon for pidfile creation, causing systemd
290+ to consider the service start to have failed. Work around for now by
291+ not telling systemd to use the pidfile.
292+ * Add lsb-release build dep. This is required for the
293+ --enable-build-info line in debian/rules to work correctly.
294+ * Correctly rename conffiles migrated by Debian from squid3 to squid.
295+ * Remove conffile for old upstart job Ubuntu delta.
296+ * Rename Apparmor profile conffile.
297+ * Drop old transitional Apparmor code no longer required.
298+ * Adjust AppArmor profile for squid3->squid rename.
299+ * Drop versioned AppArmor dependency (transitional; no longer
300+ required).
301+
302+ -- Robie Basak <robie.basak@ubuntu.com> Thu, 25 Feb 2016 11:42:03 +0000
303+
304 squid3 (3.5.12-1) unstable; urgency=medium
305
306 [ Amos Jeffries <amosjeffries@squid-cache.org> ]
307@@ -425,6 +687,180 @@ squid3 (3.3.8-1.1) unstable; urgency=low
308
309 -- gregor herrmann <gregoa@debian.org> Sat, 23 Nov 2013 21:05:10 +0100
310
311+squid3 (3.3.8-1ubuntu17) xenial; urgency=medium
312+
313+ * --disable-strict-error-checking to fix FTBFS due to auto_ptr defined
314+ in unique pointer headers. (LP: #1521234).
315+
316+ -- Dimitri John Ledkov <xnox@ubuntu.com> Mon, 30 Nov 2015 15:32:14 +0000
317+
318+squid3 (3.3.8-1ubuntu16) wily; urgency=medium
319+
320+ [ Tiago Stürmer Daitx ]
321+ * d/patches/fix-logical-not-parentheses-warning.patch: Fix warning for
322+ logical-not-parentheses which caused squid to FTBFS. (LP: #1496924)
323+ * d/patches/netfilter_fix.patch: Backported from Squid Bug #4323.
324+ (LP: #1496223)
325+ * d/patches/fix-pod2name-pipe-failure.patch: Add --name parameter to
326+ pod2man (LP: #1501566)
327+ * roll back build-dependency to libecap2-dev, this version of squid3 is not
328+ compatible with libecap3 and libecap3 transition has been rolled back for
329+ wily.
330+
331+ -- Steve Langasek <steve.langasek@ubuntu.com> Fri, 09 Oct 2015 00:29:47 +0000
332+
333+squid3 (3.3.8-1ubuntu15) wily; urgency=medium
334+
335+ * Build-depend on libecap3-dev instead of libecap2-dev.
336+
337+ -- Matthias Klose <doko@ubuntu.com> Wed, 02 Sep 2015 12:16:29 +0200
338+
339+squid3 (3.3.8-1ubuntu14) vivid; urgency=medium
340+
341+ * Add versioned dependency on init-system-helpers (>> 1.22ubuntu5) to ensure
342+ we have the apparmor-profile-load script at boot time. (LP: #1432683)
343+
344+ -- Serge Hallyn <serge.hallyn@ubuntu.com> Thu, 02 Apr 2015 11:12:27 -0500
345+
346+squid3 (3.3.8-1ubuntu13) vivid; urgency=medium
347+
348+ * d/squid3.prerm: Removed redundant upstart-only code. Equivalent
349+ operations are carried out by debhelper-generated code in a more
350+ generic manner. (LP: #1424508)
351+
352+ -- Oleg Strikov <oleg.strikov@canonical.com> Thu, 05 Mar 2015 14:24:33 +0300
353+
354+squid3 (3.3.8-1ubuntu12) vivid; urgency=medium
355+
356+ * debian/tests/testlib_httpd.py: Use "service" command instead of upstart
357+ specific ones, and simplify the logic.
358+ * debian/tests/testlib.py, check_exe(): Check /proc/pid/exe symlink instead
359+ of parsing cmdline; the latter has "(squid-1)" with the init.d script, and
360+ it's not really what we are interested in.
361+
362+ -- Martin Pitt <martin.pitt@ubuntu.com> Fri, 06 Mar 2015 12:10:59 +0100
363+
364+squid3 (3.3.8-1ubuntu11) vivid; urgency=medium
365+
366+ * d/patches/fix-caching-vary-header.patch: Added upstream patch
367+ for the bug which prevented squid from caching responses with
368+ Vary header. (LP: #1336742)
369+
370+ -- Oleg Strikov <oleg.strikov@canonical.com> Wed, 04 Mar 2015 15:08:54 +0300
371+
372+squid3 (3.3.8-1ubuntu10) vivid; urgency=medium
373+
374+ [Jacek Nykis]
375+ * d/usr.sbin.squid3: Apparmor profile has been changed to allow child
376+ processes to run execvp(argv[0], [kidname, ...]). (LP: #1416039)
377+
378+ -- Oleg Strikov <oleg.strikov@canonical.com> Tue, 03 Mar 2015 18:18:20 +0300
379+
380+squid3 (3.3.8-1ubuntu9) vivid; urgency=medium
381+
382+ * Fix various ICMP handling issues in Squid pinger. (LP: #1384943)
383+
384+ -- Jorge Niedbalski <jorge.niedbalski@canonical.com> Tue, 18 Nov 2014 14:47:33 -0300
385+
386+squid3 (3.3.8-1ubuntu8) utopic; urgency=medium
387+
388+ * SECURITY UPDATE: Ignore Range headers with unidentifiable byte-range
389+ values
390+ - debian/patches/CVE-2014-3609.patch: adjust src/HttpHdrRange.cc to
391+ return an error if unable to determine the byte value for ranges
392+ - CVE-2014-3609
393+
394+ -- Jamie Strandboge <jamie@ubuntu.com> Tue, 26 Aug 2014 13:51:07 -0500
395+
396+squid3 (3.3.8-1ubuntu7) utopic; urgency=medium
397+
398+ * Put back the init.d script, for compatibility with insserv. (LP: #1323274)
399+
400+ -- Martin Pitt <martin.pitt@ubuntu.com> Mon, 26 May 2014 23:27:57 +0200
401+
402+squid3 (3.3.8-1ubuntu6) trusty; urgency=medium
403+
404+ * debian/rules: Force -O2 to work around build failure with -O3.
405+
406+ -- Adam Conrad <adconrad@ubuntu.com> Mon, 17 Feb 2014 20:13:30 -0700
407+
408+squid3 (3.3.8-1ubuntu5) trusty; urgency=low
409+
410+ [ Yolanda Robla ]
411+ * debian/control: added lsb-release dependency
412+ * debian/patches/fix-distribution.patch: added patch to show distribution
413+
414+ [ Dimitri John Ledkov ]
415+ * Enable parallel build
416+
417+ -- Yolanda Robla <yolanda.robla@canonical.com> Wed, 11 Dec 2013 10:51:45 +0000
418+
419+squid3 (3.3.8-1ubuntu4) trusty; urgency=low
420+
421+ * Fix perl & pod2man config.tests.
422+
423+ -- Dmitrijs Ledkovs <xnox@ubuntu.com> Mon, 04 Nov 2013 02:17:30 +0000
424+
425+squid3 (3.3.8-1ubuntu3) saucy; urgency=low
426+
427+ * d/tests/squid: Disable seccomp sandboxing in vsftpd until it works
428+ reliably (http://pad.lv/1219857), restart vsftpd using service
429+ command.
430+
431+ -- James Page <james.page@ubuntu.com> Mon, 02 Sep 2013 15:50:41 +0100
432+
433+squid3 (3.3.8-1ubuntu2) saucy; urgency=low
434+
435+ * d/usr.sbin.squid3: Update apparmor profile to allow pinger process to
436+ create and use ICMP ports for ipv4/ipv6.
437+
438+ -- James Page <james.page@ubuntu.com> Mon, 02 Sep 2013 11:06:54 +0100
439+
440+squid3 (3.3.8-1ubuntu1) saucy; urgency=low
441+
442+ * Merge from Debian unstable, remaining changes:
443+ + debian/control:
444+ - Update maintainer.
445+ - Suggests apparmor (>= 2.3)
446+ - Depends on ssl-cert ((>= 1.0-11ubuntu1), autopkgtests
447+ + debian/squid3.upstart
448+ - Move ulimit command to script section so that it applies
449+ to the started squid daemon. Thanks to Timur Irmatov (LP: 986159)
450+ - Work around squid not handling SIGHUP by adding respawn to
451+ upstart job. (LP: 978356)
452+ + debian/NEWS.Debian: Rename NEWS.debian, add note regarding squid3
453+ transition in 12.04 (LP: 924739)
454+ + debian/rules
455+ - Re-enable all hardening options lost in the squid->squid3
456+ transition (LP: 986314)
457+ + squid3.resolvconf, debian/squid3.postinst, debian/squid3.postrm,
458+ debian/squid3.preinst, debian/squid3.prerm:
459+ - Convert init script to upstart
460+ + debian/patches/99-ubuntu-ssl-cert-snakeoil:
461+ - Use snakeoil certificates.
462+ + debian/logrotate
463+ - Use sar-reports rather than sarg-maint. (LP: 26616)
464+ + debian/patches/90-cf.data.ubuntu.dpatch:
465+ - Add an example refresh pattern for debs.
466+ (foundations-lucid-local-report spec)
467+ + Add disabled by default AppArmor profile (LP: 497790)
468+ - debian/squid3.upstart: load profile in pre-start stanza
469+ - add debian/usr.sbin.squid3 profile
470+ - debian/rules:
471+ + install debian/usr.sbin.squid3, etc/apparmor.d/force-complain and
472+ etc/apparmor.d/disable into $(INSTALLDIR)
473+ + use dh_apparmor
474+ - debian/squid3.install: install etc/apparmor.d/disable, force-complain
475+ and usr.sbin.squid3
476+ - debian/squid3.preinst: disable profile on clean install or upgrades
477+ from earlier than when we shipped the profile
478+ + debian/tests:
479+ - Add autopkgtests.
480+ * d/control: Add dependency package for squid -> squid3 (LP: #1211942).
481+ * d/control: Add dh-apparmor to BD's.
482+
483+ -- James Page <james.page@ubuntu.com> Wed, 14 Aug 2013 09:03:55 +0100
484+
485 squid3 (3.3.8-1) unstable; urgency=high
486
487 * Urgency high due to security fixes
488@@ -445,6 +881,65 @@ squid3 (3.3.8-1) unstable; urgency=high
489
490 -- Luigi Gangitano <luigi@debian.org> Sun, 21 Jul 2013 18:28:36 +0200
491
492+squid3 (3.3.4-1ubuntu1) saucy; urgency=low
493+
494+ * Merge from Debian unstable (LP: #1199883). Remaining changes:
495+ + debian/control:
496+ - Update maintainer.
497+ - Suggests apparmor (>= 2.3)
498+ - Depends on ssl-cert ((>= 1.0-11ubuntu1), autopkgtests
499+ + debian/squid3.upstart
500+ - Move ulimit command to script section so that it applies
501+ to the started squid daemon. Thanks to Timur Irmatov (LP: 986159)
502+ - Work around squid not handling SIGHUP by adding respawn to
503+ upstart job. (LP: 978356)
504+ + debian/NEWS.Debian: Rename NEWS.debian, add note regarding squid3
505+ transition in 12.04 (LP: 924739)
506+ + debian/rules
507+ - Re-enable all hardening options lost in the squid->squid3
508+ transition (LP: 986314)
509+ + squid3.resolvconf, debian/squid3.postinst, debian/squid3.postrm,
510+ debian/squid3.preinst, debian/squid3.prerm:
511+ - Convert init script to upstart
512+ + debian/patches/99-ubuntu-ssl-cert-snakeoil:
513+ - Use snakeoil certificates.
514+ + debian/logrotate
515+ - Use sar-reports rather than sarg-maint. (LP: 26616)
516+ + debian/patches/90-cf.data.ubuntu.dpatch:
517+ - Add an example refresh pattern for debs.
518+ (foundations-lucid-local-report spec)
519+ + Add disabled by default AppArmor profile (LP: 497790)
520+ - debian/squid3.upstart: load profile in pre-start stanza
521+ - add debian/usr.sbin.squid3 profile
522+ - debian/rules:
523+ + install debian/usr.sbin.squid3, etc/apparmor.d/force-complain and
524+ etc/apparmor.d/disable into $(INSTALLDIR)
525+ + use dh_apparmor
526+ - debian/squid3.install: install etc/apparmor.d/disable, force-complain
527+ and usr.sbin.squid3
528+ - debian/squid3.preinst: disable profile on clean install or upgrades
529+ from earlier than when we shipped the profile
530+ + debian/tests:
531+ - Add autopkgtests.
532+
533+ * Dropped:
534+ - debian/patches: dropped patches, superseded by new release:
535+ + 98-CVE-2012-5643.patch
536+ + 99-lp1117517_r12473.patch
537+ - debian/rules: fix FTBFS, removed --with-cppunit-basedir flag,
538+ included in Debian.
539+ - debian/control: Dropped transitional packages from squid, no
540+ longer required.
541+
542+ * Refreshed patches:
543+ - 01-cf.data.debian.patch
544+ - 02-makefile-defaults.patch
545+ - 15-cachemgr-default-config.patch
546+
547+ * debian/tests/test-squid.py: fixed case problem with ftp test
548+
549+ -- Yolanda Robla <yolanda.robla@canonical.com> Wed, 10 Jul 2013 17:12:42 +0200
550+
551 squid3 (3.3.4-1) unstable; urgency=low
552
553 * New upstream release
554@@ -548,6 +1043,92 @@ squid3 (3.1.20-2) unstable; urgency=low
555
556 -- Luigi Gangitano <luigi@debian.org> Thu, 06 Dec 2012 20:02:56 +0100
557
558+squid3 (3.1.20-1ubuntu7) saucy; urgency=low
559+
560+ * debian/tests: Run ftp tests against local vsftpd instead of ftp.ubuntu.com.
561+
562+ -- Yolanda Robla <yolanda.robla@canonical.com> Mon, 17 Jun 2013 11:00:17 +0200
563+
564+squid3 (3.1.20-1ubuntu6) saucy; urgency=low
565+
566+ * debian/tests: Fix start/stop of squid3.
567+
568+ -- Yolanda Robla <yolanda.robla@canonical.com> Mon, 10 Jun 2013 10:30:33 +0200
569+
570+squid3 (3.1.20-1ubuntu5) saucy; urgency=low
571+
572+ * debian/rules: fix FTBFS, removed --with-cppunit-basedir flag
573+
574+ -- Yolanda Robla <yolanda.robla@canonical.com> Mon, 27 May 2013 14:50:11 +0200
575+
576+squid3 (3.1.20-1ubuntu4) saucy; urgency=low
577+
578+ * debian/tests: Add autopkgtest.
579+
580+ -- Yolanda <yolanda.robla@canonical.com> Mon, 27 May 2013 11:24:35 +0200
581+
582+squid3 (3.1.20-1ubuntu3) raring-proposed; urgency=low
583+
584+ * fix FTBFS with newer glibc (LP: #1117517)
585+
586+ -- Jamie Strandboge <jamie@ubuntu.com> Wed, 06 Feb 2013 11:37:29 -0600
587+
588+squid3 (3.1.20-1ubuntu2) raring-proposed; urgency=low
589+
590+ [ Seth Arnold ]
591+ * SECURITY UPDATE: denial of service via cachemgr.cgi insufficient input
592+ validation
593+ - debian/patches/98-CVE-2012-5643.patch: modify cachemgr.cc to properly
594+ free memory and handle input in chunks
595+ - Based on
596+ http://www.squid-cache.org/Versions/v3/3.1/changesets/SQUID-2012_1.patch
597+ - CVE-2012-5643
598+ - CVE-2013-0189
599+
600+ -- Jamie Strandboge <jamie@ubuntu.com> Wed, 06 Feb 2013 09:56:53 -0600
601+
602+squid3 (3.1.20-1ubuntu1) quantal; urgency=low
603+
604+ * Merge from Debian testing (LP: #1016560). Remaining changes:
605+ + debian/control:
606+ - Update maintainer.
607+ - Suggests apparmor (>= 2.3)
608+ - Depends on ssl-cert ((>= 1.0-11ubuntu1)
609+ - Add transitional dummy packages
610+ + debian/squid3.upstart
611+ - Move ulimit command to script section so that it applies
612+ to the started squid daemon. Thanks to Timur Irmatov (LP: 986159)
613+ - Work around squid not handling SIGHUP by adding respawn to
614+ upstart job. (LP: 978356)
615+ + debian/NEWS.Debian: Rename NEWS.debian, add note regarding squid3
616+ transition in 12.04 (LP: 924739)
617+ + debian/rules
618+ - Re-enable all hardening options lost in the squid->squid3
619+ transition (LP: 986314)
620+ + squid3.resolvconf, debian/squid3.postinst, debian/squid3.postrm,
621+ debian/squid3.preinst, debian/squid3.prerm:
622+ - Convert init script to upstart
623+ + debian/patches/99-ubuntu-ssl-cert-snakeoil:
624+ - Use snakeoil certificates.
625+ + debian/logrotate
626+ - Use sar-reports rather than sarg-maint. (LP: 26616)
627+ + debian/patches/90-cf.data.ubuntu.dpatch:
628+ - Add an example refresh pattern for debs.
629+ (foundations-lucid-local-report spec)
630+ + Add disabled by default AppArmor profile (LP: 497790)
631+ - debian/squid3.upstart: load profile in pre-start stanza
632+ - add debian/usr.sbin.squid3 profile
633+ - debian/rules:
634+ + install debian/usr.sbin.squid3, etc/apparmor.d/force-complain and
635+ etc/apparmor.d/disable into $(INSTALLDIR)
636+ + use dh_apparmor
637+ - debian/squid3.install: install etc/apparmor.d/disable, force-complain
638+ and usr.sbin.squid3
639+ - debian/squid3.preinst: disable profile on clean install or upgrades
640+ from earlier than when we shipped the profile
641+
642+ -- Stefan Bader <stefan.bader@canonical.com> Fri, 22 Jun 2012 14:18:00 +0200
643+
644 squid3 (3.1.20-1) unstable; urgency=low
645
646 * New upstream release
647@@ -564,6 +1145,66 @@ squid3 (3.1.20-1) unstable; urgency=low
648
649 -- Luigi Gangitano <luigi@debian.org> Mon, 18 Jun 2012 14:20:53 +0200
650
651+squid3 (3.1.19-1ubuntu5) quantal; urgency=low
652+
653+ * d/squid3.upstart: Work around squid not handling SIGHUP by
654+ adding respawn to upstart job. (LP: #978356)
655+
656+ -- Clint Byrum <clint@ubuntu.com> Tue, 19 Jun 2012 15:35:19 -0700
657+
658+squid3 (3.1.19-1ubuntu4) quantal; urgency=low
659+
660+ * Add disabled by default AppArmor profile (LP: #497790)
661+ - debian/squid3.upstart: load profile in pre-start stanza
662+ - add debian/usr.sbin.squid3 profile
663+ - debian/rules:
664+ + install debian/usr.sbin.squid3, etc/apparmor.d/force-complain and
665+ etc/apparmor.d/disable into $(INSTALLDIR)
666+ + use dh_apparmor
667+ - debian/control: suggests apparmor (>= 2.3)
668+ - debian/squid3.install: install etc/apparmor.d/disable, force-complain
669+ and usr.sbin.squid3
670+ - debian/squid3.preinst: disable profile on clean install or upgrades
671+ from earlier than when we shipped the profile
672+
673+ -- Jamie Strandboge <jamie@ubuntu.com> Wed, 13 Jun 2012 11:32:14 -0500
674+
675+squid3 (3.1.19-1ubuntu3.1) quantal; urgency=low
676+
677+ * debian/rules: re-enable all hardening options lost in the
678+ squid->squid3 transition (LP: #986314)
679+ * debian/squid3.upstart: move ulimit command to script section
680+ so that it applies to the started squid daemon. Thanks to Timur
681+ Irmatov (LP: #986159)
682+
683+ -- Jamie Strandboge <jamie@ubuntu.com> Wed, 13 Jun 2012 09:06:51 -0500
684+
685+squid3 (3.1.19-1ubuntu2) precise; urgency=low
686+
687+ * debian/NEWS.Debian: Rename NEWS.debian, add note regarding squid3
688+ transition in 12.04 (LP: #924739)
689+
690+ -- Adam Gandelman <adamg@canonical.com> Thu, 12 Apr 2012 13:46:10 -0700
691+
692+squid3 (3.1.19-1ubuntu1) precise; urgency=low
693+
694+ * Merge from Debian testing. Remaining changes:
695+ + debian/control:
696+ - Update maintainer.
697+ + debian/squid3.upstart, debian/rules, squid3.resolvconf,
698+ debian/squid3.postinst, debian/squid3.postrm, debian/squid3.preinst,
699+ debian/squid3.prerm: Convert init script to upstart
700+ + debian/control, debian/patches/99-ubuntu-ssl-cert-snakeoil: Use
701+ snakeoil certificates.
702+ + debian/logrotate: Use sar-reports rather than sarg-maint. (LP: 26616)
703+ + debian/patches/90-cf.data.ubuntu.dpatch: Add an example refresh pattern
704+ for debs. (foundations-lucid-local-report spec)
705+ + Add transitional dummy packages
706+ * New upstream bugfix release fixes swap.state corruption, so squid will
707+ now start after a reboot. (LP: #930252)
708+
709+ -- Christopher James Halse Rogers <raof@ubuntu.com> Tue, 21 Feb 2012 18:51:26 +1100
710+
711 squid3 (3.1.19-1) unstable; urgency=low
712
713 * New upstream release
714@@ -575,6 +1216,24 @@ squid3 (3.1.19-1) unstable; urgency=low
715
716 -- Luigi Gangitano <luigi@debian.org> Tue, 07 Feb 2012 16:19:12 +0100
717
718+squid3 (3.1.18-1ubuntu1) precise; urgency=low
719+
720+ [ Ubuntu Merge-o-Matic ]
721+ * Merge from Debian testing. Remaining changes:
722+ + debian/control:
723+ - Update maintainer.
724+ + debian/squid3.upstart, debian/rules, squid3.resolvconf,
725+ debian/squid3.postinst, debian/squid3.postrm, debian/squid3.preinst,
726+ debian/squid3.prerm: Convert init script to upstart
727+ + debian/control, debian/patches/99-ubuntu-ssl-cert-snakeoil: Use
728+ snakeoil certificates.
729+ + debian/logrotate: Use sar-reports rather than sarg-maint. (LP: #26616)
730+ + debian/patches/90-cf.data.ubuntu.dpatch: Add an example refresh pattern
731+ for debs. (foundations-lucid-local-report spec)
732+ + Add transitional dummy packages
733+
734+ -- Chuck Short <zulcss@ubuntu.com> Mon, 30 Jan 2012 10:24:33 -0500
735+
736 squid3 (3.1.18-1) unstable; urgency=low
737
738 * New upstream release
739@@ -584,6 +1243,23 @@ squid3 (3.1.18-1) unstable; urgency=low
740
741 -- Luigi Gangitano <luigi@debian.org> Mon, 26 Dec 2011 22:04:28 +0100
742
743+squid3 (3.1.16-1ubuntu1) precise; urgency=low
744+
745+ * Merge from Debian testing. Remaining changes:
746+ + debian/control:
747+ - Update maintainer.
748+ + debian/squid3.upstart, debian/rules, squid3.resolvconf,
749+ debian/squid3.postinst, debian/squid3.postrm, debian/squid3.preinst,
750+ debian/squid3.prerm: Convert init script to upstart
751+ + debian/control, debian/patches/99-ubuntu-ssl-cert-snakeoil: Use
752+ snakeoil certificates.
753+ + debian/logrotate: Use sar-reports rather than sarg-maint. (LP: #26616)
754+ + debian/patches/90-cf.data.ubuntu.dpatch: Add an example refresh pattern
755+ for debs. (foundations-lucid-local-report spec)
756+ + Add transitional dummy packages
757+
758+ -- Chuck Short <zulcss@ubuntu.com> Mon, 19 Dec 2011 21:35:43 +0000
759+
760 squid3 (3.1.16-1) unstable; urgency=low
761
762 * New upstream release
763@@ -596,6 +1272,40 @@ squid3 (3.1.16-1) unstable; urgency=low
764
765 -- Luigi Gangitano <luigi@debian.org> Thu, 3 Nov 2011 13:37:17 +0100
766
767+squid3 (3.1.15-1ubuntu3) precise; urgency=low
768+
769+ * debian/squid3.upstart: Properly return 0 from maxfds() if $SQUID_MAXFD is
770+ unset, else pre-start will fail as well. Also fix paths to config file.
771+ (LP: #891445)
772+ * debian/squid3.upstart: Modify to better reflect functionality of Debian's
773+ squid3.rc
774+ * debian/rules: Fix permissions on upstart job
775+
776+ -- Adam Gandelman <adamg@canonical.com> Wed, 16 Nov 2011 18:26:25 -0800
777+
778+squid3 (3.1.15-1ubuntu2) precise; urgency=low
779+
780+ * Fix spelling of squid-common transitional package name.
781+ * Remove meaningless self-conflicts.
782+
783+ -- Colin Watson <cjwatson@ubuntu.com> Fri, 11 Nov 2011 10:33:44 +0000
784+
785+squid3 (3.1.15-1ubuntu1) precise; urgency=low
786+
787+ * debian/control:
788+ + Update maintainer.
789+ * debian/squid3.upstart, debian/rules, squid3.resolvconf,
790+ debian/squid3.postinst, debian/squid3.postrm, debian/squid3.preinst,
791+ debian/squid3.prerm: Convert init script to upstart
792+ * debian/control, debian/patches/99-ubuntu-ssl-cert-snakeoil: Use
793+ snakeoil certificates.
794+ * debian/logrotate: Use sar-reports rather than sarg-maint. (LP: #26616)
795+ * debian/patches/90-cf.data.ubuntu.dpatch: Add an example refresh pattern
796+ for debs. (foundations-lucid-local-report spec)
797+ * Add transitional dummy packages.
798+
799+ -- Chuck Short <zulcss@ubuntu.com> Thu, 10 Nov 2011 08:59:31 -0500
800+
801 squid3 (3.1.15-1) unstable; urgency=high
802
803 * Urgency high due to security fixes
804@@ -1341,7 +2051,6 @@ squid3 (3.0.PRE4-1) unstable; urgency=low
805
806 -- Luigi Gangitano <luigi@debian.org> Mon, 3 Jul 2006 16:47:43 +0200
807
808-
809 squid3 (3.0.PRE3.20060422-2) unstable; urgency=low
810
811 * debian/control
812@@ -1354,3 +2063,4 @@ squid3 (3.0.PRE3.20060422-1) unstable; urgency=low
813 * First package attempt
814
815 -- Luigi Gangitano <luigi@debian.org> Sat, 22 Apr 2006 01:19:36 +0200
816+
817diff --git a/debian/control b/debian/control
818index 4535682..169918d 100644
819--- a/debian/control
820+++ b/debian/control
821@@ -1,13 +1,14 @@
822 Source: squid3
823 Section: web
824 Priority: optional
825-Maintainer: Luigi Gangitano <luigi@debian.org>
826+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
827+XSBC-Original-Maintainer: Luigi Gangitano <luigi@debian.org>
828 Uploaders: Santiago Garcia Mantinan <manty@debian.org>
829 Homepage: http://www.squid-cache.org
830 Standards-Version: 3.9.8
831 Vcs-Git: git://anonscm.debian.org/pkg-squid/pkg-squid3.git/
832 Vcs-Browser: https://anonscm.debian.org/git/pkg-squid/pkg-squid3.git/
833-Build-Depends: libldap2-dev, libpam0g-dev, libdb-dev, cdbs, libsasl2-dev, debhelper (>=10), libcppunit-dev, libkrb5-dev, comerr-dev, libcap2-dev [linux-any], libecap3-dev (>= 1.0.1-2), libexpat1-dev, libxml2-dev, autotools-dev, libltdl-dev, dpkg-dev (>= 1.16.1~), pkg-config, libnetfilter-conntrack-dev [linux-any], nettle-dev, libgnutls28-dev, lsb-release
834+Build-Depends: libldap2-dev, libpam0g-dev, libdb-dev, cdbs, libsasl2-dev, debhelper (>=10), libcppunit-dev, libkrb5-dev, comerr-dev, libcap2-dev [linux-any], libecap3-dev (>= 1.0.1-2), libexpat1-dev, libxml2-dev, autotools-dev, libltdl-dev, dpkg-dev (>= 1.16.1~), pkg-config, libnetfilter-conntrack-dev [linux-any], nettle-dev, libgnutls28-dev, lsb-release, dh-apparmor, dh-autoreconf
835 XS-Testsuite: autopkgtest
836
837 Package: squid3
838@@ -25,11 +26,9 @@ Description: Transitional package
839 Package: squid
840 Architecture: any
841 Pre-Depends: adduser
842-Depends: ${shlibs:Depends}, ${misc:Depends}, netbase, logrotate (>= 3.5.4-1), squid-common (>= ${source:Version}), lsb-base, libdbi-perl
843-Suggests: squidclient, squid-cgi, squid-purge, resolvconf (>= 0.40), smbclient, ufw, winbindd
844+Depends: ${shlibs:Depends}, ${misc:Depends}, netbase, logrotate (>= 3.5.4-1), squid-common (>= ${source:Version}), lsb-base, libdbi-perl, ssl-cert
845+Suggests: squidclient, squid-cgi, squid-purge, resolvconf (>= 0.40), smbclient, ufw, winbindd, apparmor
846 Recommends: libcap2-bin [linux-any]
847-Conflicts: squid3 (<< ${binary:Version})
848-Replaces: squid3
849 Description: Full featured Web Proxy cache (HTTP proxy)
850 Squid is a high-performance proxy caching server for web clients, supporting
851 FTP, gopher, ICY and HTTP data objects.
852diff --git a/debian/patches/90-cf.data.ubuntu.patch b/debian/patches/90-cf.data.ubuntu.patch
853new file mode 100644
854index 0000000..86e412c
855--- /dev/null
856+++ b/debian/patches/90-cf.data.ubuntu.patch
857@@ -0,0 +1,12 @@
858+--- a/src/cf.data.pre
859++++ b/src/cf.data.pre
860+@@ -4545,6 +4545,9 @@ NOCOMMENT_START
861+ refresh_pattern ^ftp: 1440 20% 10080
862+ refresh_pattern ^gopher: 1440 0% 1440
863+ refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
864++refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
865++# example lin deb packages
866++#refresh_pattern (\.deb|\.udeb)$ 129600 100% 129600
867+ refresh_pattern . 0 20% 4320
868+ NOCOMMENT_END
869+ DOC_END
870diff --git a/debian/patches/99-ubuntu-ssl-cert-snakeoil.patch b/debian/patches/99-ubuntu-ssl-cert-snakeoil.patch
871new file mode 100644
872index 0000000..d9aa380
873--- /dev/null
874+++ b/debian/patches/99-ubuntu-ssl-cert-snakeoil.patch
875@@ -0,0 +1,22 @@
876+--- a/src/cf.data.pre
877++++ b/src/cf.data.pre
878+@@ -2728,6 +2728,19 @@ DOC_START
879+ If 'sslkey' is not specified 'sslcert' is assumed to
880+ reference a combined file containing both the
881+ certificate and the key.
882++
883++ Notes:
884++
885++ On Debian/Ubuntu systems a default snakeoil certificate is
886++ available in /etc/ssl and users can set:
887++
888++ cert=/etc/ssl/certs/ssl-cert-snakeoil.pem
889++
890++ and
891++
892++ key=/etc/ssl/private/ssl-cert-snakeoil.key
893++
894++ for testing.
895+
896+ sslversion=1|2|3|4|5|6
897+ The SSL version to use when connecting to this peer
898diff --git a/debian/patches/gcc7-assert-wants-boolean.patch b/debian/patches/gcc7-assert-wants-boolean.patch
899new file mode 100644
900index 0000000..507285d
901--- /dev/null
902+++ b/debian/patches/gcc7-assert-wants-boolean.patch
903@@ -0,0 +1,23 @@
904+Origin: https://github.com/squid-cache/squid/commit/286c132b8c067449eefc842c72cdbbcf0a1c54df
905+Author: Amos Jeffries <squid3@treenet.co.nz>
906+Description: assert() takes a boolean
907+ This was extracted from upstream's commit to address the int-in-bool-context
908+ warning.
909+Bug-Ubuntu: https://launchpad.net/bugs/1712668
910+Bug-Debian: https://bugs.debian.org/853668
911+Bug: http://bugs.squid-cache.org/show_bug.cgi?id=4671
912+Last-Update: 2017-08-23
913+
914+diff --git a/src/DiskIO/DiskThreads/aiops.cc b/src/DiskIO/DiskThreads/aiops.cc
915+index b44adfa..e11f948 100644
916+--- a/src/DiskIO/DiskThreads/aiops.cc
917++++ b/src/DiskIO/DiskThreads/aiops.cc
918+@@ -290,7 +290,7 @@ squidaio_init(void)
919+ /* Create threads and get them to sit in their wait loop */
920+ squidaio_thread_pool = memPoolCreate("aio_thread", sizeof(squidaio_thread_t));
921+
922+- assert(NUMTHREADS);
923++ assert(NUMTHREADS != 0);
924+
925+ for (i = 0; i < NUMTHREADS; ++i) {
926+ threadp = (squidaio_thread_t *)squidaio_thread_pool->alloc();
927diff --git a/debian/patches/gcc7-squidpurge-4695.patch b/debian/patches/gcc7-squidpurge-4695.patch
928new file mode 100644
929index 0000000..f3ec0bb
930--- /dev/null
931+++ b/debian/patches/gcc7-squidpurge-4695.patch
932@@ -0,0 +1,29 @@
933+Description: Bug 4695: squidpurge: GCC 7 build errors
934+Origin: https://github.com/squid-cache/squid/commit/6a41367f4985bf1b3fcd3aa32d1dc9d0108ba350
935+Author: Lubos Uhliarik <luhliari@redhat.com>
936+Bug-Ubuntu: https://launchpad.net/bugs/1712668
937+Bug-Debian: https://bugs.debian.org/853668
938+Bug: http://bugs.squid-cache.org/show_bug.cgi?id=4695
939+
940+diff --git a/tools/purge/purge.cc b/tools/purge/purge.cc
941+index 3ef9147..c6d1f73 100644
942+--- a/tools/purge/purge.cc
943++++ b/tools/purge/purge.cc
944+@@ -272,7 +272,7 @@ log_extended( const char* fn, int code, long size, const SquidMetaList* meta )
945+ snprintf( md5, sizeof(md5), "%-32s", "(no_md5_data_available)" );
946+ }
947+
948+- char timeb[64];
949++ char timeb[256];
950+ if ( meta && (findings = meta->search( STORE_META_STD )) ) {
951+ StoreMetaStd temp;
952+ // make data aligned, avoid SIGBUS on RISC machines (ARGH!)
953+@@ -283,7 +283,7 @@ log_extended( const char* fn, int code, long size, const SquidMetaList* meta )
954+ } else if ( meta && (findings = meta->search( STORE_META_STD_LFS )) ) {
955+ StoreMetaStdLFS temp;
956+ // make data aligned, avoid SIGBUS on RISC machines (ARGH!)
957+- memcpy( &temp, findings->data, sizeof(StoreMetaStd) );
958++ memcpy( &temp, findings->data, sizeof(StoreMetaStdLFS) );
959+ snprintf( timeb, sizeof(timeb), "%08lx %08lx %08lx %08lx %04x %5hu ",
960+ (unsigned long)temp.timestamp, (unsigned long)temp.lastref,
961+ (unsigned long)temp.expires, (unsigned long)temp.lastmod, temp.flags, temp.refcount );
962diff --git a/debian/patches/series b/debian/patches/series
963index 1c214dd..fd39da5 100644
964--- a/debian/patches/series
965+++ b/debian/patches/series
966@@ -1,2 +1,6 @@
967+gcc7-squidpurge-4695.patch
968+gcc7-assert-wants-boolean.patch
969 0001-Default-configuration-file-for-debian.patch
970 0002-Change-default-file-locations-for-debian.patch
971+90-cf.data.ubuntu.patch
972+99-ubuntu-ssl-cert-snakeoil.patch
973diff --git a/debian/rules b/debian/rules
974index 7b2322c..e13b0a1 100755
975--- a/debian/rules
976+++ b/debian/rules
977@@ -2,12 +2,15 @@
978
979 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
980 export DEB_CFLAGS_MAINT_APPEND = -Wall
981+# see https://launchpad.net/bugs/1712668
982+export DEB_CXXFLAGS_MAINT_APPEND = -Wno-error=deprecated -Wno-error=format-truncation
983 export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
984 include /usr/share/dpkg/buildflags.mk
985
986 include /usr/share/cdbs/1/rules/debhelper.mk
987 include /usr/share/cdbs/1/class/autotools.mk
988-
989+include /usr/share/cdbs/1/rules/autoreconf.mk
990+
991 INSTALLDIR := $(CURDIR)/debian/tmp
992 datadir=/usr/share/squid
993
994@@ -84,6 +87,10 @@ install/squid::
995 install -m 755 -g root -d $(INSTALLDIR)/usr/share/man/man1
996 mv $(INSTALLDIR)/usr/bin/purge $(INSTALLDIR)/usr/bin/squid-purge
997 install -m 644 -g root debian/squid-purge.8 $(INSTALLDIR)/usr/share/man/man8
998+ install -m 755 -g root -d $(INSTALLDIR)/etc/apparmor.d/force-complain
999+ install -m 755 -g root -d $(INSTALLDIR)/etc/apparmor.d/disable
1000+ install -m 644 -g root debian/usr.sbin.squid $(INSTALLDIR)/etc/apparmor.d
1001+ dh_apparmor --profile-name=usr.sbin.squid -psquid
1002
1003 clean::
1004 # nothing to do
1005diff --git a/debian/squid.install b/debian/squid.install
1006index 0f21217..003ee23 100644
1007--- a/debian/squid.install
1008+++ b/debian/squid.install
1009@@ -26,3 +26,6 @@ usr/share/man/man8/log_db_daemon.8
1010 usr/share/man/man8/negotiate_kerberos_auth.8
1011 usr/share/man/man8/storeid_file_rewrite.8
1012 usr/share/man/man8/squid.8
1013+etc/apparmor.d/disable
1014+etc/apparmor.d/force-complain
1015+etc/apparmor.d/usr.sbin.squid
1016diff --git a/debian/squid.preinst b/debian/squid.preinst
1017index 6b490e0..593ffa9 100644
1018--- a/debian/squid.preinst
1019+++ b/debian/squid.preinst
1020@@ -63,6 +63,21 @@ then
1021 chsh -s /bin/sh proxy
1022 fi
1023
1024+disable_profile() {
1025+ APP_CONFFILE="/etc/apparmor.d/usr.sbin.squid"
1026+ APP_DISABLE="/etc/apparmor.d/disable/usr.sbin.squid"
1027+ # Create a symlink to the yet-to-be-unpacked profile
1028+ if [ ! -e "$APP_CONFFILE" ]; then
1029+ mkdir -p `dirname $APP_DISABLE` 2>/dev/null || true
1030+ ln -sf $APP_CONFFILE $APP_DISABLE
1031+ fi
1032+}
1033+
1034+if [ "$1" = "install" ]; then
1035+ # Disable AppArmor profile on install
1036+ disable_profile
1037+fi
1038+
1039 # dh_installdeb will replace this with shell code automatically
1040 # generated by other debhelper scripts.
1041
1042diff --git a/debian/squid.rc b/debian/squid.rc
1043index 1f459d5..67e6844 100644
1044--- a/debian/squid.rc
1045+++ b/debian/squid.rc
1046@@ -4,8 +4,6 @@
1047 #
1048 # Version: @(#)squid.rc 1.0 07-Jul-2006 luigi@debian.org
1049 #
1050-# pidfile: /var/run/squid.pid
1051-#
1052 ### BEGIN INIT INFO
1053 # Provides: squid
1054 # Required-Start: $network $remote_fs $syslog
1055diff --git a/debian/squid3.postinst b/debian/squid3.postinst
1056index d69744a..02f4ab8 100644
1057--- a/debian/squid3.postinst
1058+++ b/debian/squid3.postinst
1059@@ -32,17 +32,6 @@ if test -d /etc/squid3 && dpkg --compare-versions "$2" lt '3.5'; then
1060 fi
1061 fi
1062
1063-case "$1" in
1064- abort-upgrade|abort-remove|abort-deconfigure)
1065- ;;
1066- *)
1067- #
1068- # Unknown action - do nothing.
1069- #
1070- exit 0
1071- ;;
1072-esac
1073-
1074 # dh_installdeb will replace this with shell code automatically
1075 # generated by other debhelper scripts.
1076
1077diff --git a/debian/squid3.preinst b/debian/squid3.preinst
1078index 848f286..8ab65e1 100644
1079--- a/debian/squid3.preinst
1080+++ b/debian/squid3.preinst
1081@@ -26,14 +26,6 @@ if test -d /etc/squid3 ; then
1082 /etc/squid3/errorpage.css /etc/squid/errorpage.css 3.5.4-1~ squid3 -- "$@"
1083 fi
1084
1085-case "$1" in
1086- upgrade|install-upgrade)
1087- ;;
1088- abort-upgrade)
1089- exit 0
1090- ;;
1091-esac
1092-
1093 # dh_installdeb will replace this with shell code automatically
1094 # generated by other debhelper scripts.
1095
1096diff --git a/debian/tests/control b/debian/tests/control
1097index 0b1e313..4e5b715 100644
1098--- a/debian/tests/control
1099+++ b/debian/tests/control
1100@@ -1,3 +1,7 @@
1101 Tests: upstream-test-suite
1102 Depends: @builddeps@, fakeroot, squid
1103 Restrictions: allow-stderr
1104+
1105+Tests: squid
1106+Depends: squid, squidclient, elinks, netcat, pygopherd, apparmor-utils, vsftpd
1107+Restrictions: needs-root
1108diff --git a/debian/tests/squid b/debian/tests/squid
1109new file mode 100755
1110index 0000000..f17feef
1111--- /dev/null
1112+++ b/debian/tests/squid
1113@@ -0,0 +1,11 @@
1114+#!/bin/bash
1115+#--------------
1116+# Testing squid
1117+#--------------
1118+set -e
1119+
1120+# configure vsftpd
1121+sed -i "s/anonymous_enable[[:blank:]]*=[[:blank:]]*.*/anonymous_enable=YES/g" /etc/vsftpd.conf
1122+echo "seccomp_sandbox=NO" >> /etc/vsftpd.conf
1123+service vsftpd restart 2>&1 > /dev/null
1124+python `dirname $0`/test-squid.py 2>&1
1125diff --git a/debian/tests/test-squid.py b/debian/tests/test-squid.py
1126new file mode 100644
1127index 0000000..943dd9a
1128--- /dev/null
1129+++ b/debian/tests/test-squid.py
1130@@ -0,0 +1,221 @@
1131+#!/usr/bin/python
1132+#
1133+# test-squid.py quality assurance test script
1134+# Copyright (C) 2008-2013 Canonical Ltd.
1135+# Author: Jamie Strandboge <jamie@canonical.com>
1136+#
1137+# This program is free software: you can redistribute it and/or modify
1138+# it under the terms of the GNU General Public License version 2,
1139+# as published by the Free Software Foundation.
1140+#
1141+# This program is distributed in the hope that it will be useful,
1142+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1143+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1144+# GNU General Public License for more details.
1145+#
1146+# You should have received a copy of the GNU General Public License
1147+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1148+#
1149+
1150+'''
1151+ *** IMPORTANT ***
1152+ DO NOT RUN ON A PRODUCTION SERVER.
1153+ *** IMPORTANT ***
1154+
1155+ How to run:
1156+ $ sudo apt-get remove --purge squid
1157+ $ sudo apt-get -y install squid squidclient python-unit elinks netcat
1158+ $ sudo ./test-squid.py -v
1159+
1160+ NOTE:
1161+ The host running this script needs to have access to the internet
1162+
1163+ TODO:
1164+ acls
1165+ ident
1166+ purge (via squidclient)
1167+ ...
1168+ squidguard:
1169+ - test with:
1170+ $ echo "http://blocked.com 1.2.3.4/- - GET -" | squidGuard -c /etc/squid/squidGuard.conf -d
1171+ if using a 'redirect', then the redirect URL is displayed, otherwise
1172+ nothing
1173+ - test block with the following in default acl in squidGuard.conf:
1174+ pass local none
1175+ redirect http://www.example.com/redirected.html
1176+ - test pass with the following in default acl in squidGuard.conf:
1177+ pass local all
1178+ redirect http://www.example.com/redirected.html
1179+ - test domains and urls with something like the following acl:
1180+ dest bad {
1181+ domainlist test/domains
1182+ urllist test/urls
1183+ }
1184+ acl {
1185+ default {
1186+ pass !bad all
1187+ redirect http://www.example.com/redirected.html
1188+ }
1189+ }
1190+
1191+ then create /var/lib/squidguard/db/test/domains with:
1192+ blocked.com
1193+
1194+ Test with:
1195+ $ echo "http://ok.com 1.2.3.4/- - GET -" | squidGuard -c /etc/squid/squidGuard.conf -d
1196+ $ echo "http://blocked.com 1.2.3.4/- - GET -" | squidGuard -c /etc/squid/squidGuard.conf -d
1197+'''
1198+
1199+# QRT-Packages: squid squidclient python-unit elinks netcat pygopherd apparmor-utils
1200+# QRT-Depends: testlib_httpd.py private/qrt/squid.py
1201+
1202+import unittest, subprocess
1203+import os
1204+import sys
1205+import testlib
1206+import testlib_httpd
1207+import time
1208+import tempfile
1209+
1210+try:
1211+ from private.qrt.squid import PrivateSquidTest
1212+except ImportError:
1213+ class PrivateSquidTest(object):
1214+ '''Empty class'''
1215+ print >>sys.stdout, "Skipping private tests"
1216+
1217+class BasicTest(testlib_httpd.HttpdCommon, PrivateSquidTest):
1218+ '''Test basic functionality'''
1219+ def setUp(self):
1220+ '''Setup mechanisms'''
1221+
1222+ # for some reason, squid on maverick is missing the init.d
1223+ # upstart compatibility symlink
1224+ if self.lsb_release['Release'] == 10.10 and not os.path.exists("/etc/init.d/squid"):
1225+ os.symlink("/lib/init/upstart-job", "/etc/init.d/squid")
1226+
1227+ self._set_initscript("/etc/init.d/squid")
1228+ if self.lsb_release['Release'] >= 12.04:
1229+ self._set_initscript("squid")
1230+
1231+ testlib_httpd.HttpdCommon._setUp(self)
1232+
1233+ self.gophermap = "/var/gopher/gophermap"
1234+
1235+ self.aa_profile = "usr.sbin.squid"
1236+ self.aa_abs_profile = "/etc/apparmor.d/%s" % self.aa_profile
1237+ self.version_with_apparmor = 12.10
1238+ # This hack is only used until we have tests run both confined and
1239+ # unconfined
1240+ self.aa_unload_at_teardown = False
1241+
1242+ def tearDown(self):
1243+ '''Shutdown methods'''
1244+ testlib_httpd.HttpdCommon._tearDown(self)
1245+ testlib.config_restore(self.gophermap)
1246+
1247+ def test_daemons(self):
1248+ '''Test daemon'''
1249+ pidfile = "/run/squid.pid"
1250+ exe = "squid"
1251+
1252+ if self.lsb_release['Release'] < 12.04:
1253+ pidfile = "/var/run/squid.pid"
1254+ exe = "squid"
1255+
1256+ self.assertTrue(testlib.check_pidfile(exe, pidfile))
1257+
1258+ def test_http_proxy(self):
1259+ '''Test http'''
1260+ self._test_url_proxy("http://www.ubuntu.com/", "Canonical", "http://localhost:3128/")
1261+
1262+ def test_https_proxy(self):
1263+ '''Test https'''
1264+ self._test_url_proxy("https://wiki.ubuntu.com/", "Community", "http://localhost:3128/")
1265+
1266+ def test_ftp_proxy(self):
1267+ '''Test ftp'''
1268+ self._test_url_proxy("ftp://anonymous@localhost:21", "irectory", "http://localhost:3128/")
1269+
1270+ def test_squidclient(self):
1271+ '''Test squidclient'''
1272+ urls = ['http://www.ubuntu.com/', 'https://wiki.ubuntu.com/', \
1273+ 'ftp://anonymous@localhost:21', 'gopher://127.0.0.1']
1274+
1275+ for url in urls:
1276+ rc, report = testlib.cmd(['squidclient', '-h', '127.0.0.1', '-p', '3128', '-r', url])
1277+ expected = 0
1278+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
1279+ self.assertEquals(expected, rc, result + report)
1280+
1281+ def test_CVE_2011_3205(self):
1282+ '''Test parsing lines > 4096 in length (CVE-2011-3205)'''
1283+
1284+ longline = "ABCDEF" * 4096
1285+
1286+ testlib.config_replace(self.gophermap, """Welcome to Pygopherd! You can place your documents
1287+in /var/gopher for future use. You can remove the gophermap
1288+file there to get rid of this message, or you can edit it to
1289+use other things. (You'll need to do at least one of these
1290+two things in order to get your own data to show up!)
1291+
1292+%s
1293+
1294+Some links to get you started:
1295+
1296+1Pygopherd Home /devel/gopher/pygopherd gopher.quux.org 70
1297+1Quux.Org Mega Server / gopher.quux.org 70
1298+1The Gopher Project /Software/Gopher gopher.quux.org 70
1299+1Traditional UMN Home Gopher / gopher.tc.umn.edu 70
1300+
1301+Welcome to the world of Gopher and enjoy!
1302+""" %(longline), append=False)
1303+
1304+ rc, report = testlib.cmd(['squidclient', '-h', '127.0.0.1', '-p', '3128', '-r', "gopher://127.0.0.1"])
1305+ expected = 0
1306+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
1307+ self.assertEquals(expected, rc, result + report)
1308+
1309+ # Run this last so if we enable the profile then we don't unload it
1310+ def test_zz_apparmor(self):
1311+ '''Test apparmor'''
1312+ if self.lsb_release['Release'] < 12.10:
1313+ self._skipped("No profile in 12.04 and under")
1314+
1315+ self.aa_unload_at_teardown = True
1316+
1317+ # Currently while we have a profile, it is shipped disabled by default.
1318+ # Verify that.
1319+ rc, report = testlib.check_apparmor(self.aa_abs_profile, 12.10, is_running=False)
1320+ expected = 1
1321+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
1322+ self.assertEquals(rc, expected, result + report)
1323+
1324+ # Verify it is syntactically correct
1325+ rc, report = testlib.cmd(['apparmor_parser', '-p', self.aa_abs_profile])
1326+ expected = 0
1327+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
1328+ self.assertEquals(rc, expected, result + report)
1329+
1330+ # Verify it loads ok
1331+ rc, report = testlib.cmd(['aa-enforce', self.aa_abs_profile])
1332+ expected = 0
1333+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
1334+ self.assertEquals(rc, expected, result + report)
1335+
1336+ self._stop()
1337+ self._start()
1338+
1339+ rc, report = testlib.check_apparmor(self.aa_abs_profile, 12.10, is_running=True)
1340+ expected = 1
1341+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
1342+ self.assertEquals(rc, expected, result + report)
1343+
1344+
1345+if __name__ == '__main__':
1346+ suite = unittest.TestSuite()
1347+ suite.addTest(unittest.TestLoader().loadTestsFromTestCase(BasicTest))
1348+
1349+ rc = unittest.TextTestRunner(verbosity=2).run(suite)
1350+ if not rc.wasSuccessful():
1351+ sys.exit(1)
1352diff --git a/debian/tests/testlib.py b/debian/tests/testlib.py
1353new file mode 100644
1354index 0000000..4e51f3d
1355--- /dev/null
1356+++ b/debian/tests/testlib.py
1357@@ -0,0 +1,1133 @@
1358+#
1359+# testlib.py quality assurance test script
1360+# Copyright (C) 2008-2011 Canonical Ltd.
1361+#
1362+# This library is free software; you can redistribute it and/or
1363+# modify it under the terms of the GNU Library General Public
1364+# License as published by the Free Software Foundation; either
1365+# version 2 of the License.
1366+#
1367+# This library is distributed in the hope that it will be useful,
1368+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1369+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1370+# Library General Public License for more details.
1371+#
1372+# You should have received a copy of the GNU Library General Public
1373+# License along with this program. If not, see
1374+# <http://www.gnu.org/licenses/>.
1375+#
1376+
1377+'''Common classes and functions for package tests.'''
1378+
1379+import string, random, crypt, subprocess, pwd, grp, signal, time, unittest, tempfile, shutil, os, os.path, re, glob
1380+import sys, socket, gzip
1381+from stat import *
1382+from encodings import string_escape
1383+
1384+import warnings
1385+warnings.filterwarnings('ignore', message=r'.*apt_pkg\.TagFile.*', category=DeprecationWarning)
1386+try:
1387+ import apt_pkg
1388+ apt_pkg.InitSystem();
1389+except:
1390+ # On non-Debian system, fall back to simple comparison without debianisms
1391+ class apt_pkg(object):
1392+ def VersionCompare(one, two):
1393+ list_one = one.split('.')
1394+ list_two = two.split('.')
1395+ while len(list_one)>0 and len(list_two)>0:
1396+ if list_one[0] > list_two[0]:
1397+ return 1
1398+ if list_one[0] < list_two[0]:
1399+ return -1
1400+ list_one.pop(0)
1401+ list_two.pop(0)
1402+ return 0
1403+
1404+bogus_nxdomain = "208.69.32.132"
1405+
1406+# http://www.chiark.greenend.org.uk/ucgi/~cjwatson/blosxom/2009-07-02-python-sigpipe.html
1407+# This is needed so that the subprocesses that produce endless output
1408+# actually quit when the reader goes away.
1409+import signal
1410+def subprocess_setup():
1411+ # Python installs a SIGPIPE handler by default. This is usually not what
1412+ # non-Python subprocesses expect.
1413+ signal.signal(signal.SIGPIPE, signal.SIG_DFL)
1414+
1415+class TimedOutException(Exception):
1416+ def __init__(self, value = "Timed Out"):
1417+ self.value = value
1418+ def __str__(self):
1419+ return repr(self.value)
1420+
1421+def _restore_backup(path):
1422+ pathbackup = path + '.autotest'
1423+ if os.path.exists(pathbackup):
1424+ shutil.move(pathbackup, path)
1425+
1426+def _save_backup(path):
1427+ pathbackup = path + '.autotest'
1428+ if os.path.exists(path) and not os.path.exists(pathbackup):
1429+ shutil.copy2(path, pathbackup)
1430+ # copy2 does not copy ownership, so do it here.
1431+ # Reference: http://docs.python.org/library/shutil.html
1432+ a = os.stat(path)
1433+ os.chown(pathbackup, a[4], a[5])
1434+
1435+def config_copydir(path):
1436+ if os.path.exists(path) and not os.path.isdir(path):
1437+ raise OSError, "'%s' is not a directory" % (path)
1438+ _restore_backup(path)
1439+
1440+ pathbackup = path + '.autotest'
1441+ if os.path.exists(path):
1442+ shutil.copytree(path, pathbackup, symlinks=True)
1443+
1444+def config_replace(path,contents,append=False):
1445+ '''Replace (or append) to a config file'''
1446+ _restore_backup(path)
1447+ if os.path.exists(path):
1448+ _save_backup(path)
1449+ if append:
1450+ contents = file(path).read() + contents
1451+ open(path, 'w').write(contents)
1452+
1453+def config_comment(path, field):
1454+ _save_backup(path)
1455+ contents = ""
1456+ for line in file(path):
1457+ if re.search("^\s*%s\s*=" % (field), line):
1458+ line = "#" + line
1459+ contents += line
1460+
1461+ open(path+'.new', 'w').write(contents)
1462+ os.rename(path+'.new', path)
1463+
1464+def config_set(path, field, value, spaces=True):
1465+ _save_backup(path)
1466+ contents = ""
1467+ if spaces==True:
1468+ setting = '%s = %s\n' % (field, value)
1469+ else:
1470+ setting = '%s=%s\n' % (field, value)
1471+ found = False
1472+ for line in file(path):
1473+ if re.search("^\s*%s\s*=" % (field), line):
1474+ found = True
1475+ line = setting
1476+ contents += line
1477+ if not found:
1478+ contents += setting
1479+
1480+ open(path+'.new', 'w').write(contents)
1481+ os.rename(path+'.new', path)
1482+
1483+def config_patch(path, patch, depth=1):
1484+ '''Patch a config file'''
1485+ _restore_backup(path)
1486+ _save_backup(path)
1487+
1488+ handle, name = mkstemp_fill(patch)
1489+ rc = subprocess.call(['/usr/bin/patch', '-p%s' %(depth), path], stdin=handle, stdout=subprocess.PIPE)
1490+ os.unlink(name)
1491+ if rc != 0:
1492+ raise Exception("Patch failed")
1493+
1494+def config_restore(path):
1495+ '''Rename a replaced config file back to its initial state'''
1496+ _restore_backup(path)
1497+
1498+def timeout(secs, f, *args):
1499+ def handler(signum, frame):
1500+ raise TimedOutException()
1501+
1502+ old = signal.signal(signal.SIGALRM, handler)
1503+ result = None
1504+ signal.alarm(secs)
1505+ try:
1506+ result = f(*args)
1507+ finally:
1508+ signal.alarm(0)
1509+ signal.signal(signal.SIGALRM, old)
1510+
1511+ return result
1512+
1513+def require_nonroot():
1514+ if os.geteuid() == 0:
1515+ print >>sys.stderr, "This series of tests should be run as a regular user with sudo access, not as root."
1516+ sys.exit(1)
1517+
1518+def require_root():
1519+ if os.geteuid() != 0:
1520+ print >>sys.stderr, "This series of tests should be run with root privileges (e.g. via sudo)."
1521+ sys.exit(1)
1522+
1523+def require_sudo():
1524+ if os.geteuid() != 0 or os.environ.get('SUDO_USER', None) == None:
1525+ print >>sys.stderr, "This series of tests must be run under sudo."
1526+ sys.exit(1)
1527+ if os.environ['SUDO_USER'] == 'root':
1528+ print >>sys.stderr, 'Please run this test using sudo from a regular user. (You ran sudo from root.)'
1529+ sys.exit(1)
1530+
1531+def random_string(length,lower=False):
1532+ '''Return a random string, consisting of ASCII letters, with given
1533+ length.'''
1534+
1535+ s = ''
1536+ selection = string.letters
1537+ if lower:
1538+ selection = string.lowercase
1539+ maxind = len(selection)-1
1540+ for l in range(length):
1541+ s += selection[random.randint(0, maxind)]
1542+ return s
1543+
1544+def mkstemp_fill(contents,suffix='',prefix='testlib-',dir=None):
1545+ '''As tempfile.mkstemp does, return a (file, name) pair, but with
1546+ prefilled contents.'''
1547+
1548+ handle, name = tempfile.mkstemp(suffix=suffix,prefix=prefix,dir=dir)
1549+ os.close(handle)
1550+ handle = file(name,"w+")
1551+ handle.write(contents)
1552+ handle.flush()
1553+ handle.seek(0)
1554+
1555+ return handle, name
1556+
1557+def create_fill(path, contents, mode=0644):
1558+ '''Safely create a page'''
1559+ # make the temp file in the same dir as the destination file so we
1560+ # don't get invalid cross-device link errors when we rename
1561+ handle, name = mkstemp_fill(contents, dir=os.path.dirname(path))
1562+ handle.close()
1563+ os.rename(name, path)
1564+ os.chmod(path, mode)
1565+
1566+def login_exists(login):
1567+ '''Checks whether the given login exists on the system.'''
1568+
1569+ try:
1570+ pwd.getpwnam(login)
1571+ return True
1572+ except KeyError:
1573+ return False
1574+
1575+def group_exists(group):
1576+ '''Checks whether the given login exists on the system.'''
1577+
1578+ try:
1579+ grp.getgrnam(group)
1580+ return True
1581+ except KeyError:
1582+ return False
1583+
1584+def recursive_rm(dirPath, contents_only=False):
1585+ '''recursively remove directory'''
1586+ names = os.listdir(dirPath)
1587+ for name in names:
1588+ path = os.path.join(dirPath, name)
1589+ if os.path.islink(path) or not os.path.isdir(path):
1590+ os.unlink(path)
1591+ else:
1592+ recursive_rm(path)
1593+ if contents_only == False:
1594+ os.rmdir(dirPath)
1595+
1596+def check_pidfile(exe, pidfile):
1597+ '''Checks if pid in pidfile is running'''
1598+ if not os.path.exists(pidfile):
1599+ return False
1600+
1601+ # get the pid
1602+ try:
1603+ fd = open(pidfile, 'r')
1604+ pid = fd.readline().rstrip('\n')
1605+ fd.close()
1606+ except:
1607+ return False
1608+
1609+ return check_pid(exe, pid)
1610+
1611+def check_pid(exe, pid):
1612+ '''Checks if pid is running'''
1613+
1614+ exelink = "/proc/%s/exe" % (str(pid))
1615+ if not os.path.exists(exelink):
1616+ return False
1617+ pidexe = os.path.basename(os.readlink(exelink))
1618+ if pidexe == exe:
1619+ return True
1620+ sys.stderr.write('check_pid(%s): expected %s, got %s' % (pid, exe, pidexe))
1621+ return False
1622+
1623+def check_port(port, proto, ver=4):
1624+ '''Check if something is listening on the specified port.
1625+ WARNING: for some reason this does not work with a bind mounted /proc
1626+ '''
1627+ assert (port >= 1)
1628+ assert (port <= 65535)
1629+ assert (proto.lower() == "tcp" or proto.lower() == "udp")
1630+ assert (ver == 4 or ver == 6)
1631+
1632+ fn = "/proc/net/%s" % (proto)
1633+ if ver == 6:
1634+ fn += str(ver)
1635+
1636+ rc, report = cmd(['cat', fn])
1637+ assert (rc == 0)
1638+
1639+ hport = "%0.4x" % port
1640+
1641+ if re.search(': [0-9a-f]{8}:%s [0-9a-f]' % str(hport).lower(), report.lower()):
1642+ return True
1643+ return False
1644+
1645+def get_arch():
1646+ '''Get the current architecture'''
1647+ rc, report = cmd(['uname', '-m'])
1648+ assert (rc == 0)
1649+ return report.strip()
1650+
1651+def get_memory():
1652+ '''Gets total ram and swap'''
1653+ meminfo = "/proc/meminfo"
1654+ memtotal = 0
1655+ swaptotal = 0
1656+ if not os.path.exists(meminfo):
1657+ return (False, False)
1658+
1659+ try:
1660+ fd = open(meminfo, 'r')
1661+ for line in fd.readlines():
1662+ splitline = line.split()
1663+ if splitline[0] == 'MemTotal:':
1664+ memtotal = int(splitline[1])
1665+ elif splitline[0] == 'SwapTotal:':
1666+ swaptotal = int(splitline[1])
1667+ fd.close()
1668+ except:
1669+ return (False, False)
1670+
1671+ return (memtotal,swaptotal)
1672+
1673+def is_running_in_vm():
1674+ '''Check if running under a VM'''
1675+ # add other virtualization environments here
1676+ for search in ['QEMU Virtual CPU']:
1677+ rc, report = cmd_pipe(['dmesg'], ['grep', search])
1678+ if rc == 0:
1679+ return True
1680+ return False
1681+
1682+def ubuntu_release():
1683+ '''Get the Ubuntu release'''
1684+ f = "/etc/lsb-release"
1685+ try:
1686+ size = os.stat(f)[ST_SIZE]
1687+ except:
1688+ return "UNKNOWN"
1689+
1690+ if size > 1024*1024:
1691+ raise IOError, 'Could not open "%s" (too big)' % f
1692+
1693+ try:
1694+ fh = open("/etc/lsb-release", 'r')
1695+ except:
1696+ raise
1697+
1698+ lines = fh.readlines()
1699+ fh.close()
1700+
1701+ pat = re.compile(r'DISTRIB_CODENAME')
1702+ for line in lines:
1703+ if pat.search(line):
1704+ return line.split('=')[1].rstrip('\n').rstrip('\r')
1705+
1706+ return "UNKNOWN"
1707+
1708+def cmd(command, input = None, stderr = subprocess.STDOUT, stdout = subprocess.PIPE, stdin = None, timeout = None):
1709+ '''Try to execute given command (array) and return its stdout, or return
1710+ a textual error if it failed.'''
1711+
1712+ try:
1713+ sp = subprocess.Popen(command, stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True, preexec_fn=subprocess_setup)
1714+ except OSError, e:
1715+ return [127, str(e)]
1716+
1717+ out, outerr = sp.communicate(input)
1718+ # Handle redirection of stdout
1719+ if out == None:
1720+ out = ''
1721+ # Handle redirection of stderr
1722+ if outerr == None:
1723+ outerr = ''
1724+ return [sp.returncode,out+outerr]
1725+
1726+def cmd_pipe(command1, command2, input = None, stderr = subprocess.STDOUT, stdin = None):
1727+ '''Try to pipe command1 into command2.'''
1728+ try:
1729+ sp1 = subprocess.Popen(command1, stdin=stdin, stdout=subprocess.PIPE, stderr=stderr, close_fds=True)
1730+ sp2 = subprocess.Popen(command2, stdin=sp1.stdout, stdout=subprocess.PIPE, stderr=stderr, close_fds=True)
1731+ except OSError, e:
1732+ return [127, str(e)]
1733+
1734+ out = sp2.communicate(input)[0]
1735+ return [sp2.returncode,out]
1736+
1737+def cwd_has_enough_space(cdir, total_bytes):
1738+ '''Determine if the partition of the current working directory has 'bytes'
1739+ free.'''
1740+ rc, df_output = cmd(['df'])
1741+ result = 'Got exit code %d, expected %d\n' % (rc, 0)
1742+ if rc != 0:
1743+ return False
1744+
1745+ kb = total_bytes / 1024
1746+
1747+ mounts = dict()
1748+ for line in df_output.splitlines():
1749+ if '/' not in line:
1750+ continue
1751+ tmp = line.split()
1752+ mounts[tmp[5]] = int(tmp[3])
1753+
1754+ cdir = os.getcwd()
1755+ while cdir != '/':
1756+ if not mounts.has_key(cdir):
1757+ cdir = os.path.dirname(cdir)
1758+ continue
1759+ if kb < mounts[cdir]:
1760+ return True
1761+ else:
1762+ return False
1763+
1764+ if kb < mounts['/']:
1765+ return True
1766+
1767+ return False
1768+
1769+def get_md5(filename):
1770+ '''Gets the md5sum of the file specified'''
1771+
1772+ (rc, report) = cmd(["/usr/bin/md5sum", "-b", filename])
1773+ expected = 0
1774+ assert (expected == rc)
1775+
1776+ return report.split(' ')[0]
1777+
1778+def dpkg_compare_installed_version(pkg, check, version):
1779+ '''Gets the version for the installed package, and compares it to the
1780+ specified version.
1781+ '''
1782+ (rc, report) = cmd(["/usr/bin/dpkg", "-s", pkg])
1783+ assert (rc == 0)
1784+ assert ("Status: install ok installed" in report)
1785+ installed_version = ""
1786+ for line in report.splitlines():
1787+ if line.startswith("Version: "):
1788+ installed_version = line.split()[1]
1789+
1790+ assert (installed_version != "")
1791+
1792+ (rc, report) = cmd(["/usr/bin/dpkg", "--compare-versions", installed_version, check, version])
1793+ assert (rc == 0 or rc == 1)
1794+ if rc == 0:
1795+ return True
1796+ return False
1797+
1798+def prepare_source(source, builder, cached_src, build_src, patch_system):
1799+ '''Download and unpack source package, installing necessary build depends,
1800+ adjusting the permissions for the 'builder' user, and returning the
1801+ directory of the unpacked source. Patch system can be one of:
1802+ - cdbs
1803+ - dpatch
1804+ - quilt
1805+ - quiltv3
1806+ - None (not the string)
1807+
1808+ This is normally used like this:
1809+
1810+ def setUp(self):
1811+ ...
1812+ self.topdir = os.getcwd()
1813+ self.cached_src = os.path.join(os.getcwd(), "source")
1814+ self.tmpdir = tempfile.mkdtemp(prefix='testlib', dir='/tmp')
1815+ self.builder = testlib.TestUser()
1816+ testlib.cmd(['chgrp', self.builder.login, self.tmpdir])
1817+ os.chmod(self.tmpdir, 0775)
1818+
1819+ def tearDown(self):
1820+ ...
1821+ self.builder = None
1822+ self.topdir = os.getcwd()
1823+ if os.path.exists(self.tmpdir):
1824+ testlib.recursive_rm(self.tmpdir)
1825+
1826+ def test_suite_build(self):
1827+ ...
1828+ build_dir = testlib.prepare_source('foo', \
1829+ self.builder, \
1830+ self.cached_src, \
1831+ os.path.join(self.tmpdir, \
1832+ os.path.basename(self.cached_src)),
1833+ "quilt")
1834+ os.chdir(build_dir)
1835+
1836+ # Example for typical build, adjust as necessary
1837+ print ""
1838+ print " make clean"
1839+ rc, report = testlib.cmd(['sudo', '-u', self.builder.login, 'make', 'clean'])
1840+
1841+ print " configure"
1842+ rc, report = testlib.cmd(['sudo', '-u', self.builder.login, './configure', '--prefix=%s' % self.tmpdir, '--enable-debug'])
1843+
1844+ print " make (will take a while)"
1845+ rc, report = testlib.cmd(['sudo', '-u', self.builder.login, 'make'])
1846+
1847+ print " make check (will take a while)",
1848+ rc, report = testlib.cmd(['sudo', '-u', self.builder.login, 'make', 'check'])
1849+ expected = 0
1850+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
1851+ self.assertEquals(expected, rc, result + report)
1852+
1853+ def test_suite_cleanup(self):
1854+ ...
1855+ if os.path.exists(self.cached_src):
1856+ testlib.recursive_rm(self.cached_src)
1857+
1858+ It is up to the caller to clean up cached_src and build_src (as in the
1859+ above example, often the build_src is in a tmpdir that is cleaned in
1860+ tearDown() and the cached_src is cleaned in a one time clean-up
1861+ operation (eg 'test_suite_cleanup()) which must be run after the build
1862+ suite test (obviously).
1863+ '''
1864+
1865+ # Make sure we have a clean slate
1866+ assert (os.path.exists(os.path.dirname(build_src)))
1867+ assert (not os.path.exists(build_src))
1868+
1869+ cdir = os.getcwd()
1870+ if os.path.exists(cached_src):
1871+ shutil.copytree(cached_src, build_src)
1872+ os.chdir(build_src)
1873+ else:
1874+ # Only install the build dependencies on the initial setup
1875+ rc, report = cmd(['apt-get','-y','--force-yes','build-dep',source])
1876+ assert (rc == 0)
1877+
1878+ os.makedirs(build_src)
1879+ os.chdir(build_src)
1880+
1881+ # These are always needed
1882+ pkgs = ['build-essential', 'dpkg-dev', 'fakeroot']
1883+ rc, report = cmd(['apt-get','-y','--force-yes','install'] + pkgs)
1884+ assert (rc == 0)
1885+
1886+ rc, report = cmd(['apt-get','source',source])
1887+ assert (rc == 0)
1888+ shutil.copytree(build_src, cached_src)
1889+
1890+ unpacked_dir = os.path.join(build_src, glob.glob('%s-*' % source)[0])
1891+
1892+ # Now apply the patches. Do it here so that we don't mess up our cached
1893+ # sources.
1894+ os.chdir(unpacked_dir)
1895+ assert (patch_system in ['cdbs', 'dpatch', 'quilt', 'quiltv3', None])
1896+ if patch_system != None and patch_system != "quiltv3":
1897+ if patch_system == "quilt":
1898+ os.environ.setdefault('QUILT_PATCHES','debian/patches')
1899+ rc, report = cmd(['quilt', 'push', '-a'])
1900+ assert (rc == 0)
1901+ elif patch_system == "cdbs":
1902+ rc, report = cmd(['./debian/rules', 'apply-patches'])
1903+ assert (rc == 0)
1904+ elif patch_system == "dpatch":
1905+ rc, report = cmd(['dpatch', 'apply-all'])
1906+ assert (rc == 0)
1907+
1908+ cmd(['chown', '-R', '%s:%s' % (builder.uid, builder.gid), build_src])
1909+ os.chdir(cdir)
1910+
1911+ return unpacked_dir
1912+
1913+def _aa_status():
1914+ '''Get aa-status output'''
1915+ exe = "/usr/sbin/aa-status"
1916+ assert (os.path.exists(exe))
1917+ if os.geteuid() == 0:
1918+ return cmd([exe])
1919+ return cmd(['sudo', exe])
1920+
1921+def is_apparmor_loaded(path):
1922+ '''Check if profile is loaded'''
1923+ rc, report = _aa_status()
1924+ if rc != 0:
1925+ return False
1926+
1927+ for line in report.splitlines():
1928+ if line.endswith(path):
1929+ return True
1930+ return False
1931+
1932+def is_apparmor_confined(path):
1933+ '''Check if application is confined'''
1934+ rc, report = _aa_status()
1935+ if rc != 0:
1936+ return False
1937+
1938+ for line in report.splitlines():
1939+ if re.search('%s \(' % path, line):
1940+ return True
1941+ return False
1942+
1943+def check_apparmor(path, first_ubuntu_release, is_running=True):
1944+ '''Check if path is loaded and confined for everything higher than the
1945+ first Ubuntu release specified.
1946+
1947+ Usage:
1948+ rc, report = testlib.check_apparmor('/usr/sbin/foo', 8.04, is_running=True)
1949+ if rc < 0:
1950+ return self._skipped(report)
1951+
1952+ expected = 0
1953+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
1954+ self.assertEquals(expected, rc, result + report)
1955+ '''
1956+ global manager
1957+ rc = -1
1958+
1959+ if manager.lsb_release["Release"] < first_ubuntu_release:
1960+ return (rc, "Skipped apparmor check")
1961+
1962+ if not os.path.exists('/sbin/apparmor_parser'):
1963+ return (rc, "Skipped (couldn't find apparmor_parser)")
1964+
1965+ rc = 0
1966+ msg = ""
1967+ if not is_apparmor_loaded(path):
1968+ rc = 1
1969+ msg = "Profile not loaded for '%s'" % path
1970+
1971+ # this check only makes sense it the 'path' is currently executing
1972+ if is_running and rc == 0 and not is_apparmor_confined(path):
1973+ rc = 1
1974+ msg = "'%s' is not running in enforce mode" % path
1975+
1976+ return (rc, msg)
1977+
1978+def get_gcc_version(gcc, full=True):
1979+ gcc_version = 'none'
1980+ if not gcc.startswith('/'):
1981+ gcc = '/usr/bin/%s' % (gcc)
1982+ if os.path.exists(gcc):
1983+ gcc_version = 'unknown'
1984+ lines = cmd([gcc,'-v'])[1].strip().splitlines()
1985+ version_lines = [x for x in lines if x.startswith('gcc version')]
1986+ if len(version_lines) == 1:
1987+ gcc_version = " ".join(version_lines[0].split()[2:])
1988+ if not full:
1989+ return gcc_version.split()[0]
1990+ return gcc_version
1991+
1992+def is_kdeinit_running():
1993+ '''Test if kdeinit is running'''
1994+ # applications that use kdeinit will spawn it if it isn't running in the
1995+ # test. This is a problem because it does not exit. This is a helper to
1996+ # check for it.
1997+ rc, report = cmd(['ps', 'x'])
1998+ if 'kdeinit4 Running' not in report:
1999+ print >>sys.stderr, ("kdeinit not running (you may start/stop any KDE application then run this script again)")
2000+ return False
2001+ return True
2002+
2003+def get_pkgconfig_flags(libs=[]):
2004+ '''Find pkg-config flags for libraries'''
2005+ assert (len(libs) > 0)
2006+ rc, pkg_config = cmd(['pkg-config', '--cflags', '--libs'] + libs)
2007+ expected = 0
2008+ if rc != expected:
2009+ print >>sys.stderr, 'Got exit code %d, expected %d\n' % (rc, expected)
2010+ assert(rc == expected)
2011+ return pkg_config.split()
2012+
2013+class TestDaemon:
2014+ '''Helper class to manage daemons consistently'''
2015+ def __init__(self, init):
2016+ '''Setup daemon attributes'''
2017+ self.initscript = init
2018+
2019+ def start(self):
2020+ '''Start daemon'''
2021+ rc, report = cmd([self.initscript, 'start'])
2022+ expected = 0
2023+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
2024+ time.sleep(2)
2025+ if expected != rc:
2026+ return (False, result + report)
2027+
2028+ if "fail" in report:
2029+ return (False, "Found 'fail' in report\n" + report)
2030+
2031+ return (True, "")
2032+
2033+ def stop(self):
2034+ '''Stop daemon'''
2035+ rc, report = cmd([self.initscript, 'stop'])
2036+ expected = 0
2037+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
2038+ if expected != rc:
2039+ return (False, result + report)
2040+
2041+ if "fail" in report:
2042+ return (False, "Found 'fail' in report\n" + report)
2043+
2044+ return (True, "")
2045+
2046+ def reload(self):
2047+ '''Reload daemon'''
2048+ rc, report = cmd([self.initscript, 'force-reload'])
2049+ expected = 0
2050+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
2051+ if expected != rc:
2052+ return (False, result + report)
2053+
2054+ if "fail" in report:
2055+ return (False, "Found 'fail' in report\n" + report)
2056+
2057+ return (True, "")
2058+
2059+ def restart(self):
2060+ '''Restart daemon'''
2061+ (res, str) = self.stop()
2062+ if not res:
2063+ return (res, str)
2064+
2065+ (res, str) = self.start()
2066+ if not res:
2067+ return (res, str)
2068+
2069+ return (True, "")
2070+
2071+ def status(self):
2072+ '''Check daemon status'''
2073+ rc, report = cmd([self.initscript, 'status'])
2074+ expected = 0
2075+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
2076+ if expected != rc:
2077+ return (False, result + report)
2078+
2079+ if "fail" in report:
2080+ return (False, "Found 'fail' in report\n" + report)
2081+
2082+ return (True, "")
2083+
2084+class TestlibManager(object):
2085+ '''Singleton class used to set up per-test-run information'''
2086+ def __init__(self):
2087+ # Set glibc aborts to dump to stderr instead of the tty so test output
2088+ # is more sane.
2089+ os.environ.setdefault('LIBC_FATAL_STDERR_','1')
2090+
2091+ # check verbosity
2092+ self.verbosity = False
2093+ if (len(sys.argv) > 1 and '-v' in sys.argv[1:]):
2094+ self.verbosity = True
2095+
2096+ # Load LSB release file
2097+ self.lsb_release = dict()
2098+ if not os.path.exists('/usr/bin/lsb_release') and not os.path.exists('/bin/lsb_release'):
2099+ raise OSError, "Please install 'lsb-release'"
2100+ for line in subprocess.Popen(['lsb_release','-a'],stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()[0].splitlines():
2101+ field, value = line.split(':',1)
2102+ value=value.strip()
2103+ field=field.strip()
2104+ # Convert numerics
2105+ try:
2106+ value = float(value)
2107+ except:
2108+ pass
2109+ self.lsb_release.setdefault(field,value)
2110+
2111+ # FIXME: hack OEM releases into known-Ubuntu versions
2112+ if self.lsb_release['Distributor ID'] == "HP MIE (Mobile Internet Experience)":
2113+ if self.lsb_release['Release'] == 1.0:
2114+ self.lsb_release['Distributor ID'] = "Ubuntu"
2115+ self.lsb_release['Release'] = 8.04
2116+ else:
2117+ raise OSError, "Unknown version of HP MIE"
2118+
2119+ # FIXME: hack to assume a most-recent release if we're not
2120+ # running under Ubuntu.
2121+ if self.lsb_release['Distributor ID'] not in ["Ubuntu","Linaro"]:
2122+ self.lsb_release['Release'] = 10000
2123+ # Adjust Linaro release to pretend to be Ubuntu
2124+ if self.lsb_release['Distributor ID'] in ["Linaro"]:
2125+ self.lsb_release['Distributor ID'] = "Ubuntu"
2126+ self.lsb_release['Release'] -= 0.01
2127+
2128+ # Load arch
2129+ if not os.path.exists('/usr/bin/dpkg'):
2130+ machine = cmd(['uname','-m'])[1].strip()
2131+ if machine.endswith('86'):
2132+ self.dpkg_arch = 'i386'
2133+ elif machine.endswith('_64'):
2134+ self.dpkg_arch = 'amd64'
2135+ elif machine.startswith('arm'):
2136+ self.dpkg_arch = 'armel'
2137+ else:
2138+ raise ValueError, "Unknown machine type '%s'" % (machine)
2139+ else:
2140+ self.dpkg_arch = cmd(['dpkg','--print-architecture'])[1].strip()
2141+
2142+ # Find kernel version
2143+ self.kernel_is_ubuntu = False
2144+ self.kernel_version_signature = None
2145+ self.kernel_version = cmd(["uname","-r"])[1].strip()
2146+ versig = '/proc/version_signature'
2147+ if os.path.exists(versig):
2148+ self.kernel_is_ubuntu = True
2149+ self.kernel_version_signature = file(versig).read().strip()
2150+ self.kernel_version_ubuntu = self.kernel_version
2151+ elif os.path.exists('/usr/bin/dpkg'):
2152+ # this can easily be inaccurate but is only an issue for Dapper
2153+ rc, out = cmd(['dpkg','-l','linux-image-%s' % (self.kernel_version)])
2154+ if rc == 0:
2155+ self.kernel_version_signature = out.strip().split('\n').pop().split()[2]
2156+ self.kernel_version_ubuntu = self.kernel_version_signature
2157+ if self.kernel_version_signature == None:
2158+ # Attempt to fall back to something for non-Debian-based
2159+ self.kernel_version_signature = self.kernel_version
2160+ self.kernel_version_ubuntu = self.kernel_version
2161+ # Build ubuntu version without hardware suffix
2162+ try:
2163+ self.kernel_version_ubuntu = "-".join([x for x in self.kernel_version_signature.split(' ')[1].split('-') if re.search('^[0-9]', x)])
2164+ except:
2165+ pass
2166+
2167+ # Find gcc version
2168+ self.gcc_version = get_gcc_version('gcc')
2169+
2170+ # Find libc
2171+ self.path_libc = [x.split()[2] for x in cmd(['ldd','/bin/ls'])[1].splitlines() if x.startswith('\tlibc.so.')][0]
2172+
2173+ # Report self
2174+ if self.verbosity:
2175+ kernel = self.kernel_version_ubuntu
2176+ if kernel != self.kernel_version_signature:
2177+ kernel += " (%s)" % (self.kernel_version_signature)
2178+ print >>sys.stdout, "Running test: '%s' distro: '%s %.2f' kernel: '%s' arch: '%s' uid: %d/%d SUDO_USER: '%s')" % ( \
2179+ sys.argv[0],
2180+ self.lsb_release['Distributor ID'],
2181+ self.lsb_release['Release'],
2182+ kernel,
2183+ self.dpkg_arch,
2184+ os.geteuid(), os.getuid(),
2185+ os.environ.get('SUDO_USER', ''))
2186+ sys.stdout.flush()
2187+
2188+ # Additional heuristics
2189+ #if os.environ.get('SUDO_USER', os.environ.get('USER', '')) in ['mdeslaur']:
2190+ # sys.stdout.write("Replying to Marc Deslauriers in http://launchpad.net/bugs/%d: " % random.randint(600000, 980000))
2191+ # sys.stdout.flush()
2192+ # time.sleep(0.5)
2193+ # sys.stdout.write("destroyed\n")
2194+ # time.sleep(0.5)
2195+
2196+ def hello(self, msg):
2197+ print >>sys.stderr, "Hello from %s" % (msg)
2198+# The central instance
2199+manager = TestlibManager()
2200+
2201+class TestlibCase(unittest.TestCase):
2202+ def __init__(self, *args):
2203+ '''This is called for each TestCase test instance, which isn't much better
2204+ than SetUp.'''
2205+
2206+ unittest.TestCase.__init__(self, *args)
2207+
2208+ # Attach to and duplicate dicts from manager singleton
2209+ self.manager = manager
2210+ #self.manager.hello(repr(self) + repr(*args))
2211+ self.my_verbosity = self.manager.verbosity
2212+ self.lsb_release = self.manager.lsb_release
2213+ self.dpkg_arch = self.manager.dpkg_arch
2214+ self.kernel_version = self.manager.kernel_version
2215+ self.kernel_version_signature = self.manager.kernel_version_signature
2216+ self.kernel_version_ubuntu = self.manager.kernel_version_ubuntu
2217+ self.kernel_is_ubuntu = self.manager.kernel_is_ubuntu
2218+ self.gcc_version = self.manager.gcc_version
2219+ self.path_libc = self.manager.path_libc
2220+
2221+ def version_compare(self, one, two):
2222+ return apt_pkg.VersionCompare(one,two)
2223+
2224+ def assertFileType(self, filename, filetype):
2225+ '''Checks the file type of the file specified'''
2226+
2227+ (rc, report, out) = self._testlib_shell_cmd(["/usr/bin/file", "-b", filename])
2228+ out = out.strip()
2229+ expected = 0
2230+ # Absolutely no idea why this happens on Hardy
2231+ if self.lsb_release['Release'] == 8.04 and rc == 255 and len(out) > 0:
2232+ rc = 0
2233+ result = 'Got exit code %d, expected %d:\n%s\n' % (rc, expected, report)
2234+ self.assertEquals(expected, rc, result)
2235+
2236+ filetype = '^%s$' % (filetype)
2237+ result = 'File type reported by file: [%s], expected regex: [%s]\n' % (out, filetype)
2238+ self.assertNotEquals(None, re.search(filetype, out), result)
2239+
2240+ def yank_commonname_from_cert(self, certfile):
2241+ '''Extract the commonName from a given PEM'''
2242+ rc, out = cmd(['openssl','asn1parse','-in',certfile])
2243+ if rc == 0:
2244+ ready = False
2245+ for line in out.splitlines():
2246+ if ready:
2247+ return line.split(':')[-1]
2248+ if ':commonName' in line:
2249+ ready = True
2250+ return socket.getfqdn()
2251+
2252+ def announce(self, text):
2253+ if self.my_verbosity:
2254+ print >>sys.stdout, "(%s) " % (text),
2255+ sys.stdout.flush()
2256+
2257+ def make_clean(self):
2258+ rc, output = self.shell_cmd(['make','clean'])
2259+ self.assertEquals(rc, 0, output)
2260+
2261+ def get_makefile_compiler(self):
2262+ # Find potential compiler name
2263+ compiler = 'gcc'
2264+ if os.path.exists('Makefile'):
2265+ for line in open('Makefile'):
2266+ if line.startswith('CC') and '=' in line:
2267+ items = [x.strip() for x in line.split('=')]
2268+ if items[0] == 'CC':
2269+ compiler = items[1]
2270+ break
2271+ return compiler
2272+
2273+ def make_target(self, target, expected=0):
2274+ '''Compile a target and report output'''
2275+
2276+ compiler = self.get_makefile_compiler()
2277+ rc, output = self.shell_cmd(['make',target])
2278+ self.assertEquals(rc, expected, 'rc(%d)!=%d:\n' % (rc, expected) + output)
2279+ self.assertTrue('%s ' % (compiler) in output, 'Expected "%s":' % (compiler) + output)
2280+ return output
2281+
2282+ # call as return testlib.skipped()
2283+ def _skipped(self, reason=""):
2284+ '''Provide a visible way to indicate that a test was skipped'''
2285+ if reason != "":
2286+ reason = ': %s' % (reason)
2287+ self.announce("skipped%s" % (reason))
2288+ return False
2289+
2290+ def _testlib_shell_cmd(self,args,stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT):
2291+ argstr = "'" + "', '".join(args).strip() + "'"
2292+ rc, out = cmd(args,stdin=stdin,stdout=stdout,stderr=stderr)
2293+ report = 'Command: ' + argstr + '\nOutput:\n' + out
2294+ return rc, report, out
2295+
2296+ def shell_cmd(self, args, stdin=None):
2297+ return cmd(args,stdin=stdin)
2298+
2299+ def assertShellExitEquals(self, expected, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg=""):
2300+ '''Test a shell command matches a specific exit code'''
2301+ rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr)
2302+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
2303+ self.assertEquals(expected, rc, msg + result + report)
2304+
2305+ def assertShellExitNotEquals(self, unwanted, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg=""):
2306+ '''Test a shell command doesn't match a specific exit code'''
2307+ rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr)
2308+ result = 'Got (unwanted) exit code %d\n' % rc
2309+ self.assertNotEquals(unwanted, rc, msg + result + report)
2310+
2311+ def assertShellOutputContains(self, text, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg="", invert=False):
2312+ '''Test a shell command contains a specific output'''
2313+ rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr)
2314+ result = 'Got exit code %d. Looking for text "%s"\n' % (rc, text)
2315+ if not invert:
2316+ self.assertTrue(text in out, msg + result + report)
2317+ else:
2318+ self.assertFalse(text in out, msg + result + report)
2319+
2320+ def assertShellOutputEquals(self, text, args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, msg="", invert=False, expected=None):
2321+ '''Test a shell command matches a specific output'''
2322+ rc, report, out = self._testlib_shell_cmd(args, stdin=stdin, stdout=stdout, stderr=stderr)
2323+ result = 'Got exit code %d. Looking for exact text "%s" (%s)\n' % (rc, text, " ".join(args))
2324+ if not invert:
2325+ self.assertEquals(text, out, msg + result + report)
2326+ else:
2327+ self.assertNotEquals(text, out, msg + result + report)
2328+ if expected != None:
2329+ result = 'Got exit code %d. Expected %d (%s)\n' % (rc, expected, " ".join(args))
2330+ self.assertEquals(rc, expected, msg + result + report)
2331+
2332+ def _word_find(self, report, content, invert=False):
2333+ '''Check for a specific string'''
2334+ if invert:
2335+ warning = 'Found "%s"\n' % content
2336+ self.assertTrue(content not in report, warning + report)
2337+ else:
2338+ warning = 'Could not find "%s"\n' % content
2339+ self.assertTrue(content in report, warning + report)
2340+
2341+ def _test_sysctl_value(self, path, expected, msg=None, exists=True):
2342+ sysctl = '/proc/sys/%s' % (path)
2343+ self.assertEquals(exists, os.path.exists(sysctl), sysctl)
2344+ value = None
2345+ if exists:
2346+ value = int(file(sysctl).read())
2347+ report = "%s is not %d: %d" % (sysctl, expected, value)
2348+ if msg:
2349+ report += " (%s)" % (msg)
2350+ self.assertEquals(value, expected, report)
2351+ return value
2352+
2353+ def set_sysctl_value(self, path, desired):
2354+ sysctl = '/proc/sys/%s' % (path)
2355+ self.assertTrue(os.path.exists(sysctl),"%s does not exist" % (sysctl))
2356+ file(sysctl,'w').write(str(desired))
2357+ self._test_sysctl_value(path, desired)
2358+
2359+ def kernel_at_least(self, introduced):
2360+ return self.version_compare(self.kernel_version_ubuntu,
2361+ introduced) >= 0
2362+
2363+ def kernel_claims_cve_fixed(self, cve):
2364+ changelog = "/usr/share/doc/linux-image-%s/changelog.Debian.gz" % (self.kernel_version)
2365+ if os.path.exists(changelog):
2366+ for line in gzip.open(changelog):
2367+ if cve in line and not "revert" in line and not "Revert" in line:
2368+ return True
2369+ return False
2370+
2371+class TestGroup:
2372+ '''Create a temporary test group and remove it again in the dtor.'''
2373+
2374+ def __init__(self, group=None, lower=False):
2375+ '''Create a new group'''
2376+
2377+ self.group = None
2378+ if group:
2379+ if group_exists(group):
2380+ raise ValueError, 'group name already exists'
2381+ else:
2382+ while(True):
2383+ group = random_string(7,lower=lower)
2384+ if not group_exists(group):
2385+ break
2386+
2387+ assert subprocess.call(['groupadd',group]) == 0
2388+ self.group = group
2389+ g = grp.getgrnam(self.group)
2390+ self.gid = g[2]
2391+
2392+ def __del__(self):
2393+ '''Remove the created group.'''
2394+
2395+ if self.group:
2396+ rc, report = cmd(['groupdel', self.group])
2397+ assert rc == 0
2398+
2399+class TestUser:
2400+ '''Create a temporary test user and remove it again in the dtor.'''
2401+
2402+ def __init__(self, login=None, home=True, group=None, uidmin=None, lower=False, shell=None):
2403+ '''Create a new user account with a random password.
2404+
2405+ By default, the login name is random, too, but can be explicitly
2406+ specified with 'login'. By default, a home directory is created, this
2407+ can be suppressed with 'home=False'.'''
2408+
2409+ self.login = None
2410+
2411+ if os.geteuid() != 0:
2412+ raise ValueError, "You must be root to run this test"
2413+
2414+ if login:
2415+ if login_exists(login):
2416+ raise ValueError, 'login name already exists'
2417+ else:
2418+ while(True):
2419+ login = 't' + random_string(7,lower=lower)
2420+ if not login_exists(login):
2421+ break
2422+
2423+ self.salt = random_string(2)
2424+ self.password = random_string(8,lower=lower)
2425+ self.crypted = crypt.crypt(self.password, self.salt)
2426+
2427+ creation = ['useradd', '-p', self.crypted]
2428+ if home:
2429+ creation += ['-m']
2430+ if group:
2431+ creation += ['-G',group]
2432+ if uidmin:
2433+ creation += ['-K','UID_MIN=%d'%uidmin]
2434+ if shell:
2435+ creation += ['-s',shell]
2436+ creation += [login]
2437+ assert subprocess.call(creation) == 0
2438+ # Set GECOS
2439+ assert subprocess.call(['usermod','-c','Buddy %s' % (login),login]) == 0
2440+
2441+ self.login = login
2442+ p = pwd.getpwnam(self.login)
2443+ self.uid = p[2]
2444+ self.gid = p[3]
2445+ self.gecos = p[4]
2446+ self.home = p[5]
2447+ self.shell = p[6]
2448+
2449+ def __del__(self):
2450+ '''Remove the created user account.'''
2451+
2452+ if self.login:
2453+ # sanity check the login name so we don't accidentally wipe too much
2454+ if len(self.login)>3 and not '/' in self.login:
2455+ subprocess.call(['rm','-rf', '/home/'+self.login, '/var/mail/'+self.login])
2456+ rc, report = cmd(['userdel', '-f', self.login])
2457+ assert rc == 0
2458+
2459+ def add_to_group(self, group):
2460+ '''Add user to the specified group name'''
2461+ rc, report = cmd(['usermod', '-G', group, self.login])
2462+ if rc != 0:
2463+ print report
2464+ assert rc == 0
2465+
2466+# Timeout handler using alarm() from John P. Speno's Pythonic Avocado
2467+class TimeoutFunctionException(Exception):
2468+ """Exception to raise on a timeout"""
2469+ pass
2470+class TimeoutFunction:
2471+ def __init__(self, function, timeout):
2472+ self.timeout = timeout
2473+ self.function = function
2474+
2475+ def handle_timeout(self, signum, frame):
2476+ raise TimeoutFunctionException()
2477+
2478+ def __call__(self, *args, **kwargs):
2479+ old = signal.signal(signal.SIGALRM, self.handle_timeout)
2480+ signal.alarm(self.timeout)
2481+ try:
2482+ result = self.function(*args, **kwargs)
2483+ finally:
2484+ signal.signal(signal.SIGALRM, old)
2485+ signal.alarm(0)
2486+ return result
2487+
2488+def main():
2489+ print "hi"
2490+ unittest.main()
2491diff --git a/debian/tests/testlib_httpd.py b/debian/tests/testlib_httpd.py
2492new file mode 100644
2493index 0000000..1468398
2494--- /dev/null
2495+++ b/debian/tests/testlib_httpd.py
2496@@ -0,0 +1,352 @@
2497+#!/usr/bin/python
2498+#
2499+# testlib_httpd.py quality assurance test script
2500+# Copyright (C) 2008-2013 Canonical Ltd.
2501+# Author: Jamie Strandboge <jamie@canonical.com>
2502+# Author: Marc Deslauriers <marc.deslauriers@canonical.com>
2503+#
2504+# This program is free software: you can redistribute it and/or modify
2505+# it under the terms of the GNU General Public License version 3,
2506+# as published by the Free Software Foundation.
2507+#
2508+# This program is distributed in the hope that it will be useful,
2509+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2510+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2511+# GNU General Public License for more details.
2512+#
2513+# You should have received a copy of the GNU General Public License
2514+# along with this program. If not, see <httpd://www.gnu.org/licenses/>.
2515+#
2516+
2517+import unittest, subprocess
2518+import os
2519+import sys
2520+import tempfile
2521+import testlib
2522+import time
2523+import socket
2524+import shutil
2525+import cookielib
2526+import urllib2
2527+import re
2528+import base64
2529+
2530+class HttpdCommon(testlib.TestlibCase):
2531+ '''Common functions'''
2532+ def _setUp(self, clearlogs = False):
2533+ '''Setup'''
2534+ self.release = self.lsb_release['Codename']
2535+ self.html_page = "/var/www/test.html"
2536+ self.php_page = "/var/www/test.php"
2537+ self.cgi_page = "/usr/lib/cgi-bin/test-cgi.pl"
2538+ self.apache2_default = "/etc/default/apache2"
2539+ self.ssl_key = "/etc/ssl/private/server.key"
2540+ self.ssl_crt = "/etc/ssl/certs/server.crt"
2541+ self.ssl_site = "/etc/apache2/sites-enabled/999-testlib"
2542+ self.ports_file = "/etc/apache2/ports.conf"
2543+ self.access_log = "/var/log/apache2/access.log"
2544+ self.error_log = "/var/log/apache2/error.log"
2545+ if not hasattr(self, 'initscript'):
2546+ self._set_initscript("apache2")
2547+
2548+ # Dapper's apache2 is disabled by default
2549+ if self.lsb_release['Release'] == 6.06:
2550+ testlib.config_replace(self.apache2_default, "", append=True)
2551+ subprocess.call(['sed', '-i', 's/NO_START=1/NO_START=0/', self.apache2_default])
2552+
2553+ self._stop()
2554+ if clearlogs == True:
2555+ self._clearlogs()
2556+ self._start()
2557+
2558+ def _set_initscript(self, initscript):
2559+ self.initscript = initscript
2560+
2561+ def _tearDown(self):
2562+ '''Clean up after each test_* function'''
2563+ self._stop()
2564+ time.sleep(2)
2565+ if os.path.exists(self.html_page):
2566+ os.unlink(self.html_page)
2567+ if os.path.exists(self.php_page):
2568+ os.unlink(self.php_page)
2569+ if os.path.exists(self.cgi_page):
2570+ os.unlink(self.cgi_page)
2571+ if os.path.exists(self.ssl_key):
2572+ os.unlink(self.ssl_key)
2573+ if os.path.exists(self.ssl_crt):
2574+ os.unlink(self.ssl_crt)
2575+ if os.path.exists(self.ssl_site):
2576+ os.unlink(self.ssl_site)
2577+ self._disable_mod("ssl")
2578+ testlib.config_restore(self.ports_file)
2579+ testlib.config_restore(self.apache2_default)
2580+
2581+ def _start(self):
2582+ '''Start process'''
2583+ rc, report = testlib.cmd(['service', self.initscript, 'start'])
2584+ expected = 0
2585+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
2586+ self.assertEquals(expected, rc, result + report)
2587+ time.sleep(2)
2588+
2589+ def _stop(self):
2590+ '''Stop process'''
2591+ rc, report = testlib.cmd(['service', self.initscript, 'stop'])
2592+ expected = 0
2593+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
2594+ self.assertEquals(expected, rc, result + report)
2595+
2596+ def _clearlogs(self):
2597+ '''Clear httpd logs'''
2598+ if os.path.exists(self.access_log):
2599+ os.unlink(self.access_log)
2600+ if os.path.exists(self.error_log):
2601+ os.unlink(self.error_log)
2602+
2603+ def __disable_mod(self, mod):
2604+ if not os.path.exists(os.path.join("/etc/apache2/mods-available", mod + \
2605+ ".load")):
2606+ return
2607+ if not os.path.exists("/usr/sbin/a2dismod"):
2608+ return
2609+ rc, report = testlib.cmd(['a2dismod', mod])
2610+ expected = 0
2611+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
2612+ self.assertEquals(expected, rc, result + report)
2613+
2614+ def _disable_mod(self, mod):
2615+ self.__disable_mod(mod)
2616+ self._restart()
2617+ time.sleep(2)
2618+
2619+ def _disable_mods(self, mods):
2620+ '''take a list of modules to disable'''
2621+ for mod in mods:
2622+ self.__disable_mod(mod)
2623+ self._restart()
2624+ time.sleep(2)
2625+
2626+ def __enable_mod(self, mod):
2627+ rc, report = testlib.cmd(['a2enmod', mod])
2628+ expected = 0
2629+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
2630+ self.assertEquals(expected, rc, result + report)
2631+
2632+ def _enable_mod(self, mod):
2633+ self.__enable_mod(mod)
2634+ # for some reason, force-reload doesn't work
2635+ # if self.lsb_release['Release'] >= 8.04:
2636+ # self._reload()
2637+ # else:
2638+ self._restart()
2639+ time.sleep(2)
2640+
2641+ def _enable_mods(self, mods):
2642+ '''take a list of modules to enable'''
2643+ for mod in mods:
2644+ self.__enable_mod(mod)
2645+ # for some reason, force-reload doesn't work
2646+ # if self.lsb_release['Release'] >= 8.04:
2647+ # self._reload()
2648+ # else:
2649+ self._restart()
2650+ time.sleep(2)
2651+
2652+ def _disable_site(self, sitename):
2653+ rc, report = testlib.cmd(['a2dissite', sitename])
2654+ expected = 0
2655+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
2656+ self.assertEquals(expected, rc, result + report)
2657+ self._restart()
2658+ time.sleep(2)
2659+
2660+ def _enable_site(self, sitename):
2661+ rc, report = testlib.cmd(['a2ensite', sitename])
2662+ expected = 0
2663+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
2664+ self.assertEquals(expected, rc, result + report)
2665+ # for some reason, force-reload doesn't work
2666+ # if self.lsb_release['Release'] >= 8.04:
2667+ # self._reload()
2668+ #else:
2669+ self._restart()
2670+ time.sleep(2)
2671+
2672+ def _reload(self):
2673+ '''Reload httpd'''
2674+ rc, report = testlib.cmd([self.initscript, 'force-reload'])
2675+ expected = 0
2676+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
2677+ self.assertEquals(expected, rc, result + report)
2678+
2679+ def _restart(self):
2680+ '''Restart httpd'''
2681+ self._stop()
2682+ self._start()
2683+
2684+ def _prepare_ssl(self, srvkey, srvcert):
2685+ '''Prepare Apache for ssl connections'''
2686+ self._enable_mod("ssl")
2687+
2688+ # copy instead of rename so we don't get invalid cross-device link errors
2689+ shutil.copy(srvkey, self.ssl_key)
2690+ shutil.copy(srvcert, self.ssl_crt)
2691+
2692+ if self.lsb_release['Release'] <= 7.04:
2693+ testlib.config_replace(self.ports_file, "Listen 443", True)
2694+
2695+ # create the conffile entry
2696+ site_contents = '''
2697+NameVirtualHost *:443
2698+<VirtualHost *:443>
2699+ SSLEngine on
2700+ SSLOptions +StrictRequire
2701+ SSLCertificateFile /etc/ssl/certs/server.crt
2702+ SSLCertificateKeyFile /etc/ssl/private/server.key
2703+
2704+ ServerAdmin webmaster@localhost
2705+
2706+ DocumentRoot /var/www/
2707+ ErrorLog /var/log/apache2/error.log
2708+
2709+ # Possible values include: debug, info, notice, warn, error, crit,
2710+ # alert, emerg.
2711+ LogLevel warn
2712+
2713+ CustomLog /var/log/apache2/access.log combined
2714+ ServerSignature On
2715+</VirtualHost>
2716+'''
2717+ testlib.create_fill(self.ssl_site, site_contents)
2718+ self._reload()
2719+
2720+ def _test_url_proxy(self, url="http://localhost/", content="", proxy="localhost:3128"):
2721+ '''Test the given url'''
2722+ rc, report = testlib.cmd(['elinks', '-verbose', '2', '-no-home', '1', '-eval', 'set protocol.ftp.proxy.host = "%s"' %(proxy), '-eval',
2723+ 'set protocol.http.proxy.host = "%s"' %(proxy), '-eval', 'set protocol.https.proxy.host = "%s"' %(proxy), '-dump', url])
2724+ expected = 0
2725+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
2726+ self.assertEquals(expected, rc, result + report)
2727+
2728+ if content != "":
2729+ self._word_find(report, content)
2730+
2731+ def _test_url(self, url="http://localhost/", content="", invert=False, source=False):
2732+ '''Test the given url'''
2733+ if source:
2734+ report = self._get_page_source(url)
2735+ else:
2736+ report = self._get_page(url)
2737+
2738+ if content != "":
2739+ self._word_find(report, content, invert)
2740+
2741+ def _get_page_source(self, url="http://localhost/", data='', headers=None):
2742+ '''Fetch html source'''
2743+ cookies = "/tmp/cookies.lwp"
2744+ testlib.create_fill(cookies, "#LWP-Cookies-2.0")
2745+
2746+ if headers == None:
2747+ headers = {'User-agent' : 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}
2748+
2749+ clean_url = url
2750+ if re.search(r'http(|s)://.*:.*@[a-z].*', url):
2751+ tmp = re.sub(r'^http(|s)://', '', url)
2752+ username = tmp.split('@')[0].split(':')[0]
2753+ password = tmp.split('@')[0].split(':')[1]
2754+ base64_str = base64.encodestring('%s:%s' % (username, password))[:-1]
2755+ headers['Authorization'] = "Basic %s" % (base64_str)
2756+ # strip out the username and password from the url
2757+ clean_url = re.sub(r'%s:%s@' % (username, password), '', url)
2758+
2759+ cj = cookielib.LWPCookieJar(filename=cookies)
2760+ cj.load()
2761+
2762+ opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
2763+ urllib2.install_opener(opener)
2764+
2765+ try:
2766+ if data != '':
2767+ req = urllib2.Request(clean_url, data, headers)
2768+ else:
2769+ req = urllib2.Request(clean_url, headers=headers)
2770+ except:
2771+ raise
2772+
2773+ tries = 0
2774+ failed = True
2775+ while tries < 3:
2776+ try:
2777+ handle = urllib2.urlopen(req)
2778+ failed = False
2779+ break
2780+ except urllib2.HTTPError, e:
2781+ raise
2782+ if e.code != 503:
2783+ # for debugging
2784+ #print >>sys.stderr, 'Error retrieving page "url=%s", "data=%s"' % (url, data)
2785+ raise
2786+ tries += 1
2787+ time.sleep(2)
2788+
2789+ self.assertFalse(failed, 'Could not retrieve page "url=%s", "data=%s"' % (url, data))
2790+ html = handle.read()
2791+ cj.save()
2792+
2793+ return html
2794+
2795+ def _get_page(self, url="http://localhost/"):
2796+ '''Get contents of given url'''
2797+ rc, report = testlib.cmd(['elinks', '-verbose', '2', '-no-home', '1', '-dump', url])
2798+ expected = 0
2799+
2800+ result = 'Got exit code %d, expected %d\n' % (rc, expected)
2801+ self.assertEquals(expected, rc, result + report)
2802+
2803+ return report
2804+
2805+ def _test_raw(self, request="", content="", host="localhost", port=80, invert = False, limit=1024):
2806+ '''Test the given url with a raw socket to include headers'''
2807+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2808+ s.connect((host, port))
2809+ s.send(request)
2810+ data = s.recv(limit)
2811+ s.close()
2812+
2813+ if content != "":
2814+ self._word_find(data, content, invert = invert)
2815+
2816+def create_php_page(page, php_content=None):
2817+ '''Create a basic php page'''
2818+
2819+ # complexity here is due to maintaining interface compatability when
2820+ # php_content is not provided
2821+ if not php_content:
2822+ str = "php works"
2823+ php_content = "echo '" + str + "'; "
2824+ else:
2825+ str = php_content
2826+ script = '''<?php
2827+%s
2828+?>''' %(php_content)
2829+ testlib.create_fill(page, script)
2830+ return str
2831+
2832+def create_perl_script(page):
2833+ '''Create a basic perl script'''
2834+ str = "perl works"
2835+ script = '''#!/usr/bin/perl
2836+print "Content-Type: text/plain\\n\\n";
2837+print "''' + str + '''\\n";
2838+
2839+'''
2840+ testlib.create_fill(page, script, 0755)
2841+
2842+ return str
2843+
2844+def create_html_page(page):
2845+ '''Create html page'''
2846+ str = "html works"
2847+ testlib.create_fill(page, "<html><body>" + str + "</body></html>")
2848+ return str
2849diff --git a/debian/tests/upstream-test-suite b/debian/tests/upstream-test-suite
2850index 4f6b332..ec3e370 100644
2851--- a/debian/tests/upstream-test-suite
2852+++ b/debian/tests/upstream-test-suite
2853@@ -2,7 +2,7 @@
2854 set -e
2855
2856 dpkg-source --before-build `pwd`
2857-sed -i -e 's/\$(top_builddir)\/src\/squid/\/usr\/sbin\/squid/' test-suite/Makefile.am
2858+sed -i -e 's/\$(top_builddir)\/src\/squid\ /\/usr\/sbin\/squid\ /' test-suite/Makefile.am
2859 dpkg-buildpackage -rfakeroot --target=pre-build
2860 dpkg-buildpackage -rfakeroot --target=common-configure-arch 2>/dev/null
2861 make -C src/base libbase.la
2862diff --git a/debian/usr.sbin.squid b/debian/usr.sbin.squid
2863new file mode 100644
2864index 0000000..2a400e9
2865--- /dev/null
2866+++ b/debian/usr.sbin.squid
2867@@ -0,0 +1,75 @@
2868+# Author: Simon Deziel
2869+# Jamie Strandboge
2870+# vim:syntax=apparmor
2871+#include <tunables/global>
2872+
2873+/usr/sbin/squid {
2874+ #include <abstractions/base>
2875+ #include <abstractions/kerberosclient>
2876+ #include <abstractions/nameservice>
2877+
2878+ capability net_raw,
2879+ capability setuid,
2880+ capability setgid,
2881+ capability sys_chroot,
2882+
2883+ # allow child processes to run execvp(argv[0], [kidname, ...])
2884+ /usr/sbin/squid ix,
2885+
2886+ # pinger
2887+ network inet raw,
2888+ network inet6 raw,
2889+
2890+ /etc/mtab r,
2891+ @{PROC}/[0-9]*/mounts r,
2892+ @{PROC}/mounts r,
2893+
2894+ # squid3 configuration
2895+ /etc/squid/** r,
2896+ /{,var/}run/squid.pid rwk,
2897+ /var/spool/squid/ r,
2898+ /var/spool/squid/** rwk,
2899+ /usr/lib/squid{,3}/* rmix,
2900+ /usr/share/squid/** r,
2901+ /var/log/squid/* rw,
2902+
2903+ # squid-langpack
2904+ /usr/share/squid-langpack/** r,
2905+
2906+ # maas-proxy
2907+ /var/lib/maas/maas-proxy.conf r,
2908+ /var/log/maas/proxy/** rw,
2909+ /var/spool/maas-proxy/ r,
2910+ /var/spool/maas-proxy/** rwk,
2911+
2912+ # squid-deb-proxy
2913+ /etc/squid-deb-proxy/** r,
2914+ /{,var/}run/squid-deb-proxy.pid rwk,
2915+ /var/cache/squid-deb-proxy/ r,
2916+ /var/cache/squid-deb-proxy/** rwk,
2917+ /var/log/squid-deb-proxy/* rw,
2918+ owner /dev/shm/** rmw,
2919+
2920+ # squidguard
2921+ /usr/bin/squidGuard Cx -> squidguard,
2922+ profile squidguard {
2923+ #include <abstractions/base>
2924+
2925+ /etc/squid/squidGuard.conf r,
2926+ /var/log/squid{,3}/squidGuard.log w,
2927+ /var/lib/squidguard/** rw,
2928+
2929+ # squidguard by default uses /var/log/squid as its logdir, however, we
2930+ # don't want it to access squid's logs, only its own. Explicitly deny
2931+ # access to squid's files but allow all others since the user may specify
2932+ # anything for the squidGurad 'log' directive.
2933+ /var/log/squid{,3}/* rw,
2934+ audit deny /var/log/squid{,3}/{access,cache,store}.log* rw,
2935+
2936+ # Site-specific additions and overrides. See local/README for details.
2937+ #include <local/usr.sbin.squid>
2938+ }
2939+
2940+ # Site-specific additions and overrides. See local/README for details.
2941+ #include <local/usr.sbin.squid>
2942+}

Subscribers

People subscribed via source and target branches