Systemd/src/import
Dongsu Park 21224070e8 importd, basic/string-util: use case-insensitive comparison for HTTP headers
According to RFC2616[1], HTTP header names are case-insensitive. So
it's totally valid to have a header starting with either `Date:` or
`date:`.

However, when systemd-importd pulls an image from an HTTP server, it
parses HTTP headers by comparing header names as-is, without any
conversion. That causes failures when some HTTP servers return headers
with different combinations of upper-/lower-cases.

An example:
https://alpha.release.flatcar-linux.net/amd64-usr/current/flatcar_developer_container.bin.bz2 returns `Etag: "pe89so9oir60"`,
while https://alpha.release.core-os.net/amd64-usr/current/coreos_developer_container.bin.bz2
returns `ETag: "f03372edea9a1e7232e282c346099857"`.
Since systemd-importd expects to see `ETag`, the etag for the Container Linux image
is correctly interpreted as a part of the hidden file name.
However, it cannot parse etag for Flatcar Linux, so the etag the Flatcar Linux image
is not appended to the hidden file name.

```
$ sudo ls -al /var/lib/machines/
-r--r--r--  1 root root 3303014400 Aug 21 20:07 '.raw-https:\x2f\x2falpha\x2erelease\x2ecore-os\x2enet\x2famd64-usr\x2fcurrent\x2fcoreos_developer_container\x2ebin\x2ebz2.\x22f03372edea9a1e7232e282c346099857\x22.raw'
-r--r--r--  1 root root 3303014400 Aug 17 06:15 '.raw-https:\x2f\x2falpha\x2erelease\x2eflatcar-linux\x2enet\x2famd64-usr\x2fcurrent\x2fflatcar_developer_container\x2ebin\x2ebz2.raw'
```

As a result, when the Flatcar image is removed and downloaded again,
systemd-importd is not able to determine if the file has been already
downloaded, so it always download it again. Then it fails to rename it
to an expected name, because there's already a hidden file.

To fix this issue, let's introduce a new helper function
`memory_startswith_no_case()`, which compares memory regions in a
case-insensitive way. Use this function in `curl_header_strdup()`.

See also https://github.com/kinvolk/kube-spawn/issues/304

[1]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
2018-09-03 22:59:27 +02:00
..
curl-util.c importd, basic/string-util: use case-insensitive comparison for HTTP headers 2018-09-03 22:59:27 +02:00
curl-util.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
export-raw.c tree-wide: port various bits over to open_parent() 2018-07-23 13:38:18 +02:00
export-raw.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
export-tar.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
export-tar.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
export.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
import-common.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
import-common.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
import-compress.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
import-compress.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
import-pubring.gpg import: add image verification using gpg 2015-01-21 04:03:54 +01:00
import-raw.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
import-raw.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
import-tar.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
import-tar.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
import.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
importd.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
meson.build Drop my copyright headers 2018-06-14 13:03:20 +02:00
org.freedesktop.import1.conf Add SPDX license headers to various assorted files 2017-11-19 19:08:15 +01:00
org.freedesktop.import1.policy meson: drop unnecessary "transformation" of policy files 2018-02-16 13:01:12 +01:00
org.freedesktop.import1.service Add SPDX license headers to various assorted files 2017-11-19 19:08:15 +01:00
pull-common.c import: drop unnecessary condition 2018-06-25 13:54:44 +09:00
pull-common.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
pull-job.c pull: initialize libgcrypt before calling any functions provided by libgcrypt 2018-07-13 19:47:49 +02:00
pull-job.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
pull-raw.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
pull-raw.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
pull-tar.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
pull-tar.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
pull.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
qcow2-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
qcow2-util.h tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-qcow2.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00