From 761008f1b6c83ee39f199cbdf78d19c71fe1cfde Mon Sep 17 00:00:00 2001 From: John Johansen Date: Fri, 12 Jun 2020 04:24:30 -0700 Subject: [PATCH] parser: fix yyerror message to not duplicate file name output yyerror is outputting the file name twice when not in a profile or the profilename global is not defined. Drop the second output of the file name as it just clutters up the error message. MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/610 Signed-off-by: John Johansen Acked-by: Mike Salvatore --- parser/parser_yacc.y | 6 ++---- parser/tst/errors.py | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/parser/parser_yacc.y b/parser/parser_yacc.y index 8569f37b5..1d1c170c6 100644 --- a/parser/parser_yacc.y +++ b/parser/parser_yacc.y @@ -1636,13 +1636,11 @@ void vprintyyerror(const char *msg, va_list argptr) if (profilename) { PERROR(_("AppArmor parser error for %s%s%s at line %d: %s\n"), profilename, - current_filename ? " in " : "", + current_filename ? " in profile " : "", current_filename ? current_filename : "", current_lineno, buf); } else { - PERROR(_("AppArmor parser error,%s%s line %d: %s\n"), - current_filename ? " in " : "", - current_filename ? current_filename : "", + PERROR(_("AppArmor parser error at line %d: %s\n"), current_lineno, buf); } } diff --git a/parser/tst/errors.py b/parser/tst/errors.py index ef3cf2836..e0ed9a62a 100755 --- a/parser/tst/errors.py +++ b/parser/tst/errors.py @@ -45,25 +45,25 @@ class AAErrorTests(testlib.AATestTemplate): def test_single(self): self._run_test( 'errors/single.sd', - "AppArmor parser error for errors/single.sd in errors/single.sd at line 3: Could not open 'failure'", + "AppArmor parser error for errors/single.sd in profile errors/single.sd at line 3: Could not open 'failure'", ) def test_double(self): self._run_test( 'errors/double.sd', - "AppArmor parser error for errors/double.sd in errors/includes/busted at line 66: Could not open 'does-not-exist'", + "AppArmor parser error for errors/double.sd in profile errors/includes/busted at line 66: Could not open 'does-not-exist'", ) def test_modefail(self): self._run_test( 'errors/modefail.sd', - "AppArmor parser error for errors/modefail.sd in errors/modefail.sd at line 6: syntax error", + "AppArmor parser error for errors/modefail.sd in profile errors/modefail.sd at line 6: syntax error, unexpected TOK_ID, expecting TOK_MODE", ) def test_multi_include(self): self._run_test( 'errors/multi_include.sd', - "AppArmor parser error for errors/multi_include.sd in errors/multi_include.sd at line 12: Could not open 'failure'", + "AppArmor parser error for errors/multi_include.sd in profile errors/multi_include.sd at line 12: Could not open 'failure'", ) def test_deprecation1(self):