Commit graph

19 commits

Author SHA1 Message Date
Daniel Eklöf
29cccadd1d
tllist: is now an external "library", so use <> includes 2019-11-17 19:19:55 +01:00
Daniel Eklöf
54f750c494
server: disable debug output 2019-11-05 14:36:58 +01:00
Daniel Eklöf
9abc5ca971
server/client: harden reading of initialization data, and make async
* Client terminal initialization data is now received
  asynchronously. To facilitate this, a couple of minor changes to the
  protocol was made:
    - The client now starts with sending a 4-byte unsigned integer
      with the *total* size of the initialization data (*not*
      including the size field itself.
    - Strings (TERM variable + argv) are now sent NULL-terminated

* The server allocates a single buffer, and fills it
  asynchronously. When full (as indicated by the initial 'total size'
  integer), we parse it (taking care not to read outside boundaries
  etc, and verifies the lengths (of the TERM variable and argv array)
  indicated by the client matches the actual lengths of the strings
  received.

* The server now ignores 'unexpected' data received from the client,
  after the terminal has been instantiated.
2019-11-05 10:08:30 +01:00
Daniel Eklöf
5b3fe4492c
server: workaround evil clients
If the clients attempt to send more data after we've instantiated the
terminal, just consume the data but ignore it.
2019-11-05 09:31:47 +01:00
Daniel Eklöf
5f77f0e999
server: don't cache argc/argv in client context 2019-11-05 09:31:14 +01:00
Daniel Eklöf
a8cb6c531e
Remove unneeded include 2019-11-03 13:07:19 +01:00
Daniel Eklöf
a326427caf
server: set CLOEXEC | NONBLOCK directly in socket() call 2019-11-03 01:48:40 +01:00
Daniel Eklöf
b4c810cf50
Merge branch 'master' into async-ptmx 2019-11-03 01:14:48 +01:00
Daniel Eklöf
8d9ad96b52
server: FD_CLOEXEC is a file descriptor flag, not a file status flag 2019-11-03 01:11:02 +01:00
Daniel Eklöf
79c3121aa3
misc: fdm already logs failures 2019-11-03 00:52:24 +01:00
Daniel Eklöf
1543c71f78
server: server_destroy(): unlink UNIX socket 2019-11-02 23:32:13 +01:00
Daniel Eklöf
ad26914631
server: use a non-blocking socket when trying to connect
When checking of a 'foot --server' instance is already running, we try
to connect to the UNIX socket we're planning on listening on.

In most cases, this will fail hard and fast. But under certain
circumstances, we can get stuck in connect() waiting for a connection
timeout.

Since it should be possible to establish a connection immediately *if*
there's someone actually listening on the socket, rely on the fact
that connect() will fail with a EINPROGRESS if a connection can *not*
be established immediately (and thus no one is listening on it).
2019-11-02 23:25:14 +01:00
Daniel Eklöf
338747dc5a
server: don't get stuck in read() if TERM length is 0 2019-11-02 12:17:30 +01:00
Daniel Eklöf
a1ba4cb010
server: don't get stuck in read() if length of argv argument is 0 2019-11-02 12:16:50 +01:00
Daniel Eklöf
035ace33b6
server: purge shm buffers when terminal is destroyed 2019-11-02 00:49:25 +01:00
Daniel Eklöf
19c099236b
server: add debug logging of client argc/argv 2019-11-02 00:00:31 +01:00
Daniel Eklöf
438d6eaff0
client/server: add -t,--term to footclient 2019-11-01 21:10:47 +01:00
Daniel Eklöf
0bd2ddd8ad
term_init(): initialize slave TERM from term_init() argument 2019-11-01 21:03:08 +01:00
Daniel Eklöf
a1efd65746
server: implement a --server mode
In this mode, foot listens on a UNIX socket and creates terminal
windows when clients connect.

A connecting client sends argc/argv to the server, and the server
instantiates a new terminal window.

When the terminal window is closed, the exit code is sent back to the
client.
2019-11-01 20:39:09 +01:00