kitty +open: Ask for confirmation when running executables

Workaround for badly designed program that try to open links in
untrusted documents that point to executables on the local system.
They should really not be doing that, but, since such programs do exist,
let's be safe by default.

Users that use better designed programs and want to disable the
confirmations can do so by writing their own launch-actions.conf
This commit is contained in:
Kovid Goyal 2025-03-20 14:00:09 +05:30
parent 191ea16cd7
commit ce5cfdd9ca
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 13 additions and 5 deletions

View file

@ -102,6 +102,12 @@ Detailed list of changes
background text colors. Works in a perceptual color for best color accuracy
(:pull:`8420`)
- :ref:`kitty +open <launch_actions>`: Ask for confirmation by default when running executables
to work around some badly designed programs that try to open links in
documents that point to executable files. Can be overridden by specifying
your own :file:`launch-actions.conf`.
0.40.1 [2025-03-18]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -240,25 +240,27 @@ def default_open_actions() -> tuple[OpenAction, ...]:
@run_once
def default_launch_actions() -> tuple[OpenAction, ...]:
return tuple(parse('''\
# Open script files
# Open script files. Change confirm-always to confirm-never or confirm-if-needed to
# disable confirmation for all or executable files respectively.
protocol file
ext sh,command,tool
action launch --hold --type=os-window kitten __shebang__ confirm-if-needed $FILE_PATH $SHELL
action launch --hold --type=os-window kitten __shebang__ confirm-always $FILE_PATH $SHELL
# Open shell specific script files
protocol file
ext fish,bash,zsh
action launch --hold --type=os-window kitten __shebang__ confirm-if-needed $FILE_PATH __ext__
action launch --hold --type=os-window kitten __shebang__ confirm-always $FILE_PATH __ext__
# Open directories
protocol file
mime inode/directory
action launch --type=os-window --cwd -- $FILE_PATH
# Open executable file
# Open executable file. Remove kitten __confirm_and_run_exe__ to execute
# without confirmation.
protocol file
mime inode/executable,application/vnd.microsoft.portable-executable
action launch --hold --type=os-window -- $FILE_PATH
action launch --hold --type=os-window -- kitten __confirm_and_run_exe__ $FILE_PATH
# Open text files without fragments in the editor
protocol file