Commit Graph

151 Commits

Author SHA1 Message Date
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
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 4835dcf5ee Various switch statement fixes. 2017-08-06 22:22:25 -04:00
John Hood 3346419724 Remove excessive parentheses
There are many more.
2017-08-06 22:22:20 -04:00
John Hood 43785eb820 Collapse nested conditionals. 2017-08-06 22:21:56 -04:00
John Hood 42d2b5d029 Use shared_ptr and references for Actions.
This slows terminal emulation slightly.
2017-08-02 22:07:02 -04:00
John Hood 8f68400c13 Convert new/delete to shared_ptr. 2017-08-02 22:07:02 -04:00
John Hood 4902970486 Fix utempter #ifdefs. 2017-08-02 22:07:02 -04:00
John Hood 48e9dd169f Reformat printed strings in source
Consolidate multiple printfs.
Break up multiline strings with string concatentation, for better
 clarity and shorter lines.
Use fputs where appropriate.

This also has the benefit of producing a single constant string with
copyright and versions in the binaries.
2017-08-02 00:02:52 -04:00
John Hood 32b1e6ee4b Print {,/var}/run/motd.dynamic on Ubuntu. 2017-04-24 22:40:30 -04:00
John Hood 3f0ac51071 Don't print /etc/motd on IllumOS. 2017-04-24 22:40:30 -04:00
Jérémie Courrèges-Anglas c0bf8053b2 Remove deprecated pledge("ioctl")
Unbreaks mosh on recent (> 2017/03/18) OpenBSD systems.
2017-03-20 09:54:33 -04:00
John Hood bb54325dc9 s/geteuid/getuid/ for correct user lookups
Addresses an issue mentioned in #193.
2016-11-23 17:03:45 -05:00
Anders Kaseorg 94027efc45 Make all commands properly support --help and --version
These should output to stdout and exit with status 0.  Passing
std-options to AM_INIT_AUTOMAKE causes ‘make installcheck’ (hence also
‘make distcheck’) to verify this.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2016-11-19 17:15:48 -05:00
John Hood 9ffbeddbc8 Put spin debug under -vv flag, and add to mosh-client 2016-11-06 06:15:41 -05:00
John Hood 22f5d58144 Exit gracefully on pty write or ioctl failure.
Fixes #821, OS X abnormal exit on client input at mosh-server
shutdown.  On OpenIndiana, TIOCG[GS]WINSZ also fail in this situation.
2016-11-06 06:14:02 -05:00
John Hood 795549aafb OpenIndiana pid_t is long int 2016-11-06 06:09:49 -05:00
John Hood 1077db41b6 Support OpenBSD 6.0 pledge() syscall for sandboxing. 2016-09-19 13:23:16 -04:00
John Hood 39ea3d9512 Fix excess newlines on mosh startup/shutdown.
Fixes #788.

This also works around issues with remote pty typeahead echo corrupting output
from mosh-server.
2016-09-19 13:23:16 -04:00
John Hood 70d48fbcc0 Add --no-ssh-pty option.
This eliminates issues with typeahead being echoed by the remote pty
and corrupting remote output from mosh-server to the mosh script, but
cannot be made default because older mosh-servers require a pty.
2016-09-19 13:23:15 -04:00
John Hood 4ad131a55d Fix lost MOSH CONNECT on FreeBSD 11
This moves all routine stdout/stderr output into the parent
server, and adds tcdrain(), even though this may be a
FreeBSD pty bug.
2016-09-18 01:53:36 -04:00
John Hood 882539884e Remove unnecessary usage of #include <iostream>. Rename templated impls from .cc to -impl.h. 2016-05-14 00:10:59 -04:00
John Hood da30bb74a2 Coverity fixes: deref of stale pointer
I think this one was actually impossible to trigger.
2016-05-10 23:57:29 -04:00
John Hood 880c639361 Include POSIX header strings.h for strncasecmp()
Motivated by Cygwin.
2016-05-08 20:46:58 -04:00
John Hood d4832ca63a Fix bugs in resize handling.
* A resize action could be applied to the framebuffer but discarded
  before being applied to termios, causing them to be out of sync.

* Only every second action was skipped, instead of skipping
  consecutive resize actions, as intended.

Found by inspection, not seen in actual usage or by the window-resize
test.
2016-03-30 23:52:19 -04:00
John Hood 1de6575e59 mosh-server.cc: Do not start user shell until network session starts 2016-03-30 23:52:19 -04:00
John Hood ca21788c96 Remove usage of exceptional fdsets with select(). 2016-01-11 04:35:21 -05:00
John Hood 90a529b18a Fix broken compile on Ubuntu 12.04 2015-12-07 00:25:47 -05:00
john hood 8609f88207 mosh-server: Fix hang with ^S on OS X and FreeBSD.
Fixes #692.
2015-12-06 19:09:42 -05:00
John Hood 1e003b0e76 mosh-server: skip redundant resize requests
This might reduce redraw activity on window resize, especially for
slow servers.
2015-12-06 17:47:11 -05:00
John Hood 992fec1f30 e2e-test: Add check for Instruction verification failures. 2015-12-06 17:47:11 -05:00
John Hood b742e958b6 mosh-server: Support timeouts on lost connectivity to network client.
Closes #690.
2015-11-24 02:36:08 -05:00
Andrew Chin 8b5b7aedfa Make --help or -h work again
Also make --help go to stdout, but everywhere else print_help is used,
     go to stderr

Signed-off-by: Andrew Chin <achin@eminence32.net>
2015-11-01 01:09:00 -04:00
John Hood 7fb542c874 Change SSH_CONNECTION fallback to allow IPv6 2015-10-03 03:43:18 -04:00
Keith Winstein 2e4e601468 mosh-server.cc: compare like types.
Fixes #626 (resize not working) introduced by 543f346a
2015-06-09 15:17:48 -07:00
John Hood 543f346ac7 Fix various new compiler warnings.
terminalfunctions.cc: set_if_available() was undeclared.
Fix printf() wint_t/wchar_t warnings.
mosh-server.cc: Fix warning for side effects inside typeid().

Signed-off-by: John Hood <cgull@glup.org>
2015-06-06 13:12:32 -04:00
Anders Kaseorg b604a7d7c2 Respect HOME environment variable if set
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-05 22:53:31 -04:00
Anders Kaseorg 9019f62bf6 Respect SHELL environment variable if set
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-05 22:53:31 -04:00
Anders Kaseorg cd2ae36f36 Mark local functions as static
This helps to catch unused functions like the former mosh_read_line,
allows the compiler to make better inlining decisions, and reduces the
binary size a bit.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-04 23:52:03 -04:00
Anders Kaseorg a52b095f50 mosh-server: Remove unused mosh_read_line function
This function is buggy.  feof(file) does not become true until after
we’ve tried to read past the last character; it should instead be
checking the getc return value for EOF (which is distinct from any
unsigned char).  Really it should just be replaced by istream
&std::getline(istream &is, string &str).  Fortunately, it’s unused so
we can just delete it.

Resolves a truncated stdio return value issue found by Coverity Scan
service.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-04 23:50:40 -04:00
Anders Kaseorg c03bacd0c9 mosh-server: Catch exception for parsing nonintegral number of colors
Print a real error message instead of abnormally aborting.  Found by
Coverity Scan service.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2015-06-04 23:50:40 -04:00
Geoffrey Thomas aeffb71cfc Style cleanup: "foo &x", not "foo& x" 2015-06-04 23:47:32 -04:00
Geoffrey Thomas 5721b392ab Make all exception classes inherit from std::exception
This refactors out a very common pattern of formatting "%s: %s" with
e.function.c_str() and strerror( e.the_errno ) into just the what()
method of NetworkException. It's also a prerequisite for making cleaner
public API for any exceptions we throw, and allows us to more easily
get exceptions passed back to us to handle.
2015-06-04 23:47:31 -04:00
john hood f3073bbe5d Add git commit version info 2015-05-25 03:46:48 -04:00
Igor Bukanov 96bf5af1b4 mosh-server: allow startup with PTY with zero width or height like Emacs shell.
Closes #472
Closes #473
2014-01-04 02:55:17 -05:00
Anders Kaseorg 553918d3f2 Connection: Support IPv6 addresses
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2013-08-17 09:02:44 -04:00
Anders Kaseorg c1f96b37a1 Connection: Store the port number as a string
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2013-08-17 08:26:30 -04:00
Keith Winstein 45bba44c83 mosh-server: Allow startup without PTY 2013-07-15 11:20:07 -04:00
Keith Winstein 093bbc9111 Detached warning: Omit spurious utmp entries (generated by screen) 2013-03-10 16:31:37 -04:00
Anders Kaseorg ba8d013609 main: Don’t leak desired_ip memory
Signed-off-by: Anders Kaseorg <andersk@mit.edu>

Closes #385.
2013-03-10 15:45:52 -04:00