Every snapshot is encrypted with AES-256-GCM using a random key, stored
in the login keychain under a random id. The name of every file is
authenticated, so files cannot be swapped. The key is deleted before the
snapshot whenever it is removed, so copies of the snapshot left on disk
or in backups cannot be read.
The keychain is never allowed to show any UI. If storing the key fails
nothing is saved, if reading it fails the snapshot is deleted, with the
error logged in both cases.
The key is generated, stored and read only in C, in mlocked memory that
is cleared when freed, via a new random_secret() and the Keychain
functions in cocoa_window.m.
A new option restore_session_after_logout. When macOS asks kitty to quit
because the user is logging out, restarting or shutting down, every kitty
instance saves a snapshot: its session, including OS Window geometry, the
scrollback of every window and the command line, working directory and
environment of the instance.
The next kitty started without a session or command to run claims all
snapshots, restores the one saved by an instance with the same command
line itself and starts a separate kitty instance for each of the others,
so every instance keeps its own command line arguments and environment.
Snapshots are deleted only after their windows have been created. A
snapshot that fails to restore twice, for example because kitty crashed,
is deleted. Snapshots from an earlier logout that were never restored are
deleted when saving, using the wall clock start time of the process.
Restored scrollback is parsed before the child is allowed to run, after
the window has its final size. Only the scrollback and screen are saved,
not the scrollback pager history. Before parsing, everything except SGR,
OSC 8 and OSC 66 is removed, so a modified snapshot cannot run escape
codes such as OSC 52, and the restored output has no shell integration
marks. Programs other than the shell are not started again.
A quit is treated as being for a logout only if it is confirmed within
LOGOUT_CONFIRMATION_TIMEOUT of the logout request, and not if the quit
was cancelled in between.
Fixes#1197
The geometry of fullscreen OS Windows is the one from before they were made
fullscreen. On macOS this is now also recorded when using native fullscreen
via the window buttons/menu.
- interpret a directory argument by listing only *.kitty-session and similar files
- reuse the existing sorting logic for the directory chooser and document the workflow