AA_QUERY_LABEL(2)
π AA_QUERY_LABEL(2) π
okay bestie, so this is the AppArmor page all about aa_query_label and its little helper squad β aa_query_file_path, aa_query_file_path_len, aa_query_link_path and aa_query_link_path_len. yes, that's a lot of names, but they're all doing the same vibe: asking the kernel "hey, is this allowed?" π«Ά
β¨ NAME β¨
aa_query_labelβ query access permission associated with a labelaa_query_file_path,aa_query_file_path_lenβ query access permissions of a file pathaa_query_link_path,aa_query_link_path_lenβ query access permissions of a link path
πΈ SYNOPSIS πΈ
#include <sys/apparmor.h>
int aa_query_label(uint32_t mask, char *query, size_t size, int
*allowed, int *audited);
int aa_query_file_path(uint32_t mask, const char *label, size_t
label_len, const char *path, int *allowed, int *audited);
int aa_query_file_path_len(uint32_t mask, const char *label, size_t
label_len, const char *path, size_t path_len, int *allowed, int
*audited);
int aa_query_link_path(const char *label, const char *target, const char
*link, int *allowed, int *audited);
int aa_query_link_path_len(const char *label, size_t label_len, const
char *target, size_t target_len, const char *link, size_t link_len, int
*allowed, int *audited);
and like, don't forget to link with -lapparmor when compiling, or the whole thing just will not hit π
π¦ DESCRIPTION π¦
so aa_query_label goes and fetches the current permissions granted by the label you stuffed into the query string. it's giving "asking the vibes what's allowed rn" β¨
the query is a raw binary formatted query, and it's carrying the label plus the permission query you wanna make. the allowed and audited values that come back are interpreted boolean values β literally just telling you whether the query is allowed, and whether it's audited. no drama, no extra lore π
the mask of the query string is a bit mask of permissions to query, and it's class type dependent (peep the AA_CLASS_xxx entries in sys/apparmor.h, iykyk).
the format of the query string is also dependent on the AA_CLASS, which is exactly why the aa_query_xxx helper functions should usually be used instead of raw-dogging aa_query_label directly. if you do go straight at the interface, the query string is required to have a header of AA_QUERY_CMD_LABEL_SIZE that will be used by aa_query_label. not optional, bestie, that's the rule π
aa_query_file_path and aa_query_file_path_len are helper functions that assemble a properly formatted file path query for aa_query_label to eat. the label is a valid apparmor label as returned by aa_splitcon, with label_len being the length of the label. the path is any valid filesystem path you wanna query permissions for. and for the aa_query_file_path_len variant, the path_len parameter specifies the number of bytes in the path to use as part of the query. slay π
aa_query_link_path and aa_query_link_path_len are helper functions that assemble a properly formatted link path query for aa_query_label. the link_len and target_len parameters specify the number of bytes in the link and target to use as part of the query. icon behavior honestly π
π RETURN VALUE π
on success, 0 is returned, and the allowed and audited parameters contain a boolean value of 0 for not allowed/audited or 1 for allowed/audited. easy. on error, -1 is returned, and errno(3) is set appropriately. the way that error handling just works π
π ERRORS π
EINVAL- the requested mask is empty.
- the size of the query is less than the query
AA_QUERY_CMD_LABEL_SIZE - the apparmor kernel module is not loaded, or the kernel interface access interface is not available
ENOMEMβ insufficient memory was available. rough. πEACCESβ access to the specified label or query interface was denied. big L, but okay.ENOENTβ the specified label does not exist or is not visible.ERANGEβ the confinement data is too large to fit in the supplied buffer. it's giving "cannot fit, bestie" π
β NOTES β
the label permissions returned are only valid for the time of the query and can change at any point in the future. so like... screenshot it, because it's not staying the same π«Ά
π§ BUGS π§
none known. if you find any, please report them at <https://gitlab.com/apparmor/apparmor/-/issues>. be a main character and file that bug report β¨
π SEE ALSO π
apparmor(7), apparmor.d(5), apparmor_parser(8), aa_getcon(2), aa_splitcon(3) and <https://wiki.apparmor.net>.
and that's the page, bestie! mwah πβ¨ β courtesy of AppArmor 4.1.8, dated 2026-10-18, and this whole manual thing was AA_QUERY_LABEL(2). go query some labels, periodt πΈ
π¦ where this page comes from
- arch rolling: apparmor 4.1.8-2 Β· GPL-2.0-only AND LGPL-2.0-only AND LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms