Commit Graph

684 Commits

Author SHA1 Message Date
Alex Chernyakhovsky 325098ac07 Switch to fully-qualified #include
Previously, mosh used extensive -I flags and all of the mosh-local
makes it really hard to tell what the proper dependency graph is, so
instead remove the -I arguments in favvor of $(top_srcdir) and qualify
the paths wherever they are used.
2023-07-30 17:03:40 -04:00
Alex Chernyakhovsky 62869ae55f Rename VERSION to VERSION.stamp
-I$(top_srcdir) is not usable on macOS due to a conflicting C++ header
 `version`.
2023-07-30 17:03:40 -04:00
Alex Chernyakhovsky 68226283cb Disable emulation-attributes-bce on tmux 3.3a
tmux 3.3a has a behavior change, since reverted, that is incompatible
with this test. Unfortunately, tmux 3.3a has already made it into some
distributions, so the test has to be disabled when tmux 3.3a is encountered.
2022-10-26 19:15:04 -04:00
Benjamin Barenblat cd7050613c Audit and fix up format strings 2022-08-03 19:59:56 -04:00
Alex Chernyakhovsky 581bd67c5a Fixes for distcheck 2022-07-05 16:56:46 -04:00
Alex Chernyakhovsky 2b7dd9efc3 Correct memory leak in ocb-aes test 2022-07-05 15:36:13 -04:00
Benjamin Barenblat 1416e9a3c1 OCB: Use OpenSSL EVP instead of deprecated AES
Replace calls to AES_* APIs, which were deprecated in OpenSSL 3, with
calls to EVP_* APIs.

Closes: https://github.com/mobile-shell/mosh/issues/1174
2022-06-27 15:10:49 -10:00
Alex Chernyakhovsky 5ad20dbc50 Stop using deprecated Nettle functions
Previously, ocb_internal.cc supported different key sizes, by way of
the deprecated aes_* function family. However, in practice, mosh
always uses AES-128. In Nettle, the explicit key-size APIs are not
deprecated, so switch to AES-128 directly.

Fixes: 1202
2022-06-27 14:34:26 -10:00
Benjamin Barenblat db49808ac3 OCB: Heap-allocate keys
The OpenSSL EVP API requires that keys be heap-allocated, so switch
_ae_ctx to use pointers to keys and opaque allocation functions.

Bug: https://github.com/mobile-shell/mosh/issues/1174
2022-06-27 14:11:09 -10:00
Benjamin Barenblat ad85b90505 OCB: Make primitive AES API explicit
Explicitly define the primitive AES API used by the internal OCB
implementation, and move it into its own namespace (ocb_aes). This will
ease future implementation changes.

Also make some style fixes to affected lines: Replace C-style casts
with C++-style casts, add some missing spaces in argument lists, and
remove some `inline` that the compiler will ignore.

Bug: https://github.com/mobile-shell/mosh/issues/1174
2022-06-27 13:56:07 -10:00
Benjamin Barenblat 0a30c5acd5 Delete unused ROUNDS macro
This macro was used in the reference and AES-NI AES implementations,
both of which were deleted in a563093f16.
2022-06-27 13:56:07 -10:00
Alex Chernyakhovsky e5e62b4c76 Add nettle to the CI matrix 2022-06-27 13:46:18 -10:00
Benjamin Barenblat bacc024083 Go back to internal OCB implementation
After further discussion, the Mosh maintainers have decided to stick
with the internal OCB implementation for this release. Restore support
for using OpenSSL’s AES but internal OCB. To make this commit easy to
audit, restore the code exactly, including calls to AES functions that
are deprecated in OpenSSL 3; a future commit will update ocb_internal.cc
to use EVP instead of directly calling the AES primitives.

In anticipation of future changes, preserve support for OpenSSL’s
AES-OCB, but don’t compile it in. Add
--with-crypto-library=openssl-with-openssl-ocb and
--with-crypto-library=openssl-with-internal-ocb options to configure so
that developers can easily test Mosh using OpenSSL’s AES-OCB. These
options are intended only for testing, are undocumented, and are not
subject to any API stability guarantees.

Rework configure to look for all possible cryptography libraries first
and then dispatch on --with-crypto-library as appropriate.
2022-06-22 15:02:19 -10:00
Alex Chernyakhovsky 135a11a2bb Use OpenSSL native OCB-AES implementation
OpenSSL 3.0 deprecated many of the functions that ocb.cc used to
implement OCB-AES, causing a build failure when -Wdeprecated collided
with -Werror. Debian temporarily fixed this by suppressing the error
in #1191.

Since mosh 1.4 will be the next stable release of mosh, it should not
depend on deprecated functions in OpenSSL. Since version 1.1.0,
OpenSSL natively supports OCB-AES through the EVP_CIPHER API. @cgull
started early support for this in #924.

This change extends upon the previous work by @cgull in a few ways

 * EVP_CipherInit_ex is called in ae_init to set up the
   EVP_CIPHER_CTX. It is later called in ae_encrypt and ae_decrypt
   just to load nonce (IV in OpenSSL EVP parlance), which reduces the
   amount of initialization done per-packet. However, due to OpenSSL
   API limitations, two copies of the EVP_CIPHER_CTX are kept: one for
   encryption, and one for decryption.

 * Adds missing support for an external tag, rather than just one
   appended to the ciphertext

 * Support for non-default-sized tags

as well as some improved error handling.

Note that this change raises the minimum OpenSSL version for Mosh to
1.1.0. OpenSSL does not provide security support for versions prior to
1.1 at this time, so this is in principle reasonable dependency. If we
want to continue to support distributions (such as RHEL7) which
continue to be supported by their vendor but use an unsupported
OpenSSL, then some future work will have to restore the ocb.cc
implementation that uses the deprecated functions.

Bugs: #1174
2022-06-13 18:37:03 -10:00
Benjamin Barenblat a563093f16 Separate OpenSSL-based OCB implementation from others
Split src/crypto/ocb.cc into two files – one containing the AES-OCB
implementation backed by OpenSSL, and the other containing
implementations backed by Apple Common Crypto and Nettle. This paves the
way for a new OpenSSL implementation that uses OpenSSL 1.1’s OCB support
directly, rather than one that merely uses OpenSSL to provide the
underlying block cipher.

Remove support for rijndael-alg-fst.c and compiler-provided AES
intrinsics, since they’re not in use anymore. (Mosh can still use
hardware-accelerated AES if it’s available; it just now relies
exclusively on the underlying cryptography library to accelerate AES if
possible.)

Update the build system to conditionally compile in either
ocb_openssl.cc or ocb_internal.cc, depending on which cryptography
library you pass to ./configure.

To make this commit easy to audit, ocb_openssl.cc and ocb_internal.cc
are trivially diffable against ocb.cc (now deleted). Expected diffs
consist of a copyright notice update, a preprocessor check to ensure the
appropriate cryptography implementation has been selected, and deletions
to remove code that’s no longer in use. This does mean a substantial
amount of code is duplicated between ocb_openssl.cc and ocb_internal.cc;
however, ocb_openssl.cc should be completely replaced soon, so it won’t
be an issue in the long term.

Bug: https://github.com/mobile-shell/mosh/issues/1174
2022-06-06 16:30:41 -10:00
Alex Chernyakhovsky 2f90addb7c Revert "Remove redundant malloc/free"
This reverts commit 6321b1d9c5.

The original commit 6321b1d9c5 switched
from a malloc call of a 22400 byte buffer to a stack-allocated 22400
byte buffer, in addition to the fairly large buffers already allocated
in the functions. Some systems have fairly small stack frames, making
this 22K allocation potentially dangerous. On my stock Debian bullseye
system, I have 200809 bytes (from `getconf
_POSIX_THREAD_ATTR_STACKSIZE`); a 22400 byte buffer already represents
about 10% of the available stacksize.

Other systems, such as those with musl libc, may have either 80KiB or
128KiB [1], making this allocation represent between 18% to 28% of the
available stack space.

[1] https://wiki.musl-libc.org/functional-differences-from-glibc.html#Thread-stack-size
2022-05-30 20:55:21 -04:00
Alex Chernyakhovsky adb62e97ff Add fuzzer for the terminal
This commit adds a fuzzer for more of the terminal pipeline, adding
coverage for the input and output portions of the terminal
framebuffer.
2022-05-30 20:23:21 -04:00
Alex Chernyakhovsky 0c6e034459 Add fuzzing infrastructure
This commit adds the --enable-fuzzing (and --enable-asan, to make
fuzzing more useful) options and a sample fuzzer for the terminal
parser. At this time only libfuzzer is supported. Future changes to
add AFL to get more fuzzing capability should be possible with the
addition of the afl_driver.cc from Chromium.
2022-05-30 20:23:21 -04:00
Alex Chernyakhovsky 70a02d1e83 Add support for generating coverage reports
This change adds autoconf/automake support for building all of mosh
with gcov, and generates an lcov html report. This allows seeing which
parts ofthe source tree have good test coverage, and which can be
shored up. Eventually, it would be good to hook this up to Github
Actions to be generated automatically.
2022-05-30 19:38:10 -04:00
Andrew Chin 378dfa6aa5 Merge pull request #1150 from ncfavier/patch-1
Add tmux and alacritty to title_term_types
2021-12-10 16:07:48 -05:00
Harry Sintonen 87fd565268 Only use CLOCK_MONOTONIC_RAW with __APPLE__ systems. 2021-10-21 16:43:41 +03:00
Naïm Favier bb34ce585e Add tmux and alacritty to title_term_types
Resolves #1130
2021-08-26 19:55:08 +02:00
Harry Sintonen 57b97a4c91 Use CLOCK_MONOTONIC_RAW when available 2020-12-05 21:21:14 +02:00
John Hood 03087e7a76 If exec()ing the remote command fails, pause briefly
This makes the resulting error from mosh-server visible in ordinary usage.
2020-05-18 00:01:05 -04:00
John Hood 12199114fe Move generated includes to their own directory to avoid conflicts.
Fixes #1051, mosh fails to build on case-insensitive filesystems.

XXX This isn't perfect because autoconf/automake drop several extra
files in the directory anyway.
2020-05-17 23:55:09 -04:00
Peter Edwards c3a2756065 Apply latest consecutive resize, not earliest.
If there are consecutive resize events in the userstream to be applied in
"serve", we should apply the last/latest one in the sequence, not the
first/earliest one.

This fixes a problem where a flurry of resize events (eg, generated
by a window manager resizing the client), can cause mosh to have an
out-of-date idea as to what the physical geometry of the window is.
2019-01-04 04:06:30 -08:00
John Hood 71829ff631 unicode-later-combining.test: Document slightly. 2018-08-29 22:44:04 -04:00
John Hood fecd4ee29b Some more namespace hygiene for "using decl;". 2018-08-15 19:28:38 -04:00
John Hood 756f4f8e98 Remove "using namespace std;". 2018-08-15 19:27:23 -04:00
John Hood fb23168ed9 Always use std::min, std::max. 2018-08-15 19:26:27 -04:00
John Hood e5f8a826ef Fix bind(2) being misinterpreted as std::bind() with libc++7 on FreeBSD.
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230624
2018-08-15 01:11:48 -04:00
John Hood 4aff80b872 Fix more inappropriate const_iterator usage. 2018-08-03 19:39:08 -04:00
John Hood 9a606c2f3d src/statesync/completeterminal.cc: fix bad iterator type 2018-08-03 17:32:07 -04:00
John Hood 8ac80db419 C++03 bound functions are not available in C++17; remove
This makes me a little sad, it's time to move to C++11 or greater.
2018-08-03 16:13:47 -04:00
John Hood 5cdbad68b8 Ignore select() errors on Travis/MacOS. 2018-08-03 15:16:55 -04:00
John Hood 3ea9e3e5a4 mosh-server: improve error logging
Also stop using _exit(), believed unnecessary now with proper stdio
flushing.
2018-08-03 15:16:55 -04:00
John Hood 2a5b5410b2 Fix gcc8 snprintf truncation warning. 2018-04-11 18:10:59 -04:00
Anders Kaseorg 10dca75fb2 Type Select::got_signal as volatile sig_atomic_t
Fixes #634.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2018-01-18 19:25:05 -05:00
Michael Jarvis 21d5dca682 Use HAVE_UTEMPTER instead of HAVE_UPTEMPTER
Fix typo for issue #942:
- mosh-server incorrectly reports detached session in utmp/wtmp
2017-11-21 06:05:33 -06:00
John Hood 7cd4312dae Construct socket name correctly for tmux_check()
In moving this function from e2e-test, I forgot that it depends on a
variable set there.
2017-11-08 19:50:35 -05:00
John Hood cbca234b38 Add a separate test for BCE
This test is properly gated on tmux 2.4.
2017-11-08 19:50:35 -05:00
John Hood 968d56f885 Revert "Extend true color test to include background color erase."
This reverts commit aa96fc867f.

tmux doesn't support BCE until 2.4, so this change fails on 2.3.
2017-11-07 23:14:42 -05:00
John Hood aa96fc867f Extend true color test to include background color erase. 2017-11-06 18:38:54 -05:00
John Hood fa9335f737 Fix issue with incorrect true-color background erase colors. 2017-11-06 18:07:54 -05:00
John Hood 88bb01a50a Make Renditions::sgr() more compact in both code and output. 2017-11-06 10:28:10 -05:00
John Hood ce7ba37ad4 Overlays were getting set to the wrong colors. Fix. 2017-11-06 09:30:57 -05:00
Tom Judge ab31b0f271 Add syslog logging of connections
Log connection change events to syslog in the auth log, logging the PID,
username and remote host.

Also log session begin and end.

Co-Authored-By: John Hood <cgull@glup.org>
2017-11-05 11:54:43 -05:00
John Hood e8331437d3 Minor SGR printf type signedness fixes. 2017-11-04 14:37:11 -04:00
John Hood cf493da7b4 Make Terminal::Renditions smaller, and its members private. 2017-11-04 14:37:11 -04:00
John Hood 0ec85b508e Check tmux version for truecolor test. 2017-11-04 14:37:11 -04:00