2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 10:07:12 +00:00

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 <john.johansen@canonical.com>
Acked-by: Mike Salvatore <mike.salvatore@canonical.com>
This commit is contained in:
John Johansen 2020-06-12 04:24:30 -07:00
parent fe0d4e8aa3
commit 761008f1b6
2 changed files with 6 additions and 8 deletions

View File

@ -1636,13 +1636,11 @@ void vprintyyerror(const char *msg, va_list argptr)
if (profilename) { if (profilename) {
PERROR(_("AppArmor parser error for %s%s%s at line %d: %s\n"), PERROR(_("AppArmor parser error for %s%s%s at line %d: %s\n"),
profilename, profilename,
current_filename ? " in " : "", current_filename ? " in profile " : "",
current_filename ? current_filename : "", current_filename ? current_filename : "",
current_lineno, buf); current_lineno, buf);
} else { } else {
PERROR(_("AppArmor parser error,%s%s line %d: %s\n"), PERROR(_("AppArmor parser error at line %d: %s\n"),
current_filename ? " in " : "",
current_filename ? current_filename : "",
current_lineno, buf); current_lineno, buf);
} }
} }

View File

@ -45,25 +45,25 @@ class AAErrorTests(testlib.AATestTemplate):
def test_single(self): def test_single(self):
self._run_test( self._run_test(
'errors/single.sd', '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): def test_double(self):
self._run_test( self._run_test(
'errors/double.sd', '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): def test_modefail(self):
self._run_test( self._run_test(
'errors/modefail.sd', '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): def test_multi_include(self):
self._run_test( self._run_test(
'errors/multi_include.sd', '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): def test_deprecation1(self):