Systemd/src/test
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
..
generate-sym-test.py Mark python scripts executable 2017-05-07 20:16:47 -04:00
meson.build test-bus-address: a simple test for address parsing 2018-08-06 14:30:53 -07:00
test-acl-util.c user-util: rework get_user_creds() 2018-08-20 15:58:21 +02:00
test-af-list.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-alloc-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-architecture.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-arphrd-list.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-ask-password-api.c Drop my copyright headers 2018-06-14 13:03:20 +02:00
test-async.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-barrier.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-bitmap.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-boot-timestamps.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-bpf.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-btrfs.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-bus-util.c test-bus-util: add a test for destroy callbacks 2018-06-06 23:01:57 +02:00
test-calendarspec.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-cap-list.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-capability.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-cgroup-mask.c tree-wide: drop copyright lines for more authors 2018-06-22 16:39:45 +02:00
test-cgroup-util.c Drop my copyright headers 2018-06-14 13:03:20 +02:00
test-cgroup.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-clock.c tree-wide: use proper unicode © instead of (C) where we can 2018-06-14 10:20:20 +02:00
test-condition.c test-condition: extend tests to all ConditionSecurity= values 2018-06-20 22:46:18 +02:00
test-conf-files.c tree-wide: beautify remaining copyright statements 2018-06-14 10:20:21 +02:00
test-conf-parser.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-copy.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-cpu-set-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-daemon.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-date.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-device-nodes.c tree-wide: drop copyright lines for more authors 2018-06-22 16:39:45 +02:00
test-dissect-image.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-dlopen.c Drop my copyright headers 2018-06-14 13:03:20 +02:00
test-dns-domain.c tree-wide: drop empty comments 2018-06-29 11:00:30 +09:00
test-ellipsize.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-engine.c tree-wide: pass NULL arguments to manager_startup() directly, avoid declaring unneeded variables 2018-06-20 23:59:29 +02:00
test-env-util.c Drop my copyright headers 2018-06-14 13:03:20 +02:00
test-escape.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-exec-util.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-execute.c test: add tests for DynamicUser= with static User= whose UID and GID are different 2018-07-26 16:32:10 +09:00
test-extract-word.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-fd-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-fdset.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-fileio.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-firewall-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-format-table.c test: add a reproducer of issue #9549 2018-07-15 17:07:18 +09:00
test-fs-util.c fs-util: add new CHASE_NOFOLLOW flag to chase_symlinks() 2018-07-30 15:54:03 +02:00
test-fstab-util.c Drop my copyright headers 2018-06-14 13:03:20 +02:00
test-gcrypt-util.c Fix SPDX license tags 2018-06-14 13:05:41 +02:00
test-glob-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-hash.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-hashmap-ordered.awk meson: also indent scripts with 8 spaces 2017-04-25 08:49:16 -04:00
test-hashmap-plain.c tree-wide: drop copyright lines for more authors 2018-06-22 16:39:45 +02:00
test-hashmap.c tree-wide: drop copyright lines for more authors 2018-06-22 16:39:45 +02:00
test-helper.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-helper.h tree-wide: beautify remaining copyright statements 2018-06-14 10:20:21 +02:00
test-hexdecoct.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-hostname-util.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-hostname.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-id128.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-in-addr-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-install-root.c test: fix a memleak 2018-08-29 17:45:37 +02:00
test-install.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-io-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-ipcrm.c user-util: rework get_user_creds() 2018-08-20 15:58:21 +02:00
test-job-type.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-journal-importer.c Drop my copyright headers 2018-06-14 13:03:20 +02:00
test-libudev.c udev: move udev cleanup functions from udev-util.h to udev.h 2018-08-23 04:57:39 +09:00
test-list.c tree-wide: beautify remaining copyright statements 2018-06-14 10:20:21 +02:00
test-locale-util.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-log.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-loopback.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-mount-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-namespace.c Drop my copyright headers 2018-06-14 13:03:20 +02:00
test-netlink-manual.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-ns.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-nss.c test-nss-files: simplify module name handling 2018-07-31 19:37:49 +02:00
test-os-util.c os-util: add helpers for finding /etc/os-release 2018-05-24 17:01:57 +02:00
test-parse-util.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-path-lookup.c Drop my copyright headers 2018-06-14 13:03:20 +02:00
test-path-util.c Drop my copyright headers 2018-06-14 13:03:20 +02:00
test-path.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-prioq.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-proc-cmdline.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-process-util.c tests: skip test_get_process_cmdline_harder if `mount --make-rslave /` fails with EPERM or EACCESS 2018-07-23 11:30:57 +02:00
test-procfs-util.c Correct a number of trivial typos. 2018-06-18 22:44:44 +02:00
test-random-util.c random-util: use RDRAND for randomness if the kernel doesn't want to give us any 2018-08-21 20:13:32 +02:00
test-ratelimit.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-replace-var.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-rlimit-util.c tree-wide: drop 'This file is part of systemd' blurb 2018-06-14 10:20:20 +02:00
test-sched-prio.c tree-wide: pass NULL arguments to manager_startup() directly, avoid declaring unneeded variables 2018-06-20 23:59:29 +02:00
test-seccomp.c seccomp: add new system call filter, suitable as default whitelist for system services 2018-06-14 17:44:20 +02:00
test-selinux.c Drop my copyright headers 2018-06-14 13:03:20 +02:00
test-set.c Drop my copyright headers 2018-06-14 13:03:20 +02:00
test-sigbus.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-signal-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-siphash24.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-sizeof.c test-sizeof: another aproach to _Float128 availability detection 2018-06-20 17:06:21 +02:00
test-sleep.c sleep: fix one more printf format of a fiemap field 2018-06-28 03:29:21 +09:00
test-socket-util.c test-socket-util: avoid "memleak" reported by valgrind 2018-08-23 11:30:57 +02:00
test-specifier.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-stat-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-strbuf.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-string-util.c importd, basic/string-util: use case-insensitive comparison for HTTP headers 2018-09-03 22:59:27 +02:00
test-strip-tab-ansi.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-strv.c strv: make strv_split() accept empty string 2018-07-07 01:34:18 +09:00
test-strxcpyx.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-systemd-tmpfiles.py tree-wide: drop 'This file is part of systemd' blurb 2018-06-14 10:20:20 +02:00
test-tables.c Merge pull request #9685 from yuwata/fix-9663 2018-07-23 21:17:07 +02:00
test-terminal-util.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-time-util.c parse-util: make sure "3.+1s" or "3. 1s" are not considered valid time specification 2018-07-19 22:09:54 -07:00
test-tmpfiles.c Drop my copyright headers 2018-06-14 13:03:20 +02:00
test-udev.c udev: move udev cleanup functions from udev-util.h to udev.h 2018-08-23 04:57:39 +09:00
test-uid-range.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-umount.c core/umount: use libmount to enumerate /proc/swaps 2018-03-16 10:12:50 +01:00
test-unaligned.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-unit-file.c Drop my copyright headers 2018-06-14 13:03:20 +02:00
test-unit-name.c tree-wide: drop copyright headers from frequent contributors 2018-06-20 11:58:53 +02:00
test-user-util.c user-util: rework get_user_creds() 2018-08-20 15:58:21 +02:00
test-utf8.c tree-wide: drop copyright lines for more authors 2018-06-22 16:39:45 +02:00
test-util.c test: cast values in proper type to suppress warnings 2018-08-07 15:40:16 +02:00
test-verbs.c Drop copyrights tags for "systemd authors" 2018-06-20 12:11:12 +02:00
test-watch-pid.c core: undo the dependency inversion between unit.h and all unit types 2018-05-15 14:24:34 -04:00
test-watchdog.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-web-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-xattr-util.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00
test-xml.c tree-wide: remove Lennart's copyright lines 2018-06-14 10:20:20 +02:00