Skip to content

Commit

Permalink
Add first version of zsh completion
Browse files Browse the repository at this point in the history
Don't have duplicate descriptions and put = signs where they belong to

zsh completion function now dynamically adjusts for options (e.g. no --apparmor option without AppArmor configured)

No EXTRA_CFLAGS for cpp

Found main.c which does the argument processing. Moved some arguments into the correct #ifdef blocks

Profile selection now much better

Not more cpp. Using preproc.awk instead.

Updated bash firejail command completion to add profiles

ignore bash and zsh dynamically created completion scripts

Moved bash/zsh completions out of ALL_ITEMS to fix make install

Cleanup
  • Loading branch information
haraldkubota committed Feb 12, 2021
1 parent 6ca31ec commit a37ffc3
Show file tree
Hide file tree
Showing 8 changed files with 296 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ src/fcopy/fcopy
src/fldd/fldd
src/fbuilder/fbuilder
src/profstats/profstats
src/bash_completion/firejail.bash_completion
src/zsh_completion/_firejail
uids.h
seccomp
seccomp.debug
Expand Down
7 changes: 6 additions & 1 deletion Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ MAN_TARGET = man
MAN_SRC = src/man
endif

COMPLETIONDIRS = src/zsh_completion src/bash_completion
all: all_items mydirs $(MAN_TARGET) filters
APPS = src/firecfg/firecfg src/firejail/firejail src/firemon/firemon src/profstats/profstats
SBOX_APPS = src/faudit/faudit src/fbuilder/fbuilder src/ftee/ftee
SBOX_APPS_NON_DUMPABLE = src/fcopy/fcopy src/fldd/fldd src/fnet/fnet src/fnetfilter/fnetfilter
MYDIRS = src/lib $(MAN_SRC)
MYDIRS = src/lib $(MAN_SRC) $(COMPLETIONDIRS)
MYLIBS = src/libpostexecseccomp/libpostexecseccomp.so src/libtrace/libtrace.so src/libtracelog/libtracelog.so
COMPLETIONS = src/zsh_completion/_firejail src/bash_completion/firejail.bash_completion
MANPAGES = firejail.1 firemon.1 firecfg.1 firejail-profile.5 firejail-login.5 firejail-users.5
SBOX_APPS_NON_DUMPABLE += src/fsec-optimize/fsec-optimize src/fsec-print/fsec-print src/fseccomp/fseccomp
SECCOMP_FILTERS = seccomp seccomp.debug seccomp.32 seccomp.block_secondary seccomp.mdwx seccomp.mdwx.32
Expand Down Expand Up @@ -158,6 +160,9 @@ endif
install -m 0644 src/bash_completion/firejail.bash_completion $(DESTDIR)$(datarootdir)/bash-completion/completions/firejail
install -m 0644 src/bash_completion/firemon.bash_completion $(DESTDIR)$(datarootdir)/bash-completion/completions/firemon
install -m 0644 src/bash_completion/firecfg.bash_completion $(DESTDIR)$(datarootdir)/bash-completion/completions/firecfg
# zsh completion
install -m 0755 -d $(DESTDIR)$(datarootdir)/zsh/site-functions
install -m 0644 src/zsh_completion/_firejail $(DESTDIR)$(datarootdir)/zsh/site-functions/

install: all
$(MAKE) realinstall
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -4273,7 +4273,7 @@ fi

ac_config_files="$ac_config_files mkdeb.sh"

ac_config_files="$ac_config_files Makefile src/common.mk src/lib/Makefile src/fcopy/Makefile src/fnet/Makefile src/firejail/Makefile src/fnetfilter/Makefile src/firemon/Makefile src/libtrace/Makefile src/libtracelog/Makefile src/firecfg/Makefile src/fbuilder/Makefile src/fsec-print/Makefile src/ftee/Makefile src/faudit/Makefile src/fseccomp/Makefile src/fldd/Makefile src/libpostexecseccomp/Makefile src/fsec-optimize/Makefile src/profstats/Makefile src/man/Makefile test/Makefile"
ac_config_files="$ac_config_files Makefile src/common.mk src/lib/Makefile src/fcopy/Makefile src/fnet/Makefile src/firejail/Makefile src/fnetfilter/Makefile src/firemon/Makefile src/libtrace/Makefile src/libtracelog/Makefile src/firecfg/Makefile src/fbuilder/Makefile src/fsec-print/Makefile src/ftee/Makefile src/faudit/Makefile src/fseccomp/Makefile src/fldd/Makefile src/libpostexecseccomp/Makefile src/fsec-optimize/Makefile src/profstats/Makefile src/man/Makefile src/zsh_completion/Makefile src/bash_completion/Makefile test/Makefile"

cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ AC_CONFIG_FILES([mkdeb.sh], [chmod +x mkdeb.sh])
AC_OUTPUT(Makefile src/common.mk src/lib/Makefile src/fcopy/Makefile src/fnet/Makefile src/firejail/Makefile src/fnetfilter/Makefile \
src/firemon/Makefile src/libtrace/Makefile src/libtracelog/Makefile src/firecfg/Makefile src/fbuilder/Makefile src/fsec-print/Makefile \
src/ftee/Makefile src/faudit/Makefile src/fseccomp/Makefile src/fldd/Makefile src/libpostexecseccomp/Makefile src/fsec-optimize/Makefile \
src/profstats/Makefile src/man/Makefile test/Makefile)
src/profstats/Makefile src/man/Makefile src/zsh_completion/Makefile src/bash_completion/Makefile test/Makefile)

echo
echo "Configuration options:"
Expand Down
14 changes: 14 additions & 0 deletions src/bash_completion/Makefile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
all: firejail.bash_completion

include ../common.mk

firejail.bash_completion: firejail.bash_completion.in
gawk -f ../man/preproc.awk -- $(MANFLAGS) < $< > $@.tmp
sed "s|_SYSCONFDIR_|$(sysconfdir)|" < $@.tmp > $@
rm $@.tmp

clean:
rm -fr firejail.bash_completion

distclean: clean
rm -fr Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ __interfaces(){
cut -f 1 -d ':' /proc/net/dev | tail -n +3 | grep -v lo | xargs
}

_profiles() {
if [[ -d "$1" ]] ; then
ls -1 $1/*.profile 2>/dev/null | sed -E 's;^.*\/;;g'
fi
}
_all_profiles() {
local sys_profiles=$(_profiles _SYSCONFDIR_/firejail)
local user_profiles=$(_profiles $HOME/.config/firejail)
COMPREPLY=($(compgen -W "${sys_profiles} ${user_profiles}" -- "$cur"))
}


_firejail()
{
Expand All @@ -20,7 +31,7 @@ _firejail()
return 0
;;
--profile)
_filedir
_all_profiles
return 0
;;
--hosts-file)
Expand Down
14 changes: 14 additions & 0 deletions src/zsh_completion/Makefile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
all: _firejail

include ../common.mk

_firejail: _firejail.in
gawk -f ../man/preproc.awk -- $(MANFLAGS) < $< > $@.tmp
sed "s|_SYSCONFDIR_|$(sysconfdir)|" < $@.tmp > $@
rm $@.tmp

clean:
rm -fr _firejail

distclean: clean
rm -fr Makefile
Loading

0 comments on commit a37ffc3

Please sign in to comment.