Simon Ruderich [Fri, 2 Aug 2019 19:04:25 +0000 (21:04 +0200)]
nsscash: force UTC timezone for If-Modified-Since header
This is not strictly required as lastModified is already stored in UTC
(servers use UTC for the Last-Modified header). However, it's good
practice and prevents copy & past errors in the future. See d71bfc6
("nsscash: main_test: fix Last-Modified/If-Modified-Since headers",
2019-08-02) for the details.
Simon Ruderich [Fri, 2 Aug 2019 19:00:51 +0000 (21:00 +0200)]
nsscash: main_test: test new server response which causes an update
The existing tests only tested that a modified local version of the file
causes a download from the server. However, the modified local version
is caught by the checksum in the state file and does not verify that an
update from the server is properly applied. Thus, add this new test.
http.TimeFormat requires a time in UTC for a proper Last-Modified
header. Previously, the time was in CEST (my local timezone) which
caused all Last-Modified headers to have an offset of two hours. This
also hid a bug in the If-Modified-Since header handling: The last change
time must be truncated to seconds as the If-Modified-Since header has
only a second precision.
These bugs did not affect the current test cases. However, it affects
the test case which will be added in the next commit.
Simon Ruderich [Fri, 14 Jun 2019 18:28:29 +0000 (20:28 +0200)]
nsscash: convert: create file atomically
Previously the file was first truncated or created and then written to.
Although "convert" is not designed to be used for deployment, it is a
unexpected behavior.
Simon Ruderich [Thu, 13 Jun 2019 06:25:09 +0000 (08:25 +0200)]
nsscash: store and check hash of deployed files
The goal is to detect manual modifications of the deployed files. As we
store only the last modification in the state file and don't check the
deployed file itself, modifications go unnoticed.
An alternative would be to check the last modification time of the
deployed files. But a hash is safer as possible corruptions to the file
are detected as well.
Simon Ruderich [Wed, 12 Jun 2019 06:48:16 +0000 (08:48 +0200)]
nsscash: replace %s with %v in format string for File.Type
File.Type is an int value with a stringer go:generate statement. Using
%s breaks running `go test` (which runs `go vet`) before running `go
generate`. Using %v has the same result and uses the stringified version
when available.
Simon Ruderich [Tue, 11 Jun 2019 09:05:49 +0000 (11:05 +0200)]
nss: Makefile: don't link against asan
This is not necessary and was only a hack to handle non-empty LD_PRELOAD
environment variables. We explicitly empty LD_PRELOAD before calling our
test binaries.
Simon Ruderich [Mon, 10 Jun 2019 20:14:50 +0000 (22:14 +0200)]
nss: simplify initialization of struct file in map_file()
It's not necessary to initialize ->fd at the beginning of map_file() as
the call to open(2) will overwrite it anyway.
Also adapt a check for a valid file descriptor. Although POSIX states
that open(2) returns -1 on error, there is no reason to hard-code this
constant. Instead, check for any negative value.