mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
parser: Add warning flag that can toggle deprecation warnings
Add the flag --warn=deprecated to be able to toggle deprecation warnings MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/600 Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
0d0686becc
commit
c530c880b1
5 changed files with 7 additions and 3 deletions
|
@ -55,6 +55,7 @@ extern int parser_token;
|
|||
#define WARN_RULE_NOT_ENFORCED 1
|
||||
#define WARN_RULE_DOWNGRADED 2
|
||||
#define WARN_ABI 4
|
||||
#define WARN_DEPRECATED 8
|
||||
|
||||
extern dfaflags_t warnflags;
|
||||
|
||||
|
|
|
@ -250,6 +250,7 @@ optflag_table_t warnflag_table[] = {
|
|||
{ 0, "rule-not-enforced", "warn if a rule is not enforced", WARN_RULE_NOT_ENFORCED },
|
||||
{ 0, "rule-downgraded", "warn if a rule is downgraded to a lesser but still enforcing rule", WARN_RULE_DOWNGRADED },
|
||||
{ 0, "abi", "warn if there are abi issues in the profile", WARN_ABI },
|
||||
{ 0, "deprecated", "warn if something in the profile is deprecated", WARN_DEPRECATED },
|
||||
{ 0, NULL, NULL, 0 },
|
||||
};
|
||||
|
||||
|
@ -1427,7 +1428,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (create_cache_dir)
|
||||
pwarn(_("The --create-cache-dir option is deprecated. Please use --write-cache.\n"));
|
||||
pwarn_onflag(WARN_DEPRECATED, _("The --create-cache-dir option is deprecated. Please use --write-cache.\n"));
|
||||
retval = aa_policy_cache_new(&policy_cache, kernel_features,
|
||||
AT_FDCWD, cacheloc[0], max_caches);
|
||||
if (retval) {
|
||||
|
|
|
@ -522,7 +522,7 @@ static int warned_uppercase = 0;
|
|||
void warn_uppercase(void)
|
||||
{
|
||||
if (!warned_uppercase) {
|
||||
pwarn(_("Uppercase qualifiers \"RWLIMX\" are deprecated, please convert to lowercase\n"
|
||||
pwarn_onflag(WARN_DEPRECATED, _("Uppercase qualifiers \"RWLIMX\" are deprecated, please convert to lowercase\n"
|
||||
"See the apparmor.d(5) manpage for details.\n"));
|
||||
warned_uppercase = 1;
|
||||
}
|
||||
|
|
|
@ -401,7 +401,7 @@ profile: opt_profile_flag profile_base
|
|||
PDEBUG("Matched: %s { ... }\n", $2->name);
|
||||
|
||||
if ($2->name[0] == '/')
|
||||
pwarn(_("The use of file paths as profile names is deprecated. See man apparmor.d for more information\n"));
|
||||
pwarn_onflag(WARN_DEPRECATED, _("The use of file paths as profile names is deprecated. See man apparmor.d for more information\n"));
|
||||
|
||||
if ($2->name[0] != '/' && !($1 || $2->ns))
|
||||
yyerror(_("Profile names must begin with a '/', namespace or keyword 'profile' or 'hat'."));
|
||||
|
|
|
@ -67,6 +67,7 @@ class AAErrorTests(testlib.AATestTemplate):
|
|||
)
|
||||
|
||||
def test_deprecation1(self):
|
||||
self.cmd_prefix.extend(['--warn=deprecated'])
|
||||
self._run_test(
|
||||
'errors/deprecation1.sd',
|
||||
"Warning from errors/deprecation1.sd (errors/deprecation1.sd line 6): The use of file paths as profile names is deprecated. See man apparmor.d for more information",
|
||||
|
@ -74,6 +75,7 @@ class AAErrorTests(testlib.AATestTemplate):
|
|||
)
|
||||
|
||||
def test_deprecation2(self):
|
||||
self.cmd_prefix.extend(['--warn=deprecated'])
|
||||
self._run_test(
|
||||
'errors/deprecation2.sd',
|
||||
"Warning from errors/deprecation2.sd (errors/deprecation2.sd line 6): The use of file paths as profile names is deprecated. See man apparmor.d for more information",
|
||||
|
|
Loading…
Add table
Reference in a new issue