Skip to content

Commit a37ffc3

Browse files
committed
Add first version of zsh completion
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
1 parent 6ca31ec commit a37ffc3

File tree

8 files changed

+296
-4
lines changed

8 files changed

+296
-4
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ src/fcopy/fcopy
3838
src/fldd/fldd
3939
src/fbuilder/fbuilder
4040
src/profstats/profstats
41+
src/bash_completion/firejail.bash_completion
42+
src/zsh_completion/_firejail
4143
uids.h
4244
seccomp
4345
seccomp.debug

Makefile.in

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ MAN_TARGET = man
2121
MAN_SRC = src/man
2222
endif
2323

24+
COMPLETIONDIRS = src/zsh_completion src/bash_completion
2425
all: all_items mydirs $(MAN_TARGET) filters
2526
APPS = src/firecfg/firecfg src/firejail/firejail src/firemon/firemon src/profstats/profstats
2627
SBOX_APPS = src/faudit/faudit src/fbuilder/fbuilder src/ftee/ftee
2728
SBOX_APPS_NON_DUMPABLE = src/fcopy/fcopy src/fldd/fldd src/fnet/fnet src/fnetfilter/fnetfilter
28-
MYDIRS = src/lib $(MAN_SRC)
29+
MYDIRS = src/lib $(MAN_SRC) $(COMPLETIONDIRS)
2930
MYLIBS = src/libpostexecseccomp/libpostexecseccomp.so src/libtrace/libtrace.so src/libtracelog/libtracelog.so
31+
COMPLETIONS = src/zsh_completion/_firejail src/bash_completion/firejail.bash_completion
3032
MANPAGES = firejail.1 firemon.1 firecfg.1 firejail-profile.5 firejail-login.5 firejail-users.5
3133
SBOX_APPS_NON_DUMPABLE += src/fsec-optimize/fsec-optimize src/fsec-print/fsec-print src/fseccomp/fseccomp
3234
SECCOMP_FILTERS = seccomp seccomp.debug seccomp.32 seccomp.block_secondary seccomp.mdwx seccomp.mdwx.32
@@ -158,6 +160,9 @@ endif
158160
install -m 0644 src/bash_completion/firejail.bash_completion $(DESTDIR)$(datarootdir)/bash-completion/completions/firejail
159161
install -m 0644 src/bash_completion/firemon.bash_completion $(DESTDIR)$(datarootdir)/bash-completion/completions/firemon
160162
install -m 0644 src/bash_completion/firecfg.bash_completion $(DESTDIR)$(datarootdir)/bash-completion/completions/firecfg
163+
# zsh completion
164+
install -m 0755 -d $(DESTDIR)$(datarootdir)/zsh/site-functions
165+
install -m 0644 src/zsh_completion/_firejail $(DESTDIR)$(datarootdir)/zsh/site-functions/
161166

162167
install: all
163168
$(MAKE) realinstall

configure

+1-1
Original file line numberDiff line numberDiff line change
@@ -4273,7 +4273,7 @@ fi
42734273

42744274
ac_config_files="$ac_config_files mkdeb.sh"
42754275

4276-
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"
4276+
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"
42774277

42784278
cat >confcache <<\_ACEOF
42794279
# This file is a shell script that caches the results of configure

configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ AC_CONFIG_FILES([mkdeb.sh], [chmod +x mkdeb.sh])
231231
AC_OUTPUT(Makefile src/common.mk src/lib/Makefile src/fcopy/Makefile src/fnet/Makefile src/firejail/Makefile src/fnetfilter/Makefile \
232232
src/firemon/Makefile src/libtrace/Makefile src/libtracelog/Makefile src/firecfg/Makefile src/fbuilder/Makefile src/fsec-print/Makefile \
233233
src/ftee/Makefile src/faudit/Makefile src/fseccomp/Makefile src/fldd/Makefile src/libpostexecseccomp/Makefile src/fsec-optimize/Makefile \
234-
src/profstats/Makefile src/man/Makefile test/Makefile)
234+
src/profstats/Makefile src/man/Makefile src/zsh_completion/Makefile src/bash_completion/Makefile test/Makefile)
235235

236236
echo
237237
echo "Configuration options:"

src/bash_completion/Makefile.in

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
all: firejail.bash_completion
2+
3+
include ../common.mk
4+
5+
firejail.bash_completion: firejail.bash_completion.in
6+
gawk -f ../man/preproc.awk -- $(MANFLAGS) < $< > $@.tmp
7+
sed "s|_SYSCONFDIR_|$(sysconfdir)|" < $@.tmp > $@
8+
rm $@.tmp
9+
10+
clean:
11+
rm -fr firejail.bash_completion
12+
13+
distclean: clean
14+
rm -fr Makefile

src/bash_completion/firejail.bash_completion renamed to src/bash_completion/firejail.bash_completion.in

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ __interfaces(){
99
cut -f 1 -d ':' /proc/net/dev | tail -n +3 | grep -v lo | xargs
1010
}
1111

12+
_profiles() {
13+
if [[ -d "$1" ]] ; then
14+
ls -1 $1/*.profile 2>/dev/null | sed -E 's;^.*\/;;g'
15+
fi
16+
}
17+
_all_profiles() {
18+
local sys_profiles=$(_profiles _SYSCONFDIR_/firejail)
19+
local user_profiles=$(_profiles $HOME/.config/firejail)
20+
COMPREPLY=($(compgen -W "${sys_profiles} ${user_profiles}" -- "$cur"))
21+
}
22+
1223

1324
_firejail()
1425
{
@@ -20,7 +31,7 @@ _firejail()
2031
return 0
2132
;;
2233
--profile)
23-
_filedir
34+
_all_profiles
2435
return 0
2536
;;
2637
--hosts-file)

src/zsh_completion/Makefile.in

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
all: _firejail
2+
3+
include ../common.mk
4+
5+
_firejail: _firejail.in
6+
gawk -f ../man/preproc.awk -- $(MANFLAGS) < $< > $@.tmp
7+
sed "s|_SYSCONFDIR_|$(sysconfdir)|" < $@.tmp > $@
8+
rm $@.tmp
9+
10+
clean:
11+
rm -fr _firejail
12+
13+
distclean: clean
14+
rm -fr Makefile

0 commit comments

Comments
 (0)