Commit Graph

71 Commits

Author SHA1 Message Date
David Kalnischkies ed793a19ec dispose http(s) 416 error page as non-content
Real webservers (like apache) actually send an error page with a 416
response, but our client didn't expect it leaving the page on the socket
to be parsed as response for the next request (http) or as file content
(https), which isn't what we want at all… Symptom is a "Bad header line"
as html usually doesn't parse that well to an http-header.

This manifests itself e.g. if we have a complete file (or larger) in
partial/ which isn't discarded by If-Range as the server doesn't support
it (or it is just newer, think: mirror rotation).
It is a sort-of regression of 78c72d0ce2,
which removed the filesize - 1 trick, but this had its own problems…

To properly test this our webserver gains the ability to reply with
transfer-encoding: chunked as most real webservers will use it to send
the dynamically generated error pages.

Closes: 768797
2014-12-09 01:13:48 +01:00
Michael Vogt 9983999d29 Fix backward compatiblity of the new pkgAcquireMethod::DropPrivsOrDie()
Do not drop privileges in the methods when using a older version of
libapt that does not support the chown magic in partial/ yet. To
do this DropPrivileges() now will ignore a empty Apt::Sandbox::User.

Cleanup all hardcoded _apt along the way.
2014-10-13 11:29:47 +02:00
Michael Vogt ee27950632 Send "Fail-Reason: MaximumSizeExceeded" from the method
Communicate the fail reason from the methods to the parent
and Rename() failed files.
2014-10-07 22:36:09 +02:00
Michael Vogt c48eea97b9 make expected-size a maximum-size check as this is what we want at this point 2014-10-07 17:47:30 +02:00
Michael Vogt 5b33fab8c9 add ftp expected size check 2014-10-07 08:43:46 +02:00
Michael Vogt 62acbba8d1 methods/https.cc: use File->Tell() here too 2014-10-07 08:16:51 +02:00
Michael Vogt a2d40703e4 make http size check work 2014-10-06 17:42:39 +02:00
Julian Andres Klode 7b18d5592f methods: Fail if we cannot drop privileges 2014-09-24 21:49:19 +02:00
Michael Vogt 3927c6da48 Drop Privileges to "Debian-apt" in most acquire methods
Add a new "Debian-apt" user that owns the /var/lib/apt/lists
and /var/cache/apt/archive directories. The methods
http, https, ftp, gpgv, gzip switch to this user when they
start.

Thanks to Julian and "ioerror" and tors "switch_id()" code.
2014-09-24 16:22:05 +02:00
Michael Vogt c6ee61eab5 Make Proxy-Auto-Detect check for each host
When doing Acquire::http{,s}::Proxy-Auto-Detect, run the auto-detect
command for each host instead of only once. This should make using
"proxy" from libproxy-tools feasible which can then be used for PAC
style or other proxy configurations.

Closes: #759264
2014-09-02 16:02:37 +02:00
Michael Vogt ffd2dd93a6 make https honor ExpectedSize as well 2014-08-26 19:20:04 -07:00
David Kalnischkies 062074cb51 enforce LFS for partial files in https range requests 2014-04-26 09:51:05 +02:00
David Kalnischkies 453b82a388 cleanup headers and especially #includes everywhere
Beside being a bit cleaner it hopefully also resolves oddball problems
I have with high levels of parallel jobs.

Git-Dch: Ignore
Reported-By: iwyu (include-what-you-use)
2014-03-13 13:58:45 +01:00
David Kalnischkies 655122418d warning: unused parameter ‘foo’ [-Wunused-parameter]
Reported-By: gcc -Wunused-parameter
Git-Dch: Ignore
2014-03-13 13:58:45 +01:00
David Kalnischkies d3e8fbb395 warning: extra ‘;’ [-Wpedantic]
Git-Dch: Ignore
Reported-By: gcc -Wpedantic
2014-03-13 13:58:45 +01:00
Michael Vogt 1e3f4083db Fix typos in documentation (codespell) 2014-02-22 18:34:33 +01:00
David Kalnischkies 889b0072a9 add a testcase to check for forbidden https→http downgrades
Git-Dch: Ignore
2014-02-14 19:15:43 +01:00
Michael Vogt dc95fee18e disable https->http redirects in libcurl
This change prevents changing the protocol from https to http.
2014-02-14 19:10:47 +01:00
David Kalnischkies f9b4f12d65 report https download start only if we really get it
Reporting it via progress means that e.g. a redirect will trigger it,
too, so you get a Get & Hit while http only reports a Hit as it should
be.
2014-02-14 00:45:10 +01:00
David Kalnischkies 246bbb611d use utimes instead of utimensat/futimens
cppcheck complains about the obsolete utime as it was removed in
POSIX1.2008 and recommends usage of utimensat/futimens instead
as those are in POSIX and so commit 9ce3cfc9 switched to them.
It is just that they aren't as portable as the standard suggests:
At least our kFreeBSD and Hurd ports stumble over it at runtime.
So to make both, the ports and cppcheck happy, we use utimes instead.

Closes: 738567
2014-02-11 02:28:27 +01:00
David Kalnischkies 9ce3cfc930 correct some style/performance/warnings from cppcheck
The most "visible" change is from utime to utimensat/futimens
as the first one isn't part of POSIX anymore.

Reported-By: cppcheck
Git-Dch: Ignore
2014-01-16 22:19:49 +01:00
David Kalnischkies fd46d30571 handle complete responses to https range requests
Servers might respond with a complete file either because they don't
support Ranges at all or the If-Range condition isn't statisfied, so we
have to parse the headers curl gets ourself to seek or truncate the file
we have so far.

This also finially adds the testcase testing a bunch of partial
situations for both, http and https - which is now all green.

Closes: 617643, 667699
LP: 1157943
2013-10-01 11:17:02 +02:00
David Kalnischkies 85050e7644 fix partial (206 and 416) support in https
As lengthy discussed in lp:1157943 partial https support was utterly
broken as a 206 response was handled as an (unhandled) error. This is
the first part of fixing it by supporting a 206 response and starting to
deal with 416.
2013-10-01 11:08:12 +02:00
Michael Vogt 5b63d2a9a2 merged patch from Daniel Hartwig to fix URI and proxy releated issues 2013-05-08 17:50:15 +02:00
Michael Vogt 597341fe0f merged from the debian-wheezy branch 2013-05-08 17:48:31 +02:00