.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "aa_features 3" .TH aa_features 3 2024-10-14 "AppArmor 4.0.3" AppArmor .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME aa_features \- an opaque object representing a set of AppArmor kernel features .PP aa_features_new \- create a new aa_features object based on a path .PP aa_features_new_from_string \- create a new aa_features object based on a string .PP aa_features_new_from_kernel \- create a new aa_features object based on the current kernel .PP aa_features_ref \- increments the ref count of an aa_features object .PP aa_features_unref \- decrements the ref count and frees the aa_features object when 0 .PP aa_features_write_to_fd \- write a string representation of an aa_features object to a file descriptor .PP aa_features_write_to_file \- write a string representation of an aa_features object to a file .PP aa_features_is_equal \- equality test for two aa_features objects .PP aa_features_supports \- provides aa_features object support status .PP aa_features_id \- provides unique identifier for an aa_features object .PP aa_features_value \- the value associated with a given feature. .SH SYNOPSIS .IX Header "SYNOPSIS" \&\fB#include \fR .PP \&\fBtypedef struct aa_features aa_features;\fR .PP \&\fBint aa_features_new(aa_features **features, int dirfd, const char *path);\fR .PP \&\fBint aa_features_new_from_file(aa_features **features, int fd);\fR .PP \&\fBint aa_features_new_from_string(aa_features **features, const char *string, size_t size);\fR .PP \&\fBint aa_features_new_from_kernel(aa_features **features);\fR .PP \&\fBaa_features *aa_features_ref(aa_features *features);\fR .PP \&\fBvoid aa_features_unref(aa_features *features);\fR .PP \&\fBint aa_features_write_to_fd(aa_features *features, int fd);\fR .PP \&\fBint aa_features_write_to_file(aa_features *features, int dirfd, const char *path);\fR .PP \&\fBbool aa_features_is_equal(aa_features *features1, aa_features *features2);\fR .PP \&\fBbool aa_features_supports(aa_features *features, const char *str);\fR .PP \&\fBchar *aa_features_id(aa_features *features);\fR .PP \&\fBchar *aa_features_value(aa_features *features, const char *str, size_t *len);\fR .PP Link with \fB\-lapparmor\fR when compiling. .SH DESCRIPTION .IX Header "DESCRIPTION" The \fIaa_features\fR object contains information about the AppArmor features supported by a kernel. 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. .PP The \fBaa_features_new()\fR function creates an \fIaa_features\fR object based upon a directory file descriptor and path. The \fIpath\fR can point to a file or directory. See the \fBopenat\fR\|(2) man page for examples of \fIdirfd\fR and \fIpath\fR. The allocated \fIfeatures\fR object must be freed using \fBaa_features_unref()\fR. .PP The \fBaa_features_new_from_file()\fR function is similar except that it accepts an open file as the argument. The allocated \fIfeatures\fR object must be freed using \fBaa_features_unref()\fR. .PP The \fBaa_features_new_from_string()\fR function is similar except that it accepts a NUL-terminated string representation of the AppArmor features as the \fIstring\fR argument. The length of the features string, not counting the NUL-terminator, must be specified as the \fIsize\fR argument. The allocated \fIfeatures\fR object must be freed using \fBaa_features_unref()\fR. .PP The \fBaa_features_new_from_kernel()\fR function creates an \fIaa_features\fR object from the current running kernel. The allocated \fIfeatures\fR object must be freed using \fBaa_features_unref()\fR. .PP \&\fBaa_features_ref()\fR increments the reference count on the \fIfeatures\fR object. .PP \&\fBaa_features_unref()\fR decrements the reference count on the \fIfeatures\fR object and releases all corresponding resources when the reference count reaches zero. .PP The \fBaa_features_write_to_fd()\fR function writes a string representation of the \&\fIfeatures\fR object to the file descriptor specified by the \fIfd\fR. .PP The \fBaa_features_write_to_file()\fR function writes a string representation of the \&\fIfeatures\fR object to the file specified by the \fIdirfd\fR and \fIpath\fR combination. .PP \&\fBaa_features_is_equal()\fR can be used to detect if the \fIfeatures1\fR and \&\fIfeatures2\fR objects are equal. The definition of equality is private to libapparmor and may be changed in ways that do not break backward compatibility. .PP The \fBaa_features_supports()\fR function can be used to query the \fIfeatures\fR object to determine if a feature is supported. The \fIstr\fR 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, \fIstr\fR would be "policy/versions/v6". .PP The \fBaa_features_id()\fR function returns a string representation of an identifier that can be used to uniquely identify an \fIaa_features\fR 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. .SH "RETURN VALUE" .IX Header "RETURN VALUE" The \fBaa_features_new()\fR family of functions return 0 on success and \fI*features\fR will point to an \fIaa_features\fR object that must be freed by \&\fBaa_features_unref()\fR. \-1 is returned on error, with errno set appropriately, and \&\fI*features\fR will be set to NULL. .PP \&\fBaa_features_ref()\fR returns the value of \fIfeatures\fR. .PP \&\fBaa_features_write_to_file()\fR returns 0 on success. \-1 is returned on error, with errno set appropriately. .PP \&\fBaa_features_is_equal()\fR returns true if \fIfeatures1\fR and \fIfeatures2\fR are equal and false if they are not equal. .PP \&\fBaa_features_supports()\fR returns true if the feature represented by \fIstr\fR is supported and false if it is not supported. .PP \&\fBaa_features_id()\fR returns a string identifying \fIfeatures\fR which must be freed by the caller. NULL is returned on error, with errno set appropriately. .PP \&\fBaa_features_value()\fR 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. .SH ERRORS .IX Header "ERRORS" The errno value will be set according to the underlying error in the \&\fIaa_features\fR family of functions that return \-1 or NULL on error. .SH NOTES .IX Header "NOTES" The \fBaa_features_id()\fR function can be found in libapparmor version 2.13. All the other aa_feature functions described above are present in libapparmor version 2.10. .PP \&\fBaa_features_unref()\fR saves the value of errno when called and restores errno before exiting in libapparmor version 2.12 and newer. .SH BUGS .IX Header "BUGS" None known. If you find any, please report them at . .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBopenat\fR\|(2), \fBaa\-features\-abi\fR\|(1) and .