2024-11-20 01:25:19 +09:00
|
|
|
#compdef fortify
|
|
|
|
|
|
|
|
_fortify_app() {
|
2024-12-21 21:13:53 +09:00
|
|
|
__fortify_files
|
|
|
|
return $?
|
2024-11-20 01:25:19 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
_fortify_run() {
|
|
|
|
_arguments \
|
2024-12-06 03:26:09 +09:00
|
|
|
'--id[App ID, leave empty to disable security context app_id]:id' \
|
2024-11-20 01:25:19 +09:00
|
|
|
'-a[Fortify application ID]: :_numbers' \
|
|
|
|
'-g[Groups inherited by the app process]: :_groups' \
|
|
|
|
'-d[Application home directory]: :_files -/' \
|
|
|
|
'-u[Passwd name within sandbox]: :_users' \
|
|
|
|
'--wayland[Share Wayland socket]' \
|
|
|
|
'-X[Share X11 socket and allow connection]' \
|
|
|
|
'--dbus[Proxy D-Bus connection]' \
|
|
|
|
'--pulse[Share PulseAudio socket and cookie]' \
|
|
|
|
'--dbus-config[Path to D-Bus proxy config file]: :_files -g "*.json"' \
|
|
|
|
'--dbus-system[Path to system D-Bus proxy config file]: :_files -g "*.json"' \
|
|
|
|
'--mpris[Allow owning MPRIS D-Bus path]' \
|
|
|
|
'--dbus-log[Force logging in the D-Bus proxy]'
|
|
|
|
}
|
|
|
|
|
2024-12-21 20:34:40 +09:00
|
|
|
_fortify_ps() {
|
|
|
|
_arguments \
|
|
|
|
'--short[Print instance id]'
|
|
|
|
}
|
|
|
|
|
2024-12-21 21:13:53 +09:00
|
|
|
_fortify_show() {
|
|
|
|
_alternative \
|
|
|
|
'instances:domains:__fortify_instances' \
|
|
|
|
'files:files:__fortify_files'
|
|
|
|
}
|
|
|
|
|
|
|
|
__fortify_files() {
|
|
|
|
_files -g "*.(json|ftfy)"
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
__fortify_instances() {
|
|
|
|
local -a out
|
|
|
|
shift -p
|
|
|
|
out=( ${(f)"$(_call_program commands fortify ps --short 2>&1)"} )
|
|
|
|
if (( $#out == 0 )); then
|
|
|
|
_message "No active instances"
|
|
|
|
else
|
|
|
|
_describe "active instances" out
|
|
|
|
fi
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
2024-11-20 01:25:19 +09:00
|
|
|
(( $+functions[_fortify_commands] )) || _fortify_commands()
|
|
|
|
{
|
|
|
|
local -a _fortify_cmds
|
|
|
|
_fortify_cmds=(
|
|
|
|
"app:Launch app defined by the specified config file"
|
|
|
|
"run:Configure and start a permissive default sandbox"
|
2024-12-21 00:32:34 +09:00
|
|
|
"show:Show the contents of an app configuration"
|
2024-11-20 01:25:19 +09:00
|
|
|
"ps:List active apps and their state"
|
|
|
|
"version:Show fortify version"
|
|
|
|
"license:Show full license text"
|
|
|
|
"template:Produce a config template"
|
|
|
|
"help:Show help message"
|
|
|
|
)
|
|
|
|
if (( CURRENT == 1 )); then
|
2024-12-21 00:32:34 +09:00
|
|
|
_describe -t commands 'action' _fortify_cmds || compadd "$@"
|
2024-11-20 01:25:19 +09:00
|
|
|
else
|
|
|
|
local curcontext="$curcontext"
|
|
|
|
cmd="${${_fortify_cmds[(r)$words[1]:*]%%:*}}"
|
|
|
|
if (( $+functions[_fortify_$cmd] )); then
|
|
|
|
_fortify_$cmd
|
|
|
|
else
|
|
|
|
_message "no more options"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_arguments -C \
|
|
|
|
'-v[Verbose output]' \
|
2024-12-21 00:32:34 +09:00
|
|
|
'--json[Format output in JSON when applicable]' \
|
2024-11-20 01:25:19 +09:00
|
|
|
'*::fortify command:_fortify_commands'
|