chiark / gitweb /
secnet.git
4 years agopubkeys: Improve debug message for expected ENOENT
Ian Jackson [Sat, 23 Nov 2019 17:28:11 +0000 (17:28 +0000)]
pubkeys: Improve debug message for expected ENOENT

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agopubkeys: Pass a cloc to loadpub
Ian Jackson [Sat, 23 Nov 2019 10:51:53 +0000 (10:51 +0000)]
pubkeys: Pass a cloc to loadpub

This will be used for error reporting.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agopubkeys: Move path and lno into a struct cloc
Ian Jackson [Sat, 23 Nov 2019 11:28:56 +0000 (11:28 +0000)]
pubkeys: Move path and lno into a struct cloc

No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agopubkeys: Print file path in some log messages
Ian Jackson [Sat, 16 Nov 2019 21:42:45 +0000 (21:42 +0000)]
pubkeys: Print file path in some log messages

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agopubkeys: Introduce `pkgf' fallback groups
Ian Jackson [Mon, 2 Dec 2019 00:18:26 +0000 (00:18 +0000)]
pubkeys: Introduce `pkgf' fallback groups

This involves a new directive alias facility.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agopubkeys: Provide `fallback_skip' variable
Ian Jackson [Fri, 6 Dec 2019 23:53:35 +0000 (23:53 +0000)]
pubkeys: Provide `fallback_skip' variable

Currently nothing sets this nonzero.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agopubkeys: Provide ability to add extra action to KEYWORD
Ian Jackson [Fri, 6 Dec 2019 23:51:52 +0000 (23:51 +0000)]
pubkeys: Provide ability to add extra action to KEYWORD

Nothing uses this yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agopubkeys: Provide parser (and spec) for peer pubkeys files
Ian Jackson [Sun, 29 Sep 2019 10:09:35 +0000 (11:09 +0100)]
pubkeys: Provide parser (and spec) for peer pubkeys files

Nothing uses this yet; also, we don't have code in make-secnet-sites
to generate these either.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoportability: Provide implementation of fmemopen
Ian Jackson [Tue, 26 Nov 2019 22:16:22 +0000 (22:16 +0000)]
portability: Provide implementation of fmemopen

We are going to want one of these.  I have tested it as follows:

1. In configure.ac just before AC_CHECK_FUNCS, add:  LIBS+=-lbsd
2. In osdep.c, add:  #include <bsd/stdio.h>
3. Change all fmemopen to Yfmemopen, with
     git-ls-files | perl -lne 'print if lstat and -f _' | xargs perl -i~ -pe 's/fmemopen/Y$&/gi'

The result is that we do not find Yfmemopen.  The tests still pass and
I have verified that my stunt implementation is called.

FTR, this rune undoes the Y:
     git-ls-files | perl -lne 'print if lstat and -f _' | xargs perl -i~ -pe 's/Y(fmemopen)/$1/gi'

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoProvide osdep.[ch], currently empty
Ian Jackson [Tue, 26 Nov 2019 22:14:23 +0000 (22:14 +0000)]
Provide osdep.[ch], currently empty

These will be used for compatibility implementations.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agobase91: Python: make `import' work
Ian Jackson [Fri, 8 Nov 2019 20:26:35 +0000 (20:26 +0000)]
base91: Python: make `import' work

We have subtree merged the base91 python module as base91-python.

We will want to be able to `import base91'.  So make a symlink
`base91.py', and arrange to install it.  ($(INSTALL) installs a copy
of the file, not the link, as we need it to.)

This is getting rather intimate with the file structure of the
upstream base91-python.  If base91-python ever becomes more
complicated, and this breaks, it would surely be best to make it into
its own package.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agobase91: CREDITS: Add information about Python library
Ian Jackson [Wed, 4 Dec 2019 23:22:58 +0000 (23:22 +0000)]
base91: CREDITS: Add information about Python library

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoAdd 'base91-python/' from commit '749aa78cf12496cca4b9bf3eafe045809fc0da10'
Ian Jackson [Sat, 15 Feb 2020 21:56:19 +0000 (21:56 +0000)]
Add 'base91-python/' from commit '749aa78cf12496cca4b9bf3eafe045809fc0da10'

Upstream is
    https://github.com/Fuyukai/base91-python

git-subtree-dir: base91-python
git-subtree-mainline: 7fcfcb3210f7bdaddc5a1fc68586846b31adab63
git-subtree-split: 749aa78cf12496cca4b9bf3eafe045809fc0da10

4 years agobase91: Link it into secnet
Ian Jackson [Tue, 26 Nov 2019 23:37:51 +0000 (23:37 +0000)]
base91: Link it into secnet

This means that code in secnet can #include it and then call it.
Nothing does yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agobase91: Patch the C version for our charset change
Ian Jackson [Sun, 17 Nov 2019 01:49:18 +0000 (01:49 +0000)]
base91: Patch the C version for our charset change

The base91.c.patch file was made by editing base91.c by hand and
running git diff.  The change to enctab is the obvious one.
The change to dectab was simply done by hand based on inspection.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agobase91: Build the C basE91 code with our own renaming
Ian Jackson [Sun, 17 Nov 2019 01:44:30 +0000 (01:44 +0000)]
base91: Build the C basE91 code with our own renaming

We want to use a variant character set.  This will mean patching the
library.  (That will happen in a moment.)  It seems unwise, and
perhaps rude, to make a thing that has the same name as the official
basE91 but has a different and incompatible encoding.

So we change all the names: `basE91' and `base91' become base91s.

We don't change the leaf filenames because that's rather
inconvenient.  We do put it all in a base91s subdirectory.

Rather than running the basE91 upstream makefile, or trying to sed it,
or something, we simply make our own makefile.  It is simple enough.
The only complication is that the "source" files are all actually made
by this name substitution perl rune.

Overall, the chief result is that we build a base91s/base91s utility,
by default.

Right now it does not have our charset change, so it is not ready for
use yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agobase91: CREDITS: Add information about C library
Ian Jackson [Wed, 4 Dec 2019 23:54:29 +0000 (23:54 +0000)]
base91: CREDITS: Add information about C library

We introduced this in the previous commit, but it is a bit awkward to
combine this change with a subtree merge.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoAdd 'base91-c/' from commit '664054e8f603f09badb98ef09ee1bd1e58d93659'
Ian Jackson [Sat, 15 Feb 2020 21:51:36 +0000 (21:51 +0000)]
Add 'base91-c/' from commit '664054e8f603f09badb98ef09ee1bd1e58d93659'

I imported a tarball download from
    http://downloads.sourceforge.net/base91/base91-0.6.0.tar.gz
and then made few commits of my own; you can find my base91-c at
    https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/githttp/base91.git

git-subtree-dir: base91-c
git-subtree-mainline: ed50eaeb8f01deade6e230811de72ba19da7e32f
git-subtree-split: 664054e8f603f09badb98ef09ee1bd1e58d93659

4 years agosyntax: Support &: literal (for make `grouped' multiple targets)
Ian Jackson [Sun, 26 Jan 2020 12:37:14 +0000 (12:37 +0000)]
syntax: Support &: literal (for make `grouped' multiple targets)

Very recent versions of GNU make support this syntax:

  foo bar biz &: baz boz
        echo $^ > foo
        echo $^ > bar
        echo $^ > biz

(See (make)Multiple Targets, subheading `Rules with Grouped Targets')

This use of & is nonoverlapping with everything we care about, so we
can just pass it straight through.  Passing through &: means we pass
through &:: too.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoREADME: Add subheading `Directives'
Ian Jackson [Sun, 26 Jan 2020 12:36:53 +0000 (12:36 +0000)]
README: Add subheading `Directives'

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoSyntax: Incompatible change: &$( does not do daft { thing
Ian Jackson [Sat, 11 Jan 2020 14:13:03 +0000 (14:13 +0000)]
Syntax: Incompatible change: &$( does not do daft { thing

It is silly for &$( to expand to ${.  That requires the input to
contain non-matched kinds of brackets.

The shell compatibility is not needed.  In a shell rune, you can write
&\$thing since the { } are not normally needed there at all.  If they
are then now &\${thing} is necessary.  It would be possible to steal
"&${" (or allow only "&$(") but that seems less good.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoSyntax: Provide convenience syntax &( for $(eval
Ian Jackson [Sat, 11 Jan 2020 13:58:34 +0000 (13:58 +0000)]
Syntax: Provide convenience syntax &( for $(eval

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agotests/filter/extract-doctests: Use $withspcs more
Ian Jackson [Sat, 11 Jan 2020 13:51:21 +0000 (13:51 +0000)]
tests/filter/extract-doctests: Use $withspcs more

This does away with a special case and will allow general use of
spaces in before and after expansions.

No change with current input.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agotests/filter/extract-doctests: Improve an error message
Ian Jackson [Sat, 11 Jan 2020 13:50:32 +0000 (13:50 +0000)]
tests/filter/extract-doctests: Improve an error message

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agotests/filter/extract-doctests: Recognise directives first
Ian Jackson [Sat, 11 Jan 2020 13:49:01 +0000 (13:49 +0000)]
tests/filter/extract-doctests: Recognise directives first

We are going to expand the rules for => expansions and they would
match directives too, but we don't want them to.

No functional change with existing input.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoSyntax: Incompatible change: Use &{ not &${ for macros
Ian Jackson [Sat, 11 Jan 2020 13:26:26 +0000 (13:26 +0000)]
Syntax: Incompatible change: Use &{ not &${ for macros

This will be more orthogonal with $( which will come in a moment.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoREADME: Adjust indent of &${..$..} expansion
Ian Jackson [Sat, 11 Jan 2020 13:25:42 +0000 (13:25 +0000)]
README: Adjust indent of &${..$..} expansion

No change to the meaning.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoREADME: Introduce spec for "base91s" encoding
Ian Jackson [Sun, 1 Dec 2019 16:33:21 +0000 (16:33 +0000)]
README: Introduce spec for "base91s" encoding

We have no implementations of this yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoprivcache: Remove some spurious \n in messages
Ian Jackson [Sat, 23 Nov 2019 23:41:19 +0000 (23:41 +0000)]
privcache: Remove some spurious \n in messages

I really oughtn't to have done this, but there is much code in secnet
which sets a bad example.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoprivcache: Better debug
Ian Jackson [Sat, 23 Nov 2019 19:13:13 +0000 (19:13 +0000)]
privcache: Better debug

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoprivcache: Use new pathprefix_template facility
Ian Jackson [Tue, 8 Oct 2019 16:22:49 +0000 (17:22 +0100)]
privcache: Use new pathprefix_template facility

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoprivcache: New closure for signature key handling
Ian Jackson [Sun, 29 Sep 2019 13:21:19 +0000 (14:21 +0100)]
privcache: New closure for signature key handling

This will be used by site.c, when it needs to load a key to make a
signature as demanded by the peer.

This commit introduces 5 spurious \n's in messages.
It also introduces a few ` = ' style errors.
These will be removed later.

No callers yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoutil: pathprefix_template: New facility
Ian Jackson [Tue, 8 Oct 2019 14:45:50 +0000 (15:45 +0100)]
util: pathprefix_template: New facility

We will use this for constructing public and private key filenames to
load.

No callers yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosigscheme: Interface for signature schemes
Ian Jackson [Sun, 29 Sep 2019 13:34:00 +0000 (14:34 +0100)]
sigscheme: Interface for signature schemes

There are no implementations yet.  This is split out like this for
review of the api.

We use struct buffer_if to feed key data into the scheme, in both
cases.  This will be convenient for implementations, The loadpub
caller will have the data from base91s, probably.  The loadpriv caller
will have it from a file, but we read the file in the common code.

The API we are introducing now expects each private key buffer to be
fed to the sig schemes one by one until they it finds one that likes
it.  This is in fact not necessary; it was needed in an earlier design
which does not otherwise survive in the published git history.  This
rather suboptimal API will be changed later.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosigpubkey/sigprivkey: Provide a dispose() method
Ian Jackson [Sun, 29 Sep 2019 13:21:31 +0000 (14:21 +0100)]
sigpubkey/sigprivkey: Provide a dispose() method

This is needed allow the site code to load and unload keys
dynamically.

This is just the interface, with no implemntation and no callers,
split out like this for early review.

The two xxx's will be fixed rather later in
  "rsa1: Provide dispose functions"
(but, obviously, before we add any callers).

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosigpubkey/sigprivkey: Provide a hash_if
Ian Jackson [Sun, 29 Sep 2019 12:58:02 +0000 (13:58 +0100)]
sigpubkey/sigprivkey: Provide a hash_if

Sometimes, the caller is going to want to hash things for themselves.
(Notably, site.c will want to hash the advertisements of public key
set updates.)

The hash to be used should be the one used by the signature scheme, as
that has the same security properties.

In rsa.c this moves the hash_if from common to ops, and it is now
convenient to abolish rsa_hash which is a pointless veneer over
hash_hash.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosigkey handling: Introduce serialt type
Ian Jackson [Tue, 8 Oct 2019 14:51:41 +0000 (15:51 +0100)]
sigkey handling: Introduce serialt type

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosigkey handling: define MAX_SIG_KEYS
Ian Jackson [Sun, 29 Sep 2019 19:28:46 +0000 (20:28 +0100)]
sigkey handling: define MAX_SIG_KEYS

This is going to control the number of different public keys we will
use from a keyset, and also the number we will look at when listed as
acceptable by a relying peer.

No users yet in this commit, though.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosigkey handling: Introduce sigkeyid type
Ian Jackson [Sun, 29 Sep 2019 19:27:30 +0000 (20:27 +0100)]
sigkey handling: Introduce sigkeyid type

We provide helper macros for use with printf.

The reference to pubkeys.fl.pl comment is to code which doesn't exist
yet but comes later.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agopubkey handling: Document key sets, id, etc. plan
Ian Jackson [Thu, 28 Nov 2019 13:57:44 +0000 (13:57 +0000)]
pubkey handling: Document key sets, id, etc. plan

None of this is implemented yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agomtest/t-prefix: Drop redundant setting of seddery
Ian Jackson [Wed, 4 Dec 2019 21:55:15 +0000 (21:55 +0000)]
mtest/t-prefix: Drop redundant setting of seddery

This is in mtest/common.tcl already.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agorsa: emsa_pkcs1: Fix a message
Ian Jackson [Sat, 23 Nov 2019 19:52:43 +0000 (19:52 +0000)]
rsa: emsa_pkcs1: Fix a message

This function is called during verification too, so the message
shouldn't talk about signing.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoconffile: find_cl_if: fix fail_if_invalid==False
Ian Jackson [Sun, 6 Oct 2019 22:34:33 +0000 (23:34 +0100)]
conffile: find_cl_if: fix fail_if_invalid==False

If the key was not found, this would segfault, so passing False didn't
work properly.  Currently nothing does, so this bug is latent.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agomake-secnet-sites: Tainted: Fix a lot of bad return values
Ian Jackson [Fri, 8 Nov 2019 21:18:05 +0000 (21:18 +0000)]
make-secnet-sites: Tainted: Fix a lot of bad return values

This code had remnants of a previously intended calling convention,
where object return chaining would be used.

Unfortunately in the currently used calling style, we expect to get a
boolean back everywhere, where true meas `ok'.  Returning `self' is
always treated as `ok' because it's trueish.

Luckily this doesn't cause actual security bugs because we always
return from all of the top-level entrypoints via ._rtn[val] which
checks the ._ok setting, which does properly track problems.  So we
fail an assertion rather than printing a nice message.  This is not
pretty but it is not a vulnerability.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: Drop a redundant test
Ian Jackson [Tue, 3 Dec 2019 22:10:08 +0000 (22:10 +0000)]
stest: Drop a redundant test

We were going to use this for key rollover tests etc.  But in fact
we (much later in this series) will introduce new tests for the new
key loading arrangements.  Actual key rollover will come *much* later
and there is little point having this placeholder in the meantime.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoautogen.sh: Write a comment about need for autoheader
Ian Jackson [Fri, 6 Dec 2019 13:42:50 +0000 (13:42 +0000)]
autogen.sh: Write a comment about need for autoheader

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoconfigure.ac: Do not check for lack of standard headers
Ian Jackson [Fri, 6 Dec 2019 13:27:18 +0000 (13:27 +0000)]
configure.ac: Do not check for lack of standard headers

This makes configure rather faster.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoconfigure.ac: Drop AC_STDC_HEADERS
Ian Jackson [Fri, 6 Dec 2019 13:37:23 +0000 (13:37 +0000)]
configure.ac: Drop AC_STDC_HEADERS

This is obsolete, as the docs say:

 AC_STDC_HEADERS
     Replaced by 'AC_HEADER_STDC'

 AC_HEADER_STDC
     This macro is obsolescent, as current systems have conforming
     header files.  New programs need not use this macro.

Unfortunately dropping it is not properly effective because it's
implied by some other stuff.  We are going to deal with that in a
moment.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoconfigure.ac: Drop checks for systems lacking stdint.h
Ian Jackson [Fri, 6 Dec 2019 13:03:46 +0000 (13:03 +0000)]
configure.ac: Drop checks for systems lacking stdint.h

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: Check that received packet is as expected
Ian Jackson [Sun, 24 Nov 2019 00:59:39 +0000 (00:59 +0000)]
stest: Check that received packet is as expected

It turns out that if secnet decides the link to the peer is too
broken, it loops outbound packets back to its host.  Normally this is
not obvious, because the host naturally drops such packets.

But in stest we weren't actually looking at the incoming packets at
all, so we would treat this as success!

So, instead, match the start of the packet, including the source and
destination addresses and the icmp type.  (This crude match will fail
if the reply contains any IP options, but the ping comes from the peer
secnet so it won't have.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: Decode the slip packets that come via fake netlink
Ian Jackson [Sun, 24 Nov 2019 00:59:31 +0000 (00:59 +0000)]
stest: Decode the slip packets that come via fake netlink

This will allow us to do something more sophisticated with the packet
contents.

The only functional change right now is to ignore empty `packets'.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: If one of our secnets dies, call the test a failure
Ian Jackson [Mon, 25 Nov 2019 00:01:34 +0000 (00:01 +0000)]
stest: If one of our secnets dies, call the test a failure

This involves use of TclX's `signal' facility.  In my tests it was
easy to make Tcl deadlock by doing too much work in the signal
handler.  In particular reaping children is a bad idea.  Also signals
are not blocked during the signal handler so it would have to be
reentrant.

Instead, use `after idle'.  That is quite soon enough for the reap to
run, and in my tests with TclX 8.4 it all works properly.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: Use `finish' for success exits
Ian Jackson [Sun, 24 Nov 2019 22:20:51 +0000 (22:20 +0000)]
stest: Use `finish' for success exits

vwait is a bit funny.  This is better, and it also kills our child
secnets.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: Kill our child secnets when we call finish
Ian Jackson [Mon, 25 Nov 2019 00:01:01 +0000 (00:01 +0000)]
stest: Kill our child secnets when we call finish

This stops them hanging around and, often, printing more stuff after
the test has actually failed.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: Record the pids of of the secnets we spawn
Ian Jackson [Mon, 25 Nov 2019 00:00:30 +0000 (00:00 +0000)]
stest: Record the pids of of the secnets we spawn

Nothing uses this yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: Replace the call to `exit 1' with a new proc `finish'
Ian Jackson [Sun, 24 Nov 2019 13:59:29 +0000 (13:59 +0000)]
stest: Replace the call to `exit 1' with a new proc `finish'

This is going to be used for success exits too, in a moment.
This will let us do more work when we are exiting.

The only change for now is some extra stderr output.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: Support not running secnet ourselves
Ian Jackson [Sat, 23 Nov 2019 00:38:01 +0000 (00:38 +0000)]
stest: Support not running secnet ourselves

Now the user can set SECNET_STEST_DIVERT_inside=1 (say) and instead of
actually running secnet, we print the rune we would run and ask the
user when they have started it.

A freshly started secnet (with this config, at least) just sits there
waiting for its first packet to deal with.  So if the user does this
for the 2nd secnet, that's fine - the first one will happily wait
until the test actually gets going.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: Don't prefix ./ with another ./, in socktmp
Ian Jackson [Sat, 23 Nov 2019 00:37:35 +0000 (00:37 +0000)]
stest: Don't prefix ./ with another ./, in socktmp

Makes things slightly prettier.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: Print the special env vars we pass to secnet
Ian Jackson [Sat, 23 Nov 2019 00:19:11 +0000 (00:19 +0000)]
stest: Print the special env vars we pass to secnet

We don't dump the whole environment, just selected bits.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: Print the secnet runes we run
Ian Jackson [Sat, 23 Nov 2019 00:03:58 +0000 (00:03 +0000)]
stest: Print the secnet runes we run

We can't use prexec here because we aren't using exec at all.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agotests, mtest: Provide and use `prexec' for helping with debugging
Ian Jackson [Fri, 22 Nov 2019 23:59:32 +0000 (23:59 +0000)]
tests, mtest: Provide and use `prexec' for helping with debugging

This prints the make-secnet-sites runes we are about to run.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agodir-locals: Provide python-indent-offset too
Ian Jackson [Fri, 29 Nov 2019 23:37:01 +0000 (23:37 +0000)]
dir-locals: Provide python-indent-offset too

python-indent is obsolete since Emacs 24.3.  It has been made into an
alias for python-indent-offset, but the alias is not marked safe as a
file variable.  Specifying python-indent-offset should make this work
on all relevant versions of Emacs (at least in the default
configuration).

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: Add debug logs
Ian Jackson [Sat, 23 Nov 2019 19:13:46 +0000 (19:13 +0000)]
stest: Add debug logs

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: Use new `prefix' option.
Ian Jackson [Sat, 23 Nov 2019 17:57:56 +0000 (17:57 +0000)]
stest: Use new `prefix' option.

This lets us distinguish output from our two secnets.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agostest: Use stderr, not tty, for logging
Ian Jackson [Sat, 23 Nov 2019 17:50:46 +0000 (17:50 +0000)]
stest: Use stderr, not tty, for logging

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agologfile: New `prefix' option.
Ian Jackson [Sat, 23 Nov 2019 17:57:46 +0000 (17:57 +0000)]
logfile: New `prefix' option.

This allows the config file to add a fixed string to log messages.
This will be useful in our test suite, which mixes up output from
two instances of secnet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agologfile: Do not log differently with --nodetach
Ian Jackson [Sat, 23 Nov 2019 17:52:31 +0000 (17:52 +0000)]
logfile: Do not log differently with --nodetach

This is actually quite anoying.  There is no good reason for leaving
off the timestamps in tests, or manual debugging, etc.

If at some point we want to support running under some kind of
log-capturing daemon supervisor which timestamps everything, we can
easily make this conditional again.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agologfile: Remove redundant check for st->f
Ian Jackson [Sat, 23 Nov 2019 17:51:04 +0000 (17:51 +0000)]
logfile: Remove redundant check for st->f

st->f is now always non-null.  If no filename is specified, it is
stderr.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agologfile: Log to stderr by default (`filename' key now optional)
Ian Jackson [Sat, 23 Nov 2019 17:50:28 +0000 (17:50 +0000)]
logfile: Log to stderr by default (`filename' key now optional)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosecnet: Make stderr line buffered
Ian Jackson [Sun, 24 Nov 2019 01:00:20 +0000 (01:00 +0000)]
secnet: Make stderr line buffered

This helps not interleave output in tests.  We write output in lines,
so this is fine.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoMerge subdirmk 0.3
Ian Jackson [Mon, 30 Dec 2019 13:14:45 +0000 (13:14 +0000)]
Merge subdirmk 0.3

4 years agotests: Provide make-release script
Ian Jackson [Mon, 30 Dec 2019 12:59:57 +0000 (12:59 +0000)]
tests: Provide make-release script

Not really `tests' but I don't want to add a whole new directory just
for this.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agotests: Provide advance-tested script
Ian Jackson [Mon, 30 Dec 2019 12:50:30 +0000 (12:50 +0000)]
tests: Provide advance-tested script

Useful for our own testing.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosubdirmk: Merge new version and fix everything
Ian Jackson [Mon, 30 Dec 2019 12:06:47 +0000 (12:06 +0000)]
subdirmk: Merge new version and fix everything

git subtree pull, but many incompatible changes - so also fixed up the
secnet code to match.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoMerge subdirmk
Ian Jackson [Mon, 30 Dec 2019 12:06:12 +0000 (12:06 +0000)]
Merge subdirmk

4 years agoMerge subdirmk
Ian Jackson [Sun, 29 Dec 2019 14:23:00 +0000 (14:23 +0000)]
Merge subdirmk

4 years agoLegal: Update tests/filter/ inputs and outputs
Ian Jackson [Mon, 30 Dec 2019 11:58:11 +0000 (11:58 +0000)]
Legal: Update tests/filter/ inputs and outputs

We judiciously use # vs. &# for the legal comment so that each
expected output file contains one notice.

The following files, which are wholly constructed by running
generate and reviewing the diffs, do not have a legal notice:
  tests/filter/main.mk.expected
  tests/filter/stderr.expected
  tests/filter/sub/Dir.mk.expected
This is OK I think.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoLegal: Add copyright, licence and warranty notice to many files
Ian Jackson [Mon, 30 Dec 2019 11:17:17 +0000 (11:17 +0000)]
Legal: Add copyright, licence and warranty notice to many files

The .sd.mk and .expected files in tests/filter/ are more complicated.
We'll do those in a moment.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoLegal: Add NO WARRANTY everywhere
Ian Jackson [Mon, 30 Dec 2019 11:09:36 +0000 (11:09 +0000)]
Legal: Add NO WARRANTY everywhere

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agogenerate: Avoid $err_file undefined warning during startup
Ian Jackson [Mon, 30 Dec 2019 11:02:59 +0000 (11:02 +0000)]
generate: Avoid $err_file undefined warning during startup

If, for example, one of the input files implied by the command line
arguments is missing, err is called with $err_file not yet set.

Handle this case.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agogenerate: Mention suppressions when warning re VAR vs &VAR
Ian Jackson [Sun, 29 Dec 2019 15:56:44 +0000 (15:56 +0000)]
generate: Mention suppressions when warning re VAR vs &VAR

When we are actually printing the warning, report all the locations,
including the suppressed ones.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoSyntax: Support &:local+global !...
Ian Jackson [Sun, 29 Dec 2019 15:50:28 +0000 (15:50 +0000)]
Syntax: Support &:local+global !...

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agotests/filter: Test &:local+global & vs non-&
Ian Jackson [Sun, 29 Dec 2019 15:46:54 +0000 (15:46 +0000)]
tests/filter: Test &:local+global & vs non-&

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoSyntax: Rescope effect of &:local+global
Ian Jackson [Sun, 29 Dec 2019 15:18:39 +0000 (15:18 +0000)]
Syntax: Rescope effect of &:local+global

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agosubdirmk: Fix a Subdir left over in README
Ian Jackson [Sun, 29 Dec 2019 14:32:49 +0000 (14:32 +0000)]
subdirmk: Fix a Subdir left over in README

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoSyntax: Expand &$( and &$NN to use ${ } rather than $( )
Ian Jackson [Sun, 29 Dec 2019 14:17:00 +0000 (14:17 +0000)]
Syntax: Expand &$( and &$NN to use ${ } rather than $( )

And now document the use of $&+ for recipes.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agodoctests: Allow parenthetical comments as an expansion RHS
Ian Jackson [Sun, 29 Dec 2019 14:18:49 +0000 (14:18 +0000)]
doctests: Allow parenthetical comments as an expansion RHS

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoREADME: Swap order of &$( and &$NN
Ian Jackson [Sun, 29 Dec 2019 14:15:15 +0000 (14:15 +0000)]
README: Swap order of &$( and &$NN

We are going to add a note to &$( which applies to &$NN too, and this
makes it nicer.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoSyntax: Use ${top_srcdir} rather than $(top_srcdir)
Ian Jackson [Sun, 29 Dec 2019 14:13:52 +0000 (14:13 +0000)]
Syntax: Use ${top_srcdir} rather than $(top_srcdir)

Again, this makes it possible to use in $-doubled shell runes as well
as in make syntax.  (Assuming you have made top_srcdir be a shell
variable as well as a make variable.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoSyntax: expand &$... to ${....} rather than $(....)
Ian Jackson [Sun, 29 Dec 2019 14:03:28 +0000 (14:03 +0000)]
Syntax: expand &$... to ${....} rather than $(....)

This makes it possible to use in $-doubled shell runes as well as in
make syntax.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoWarnings: Introduce new `broken-var-ref' warning
Ian Jackson [Sun, 29 Dec 2019 14:01:22 +0000 (14:01 +0000)]
Warnings: Introduce new `broken-var-ref' warning

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agotests/filter: Print all the diffs, not just the first
Ian Jackson [Sun, 29 Dec 2019 14:00:58 +0000 (14:00 +0000)]
tests/filter: Print all the diffs, not just the first

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoREADME: Refer to example/
Ian Jackson [Sat, 28 Dec 2019 19:07:17 +0000 (19:07 +0000)]
README: Refer to example/

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoREADME: Move the "how to use" up
Ian Jackson [Sat, 28 Dec 2019 19:06:17 +0000 (19:06 +0000)]
README: Move the "how to use" up

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoREADME: Add another layer of structure
Ian Jackson [Sat, 28 Dec 2019 19:04:26 +0000 (19:04 +0000)]
README: Add another layer of structure

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoREADME: Move the Warnings section up into what is going to be spec
Ian Jackson [Sat, 28 Dec 2019 19:04:10 +0000 (19:04 +0000)]
README: Move the Warnings section up into what is going to be spec

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoREADME: deinent the macro explaation
Ian Jackson [Sat, 28 Dec 2019 18:55:45 +0000 (18:55 +0000)]
README: deinent the macro explaation

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoREADME: Further miscellaneous fixes and clarifications
Ian Jackson [Sat, 28 Dec 2019 18:55:25 +0000 (18:55 +0000)]
README: Further miscellaneous fixes and clarifications

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoREADME: Document that local+global is not 100% accurate
Ian Jackson [Sat, 28 Dec 2019 18:46:58 +0000 (18:46 +0000)]
README: Document that local+global is not 100% accurate

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
4 years agoREADME: More syntax further up
Ian Jackson [Sat, 28 Dec 2019 18:43:18 +0000 (18:43 +0000)]
README: More syntax further up

This is primary.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>