nixpkgs/nixos/tests
aszlig e1d63ada02
nginx: Fix ETag patch to ignore realpath(3) error
While our ETag patch works pretty fine if it comes to serving data off
store paths, it unfortunately broke something that might be a bit more
common, namely when using regexes to extract path components of
location directives for example.

Recently, @devhell has reported a bug with a nginx location directive
like this:

  location ~^/\~([a-z0-9_]+)(/.*)?$" {
    alias /home/$1/public_html$2;
  }

While this might look harmless at first glance, it does however cause
issues with our ETag patch. The alias directive gets broken up by nginx
like this:

  *2 http script copy: "/home/"
  *2 http script capture: "foo"
  *2 http script copy: "/public_html/"
  *2 http script capture: "bar.txt"

In our patch however, we use realpath(3) to get the canonicalised path
from ngx_http_core_loc_conf_s.root, which returns the *configured* value
from the root or alias directive. So in the example above, realpath(3)
boils down to the following syscalls:

  lstat("/home", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
  lstat("/home/$1", 0x7ffd08da6f60) = -1 ENOENT (No such file or directory)

During my review[1] of the initial patch, I didn't actually notice that
what we're doing here is returning NGX_ERROR if the realpath(3) call
fails, which in turn causes an HTTP 500 error.

Since our patch actually made the canonicalisation (and thus additional
syscalls) necessary, we really shouldn't introduce an additional error
so let's - at least for now - silently skip return value if realpath(3)
has failed.

However since we're using the unaltered root from the config we have
another issue, consider this root:

  /nix/store/...-abcde/$1

Calling realpath(3) on this path will fail (except if there's a file
called "$1" of course), so even this fix is not enough because it
results in the ETag not being set to the store path hash.

While this is very ugly and we should fix this very soon, it's not as
serious as getting HTTP 500 errors for serving static files.

I added a small NixOS VM test, which uses the example above as a
regression test.

It seems that my memory is failing these days, since apparently I *knew*
about this issue since digging for existing issues in nixpkgs, I found
this similar pull request which I even reviewed:

https://github.com/NixOS/nixpkgs/pull/66532

However, since the comments weren't addressed and the author hasn't
responded to the pull request, I decided to keep this very commit and do
a follow-up pull request.

[1]: https://github.com/NixOS/nixpkgs/pull/48337

Signed-off-by: aszlig <aszlig@nix.build>
Reported-by: @devhell
Acked-by: @7c6f434c
Acked-by: @yorickvP
Merges: https://github.com/NixOS/nixpkgs/pull/80671
Fixes: https://github.com/NixOS/nixpkgs/pull/66532
2020-03-28 02:57:21 +01:00
..
common nixos/acme: Update release note, remove redundant requires 2020-02-09 16:31:07 +00:00
google-oslogin
hadoop
hitch
hocker-fetchdocker
hydra
initrd-network-ssh
installed-tests Merge pull request #79416 from jtojnar/flatpak-1.6 2020-02-10 12:57:19 -05:00
kerberos
krb5 nixosTests.krb5: Port to python 2020-02-14 09:56:32 +01:00
kubernetes tests/kubernetes: remove unreferenced variable and import from inexsisting file 2020-03-07 00:21:11 +00:00
lorri Revert "Revert "Merge master into staging-next"" 2020-02-05 19:41:25 +01:00
nextcloud
nfs tests: fix more loaOf deprecation warnings 2020-02-17 09:57:35 +01:00
wireguard
xmpp
3proxy.nix nixosTests.3proxy: port test to python 2020-01-02 14:25:20 +02:00
acme.nix nixos/acme: Fix a.example.com test 2020-02-19 15:46:14 +01:00
all-tests.nix nginx: Fix ETag patch to ignore realpath(3) error 2020-03-28 02:57:21 +01:00
ammonite.nix
atd.nix
automysqlbackup.nix
avahi.nix
babeld.nix
bcachefs.nix
beanstalkd.nix
bees.nix
bind.nix
bittorrent.nix nixosTests.bittorrent: Refactor declarative part 2020-01-14 10:22:46 +01:00
boot-stage1.nix
boot.nix
borgbackup.nix
buildbot.nix buildbot: 2.6.0 -> 2.7.0 (#81406) 2020-02-29 18:24:02 -05:00
buildkite-agents.nix nixos/buildkite-agents: support multiple buildkite agents 2020-02-10 13:35:14 +01:00
caddy.nix
cadvisor.nix
cage.nix nixos/cage: init 2020-03-02 13:43:20 -08:00
cassandra.nix
ceph-multi-node.nix nixos/tests/ceph: Use 3 osds, the default minimum 2020-01-09 08:00:19 +01:00
ceph-single-node.nix nixos/tests/ceph: Use 3 osds, the default minimum 2020-01-09 08:00:19 +01:00
certmgr.nix nixos/tests/certmgr: Fix file permissions 2020-01-11 16:18:10 -08:00
cfssl.nix
chromium.nix nixosTests.chromium: Port to Python 2020-02-06 15:51:38 +01:00
cjdns.nix
clickhouse.nix
cloud-init.nix
cockroachdb.nix
codimd.nix
consul.nix
containers-bridge.nix
containers-ephemeral.nix
containers-extra_veth.nix
containers-hosts.nix
containers-imperative.nix nixos/nixos-container: ensure that the state-dir is cleaned up if a build fails 2020-02-11 14:42:30 +01:00
containers-ip.nix
containers-macvlans.nix
containers-physical_interfaces.nix
containers-portforward.nix
containers-reloadable.nix
containers-restart_networking.nix
containers-tmpfs.nix
corerad.nix nixos/corerad: update advertisement argument 2020-02-09 18:09:22 -08:00
couchdb.nix
deluge.nix
dhparams.nix
dnscrypt-proxy2.nix nixosTests.dnscrypt-proxy2: init 2020-02-02 21:51:19 -05:00
docker-containers.nix nixosTests.docker-containers: Port to python 2020-02-13 12:01:38 +01:00
docker-edge.nix
docker-preloader.nix
docker-registry.nix
docker-tools-overlay.nix
docker-tools.nix buildLayeredImage: Allow empty store, no paths to add 2020-02-28 14:59:04 +01:00
docker.nix
documize.nix
dokuwiki.nix nixos/dokuwiki: init module at 2018-04-22b 2020-01-24 13:27:10 +01:00
dovecot.nix
ec2.nix nixos/tests/ec2: return to passing state 2020-01-13 15:52:37 +09:00
ecryptfs.nix
elk.nix Enable elasticsearch-curator on elasticsearch 7 2020-01-15 10:12:19 +01:00
emacs-daemon.nix
env.nix
etcd-cluster.nix
etcd.nix
fancontrol.nix
fenics.nix nixosTests.fenics: Add basic test 2020-03-19 21:48:27 -07:00
ferm.nix
firefox.nix nixos/tests/firefox: support running the test with the firefox ESR version 2020-02-11 08:58:13 +01:00
firewall.nix
fish.nix
flannel.nix
fluentd.nix
fontconfig-default-fonts.nix
freeswitch.nix nixos/freeswitch: init 2020-01-30 17:16:49 +02:00
fsck.nix
gerrit.nix nixos: add gerrit module 2020-03-26 09:28:42 +01:00
gitdaemon.nix nixos/git-daemon: only create git user if it will be used 2020-02-26 15:04:36 +01:00
gitea.nix
gitlab.nix
gitolite-fcgiwrap.nix
gitolite.nix
glusterfs.nix tests: fix more loaOf deprecation warnings 2020-02-17 09:57:35 +01:00
gnome3-xorg.nix
gnome3.nix nixosTests.gnome3: wait_for_wayland at login 2020-01-30 17:51:01 -05:00
gocd-agent.nix
gocd-server.nix
gotify-server.nix
grafana.nix
graphite.nix nixos/griphite: Migrate to python3, drop graphite-pager 2020-03-22 22:47:53 -07:00
graylog.nix
grocy.nix nixos/grocy: init module 2020-02-09 21:55:27 +01:00
gvisor.nix
haka.nix
handbrake.nix
haproxy.nix
hardened.nix
hibernate.nix
home-assistant.nix nixosTests.home-assistant: port to python 2020-01-09 10:39:50 +00:00
hound.nix
i3wm.nix nixos/display-managers/auto: remove 2020-01-29 19:05:46 -05:00
icingaweb2.nix
iftop.nix
ihatemoney.nix nixosTests.ihatemoney: Port to python 2020-02-02 10:43:38 +01:00
incron.nix
influxdb.nix
initrd-network.nix nixos/initrd-network: flush interfaces before stage 2 2020-02-08 14:04:02 +01:00
installer.nix nixosTests.installer: Don't wait for the nixos-manual service 2020-03-26 01:21:34 +01:00
iodine.nix nixos/iodine: add test 2020-02-04 20:54:29 +01:00
ipfs.nix
ipv6.nix
jackett.nix
jellyfin.nix
jenkins.nix
jirafeau.nix nixos/jirefeau: add services.jirafeau module 2020-02-18 09:37:44 -08:00
kafka.nix kafka: Add 2.4 2020-01-10 21:02:03 -05:00
keepalived.nix
kernel-latest.nix
kernel-lts.nix
kernel-testing.nix
kexec.nix
keymap.nix nixosTests.keymap: Port to python 2020-02-02 10:46:54 +01:00
knot.nix knot: add keyFiles option 2020-02-12 16:36:42 +00:00
ldap.nix
leaps.nix
lidarr.nix
lightdm.nix
limesurvey.nix nixosTests.limesurvey: Port to python 2020-01-26 17:11:59 +01:00
login.nix
loki.nix
magnetico.nix
mailcatcher.nix
make-test-python.nix
make-test.nix
mathics.nix
matomo.nix
matrix-synapse.nix matrix-synapse: 1.9.1 -> 1.11.1 2020-03-15 17:09:51 +01:00
mediawiki.nix
memcached.nix
mesos.nix
mesos_test.py
metabase.nix
minidlna.nix
miniflux.nix
minio.nix
misc.nix nixosTests.misc: fix blkio sub-test with newer kernels 2020-02-02 13:20:03 +01:00
moinmoin.nix
mongodb.nix nixos/tests/mongodb: rewrite with python 2020-03-26 14:02:49 +01:00
moodle.nix
morty.nix
mosquitto.nix
mpd.nix
mpich-example.c
mumble.nix
munin.nix
mutable-users.nix
mxisd.nix
mysql-backup.nix
mysql-replication.nix
mysql.nix nixos/mysql: test with mysql80 package 2020-03-21 15:47:38 -04:00
nagios.nix
nat.nix
ndppd.nix
neo4j.nix
nesting.nix nixosTests.nesting: fix subtest scoping 2020-02-27 23:57:36 +09:00
netdata.nix
networking-proxy.nix nixosTests.networkingProxy: port to Python 2020-01-30 19:13:30 -05:00
networking.nix nixos/networkd: respect systemd.network.links also with disabled systemd-networkd 2020-03-19 14:15:32 +01:00
nexus.nix
nghttpx.nix
nginx-etag.nix
nginx-pubhtml.nix nginx: Fix ETag patch to ignore realpath(3) error 2020-03-28 02:57:21 +01:00
nginx-sso.nix
nginx.nix nixos/nginx: don't hide nginx config errors on nixos-rebuild --switch with reload enabled (#76179) 2020-01-05 00:39:23 +02:00
nix-ssh-serve.nix
nixos-generate-config.nix
novacomd.nix
nsd.nix nixosTests.nsd: Port to python 2020-02-13 16:34:02 +01:00
nzbget.nix
openarena.nix nixos/tests/openarena: run real openarena clients 2020-02-01 16:09:30 +01:00
openldap.nix
opensmtpd.nix nixos/tests/opensmtpd: bump test (&build) timeout to 30m from 30s 2020-02-25 23:08:32 +01:00
openssh.nix
openstack-image.nix nixos/tests/openstack-image: add stdenv to image for nixos-rebuild 2020-02-03 10:44:53 +09:00
orangefs.nix tests: fix more loaOf deprecation warnings 2020-02-17 09:57:35 +01:00
os-prober.nix
osrm-backend.nix
overlayfs.nix
packagekit.nix
pam-oath-login.nix
pam-u2f.nix
pantheon.nix
paperless.nix
partition.nix
pdns-recursor.nix
peerflix.nix
pgjwt.nix
pgmanage.nix
php-pcre.nix
plasma5.nix
plotinus.nix nixosTests.plotinus: Port to Python 2020-02-13 23:36:13 +01:00
postgis.nix
postgresql-wal-receiver.nix postgresql-wal-receiver: fix test for Pg12 (#80268) 2020-02-16 22:58:34 +02:00
postgresql.nix nixosTests.initdb: Move code to existing postgres test 2020-01-09 23:21:51 +01:00
powerdns.nix
pppd.nix
predictable-interface-names.nix nixos/stage-1: fix predictable interfaces names 2020-02-08 14:04:02 +01:00
printing.nix nixosTests.printing: Port to Python 2020-02-06 11:29:23 +01:00
prometheus-exporters.nix nixos/prometheus-mikrotik-exporter: init 2020-03-06 10:39:05 +01:00
prometheus.nix
proxy.nix nixosTests.proxy: Port to python 2020-01-26 17:12:03 +01:00
quagga.nix
rabbitmq.nix
radarr.nix
radicale.nix
redis.nix
redmine.nix
resolv.nix
restic.nix nixos/tests/restic.nix: add test 2020-02-07 10:36:53 +00:00
riak.nix
roundcube.nix
rspamd.nix
rss2email.nix
rsyslogd.nix nixosTests.rsyslogd: Port to python 2020-02-27 16:43:45 +01:00
run-in-machine.nix nixosTests.run-in-machine: Port to python 2020-02-14 19:05:03 +01:00
rxe.nix
samba.nix
sanoid.nix nixos/sanoid, nixos/syncoid: init module and test 2020-02-10 01:12:39 +01:00
sddm.nix
service-runner.nix nixos/service-runner.nix: Allow quotes in commands + test 2020-02-28 14:26:29 +01:00
shiori.nix
signal-desktop.nix tests: Fix signal-desktop 2020-03-09 13:13:51 +00:00
simple.nix
slurm.nix
smokeping.nix
snapper.nix
solr.nix nixosTests.solr: Port to python 2020-02-13 22:40:47 +01:00
sonarr.nix
spacecookie.nix
spike.nix
ssh-keys.nix
strongswan-swanctl.nix
sudo.nix
switch-test.nix
sympa.nix nixos/sympa: init module 2020-02-07 22:54:27 +01:00
syncthing-init.nix
syncthing-relay.nix
systemd-analyze.nix
systemd-confinement.nix
systemd-networkd-vrf.nix nixos/networkd: disable vrf sub-test which tests the behavior of tcp-packets 2020-02-25 19:54:57 +01:00
systemd-networkd.nix nixos/networkd: test routingPolicyRules with a nixos vm test 2020-03-02 15:37:40 +01:00
systemd-nspawn.nix
systemd-timesyncd.nix
systemd.nix Merge pull request #78241 from andrew-d/andrew/systemd-tests-python 2020-01-30 03:10:39 -05:00
taskserver.nix
telegraf.nix
testdb.sql
tiddlywiki.nix
timezone.nix
tinydns.nix nixos/tinydns: use local dns server to fix test 2020-02-19 12:27:29 -08:00
tor.nix
trac.nix
transmission.nix
trezord.nix
trickster.nix
trilium-server.nix
udisks2.nix
upnp.nix
uwsgi.nix
vault.nix
victoriametrics.nix victoriametrics: add module, tests 2020-01-29 19:52:14 +01:00
virtualbox.nix nixos/display-managers/auto: remove 2020-01-29 19:05:46 -05:00
wordpress.nix
xandikos.nix nixosTests.xandikos: init 2020-01-11 16:08:44 +01:00
xautolock.nix nixos/display-managers/auto: remove 2020-01-29 19:05:46 -05:00
xfce.nix nixos/display-managers/auto: remove 2020-01-29 19:05:46 -05:00
xmonad.nix nixos/display-managers/auto: remove 2020-01-29 19:05:46 -05:00
xrdp.nix nixos/display-managers/auto: remove 2020-01-29 19:05:46 -05:00
xss-lock.nix nixos/display-managers/auto: remove 2020-01-29 19:05:46 -05:00
yabar.nix nixos/display-managers/auto: remove 2020-01-29 19:05:46 -05:00
yggdrasil.nix
zfs.nix nixosTests.zfs: Refactor 2020-02-07 13:24:16 +01:00
zookeeper.nix
zsh-history.nix