From 204c45adee77e9cebfdb9458f68d31f11cbdc679 Mon Sep 17 00:00:00 2001 From: "Kelvin M. Klann" Date: Sat, 12 Aug 2023 01:48:34 -0300 Subject: 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. --- Makefile | 22 +++++++++++----------- contrib/syntax/lists/profile_commands_arg0.list | 2 +- 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) contrib/syntax/lists/profile_commands_arg0.list: src/firejail/profile.c Makefile @printf 'Generating %s from %s\n' $@ $< @sed -En 's/.*strn?cmp\(ptr, "([^ "]*[^ ])".*/\1/p' $< | \ - grep -Ev '^(include|rlimit)$$' | sed 's/\./\\./' | LC_ALL=C sort -u >$@ + grep -Ev '^(include|rlimit)$$' | LC_ALL=C sort -u >$@ # TODO: private-lib is special-cased in the code and doesn't match the regex contrib/syntax/lists/profile_commands_arg1.list: src/firejail/profile.c Makefile @printf 'Generating %s from %s\n' $@ $< - @{ sed -En 's/.*strn?cmp\(ptr, "([^"]+) ".*/\1/p' $<; echo private-lib; } | \ - LC_ALL=C sort -u >$@ + @{ sed -En 's/.*strn?cmp\(ptr, "([^"]+) ".*/\1/p' $<; \ + echo private-lib; } | LC_ALL=C sort -u >$@ contrib/syntax/lists/profile_conditionals.list: src/firejail/profile.c Makefile @printf 'Generating %s from %s\n' $@ $< @@ -139,17 +139,17 @@ contrib/syntax/lists/system_errnos.list: src/lib/errno.c Makefile @printf 'Generating %s from %s\n' $@ $< @sed -En 's/.*"(E[^"]+).*/\1/p' $< | LC_ALL=C sort -u >$@ -pipe_fromlf = { tr '\n' '|' | sed 's/|$$//'; } -space_fromlf = { tr '\n' ' ' | sed 's/ $$//'; } +regex_fromlf = { tr '\n' '|' | sed -e 's/|$$//' -e 's/\./\\\\./g'; } +space_fromlf = { tr '\n' ' ' | sed -e 's/ $$//'; } edit_syntax_file = sed \ -e "s/@make_input@/$$(basename $@). Generated from $$(basename $<) by make./" \ - -e "s/@FJ_PROFILE_COMMANDS_ARG0@/$$($(pipe_fromlf)