aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kelvin M. Klann <kmk3.code@protonmail.com>2023-08-12 01:48:34 -0300
committerLibravatar Kelvin M. Klann <kmk3.code@protonmail.com>2023-08-14 18:16:10 -0300
commit204c45adee77e9cebfdb9458f68d31f11cbdc679 (patch)
treef2826a2fca7b3d89d7f625c34f284b444303e9e1
parentbuild: print syntax list generation (diff)
downloadfirejail-204c45adee77e9cebfdb9458f68d31f11cbdc679.tar.gz
firejail-204c45adee77e9cebfdb9458f68d31f11cbdc679.tar.zst
firejail-204c45adee77e9cebfdb9458f68d31f11cbdc679.zip
build: improve char escaping of syntax lists
Escape `.` only when generating the syntax files rather than directly in the syntax lists, so that the latter contain the command names as is. This also makes the escaping apply to the arg1 syntax list as well. Note: Double escaping (`\\\\.`) is used in `regex_fromlf` because its output is used in another sed replacement (where it needs to be `\\.`). Relates to #5627.
-rw-r--r--Makefile22
-rw-r--r--contrib/syntax/lists/profile_commands_arg0.list2
2 files changed, 12 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 84fa5597a..86b45f7b2 100644
--- a/Makefile
+++ b/Makefile
@@ -106,13 +106,13 @@ syntax: $(SYNTAX_FILES)
106contrib/syntax/lists/profile_commands_arg0.list: src/firejail/profile.c Makefile 106contrib/syntax/lists/profile_commands_arg0.list: src/firejail/profile.c Makefile
107 @printf 'Generating %s from %s\n' $@ $< 107 @printf 'Generating %s from %s\n' $@ $<
108 @sed -En 's/.*strn?cmp\(ptr, "([^ "]*[^ ])".*/\1/p' $< | \ 108 @sed -En 's/.*strn?cmp\(ptr, "([^ "]*[^ ])".*/\1/p' $< | \
109 grep -Ev '^(include|rlimit)$$' | sed 's/\./\\./' | LC_ALL=C sort -u >$@ 109 grep -Ev '^(include|rlimit)$$' | LC_ALL=C sort -u >$@
110 110
111# TODO: private-lib is special-cased in the code and doesn't match the regex 111# TODO: private-lib is special-cased in the code and doesn't match the regex
112contrib/syntax/lists/profile_commands_arg1.list: src/firejail/profile.c Makefile 112contrib/syntax/lists/profile_commands_arg1.list: src/firejail/profile.c Makefile
113 @printf 'Generating %s from %s\n' $@ $< 113 @printf 'Generating %s from %s\n' $@ $<
114 @{ sed -En 's/.*strn?cmp\(ptr, "([^"]+) ".*/\1/p' $<; echo private-lib; } | \ 114 @{ sed -En 's/.*strn?cmp\(ptr, "([^"]+) ".*/\1/p' $<; \
115 LC_ALL=C sort -u >$@ 115 echo private-lib; } | LC_ALL=C sort -u >$@
116 116
117contrib/syntax/lists/profile_conditionals.list: src/firejail/profile.c Makefile 117contrib/syntax/lists/profile_conditionals.list: src/firejail/profile.c Makefile
118 @printf 'Generating %s from %s\n' $@ $< 118 @printf 'Generating %s from %s\n' $@ $<
@@ -139,17 +139,17 @@ contrib/syntax/lists/system_errnos.list: src/lib/errno.c Makefile
139 @printf 'Generating %s from %s\n' $@ $< 139 @printf 'Generating %s from %s\n' $@ $<
140 @sed -En 's/.*"(E[^"]+).*/\1/p' $< | LC_ALL=C sort -u >$@ 140 @sed -En 's/.*"(E[^"]+).*/\1/p' $< | LC_ALL=C sort -u >$@
141 141
142pipe_fromlf = { tr '\n' '|' | sed 's/|$$//'; } 142regex_fromlf = { tr '\n' '|' | sed -e 's/|$$//' -e 's/\./\\\\./g'; }
143space_fromlf = { tr '\n' ' ' | sed 's/ $$//'; } 143space_fromlf = { tr '\n' ' ' | sed -e 's/ $$//'; }
144edit_syntax_file = sed \ 144edit_syntax_file = sed \
145 -e "s/@make_input@/$$(basename $@). Generated from $$(basename $<) by make./" \ 145 -e "s/@make_input@/$$(basename $@). Generated from $$(basename $<) by make./" \
146 -e "s/@FJ_PROFILE_COMMANDS_ARG0@/$$($(pipe_fromlf) <contrib/syntax/lists/profile_commands_arg0.list)/" \ 146 -e "s/@FJ_PROFILE_COMMANDS_ARG0@/$$($(regex_fromlf) <contrib/syntax/lists/profile_commands_arg0.list)/" \
147 -e "s/@FJ_PROFILE_COMMANDS_ARG1@/$$($(pipe_fromlf) <contrib/syntax/lists/profile_commands_arg1.list)/" \ 147 -e "s/@FJ_PROFILE_COMMANDS_ARG1@/$$($(regex_fromlf) <contrib/syntax/lists/profile_commands_arg1.list)/" \
148 -e "s/@FJ_PROFILE_CONDITIONALS@/$$($(pipe_fromlf) <contrib/syntax/lists/profile_conditionals.list)/" \ 148 -e "s/@FJ_PROFILE_CONDITIONALS@/$$($(regex_fromlf) <contrib/syntax/lists/profile_conditionals.list)/" \
149 -e "s/@FJ_PROFILE_MACROS@/$$($(pipe_fromlf) <contrib/syntax/lists/profile_macros.list)/" \ 149 -e "s/@FJ_PROFILE_MACROS@/$$($(regex_fromlf) <contrib/syntax/lists/profile_macros.list)/" \
150 -e "s/@FJ_SYSCALLS@/$$($(space_fromlf) <contrib/syntax/lists/syscalls.list)/" \ 150 -e "s/@FJ_SYSCALLS@/$$($(space_fromlf) <contrib/syntax/lists/syscalls.list)/" \
151 -e "s/@FJ_SYSCALL_GROUPS@/$$($(pipe_fromlf) <contrib/syntax/lists/syscall_groups.list)/" \ 151 -e "s/@FJ_SYSCALL_GROUPS@/$$($(regex_fromlf) <contrib/syntax/lists/syscall_groups.list)/" \
152 -e "s/@FJ_SYSTEM_ERRNOS@/$$($(pipe_fromlf) <contrib/syntax/lists/system_errnos.list)/" 152 -e "s/@FJ_SYSTEM_ERRNOS@/$$($(regex_fromlf) <contrib/syntax/lists/system_errnos.list)/"
153 153
154contrib/syntax/files/example: contrib/syntax/files/example.in $(SYNTAX_LISTS) Makefile 154contrib/syntax/files/example: contrib/syntax/files/example.in $(SYNTAX_LISTS) Makefile
155 @printf 'Generating %s from %s\n' $@ $< 155 @printf 'Generating %s from %s\n' $@ $<
diff --git a/contrib/syntax/lists/profile_commands_arg0.list b/contrib/syntax/lists/profile_commands_arg0.list
index fd1bdb401..e7fecef4b 100644
--- a/contrib/syntax/lists/profile_commands_arg0.list
+++ b/contrib/syntax/lists/profile_commands_arg0.list
@@ -41,7 +41,7 @@ private-tmp
41quiet 41quiet
42restrict-namespaces 42restrict-namespaces
43seccomp 43seccomp
44seccomp\.block-secondary 44seccomp.block-secondary
45tab 45tab
46tracelog 46tracelog
47writable-etc 47writable-etc