]> ruderich.org/simon Gitweb - nsscash/nsscash.git/log
nsscash/nsscash.git
4 years agoMakefile: run go test in test target, not all target
Simon Ruderich [Wed, 12 Jun 2019 06:51:13 +0000 (08:51 +0200)]
Makefile: run go test in test target, not all target

4 years agonsscash: go fmt
Simon Ruderich [Wed, 12 Jun 2019 06:50:39 +0000 (08:50 +0200)]
nsscash: go fmt

4 years agonsscash: replace %s with %v in format string for File.Type
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.

4 years agonsscash: report error for passwd/group without trailing newline
Simon Ruderich [Wed, 12 Jun 2019 06:45:49 +0000 (08:45 +0200)]
nsscash: report error for passwd/group without trailing newline

Previously this case was hidden because ReadString() can return a string
and an EOF error. To prevent this issue from going unnoticed error out.

4 years agonss: Makefile: don't link against asan
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.

4 years agoCheck size limits and abort if they are violated
Simon Ruderich [Tue, 11 Jun 2019 09:05:08 +0000 (11:05 +0200)]
Check size limits and abort if they are violated

Also document them in the README and add tests.

4 years agonsscash: handle errors in SerializePasswd(), SerializeGroup()
Simon Ruderich [Tue, 11 Jun 2019 08:56:44 +0000 (10:56 +0200)]
nsscash: handle errors in SerializePasswd(), SerializeGroup()

No such errors are defined yet.

4 years agonsscash: support longer lines in passwd/group files
Simon Ruderich [Tue, 11 Jun 2019 08:53:43 +0000 (10:53 +0200)]
nsscash: support longer lines in passwd/group files

bufio.Scanner has an internal limit on the maximum token (= line)
length. We want to support larger lines in the future.

4 years agonss: tests: sort included headers
Simon Ruderich [Tue, 11 Jun 2019 07:48:05 +0000 (09:48 +0200)]
nss: tests: sort included headers

4 years agonss: Makefile: build libcash_test.so in tests/
Simon Ruderich [Mon, 10 Jun 2019 21:53:49 +0000 (23:53 +0200)]
nss: Makefile: build libcash_test.so in tests/

Prevents accidentally copying the test library instead of the actual NSS
library.

4 years agoREADME: document practices and tested systems
Simon Ruderich [Mon, 10 Jun 2019 21:40:00 +0000 (23:40 +0200)]
README: document practices and tested systems

4 years agonsscash: improve comments
Simon Ruderich [Mon, 10 Jun 2019 21:36:05 +0000 (23:36 +0200)]
nsscash: improve comments

4 years agonsscash: add alignBufferTo() helper
Simon Ruderich [Mon, 10 Jun 2019 21:34:45 +0000 (23:34 +0200)]
nsscash: add alignBufferTo() helper

4 years agonss: improve comments
Simon Ruderich [Mon, 10 Jun 2019 21:00:25 +0000 (23:00 +0200)]
nss: improve comments

4 years agonss: gr/pw: re-used variable
Simon Ruderich [Mon, 10 Jun 2019 20:59:08 +0000 (22:59 +0200)]
nss: gr/pw: re-used variable

Now that the key argument is const we can use this to reduces code
duplication.

4 years agonss: gr/pw: use key->name for NULL check
Simon Ruderich [Mon, 10 Jun 2019 20:57:40 +0000 (22:57 +0200)]
nss: gr/pw: use key->name for NULL check

This is consistent with search.c's bsearch_callback() which also checks
key->name first.

4 years agonss: gr/pw: make data const
Simon Ruderich [Mon, 10 Jun 2019 20:56:17 +0000 (22:56 +0200)]
nss: gr/pw: make data const

We cannot modify it anyway.

4 years agonss: search: make search_key argument const
Simon Ruderich [Mon, 10 Jun 2019 20:48:39 +0000 (22:48 +0200)]
nss: search: make search_key argument const

4 years agonss: search.h: re-order struct file members
Simon Ruderich [Mon, 10 Jun 2019 20:41:48 +0000 (22:41 +0200)]
nss: search.h: re-order struct file members

4 years agonss: file.h: re-order struct file members
Simon Ruderich [Mon, 10 Jun 2019 20:27:48 +0000 (22:27 +0200)]
nss: file.h: re-order struct file members

4 years agonss: merge cash.h into file.h
Simon Ruderich [Mon, 10 Jun 2019 20:26:00 +0000 (22:26 +0200)]
nss: merge cash.h into file.h

file.h is a more logical place anyway and this gets rid of a useless
header file.

4 years agonss: simplify initialization of struct file in map_file()
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.

4 years agoREADME: minor updates and fixes
Simon Ruderich [Sun, 9 Jun 2019 12:25:52 +0000 (14:25 +0200)]
README: minor updates and fixes

4 years agonss: Makefile: fix typo in LD_PRELOAD variable name
Simon Ruderich [Sun, 9 Jun 2019 12:11:31 +0000 (14:11 +0200)]
nss: Makefile: fix typo in LD_PRELOAD variable name

4 years agoREADME: add requirements and usage instructions
Simon Ruderich [Sat, 8 Jun 2019 14:26:17 +0000 (16:26 +0200)]
README: add requirements and usage instructions

4 years agoMakefile: run all and clean in nss/ as well
Simon Ruderich [Sat, 8 Jun 2019 13:57:23 +0000 (15:57 +0200)]
Makefile: run all and clean in nss/ as well

This way a single `make all` builds the whole project.

4 years agoMakefile: add test target
Simon Ruderich [Sat, 8 Jun 2019 13:55:58 +0000 (15:55 +0200)]
Makefile: add test target

4 years agonsscache: add comment
Simon Ruderich [Sat, 8 Jun 2019 13:54:35 +0000 (15:54 +0200)]
nsscache: add comment

4 years agonss: tests: fix typo in comment
Simon Ruderich [Sat, 8 Jun 2019 13:51:44 +0000 (15:51 +0200)]
nss: tests: fix typo in comment

4 years agonsscash: use WriteByte() instead of Write() with cast
Simon Ruderich [Sat, 8 Jun 2019 13:50:34 +0000 (15:50 +0200)]
nsscash: use WriteByte() instead of Write() with cast

Less to type and easier to read.

The old solution used '0' to pad instead 0. This isn't an issue as these
bytes are not used. But fix it as well.

4 years agonsscash: improve index sanity check
Simon Ruderich [Sat, 8 Jun 2019 13:49:55 +0000 (15:49 +0200)]
nsscash: improve index sanity check

This ensures that the index has the proper size and is not missing any
entries.

4 years agoAdd support for group files
Simon Ruderich [Sat, 8 Jun 2019 13:49:33 +0000 (15:49 +0200)]
Add support for group files

4 years agonsscash: go fmt
Simon Ruderich [Sat, 8 Jun 2019 12:34:52 +0000 (14:34 +0200)]
nsscash: go fmt

4 years agonsscash: add support to convert plain files
Simon Ruderich [Sat, 8 Jun 2019 12:33:58 +0000 (14:33 +0200)]
nsscash: add support to convert plain files

For plain files this is just a copy. But it prepares for conversion of
other types in the future.

4 years agonss: add tests
Simon Ruderich [Sat, 8 Jun 2019 12:06:55 +0000 (14:06 +0200)]
nss: add tests

These also test large parts of the Go code.

4 years agonss: move NSS function definitions to separate header
Simon Ruderich [Sat, 8 Jun 2019 11:17:36 +0000 (13:17 +0200)]
nss: move NSS function definitions to separate header

Documents which functions we provide and will be used for tests in the
future.

4 years agonss: Makefile: inline library flags
Simon Ruderich [Sat, 8 Jun 2019 11:06:04 +0000 (13:06 +0200)]
nss: Makefile: inline library flags

We want to build programs in the future which will conflict with -shared
-fPIC.

4 years agonsscash: add "convert" sub-command
Simon Ruderich [Sat, 8 Jun 2019 10:51:32 +0000 (12:51 +0200)]
nsscash: add "convert" sub-command

Permits manually converting a file without having to fetch it from a
webserver.

4 years agonsscash: remove a few empty lines
Simon Ruderich [Sat, 8 Jun 2019 10:41:01 +0000 (12:41 +0200)]
nsscash: remove a few empty lines

4 years agonsscash: go fmt
Simon Ruderich [Sat, 8 Jun 2019 10:40:35 +0000 (12:40 +0200)]
nsscash: go fmt

4 years agonsscash: add "fetch" sub-command for the default action
Simon Ruderich [Sat, 8 Jun 2019 10:39:55 +0000 (12:39 +0200)]
nsscash: add "fetch" sub-command for the default action

In preparation for more sub-commands in the future.

4 years agoFirst working version
Simon Ruderich [Sat, 8 Jun 2019 10:24:27 +0000 (12:24 +0200)]
First working version

Supports only /etc/passwd at the moment.

4 years agoInitial commit
Simon Ruderich [Sat, 8 Jun 2019 08:28:39 +0000 (10:28 +0200)]
Initial commit