diff --git a/.bzrignore b/.bzrignore index 94a209b86..05b4d442a 100644 --- a/.bzrignore +++ b/.bzrignore @@ -167,3 +167,4 @@ tests/regression/apparmor/unlink tests/regression/apparmor/xattrs tests/regression/apparmor/coredump **/__pycache__/ +*.orig diff --git a/changehat/pam_apparmor/Makefile b/changehat/pam_apparmor/Makefile index 497724b0d..092131e46 100644 --- a/changehat/pam_apparmor/Makefile +++ b/changehat/pam_apparmor/Makefile @@ -53,7 +53,7 @@ libapparmor by adding USE_SYSTEM=1 to your make command.${nl}\ AA_LINK_FLAGS = -L$(LIBAPPARMOR_PATH) AA_LDLIBS = -lapparmor endif -EXTRA_CFLAGS=$(CFLAGS) -fPIC -shared -Wall $(LIBAPPARMOR_INCLUDE) +EXTRA_CFLAGS=$(CFLAGS) $(CPPFLAGS) -fPIC -shared -Wall $(LIBAPPARMOR_INCLUDE) LINK_FLAGS=-Xlinker -x $(AA_LINK_FLAGS) LIBS=-lpam $(AA_LDLIBS) OBJECTS=${NAME}.o get_options.o diff --git a/libraries/libapparmor/doc/Makefile.am b/libraries/libapparmor/doc/Makefile.am index 39d741d66..90cc1494c 100644 --- a/libraries/libapparmor/doc/Makefile.am +++ b/libraries/libapparmor/doc/Makefile.am @@ -5,9 +5,9 @@ PODCHECKER = podchecker if ENABLE_MAN_PAGES -man_MANS = aa_change_hat.2 aa_change_profile.2 aa_getcon.2 aa_find_mountpoint.2 +man_MANS = aa_change_hat.2 aa_change_profile.2 aa_getcon.2 aa_find_mountpoint.2 aa_splitcon.3 aa_query_label.2 aa_features.3 aa_kernel_interface.3 aa_policy_cache.3 -PODS = $(subst .2,.pod,$(man_MANS)) +PODS = $(subst .2,.pod,$(man_MANS)) $(subst .3,.pod,$(man_MANS)) EXTRA_DIST = $(man_MANS) $(PODS) @@ -23,4 +23,13 @@ CLEANFILES = $(man_MANS) --stderr \ $< > $@ +%.3: %.pod + $(PODCHECKER) -warnings -warnings $< + $(POD2MAN) \ + --section=3 \ + --release="AppArmor $(VERSION)" \ + --center="AppArmor" \ + --stderr \ + $< > $@ + endif diff --git a/libraries/libapparmor/doc/aa_features.pod b/libraries/libapparmor/doc/aa_features.pod new file mode 100644 index 000000000..ffbe113ac --- /dev/null +++ b/libraries/libapparmor/doc/aa_features.pod @@ -0,0 +1,148 @@ +# 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_features - an opaque object representing a set of AppArmor kernel features + +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_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 + +=head1 SYNOPSIS + +B<#include Esys/apparmor.hE> + +B + +B + +B + +B + +B + +B + +B + +B + +B + +Link with B<-lapparmor> when compiling. + +=head1 DESCRIPTION + +The I 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. + +The aa_features_new() function creates an I object based upon a +directory file descriptor and path. The I can point to a file or +directory. See the openat(2) man page for examples of I and I. The +allocated I object must be freed using aa_features_unref(). + +The aa_features_new_from_string() function is similar except that it accepts a +NUL-terminated string representation of the AppArmor features as the I +argument. The length of the features string, not counting the NUL-terminator, +must be specified as the I argument. The allocated I object +must be freed using aa_features_unref(). + +The aa_features_new_from_kernel() function creates an I object +from the current running kernel. The allocated I object must be freed +using aa_features_unref(). + +aa_features_ref() increments the reference count on the I object. + +aa_features_unref() decrements the reference count on the I object +and releases all corresponding resources when the reference count reaches zero. + +The aa_features_write_to_file() function writes a string representation of the +I object to the file specified by the I and I +combination. + +aa_features_is_equal() can be used to detect if the I and +I objects are equal. The definition of equality is private to +libapparmor and may be changed in ways that do not break backward +compatibility. + +The aa_features_supports() function can be used to query the I object +to determine if a feature is supported. The I 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, I +would be "policy/versions/v6". + +=head1 RETURN VALUE + +The aa_features_new() family of functions return 0 on success and I<*features> +will point to an I object that must be freed by +aa_features_unref(). -1 is returned on error, with errno set appropriately, and +I<*features> will be set to NULL. + +aa_features_ref() returns the value of I. + +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 I and I are equal +and false if they are not equal. + +aa_features_supports() returns true if the feature represented by I is +supported and false if it is not supported. + +=head1 ERRORS + +The errno value will be set according to the underlying error in the +I family of functions that return -1 on error. + +=head1 NOTES + +All aa_features functions described above are present in libapparmor version +2.10 and newer. + +=head1 BUGS + +None known. If you find any, please report them at +L. + +=head1 SEE ALSO + +openat(2) and L. + +=cut diff --git a/libraries/libapparmor/doc/aa_getcon.pod b/libraries/libapparmor/doc/aa_getcon.pod index d944fecee..32ef61fc8 100644 --- a/libraries/libapparmor/doc/aa_getcon.pod +++ b/libraries/libapparmor/doc/aa_getcon.pod @@ -131,7 +131,7 @@ L. =head1 SEE ALSO -apparmor(7), apparmor.d(5), apparmor_parser(8), aa_change_profile(2) and -L. +apparmor(7), apparmor.d(5), apparmor_parser(8), aa_change_profile(2), +aa_splitcon(3) and L. =cut diff --git a/libraries/libapparmor/doc/aa_kernel_interface.pod b/libraries/libapparmor/doc/aa_kernel_interface.pod new file mode 100644 index 000000000..08084c12b --- /dev/null +++ b/libraries/libapparmor/doc/aa_kernel_interface.pod @@ -0,0 +1,162 @@ +# 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_kernel_interface - an opaque object representing the AppArmor kernel interface for policy loading, replacing, and removing + +aa_kernel_interface_new - create a new aa_kernel_interface object from an optional path + +aa_kernel_interface_ref - increments the ref count of an aa_kernel_interface object + +aa_kernel_interface_unref - decrements the ref count and frees the aa_kernel_interface object when 0 + +aa_kernel_interface_load_policy - load a policy from a buffer into the kernel + +aa_kernel_interface_load_policy_from_file - load a policy from a file into the kernel + +aa_kernel_interface_load_policy_from_fd - load a policy from a file descriptor into the kernel + +aa_kernel_interface_replace_policy - replace a policy in the kernel with a policy from a buffer + +aa_kernel_interface_replace_policy_from_file - replace a policy in the kernel with a policy from a file + +aa_kernel_interface_replace_policy_from_fd - replace a policy in the kernel with a policy from a file descriptor + +aa_kernel_interface_remove_policy - remove a policy from the kernel + +aa_kernel_interface_write_policy - write a policy to a file descriptor + +=head1 SYNOPSIS + +B<#include Esys/apparmor.hE> + +B + +B + +B + +B + +B + +B + +B + +B + +B + +B + +B + +B + +Link with B<-lapparmor> when compiling. + +=head1 DESCRIPTION + +The I object contains information about the AppArmor +kernel interface for policy loading, replacing, and removing. + +The aa_kernel_interface_new() function creates an I object +based on an optional I object and an optional path to the apparmor +directory of securityfs, which is typically found at +"/sys/kernel/security/apparmor/". If I is NULL, then the +features of the current kernel are used. When specifying a valid +I object, it must be compatible with the features of the +currently running kernel. If I is NULL, then the default location +is used. The allocated I object must be freed using +aa_kernel_interface_unref(). + +aa_kernel_interface_ref() increments the reference count on the +I object. + +aa_kernel_interface_unref() decrements the reference count on the +I object and releases all corresponding resources when the +reference count reaches zero. + +The aa_kernel_interface_load() family of functions load a policy into the +kernel. The operation will fail if a policy of the same name is already loaded. +Use the aa_kernel_interface_replace() family of functions if you wish to +replace a previously loaded policy with a new policy of the same name. The +aa_kernel_interface_replace() functions can also be used to load a policy that +does not correspond to a previously loaded policy. + +When loading or replacing from a buffer, the I will contain binary +data. The I argument must specify the size of the I argument. + +When loading or replacing from a file, the I and I combination are +used to specify the location of the file. See the openat(2) man page for +examples of I and I. + +It is also possible to load or replace from a file descriptor specified by the +I argument. The file must be open for reading and the file offset must be +set appropriately. + +The aa_kernel_interface_remove_policy() function can be used to unload a +previously loaded policy. The fully qualified policy name must be specified +with the I argument. The operation will fail if a policy matching +I is not found. + +The aa_kernel_interface_write_policy() function allows for a policy, which is +stored in I and consists of I bytes, to be written to a file +descriptor. The I must be open for writing and the file offset must be set +appropriately. + +=head1 RETURN VALUE + +The aa_kernel_interface_new() function returns 0 on success and +I<*kernel_interface> will point to an I object that must +be freed by aa_kernel_interface_unref(). -1 is returned on error, with errno +set appropriately, and I<*kernel_interface> will be set to NULL. + +aa_kernel_features_ref() returns the value of I. + +The aa_kernel_interface_load() family of functions, the +aa_kernel_interface_replace() family of functions, +aa_kernel_interface_remove(), and aa_kernel_interface_write_policy() +return 0 on success. -1 is returned on error, with errno set appropriately. + +=head1 ERRORS + +The errno value will be set according to the underlying error in the +I family of functions that return -1 on error. + +=head1 NOTES + +All aa_kernel_interface functions described above are present in libapparmor +version 2.10 and newer. + +=head1 BUGS + +None known. If you find any, please report them at +L. + +=head1 SEE ALSO + +aa_features(3), openat(2) and L. + +=cut diff --git a/libraries/libapparmor/doc/aa_policy_cache.pod b/libraries/libapparmor/doc/aa_policy_cache.pod new file mode 100644 index 000000000..672d616b1 --- /dev/null +++ b/libraries/libapparmor/doc/aa_policy_cache.pod @@ -0,0 +1,125 @@ +# 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_policy_cache - an opaque object representing an AppArmor policy cache + +aa_policy_cache_new - create a new aa_policy_cache object from a path + +aa_policy_cache_ref - increments the ref count of an aa_policy_cache object + +aa_policy_cache_unref - decrements the ref count and frees the aa_policy_cache object when 0 + +aa_policy_cache_remove - removes all policy cache files under a path + +aa_policy_cache_replace_all - performs a kernel policy replacement of all cached policies + +=head1 SYNOPSIS + +B<#include Esys/apparmor.hE> + +B + +B + +B + +B + +B + +B + +Link with B<-lapparmor> when compiling. + +=head1 DESCRIPTION + +The I object contains information about a set of AppArmor +policy cache files. The policy cache files are the binary representation of a +human-readable AppArmor profile. The binary representation is the form that is +loaded into the kernel. + +The aa_policy_cache_new() function creates an I object based +upon a directory file descriptor and path. The I must point to a +directory. See the openat(2) man page for examples of I and I. If +I is NULL, then the features of the current kernel are used. +When specifying a valid I object, it must be the compatible +with the features of the kernel of interest. The value of I should +be equal to the number of caches that should be allowed before old caches are +automatically reaped. The definition of what is considered to be an old cache +is private to libapparmor. Specifying 0 means that no new caches should be +created and only existing, valid caches may be used. Specifying UINT16_MAX +means that a new cache may be created and that the reaping of old caches is +disabled. The allocated I object must be freed using +aa_policy_cache_unref(). + +aa_policy_cache_ref() increments the reference count on the I +object. + +aa_policy_cache_unref() decrements the reference count on the I +object and releases all corresponding resources when the reference count +reaches zero. + +The aa_policy_cache_remove() function deletes all of the policy cache files +based upon a directory file descriptor and path. The I must point to a +directory. See the openat(2) man page for examples of I and I. + +The aa_policy_cache_replace_all() function can be used to perform a policy +replacement of all of the cache policies in the cache directory represented by +the I object. If I is NULL, then the current +kernel interface is used. When specifying a valid I object, +it must be the interface of the currently running kernel. + +=head1 RETURN VALUE + +The aa_policy_cache_new() function returns 0 on success and I<*policy_cache> +will point to an I object that must be freed by +aa_policy_cache_unref(). -1 is returned on error, with errno set appropriately, +and I<*policy_cache> will be set to NULL. + +aa_policy_cache_ref() returns the value of I. + +aa_policy_cache_remove() and aa_policy_cache_replace_all() return 0 on success. +-1 is returned on error, with errno set appropriately. + +=head1 ERRORS + +The errno value will be set according to the underlying error in the +I family of functions that return -1 on error. + +=head1 NOTES + +All aa_policy_cache functions described above are present in libapparmor +version 2.10 and newer. + +=head1 BUGS + +None known. If you find any, please report them at +L. + +=head1 SEE ALSO + +aa_features(3), aa_kernel_interface(3), openat(2) and +L. + +=cut diff --git a/libraries/libapparmor/doc/aa_query_label.pod b/libraries/libapparmor/doc/aa_query_label.pod new file mode 100644 index 000000000..3e943a7ad --- /dev/null +++ b/libraries/libapparmor/doc/aa_query_label.pod @@ -0,0 +1,137 @@ +# 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_query_label - query access permission associated with a label + +=head1 SYNOPSIS + +B<#include Esys/apparmor.hE> + +B + +B + +B + +B + +B + + +Link with B<-lapparmor> when compiling. + +=head1 DESCRIPTION + +The aa_query_label function fetches the current permissions granted by the +specified I