aa_features(3)

πŸ’œ aa_features(3) β€” the AppArmor features bestie πŸ’œ

okay so this is the manual page for aa_features(3) from AppArmor, and it's literally the glow-up guide for the opaque object that represents a set of AppArmor kernel features. come thru 🫢


✨ NAME ✨

aa_features β€” an opaque object representing a set of AppArmor kernel features. it's giving "mystery box but make it kernel" πŸŽ€

aa_features_new β€” create a new aa_features object based on a path.

aa_features_new_from_string β€” create a new aa_features object based on a string.

aa_features_new_from_kernel β€” create a new aa_features object based on the current kernel.

aa_features_ref β€” increments the ref count of an aa_features object.

aa_features_unref β€” decrements the ref count and frees the aa_features object when 0.

aa_features_write_to_fd β€” write a string representation of an aa_features object to a file descriptor.

aa_features_write_to_file β€” write a string representation of an aa_features object to a file.

aa_features_is_equal β€” equality test for two aa_features objects.

aa_features_supports β€” provides aa_features object support status.

aa_features_id β€” provides a unique identifier for an aa_features object.

aa_features_value β€” the value associated with a given feature.


🌸 SYNOPSIS 🌸

#include <sys/apparmor.h>

typedef struct aa_features aa_features;

int aa_features_new(aa_features **features, int dirfd, const char *path);

int aa_features_new_from_file(aa_features **features, int fd);

int aa_features_new_from_string(aa_features **features, const char *string, size_t size);

int aa_features_new_from_kernel(aa_features **features);

aa_features *aa_features_ref(aa_features *features);

void aa_features_unref(aa_features *features);

int aa_features_write_to_fd(aa_features *features, int fd);

int aa_features_write_to_file(aa_features *features, int dirfd, const char *path);

bool aa_features_is_equal(aa_features *features1, aa_features *features2);

bool aa_features_supports(aa_features *features, const char *str);

char *aa_features_id(aa_features *features);

char *aa_features_value(aa_features *features, const char *str, size_t *len);

Link with -lapparmor when compiling. don't forget, bestie, or the linker will simply not vibe with you 😭


πŸ¦‹ DESCRIPTION πŸ¦‹

The aa_features object contains info about the AppArmor features supported by a kernel. like, it's the receipts for what your kernel can actually do ✨ The feature support information is based upon the files AppArmor represents in securityfs, which is typically found at /sys/kernel/security/apparmor/features/. That information may be parsed and turned into a string or flat file in order to represent a set of features of a kernel that is not currently running. yes, it's time travel adjacent, we love that for us πŸ’…

aa_features_new() creates an aa_features object based upon a directory file descriptor and path. The path can point to a file or directory. See the openat(2) man page for examples of dirfd and path. The allocated features object must be freed using aa_features_unref(). no cap, free it.

aa_features_new_from_file() is similar except that it accepts an open file as the argument. The allocated features object must be freed using aa_features_unref().

aa_features_new_from_string() is similar except that it accepts a NUL-terminated string representation of the AppArmor features as the string argument. The length of the features string, not counting the NUL-terminator, must be specified as the size argument. The allocated features object must be freed using aa_features_unref().

aa_features_new_from_kernel() creates an aa_features object from the current running kernel. main character behaviour honestly πŸ‘‘ The allocated features object must be freed using aa_features_unref().

aa_features_ref() increments the reference count on the features object.

aa_features_unref() decrements the reference count on the features object and releases all corresponding resources when the reference count reaches zero.

aa_features_write_to_fd() writes a string representation of the features object to the file descriptor specified by fd.

aa_features_write_to_file() writes a string representation of the features object to the file specified by the dirfd and path combination.

aa_features_is_equal() can be used to detect if the features1 and features2 objects are equal. 🫢 The definition of equality is private to libapparmor and may be changed in ways that do not break backward compatibility. so like, don't build your whole personality on the internals, mmkay?

aa_features_supports() can be used to query the features object to determine if a feature is supported. The str argument should be equal to the path, relative to the "apparmor/features/" directory of securityfs, of the feature to query. For example, to test if policy version 6 is supported, str would be "policy/versions/v6". iconic little example, ate πŸ’–

aa_features_id() returns a string representation of an identifier that can be used to uniquely identify an aa_features object. The mechanism for generating the string representation is internal to libapparmor and subject to change but an example implementation is applying a hash function to the features string. iykyk 🧚


πŸŽ€ RETURN VALUE πŸŽ€

The aa_features_new() family of functions return 0 on success and *features will point to an aa_features object that must be freed by aa_features_unref(). -1 is returned on error, with errno set appropriately, and *features will be set to NULL.

aa_features_ref() returns the value of features.

aa_features_write_to_file() returns 0 on success. -1 is returned on error, with errno set appropriately.

aa_features_is_equal() returns true if features1 and features2 are equal and false if they are not equal.

aa_features_supports() returns true if the feature represented by str is supported and false if it is not supported.

aa_features_id() returns a string identifying features which must be freed by the caller. NULL is returned on error, with errno set appropriately. like, please free it, bestie, the leak is not the slay πŸ™ˆ

aa_features_value() returns a null terminated string with is associated length which must be freed by the caller. NULL is returned on error, with errno set to ENOENT if the feature was not found, ENODIR if the specified feature does not resolve to a leaf feature.


πŸ’€ ERRORS πŸ’€

The errno value will be set according to the underlying error in the aa_features family of functions that return -1 or NULL on error.


🌈 NOTES 🌈

The aa_features_id() function can be found in libapparmor version 2.13. All the other aa_feature functions described above are present in libapparmor version 2.10. history lesson, but make it cute ⭐

aa_features_unref() saves the value of errno when called and restores errno before exiting in libapparmor version 2.12 and newer. thoughtful queen behaviour, honestly πŸ’œ


πŸ“ BUGS πŸ“

None known. If you find any, please report them at <https://gitlab.com/apparmor/apparmor/-/issues>. do it for the culture πŸ¦‹


πŸ”₯ SEE ALSO πŸ”₯

openat(2), aa-features-abi(1) and <https://wiki.apparmor.net>.


okay that's the whole thing, you're literally an aa_features expert now, no cap πŸ’…βœ¨

AppArmor 4.1.8 β€” dated 2026-10-18 β€” aa_features(3) πŸŽ€ bye bestie, go free your objects πŸ’–

πŸ“¦ 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