chiark / gitweb /
otter.git
3 years agoBreak out clisupport.rs
Ian Jackson [Wed, 2 Jun 2021 22:56:05 +0000 (23:56 +0100)]
Break out clisupport.rs

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoRename atmain.rs (from apitest/main.rs)
Ian Jackson [Wed, 2 Jun 2021 22:46:02 +0000 (23:46 +0100)]
Rename atmain.rs (from apitest/main.rs)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoBreak out otter-cli into separate cargo package
Ian Jackson [Wed, 2 Jun 2021 18:51:09 +0000 (19:51 +0100)]
Break out otter-cli into separate cargo package

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoscript: sse disconnection: Check the connecting status
Ian Jackson [Wed, 2 Jun 2021 21:30:35 +0000 (22:30 +0100)]
script: sse disconnection: Check the connecting status

Don't produce an error if the browser is reconnecting.  Hopefully it
will be fine soon...

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: When accessing via ssh, make default account be ssh:
Ian Jackson [Wed, 2 Jun 2021 18:04:18 +0000 (19:04 +0100)]
otter cli: When accessing via ssh, make default account be ssh:

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Change defaulting order of server and account
Ian Jackson [Wed, 2 Jun 2021 18:03:59 +0000 (19:03 +0100)]
otter cli: Change defaulting order of server and account

We're going to need the server to decide the account.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Require an option to set ssh keys for a non-ssh: acocunt
Ian Jackson [Wed, 2 Jun 2021 17:57:40 +0000 (18:57 +0100)]
sshkeys: Require an option to set ssh keys for a non-ssh: acocunt

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoMore sophisticated handling of program name
Ian Jackson [Wed, 2 Jun 2021 17:50:23 +0000 (18:50 +0100)]
More sophisticated handling of program name

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Tests restricted command branch sawing
Ian Jackson [Wed, 2 Jun 2021 17:05:59 +0000 (18:05 +0100)]
sshkeys: Tests restricted command branch sawing

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Tests a restricted command, refactor
Ian Jackson [Wed, 2 Jun 2021 17:03:05 +0000 (18:03 +0100)]
sshkeys: Tests a restricted command, refactor

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Tests restricted command a bit more
Ian Jackson [Wed, 2 Jun 2021 17:01:13 +0000 (18:01 +0100)]
sshkeys: Tests restricted command a bit more

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Tests a restricted command, refactor
Ian Jackson [Wed, 2 Jun 2021 17:00:04 +0000 (18:00 +0100)]
sshkeys: Tests a restricted command, refactor

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Tests a restricted command
Ian Jackson [Wed, 2 Jun 2021 16:57:22 +0000 (17:57 +0100)]
sshkeys: Tests a restricted command

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Tests: Rework dummy key handling
Ian Jackson [Wed, 2 Jun 2021 16:56:58 +0000 (17:56 +0100)]
sshkeys: Tests: Rework dummy key handling

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Test that static data is included
Ian Jackson [Wed, 2 Jun 2021 16:45:50 +0000 (17:45 +0100)]
sshkeys: Test that static data is included

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Test banner and static handling
Ian Jackson [Wed, 2 Jun 2021 16:41:04 +0000 (17:41 +0100)]
sshkeys: Test banner and static handling

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Fix newline insertion
Ian Jackson [Wed, 2 Jun 2021 16:40:54 +0000 (17:40 +0100)]
sshkeys: Fix newline insertion

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Tests, wip
Ian Jackson [Tue, 1 Jun 2021 19:31:09 +0000 (20:31 +0100)]
sshkeys: Tests, wip

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Tests: Provide a dummy test key
Ian Jackson [Tue, 1 Jun 2021 19:42:50 +0000 (20:42 +0100)]
sshkeys: Tests: Provide a dummy test key

I threw the private half away.  Nevertheless, this should not be put
into any real file.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Fix auth key header newline
Ian Jackson [Wed, 2 Jun 2021 14:24:43 +0000 (15:24 +0100)]
sshkeys: Fix auth key header newline

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Fix magic banner handling
Ian Jackson [Wed, 2 Jun 2021 16:28:31 +0000 (17:28 +0100)]
sshkeys: Fix magic banner handling

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Improve ssh auth key banner and header
Ian Jackson [Wed, 2 Jun 2021 12:19:45 +0000 (13:19 +0100)]
sshkeys: Improve ssh auth key banner and header

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Some todos
Ian Jackson [Wed, 2 Jun 2021 17:10:01 +0000 (18:10 +0100)]
sshkeys: Some todos

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: sshkeys: Get line numbers right
Ian Jackson [Wed, 2 Jun 2021 16:40:43 +0000 (17:40 +0100)]
otter cli: sshkeys: Get line numbers right

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agocmdlistener: Tidy up connnection disconnect error
Ian Jackson [Wed, 2 Jun 2021 16:28:15 +0000 (17:28 +0100)]
cmdlistener: Tidy up connnection disconnect error

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: ssh keys: avoid creating account and then bailing
Ian Jackson [Wed, 2 Jun 2021 16:21:45 +0000 (17:21 +0100)]
otter cli: ssh keys: avoid creating account and then bailing

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: ssh keys: create accounts as necessary
Ian Jackson [Wed, 2 Jun 2021 16:15:42 +0000 (17:15 +0100)]
otter cli: ssh keys: create accounts as necessary

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoaccounts: Allow otter prep_access_account to never update it
Ian Jackson [Wed, 2 Jun 2021 16:13:42 +0000 (17:13 +0100)]
accounts: Allow otter prep_access_account to never update it

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoaccounts: Actually parse ssh: accounts
Ian Jackson [Wed, 2 Jun 2021 16:01:52 +0000 (17:01 +0100)]
accounts: Actually parse ssh: accounts

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: When rejecting removal of current key, print nicely
Ian Jackson [Wed, 2 Jun 2021 15:54:03 +0000 (16:54 +0100)]
otter cli: When rejecting removal of current key, print nicely

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Rename inventory_subcmd
Ian Jackson [Wed, 2 Jun 2021 00:27:39 +0000 (01:27 +0100)]
otter cli: Rename inventory_subcmd

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Suppress account selection for mgmtchannel-proxy
Ian Jackson [Wed, 2 Jun 2021 00:22:41 +0000 (01:22 +0100)]
otter cli: Suppress account selection for mgmtchannel-proxy

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Make ordinary_subcommand handle SubcommandProperties
Ian Jackson [Wed, 2 Jun 2021 00:12:38 +0000 (01:12 +0100)]
otter cli: Make ordinary_subcommand handle SubcommandProperties

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Move &Subcommand into MainOpts for convenience
Ian Jackson [Wed, 2 Jun 2021 00:18:10 +0000 (01:18 +0100)]
otter cli: Move &Subcommand into MainOpts for convenience

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Make Subcommand Debug
Ian Jackson [Wed, 2 Jun 2021 00:17:58 +0000 (01:17 +0100)]
otter cli: Make Subcommand Debug

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Make space for SubcommandProperties
Ian Jackson [Wed, 2 Jun 2021 00:10:15 +0000 (01:10 +0100)]
otter cli: Make space for SubcommandProperties

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Make Subcommand a named field struct
Ian Jackson [Wed, 2 Jun 2021 00:09:12 +0000 (01:09 +0100)]
otter cli: Make Subcommand a named field struct

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Introduce ordinary_subcmd macro
Ian Jackson [Wed, 2 Jun 2021 00:03:06 +0000 (01:03 +0100)]
otter cli: Introduce ordinary_subcmd macro

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Add paranoid whitespace check
Ian Jackson [Tue, 1 Jun 2021 20:51:26 +0000 (21:51 +0100)]
sshkeys: Add paranoid whitespace check

Newlines, in particular, would mess things up.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Do not include filename in context
Ian Jackson [Tue, 1 Jun 2021 20:50:47 +0000 (21:50 +0100)]
sshkeys: Do not include filename in context

This gets printed when we log the AuthKeysManipError.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Fix formatting of ssh authorized_keys files
Ian Jackson [Tue, 1 Jun 2021 20:48:45 +0000 (21:48 +0100)]
sshkeys: Fix formatting of ssh authorized_keys files

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Allow the creation of a fresh auth keys file
Ian Jackson [Tue, 1 Jun 2021 20:45:37 +0000 (21:45 +0100)]
sshkeys: Allow the creation of a fresh auth keys file

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoerrors: Rename AnyhowDisplay and provide .d() and use it
Ian Jackson [Tue, 1 Jun 2021 20:33:41 +0000 (21:33 +0100)]
errors: Rename AnyhowDisplay and provide .d() and use it

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoerrors: Provide AnyhowFormat and use it in two places
Ian Jackson [Tue, 1 Jun 2021 20:32:54 +0000 (21:32 +0100)]
errors: Provide AnyhowFormat and use it in two places

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoerrors: Drop some spurious uses of {:?} in messages
Ian Jackson [Tue, 1 Jun 2021 20:30:31 +0000 (21:30 +0100)]
errors: Drop some spurious uses of {:?} in messages

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agocommands: Drop a spurious \n in an error message
Ian Jackson [Tue, 1 Jun 2021 20:30:17 +0000 (21:30 +0100)]
commands: Drop a spurious \n in an error message

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoutils: Introduce anyhow::Error::for_each
Ian Jackson [Tue, 1 Jun 2021 19:57:49 +0000 (20:57 +0100)]
utils: Introduce anyhow::Error::for_each

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: mgmtchannel-proxy: Exit 0 on command EOF too
Ian Jackson [Tue, 1 Jun 2021 19:32:31 +0000 (20:32 +0100)]
otter cli: mgmtchannel-proxy: Exit 0 on command EOF too

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys internal errors: Do not share with client
Ian Jackson [Tue, 1 Jun 2021 19:30:48 +0000 (20:30 +0100)]
sshkeys internal errors: Do not share with client

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoInternalError from anyhow: Add a missing colon to the messages
Ian Jackson [Tue, 1 Jun 2021 17:38:30 +0000 (18:38 +0100)]
InternalError from anyhow: Add a missing colon to the messages

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoapitest: Initial test of ssh
Ian Jackson [Tue, 1 Jun 2021 16:04:05 +0000 (17:04 +0100)]
apitest: Initial test of ssh

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoconfig: Observe that ssh_proxy_command will be split by ssh's shell
Ian Jackson [Tue, 1 Jun 2021 17:00:46 +0000 (18:00 +0100)]
config: Observe that ssh_proxy_command will be split by ssh's shell

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Rename --ssh-proxy-command option
Ian Jackson [Tue, 1 Jun 2021 17:00:12 +0000 (18:00 +0100)]
otter cli: Rename --ssh-proxy-command option

This is shorter and more consistent.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoapitest: Provide OTTER_APITEST_START_DIR
Ian Jackson [Tue, 1 Jun 2021 16:59:32 +0000 (17:59 +0100)]
apitest: Provide OTTER_APITEST_START_DIR

Nothing uses this yet, nor, it appears, is going to, but it may come
in useful in the future, so let's keep it.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoMakefile, ssh proxy: Install a symlink
Ian Jackson [Tue, 1 Jun 2021 16:30:14 +0000 (17:30 +0100)]
Makefile, ssh proxy: Install a symlink

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Shut down CookedStdout before bundle data
Ian Jackson [Tue, 1 Jun 2021 14:40:48 +0000 (15:40 +0100)]
otter cli: Shut down CookedStdout before bundle data

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Shut down CookedStdout before proxying responses
Ian Jackson [Tue, 1 Jun 2021 14:39:36 +0000 (15:39 +0100)]
otter cli: Shut down CookedStdout before proxying responses

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Tiny fixes to stdout handling
Ian Jackson [Tue, 1 Jun 2021 14:37:23 +0000 (15:37 +0100)]
otter cli: Tiny fixes to stdout handling

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter: Introduce SubCommandSubArgs
Ian Jackson [Tue, 1 Jun 2021 14:35:05 +0000 (15:35 +0100)]
otter: Introduce SubCommandSubArgs

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Completely redo stdout handling
Ian Jackson [Tue, 1 Jun 2021 14:24:15 +0000 (15:24 +0100)]
otter cli: Completely redo stdout handling

Replace all println.  Use a common stdout buffer for everything.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Switch to CookedStdout for set-link
Ian Jackson [Tue, 1 Jun 2021 13:01:02 +0000 (14:01 +0100)]
otter cli: Switch to CookedStdout for set-link

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Switch to CookedStdout for list-ssh-keys
Ian Jackson [Tue, 1 Jun 2021 12:58:02 +0000 (13:58 +0100)]
otter cli: Switch to CookedStdout for list-ssh-keys

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: mgmtchannel proxy needs to exit on server conn eof
Ian Jackson [Tue, 1 Jun 2021 12:56:49 +0000 (13:56 +0100)]
otter cli: mgmtchannel proxy needs to exit on server conn eof

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Switch to RawStdout for mgmtchannel proxy stdout
Ian Jackson [Tue, 1 Jun 2021 12:56:37 +0000 (13:56 +0100)]
otter cli: Switch to RawStdout for mgmtchannel proxy stdout

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Use copy_interactive for mgmtchannel proxy
Ian Jackson [Tue, 1 Jun 2021 12:56:24 +0000 (13:56 +0100)]
otter cli: Use copy_interactive for mgmtchannel proxy

Fixes a buffering-induced deadlock.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Switch to CookedStdout for arg parsing
Ian Jackson [Tue, 1 Jun 2021 12:54:18 +0000 (13:54 +0100)]
otter cli: Switch to CookedStdout for arg parsing

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Switch to RawStdout for bundle download to stdout
Ian Jackson [Tue, 1 Jun 2021 12:54:42 +0000 (13:54 +0100)]
otter cli: Switch to RawStdout for bundle download to stdout

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoutils: Provide CookedStdout, buffered and with die on flush fail
Ian Jackson [Tue, 1 Jun 2021 12:58:38 +0000 (13:58 +0100)]
utils: Provide CookedStdout, buffered and with die on flush fail

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoutils: Provide RawStdout and the associated SigPipeWriter
Ian Jackson [Tue, 1 Jun 2021 12:58:22 +0000 (13:58 +0100)]
utils: Provide RawStdout and the associated SigPipeWriter

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoutils: Provide io_copy_interactive
Ian Jackson [Tue, 1 Jun 2021 12:54:07 +0000 (13:54 +0100)]
utils: Provide io_copy_interactive

stdlib io::copy insists on buffering.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agodebugreader: Make generic over D
Ian Jackson [Tue, 1 Jun 2021 10:30:43 +0000 (11:30 +0100)]
debugreader: Make generic over D

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agomgmtchannel: Insist that client connections are Debug
Ian Jackson [Tue, 1 Jun 2021 10:30:27 +0000 (11:30 +0100)]
mgmtchannel: Insist that client connections are Debug

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Do not SelectAccount when we are mgmtchannel-proxy
Ian Jackson [Tue, 1 Jun 2021 01:47:07 +0000 (02:47 +0100)]
otter cli: Do not SelectAccount when we are mgmtchannel-proxy

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Break out connect_chan
Ian Jackson [Tue, 1 Jun 2021 01:45:28 +0000 (02:45 +0100)]
otter cli: Break out connect_chan

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agomgmtchannel: Tiny error message improvement
Ian Jackson [Tue, 1 Jun 2021 01:27:29 +0000 (02:27 +0100)]
mgmtchannel: Tiny error message improvement

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agocmdlistener: Rework main loop error handling
Ian Jackson [Tue, 1 Jun 2021 01:19:59 +0000 (02:19 +0100)]
cmdlistener: Rework main loop error handling

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agocmdlistener: Display account in log messages
Ian Jackson [Tue, 1 Jun 2021 00:55:46 +0000 (01:55 +0100)]
cmdlistener: Display account in log messages

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agossh: Forbid SetRestrictedSshScope after SelectAccount
Ian Jackson [Tue, 1 Jun 2021 00:44:41 +0000 (01:44 +0100)]
ssh: Forbid SetRestrictedSshScope after SelectAccount

SelectAccount generates an Authorisation in the stream state.  We
don't want to preserve that after we drop privs.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoSlight error message tweaks
Ian Jackson [Tue, 1 Jun 2021 00:30:43 +0000 (01:30 +0100)]
Slight error message tweaks

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Implement remote ssh connection
Ian Jackson [Mon, 31 May 2021 21:20:49 +0000 (22:20 +0100)]
otter cli: Implement remote ssh connection

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoconfig: Break out some variables etc.
Ian Jackson [Mon, 31 May 2021 21:13:36 +0000 (22:13 +0100)]
config: Break out some variables etc.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Rename SL::Socket from a daft long name
Ian Jackson [Mon, 31 May 2021 10:58:42 +0000 (11:58 +0100)]
otter cli: Rename SL::Socket from a daft long name

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Prep for new kind of server connection
Ian Jackson [Mon, 31 May 2021 10:55:32 +0000 (11:55 +0100)]
otter cli: Prep for new kind of server connection

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: provide set-list-keys
Ian Jackson [Mon, 31 May 2021 00:15:11 +0000 (01:15 +0100)]
otter cli: provide set-list-keys

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: provide set-ssh-keys
Ian Jackson [Sun, 30 May 2021 22:54:02 +0000 (23:54 +0100)]
otter cli: provide set-ssh-keys

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agootter cli: Provide mgmtchannel-proxy subcommand
Ian Jackson [Sun, 30 May 2021 20:20:26 +0000 (21:20 +0100)]
otter cli: Provide mgmtchannel-proxy subcommand

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoutils: error end_process: Do not print duplicate messages
Ian Jackson [Tue, 1 Jun 2021 00:26:15 +0000 (01:26 +0100)]
utils: error end_process: Do not print duplicate messages

Sometimes we use thiserror to put {0} of an inner error in our Display
impl.  If that happens, just skip the repetition.

This is a slight bodge.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agomgmtchannel: Improve Display of MgmtChannelReadError
Ian Jackson [Tue, 1 Jun 2021 00:25:49 +0000 (01:25 +0100)]
mgmtchannel: Improve Display of MgmtChannelReadError

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoBreak out end_process ext method on anyhow::Error
Ian Jackson [Sun, 30 May 2021 21:44:21 +0000 (22:44 +0100)]
Break out end_process ext method on anyhow::Error

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoRework hex parsing
Ian Jackson [Sun, 30 May 2021 21:27:20 +0000 (22:27 +0100)]
Rework hex parsing

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agomgmtchannels: Make ClientMgmtChannel's read be Send too
Ian Jackson [Mon, 31 May 2021 21:16:21 +0000 (22:16 +0100)]
mgmtchannels: Make ClientMgmtChannel's read be Send too

We are about to need this

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Provide more traits for our types
Ian Jackson [Sun, 30 May 2021 23:46:43 +0000 (00:46 +0100)]
sshkeys: Provide more traits for our types

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Make KeySpec fields pub (!)
Ian Jackson [Sun, 30 May 2021 23:46:23 +0000 (00:46 +0100)]
sshkeys: Make KeySpec fields pub (!)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Make MgmtKeyReport fields pub (!)
Ian Jackson [Sun, 30 May 2021 23:41:37 +0000 (00:41 +0100)]
sshkeys: Make MgmtKeyReport fields pub (!)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosshkeys: Change authorized_keys command to what we are going to impl
Ian Jackson [Sun, 30 May 2021 20:20:09 +0000 (21:20 +0100)]
sshkeys: Change authorized_keys command to what we are going to impl

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoProvide parsing for sshkey::Id and Nonce and so on
Ian Jackson [Sun, 30 May 2021 20:59:54 +0000 (21:59 +0100)]
Provide parsing for sshkey::Id and Nonce and so on

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agochildio: Rename STATUS_1 from vague name
Ian Jackson [Mon, 31 May 2021 22:56:54 +0000 (23:56 +0100)]
childio: Rename STATUS_1 from vague name

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agochildio: Add some dbgs to tests
Ian Jackson [Mon, 31 May 2021 22:51:43 +0000 (23:51 +0100)]
childio: Add some dbgs to tests

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agochildio: Add a test case to simulate the Linux kernel race
Ian Jackson [Mon, 31 May 2021 22:39:20 +0000 (23:39 +0100)]
childio: Add a test case to simulate the Linux kernel race

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agochildio: When getting EOF when reading, wait blockingly for child
Ian Jackson [Mon, 31 May 2021 22:51:37 +0000 (23:51 +0100)]
childio: When getting EOF when reading, wait blockingly for child

The t_false read test was flaky.  It would sometimes panic at the
"unwrap_err".

This is because on Linux we can get EOF on a pipe which is being
closed by the kernel as a result of process termination, and then
still find that wait4 returns 0 meaning the child cannot be reaped.

I think this is quite undesirable, and I regard it as a kernel bug.
It is certainly untraditional.  For example, it is conventional for a
process that is coredumpting to finish dumping core before its fds
show up as closed.

However, the spec I have here does not appear to give a clear
guarentee that this sequence of events is impossible.  And whatever,
we have to live with it.  Bah.

In our situation we can generally expect that it is sensible to assume
that EOF means the child is in the process of exiting, and to reap it
blockingly.

Emprically I can no longer reproduce the race now.

The sequence of events as seen from the parent looks like this:

  pipe2([5, 6], O_CLOEXEC)                = 0

This is the stdin pipe.  We don't use it in this test.

  pipe2([7, 8], O_CLOEXEC)                = 0

This is the stdout pipe for the child.

I have verified in another strace that these descriptors are right,
since the post-fork child does this:
  23597 dup2(5, 0)                        = 0
  23597 dup2(8, 1)                        = 1

So, continuing with the parent:

  prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=1024, rlim_max=4*1024}) = 0
  prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=1024, rlim_max=4*1024}) = 0
  prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=1024, rlim_max=4*1024}) = 0
  prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=1024, rlim_max=4*1024}) = 0
  mmap(NULL, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f14d9a56000
  rt_sigprocmask(SIG_BLOCK, ~[], [], 8)   = 0

  clone(child_stack=0x7f14d9a5eff0, flags=CLONE_VM|CLONE_VFORK|SIGCHLD) = 12678

Here we fork.  The child runs in parallel, and is going to exit.

  munmap(0x7f14d9a56000, 36864)           = 0
  rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
  close(5)                                = 0
  close(8)                                = 0

We close our copies of the child's ends of the pipes.

  read(7, "", 10)                         = 0

We read EOF from the child's stdout.

  write(2, "[src/childio.rs:103] self.rw.rea"..., 45) = 45

This is a dbg print I put in.

  wait4(12678, 0x7fff03c3d16c, WNOHANG, NULL) = 0

Here wait4 returns 0 meaning "child has not terminated".

  write(2, "[src/childio.rs:36] self.child.l"..., 64) = 64

  write(2, "[", 1)                        = 1
  write(2, "src/childio.rs", 14)          = 14
  write(2, ":", 1)                        = 1
  write(2, "209", 3)                      = 3
  write(2, "] ", 2)                       = 2

Again some dbg print.

  --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=12678, si_uid=1001, si_status=1, si_utime=0, si_stime=0} ---

Finally we get a signal about the child but it is too late.

  write(2, "r.read(&mut buf)", 16)        = 16
  write(2, " = ", 3)                      = 3
  write(2, "Ok", 2)                       = 2
  write(2, "(\n", 2)                      = 2
  write(2, "    ", 4)                     = 4
  write(2, "0", 1)                        = 1
  write(2, ",\n", 2)                      = 2
  write(2, ")", 1)                        = 1
  write(2, "\n", 1)                       = 1

Another dbg print.

  write(2, "thread '", 8)                 = 8
  write(2, "main", 4)                     = 4
  write(2, "' panicked at '", 15)         = 15
  write(2, "called `Result::unwrap_err()` on"..., 50) = 50

And here we are panicking.

(NB that source code line numbers here and debug output are different
because this strace was not made with the exact code you find in this
commit's parent.)

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