2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 01:57:43 +00:00

aa-status: improve failure messages

Improve the failure messages around getting policy information to
be less ambiguous about what went wrong.

Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
John Johansen 2025-04-24 02:16:38 -07:00
parent 6f480cb819
commit 96d327d28a
2 changed files with 39 additions and 23 deletions

View File

@ -1038,8 +1038,10 @@ int main(int argc, char **argv)
* have policy associated.
*/
ret = get_profiles(fp, &profiles, &nprofiles);
if (ret != 0 && !opt_json) {
eprintf(_("Failed to get profiles: %d....\n"), ret);
if (ret == AA_EXIT_NO_POLICY) {
eprintf(_("No policy loaded into the kernel\n"));
} else if (ret != 0 && !opt_json) {
eprintf(_("Failed to retrieve profiles from kernel: %d....\n"), ret);
goto out;
}
@ -1068,7 +1070,7 @@ int main(int argc, char **argv)
ret = get_processes(profiles, nprofiles, &processes, &nprocesses);
if (ret != 0) {
eprintf(_("Failed to get processes: %d....\n"), ret);
eprintf(_("Failed to get confinement information from processes: %d....\n"), ret);
} else if (opt_count) {
ret = simple_filtered_process_count(outf, &filters, opt_json,
processes, nprocesses);

View File

@ -1,14 +1,14 @@
# Translations for aa_status
# Copyright (C) 2024 Canonical Ltd
# This file is distributed under the same license as the AppArmor package.
# John Johansen <john.johansen@canonical.com>, 2024.
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Canonical Ltd
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: apparmor@lists.ubuntu.com\n"
"POT-Creation-Date: 2024-08-31 17:49-0700\n"
"POT-Creation-Date: 2025-04-26 11:12-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -42,12 +42,12 @@ msgstr ""
msgid "ERROR: Failed to allocate memory\n"
msgstr ""
#: ../aa_status.c:587 ../aa_status.c:653
#: ../aa_status.c:587 ../aa_status.c:653 ../aa_status.c:603 ../aa_status.c:669
#, c-format
msgid "Error: failed to compile sub filter '%s'\n"
msgstr ""
#: ../aa_status.c:715
#: ../aa_status.c:715 ../aa_status.c:731
#, c-format
msgid ""
"Usage: %s [OPTIONS]\n"
@ -61,7 +61,7 @@ msgid ""
" --process-mixed --count --ps --mode=mixed\n"
msgstr ""
#: ../aa_status.c:734
#: ../aa_status.c:734 ../aa_status.c:750
#, c-format
msgid ""
"Usage of filters\n"
@ -77,7 +77,7 @@ msgid ""
" --filter.exe: regular expression to match executable\n"
msgstr ""
#: ../aa_status.c:762
#: ../aa_status.c:762 ../aa_status.c:778
#, c-format
msgid ""
"Usage: %s [OPTIONS]\n"
@ -103,45 +103,45 @@ msgid ""
" --help[=(legacy|filters)] this message, or info on the specified option\n"
msgstr ""
#: ../aa_status.c:856
#: ../aa_status.c:856 ../aa_status.c:872
#, c-format
msgid "Error: Invalid --help option '%s'.\n"
msgstr ""
#: ../aa_status.c:924
#: ../aa_status.c:924 ../aa_status.c:940
#, c-format
msgid "Error: Invalid --show option '%s'.\n"
msgstr ""
#: ../aa_status.c:946
#: ../aa_status.c:946 ../aa_status.c:962
msgid "Error: Invalid command.\n"
msgstr ""
#: ../aa_status.c:971
#: ../aa_status.c:971 ../aa_status.c:987
msgid "Error: Unknown options.\n"
msgstr ""
#: ../aa_status.c:983
#: ../aa_status.c:983 ../aa_status.c:999
#, c-format
msgid "Error: failed to compile mode filter '%s'\n"
msgstr ""
#: ../aa_status.c:988
#: ../aa_status.c:988 ../aa_status.c:1004
#, c-format
msgid "Error: failed to compile profiles filter '%s'\n"
msgstr ""
#: ../aa_status.c:994
#: ../aa_status.c:994 ../aa_status.c:1010
#, c-format
msgid "Error: failed to compile ps filter '%s'\n"
msgstr ""
#: ../aa_status.c:1000
#: ../aa_status.c:1000 ../aa_status.c:1016
#, c-format
msgid "Error: failed to compile exe filter '%s'\n"
msgstr ""
#: ../aa_status.c:1015
#: ../aa_status.c:1015 ../aa_status.c:1031
#, c-format
msgid "Failed to open memstream: %m\n"
msgstr ""
@ -156,10 +156,24 @@ msgstr ""
msgid "Failed to get processes: %d....\n"
msgstr ""
#: ../aa_status.c:1076
#: ../aa_status.c:1076 ../aa_status.c:1099
msgid "Failed to parse json output"
msgstr ""
#: ../aa_status.c:1083
#: ../aa_status.c:1083 ../aa_status.c:1106
msgid "Failed to print pretty json"
msgstr ""
#: ../aa_status.c:1044
#, c-format
msgid "Failed to retrieve profiles from kernel: %d....\n"
msgstr ""
#: ../aa_status.c:1073
#, c-format
msgid "Failed to get confinement information from processes: %d....\n"
msgstr ""
#: ../aa_status.c:1042
msgid "No policy loaded into the kernel\n"
msgstr ""