# This publication is intellectual property of Canonical Ltd. Its contents
# can be duplicated, either in part or in whole, provided that a copyright
# label is visibly located on each copy.
#
# All information found in this book has been compiled with utmost
# attention to detail. However, this does not guarantee complete accuracy.
# Neither Canonical Ltd, the authors, nor the translators shall be held
# liable for possible errors or the consequences thereof.
#
# Many of the software and hardware descriptions cited in this book
# are registered trademarks. All trade names are subject to copyright
# restrictions and may be registered trade marks. Canonical Ltd.
# essentially adhere to the manufacturer's spelling.
#
# Names of products and trademarks appearing in this book (with or without
# specific notation) are likewise subject to trademark and trade protection
# laws and may thus fall under copyright restrictions.
#


=pod

=head1 NAME

aa_is_enabled - determine if apparmor is available

aa_find_mountpoint - find where the apparmor interface filesystem is mounted

=head1 SYNOPSIS

B<#include E<lt>sys/apparmor.hE<gt>>

B<int aa_is_enabled(void);>

B<int aa_find_mountpoint(char **mnt);>

Link with B<-lapparmor> when compiling.

=head1 DESCRIPTION

The aa_is_enabled function returns true (1) if apparmor is enabled.
If it isn't it sets the errno(3) to reflect the reason it is not
enabled and returns 0.

The aa_find_mountpoint function finds where the apparmor filesystem is mounted
on the system, and returns a string containing the mount path.  It is the
caller's responsibility to free(3) the returned path.

=head1 RETURN VALUE

B<aa_is_enabled>
On success 1 is returned. On error, 0 is returned, and errno(3) is set
appropriately.

B<aa_find_mountpoint>
On success zero is returned. On error, -1 is returned, and errno(3) is set
appropriately.

=head1 ERRORS

# podchecker warns about duplicate link targets for EACCES, EBUSY, ENOENT,
# and ENOMEM, but this is a warning that is safe to ignore.

B<aa_is_enabled>

=over 4

=item B<ENOSYS>

AppArmor extensions to the system are not available.

=item B<ECANCELED>

AppArmor is available on the system but has been disabled at boot.

=item B<EBUSY>

AppArmor is available but only via private interfaces.

=item B<ENOENT>

AppArmor is available (and maybe even enforcing policy) but the interface is
not available.

=item B<ENOMEM>

Insufficient memory was available.

=item B<EPERM>

Did not have sufficient permissions to determine if AppArmor is enabled.

=item B<EACCES>

Did not have sufficient permissions to determine if AppArmor is enabled.

=item B<EBUSY>

AppArmor is enabled but does not have access to shared interfaces, and
only private interfaces are available.

=back

B<aa_find_mountpoint>

=over 4

=item B<ENOMEM>

Insufficient memory was available.

=item B<EACCES>

Access to the required paths was denied.

=item B<ENOENT>

The apparmor filesystem mount could not be found

=back

=head1 BUGS

None known. If you find any, please report them at
L<https://gitlab.com/apparmor/apparmor/-/issues>.

=head1 SEE ALSO

apparmor(7), apparmor.d(5), apparmor_parser(8), and
L<https://wiki.apparmor.net>.

=cut
