apparmor/profiles/Makefile

142 lines
5.4 KiB
Makefile
Raw Normal View History

# ------------------------------------------------------------------
#
# Copyright (C) 2002-2009 Novell/SUSE
# Copyright (C) 2010-2016 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
This patch adds two new make targets to the profiles package: 'check' and 'check-install'. The 'check' target will attempt to run the profiles in the working subversion directory (both in enabled/ and extras/ directories) through the apparmor_parser as a means of sanity checking the profiles. The 'check-install' target will also run the 'check' target, only against the installed location, modifiable by DESTDIR and EXTRASDIR (to match the behavior of the 'install' target). It also will run logprof (with an empty logfile) on the installation location, as logprof and the parser have differing ideas of what is a valid profile :-( . Thus 'make install check-install DESTDIR=/some/path EXTRASDIR=/other/path' will install the profiles into a location and cycle the parser and logprof over the profiles in that The 'check' target cannot run logprof as the subversion layout does not conform to a hierarchy logprof can deal with. The limitations also mean that logprof will not check the profiles in the extras/ directory. There are other passable variables that impact the 'check' and 'check-install' targets: VERBOSE - setting this variable will emit the actual commands run, mostly useful for debugging where the implementation of 'check' has gone wrong. PARSER, LOGPROF - setting these with a path to a different parser or logprof location will have the check targets use those version rather than the system utilities; e.g. "make check-install LOGPROF=../utils/logprof" to test a modified logprof in our current forge svn layout.
2006-06-05 16:39:29 +00:00
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, contact Novell, Inc.
#
# ------------------------------------------------------------------
# Makefile for LSM-based AppArmor profiles
NAME=apparmor-profiles
all: local docs
COMMONDIR=../common/
include $(COMMONDIR)/Make.rules
DESTDIR=/
PROFILES_DEST=${DESTDIR}/etc/apparmor.d
EXTRAS_DEST=${DESTDIR}/usr/share/apparmor/extra-profiles/
PROFILES_SOURCE=./apparmor.d
ABSTRACTIONS_SOURCE=./apparmor.d/abstractions
EXTRAS_SOURCE=./apparmor/profiles/extras/
SUBDIRS=$(shell find ${PROFILES_SOURCE} -type d -print)
TOPLEVEL_PROFILES=$(filter-out ${SUBDIRS}, $(wildcard ${PROFILES_SOURCE}/*))
ifdef USE_SYSTEM
PYTHONPATH=
PARSER?=apparmor_parser
LOGPROF?=aa-logprof
else
# PYTHON_DIST_BUILD_PATH based on libapparmor/swig/python/test/Makefile.am
PYTHON_DIST_BUILD_PATH = ../libraries/libapparmor/swig/python/build/$$($(PYTHON) -c "import distutils.util; import platform; print(\"lib.%s-%s\" %(distutils.util.get_platform(), platform.python_version()[:3]))")
LD_LIBRARY_PATH=../libraries/libapparmor/src/.libs/
PYTHONPATH=../utils/:$(PYTHON_DIST_BUILD_PATH)
PARSER?=../parser/apparmor_parser
# use ../utils logprof
LOGPROF?=PYTHONPATH=../utils $(PYTHON) ../utils/aa-logprof
endif
# $(PWD) is wrong when using "make -C profiles" - explicitely set it here to get the right value
PWD=$(shell pwd)
.PHONY: test-dependencies
test-dependencies: __parser
.PHONY: __parser
__parser:
ifndef USE_SYSTEM
@if [ ! -f $(PARSER) ]; then \
echo "error: $(PARSER) is missing. Pick one of these possible solutions:" 1>&2; \
echo " 1) Test using the in-tree parser by building it first and then trying again. See the top-level README for help." 1>&2; \
echo " 2) Test using the system parser by adding USE_SYSTEM=1 to your make command." 1>&2; \
exit 1; \
fi
endif
local:
for profile in ${TOPLEVEL_PROFILES}; do \
fn=$$(basename $$profile); \
echo "# Site-specific additions and overrides for '$$fn'" > ${PROFILES_SOURCE}/local/$$fn; \
grep "include[[:space:]]\\+if[[:space:]]\\+exists[[:space:]]\\+<local/$$fn>" "$$profile" >/dev/null || { echo "$$profile doesn't contain include if exists <local/$$fn>" ; exit 1; } ; \
done; \
.PHONY: install
install: local
install -m 755 -d ${PROFILES_DEST}
install -m 755 -d ${PROFILES_DEST}/disable
for dir in ${SUBDIRS} ; do \
install -m 755 -d "${PROFILES_DEST}/$${dir#${PROFILES_SOURCE}}" ; \
done
for file in $$(find ${PROFILES_SOURCE} -type f -print) ; do \
install -m 644 "$${file}" "${PROFILES_DEST}/$$(dirname $${file#${PROFILES_SOURCE}})" ; \
done
install -m 755 -d ${EXTRAS_DEST}
install -m 644 ${EXTRAS_SOURCE}/* ${EXTRAS_DEST}
LOCAL_ADDITIONS=$(filter-out ${PROFILES_SOURCE}/local/README, $(wildcard ${PROFILES_SOURCE}/local/*))
.PHONY: clean
clean:
-rm -f ${LOCAL_ADDITIONS}
This patch adds two new make targets to the profiles package: 'check' and 'check-install'. The 'check' target will attempt to run the profiles in the working subversion directory (both in enabled/ and extras/ directories) through the apparmor_parser as a means of sanity checking the profiles. The 'check-install' target will also run the 'check' target, only against the installed location, modifiable by DESTDIR and EXTRASDIR (to match the behavior of the 'install' target). It also will run logprof (with an empty logfile) on the installation location, as logprof and the parser have differing ideas of what is a valid profile :-( . Thus 'make install check-install DESTDIR=/some/path EXTRASDIR=/other/path' will install the profiles into a location and cycle the parser and logprof over the profiles in that The 'check' target cannot run logprof as the subversion layout does not conform to a hierarchy logprof can deal with. The limitations also mean that logprof will not check the profiles in the extras/ directory. There are other passable variables that impact the 'check' and 'check-install' targets: VERBOSE - setting this variable will emit the actual commands run, mostly useful for debugging where the implementation of 'check' has gone wrong. PARSER, LOGPROF - setting these with a path to a different parser or logprof location will have the check targets use those version rather than the system utilities; e.g. "make check-install LOGPROF=../utils/logprof" to test a modified logprof in our current forge svn layout.
2006-06-05 16:39:29 +00:00
ifndef VERBOSE
Q=@
else
Q=
endif
.PHONY: docs
# docs: should we have some here?
docs:
IGNORE_FILES=${EXTRAS_SOURCE}/README
CHECK_PROFILES=$(filter-out ${IGNORE_FILES} ${SUBDIRS}, $(wildcard ${PROFILES_SOURCE}/*) $(wildcard ${EXTRAS_SOURCE}/*))
# use find because Make wildcard is not recursive:
CHECK_ABSTRACTIONS=$(shell find ${ABSTRACTIONS_SOURCE} -type f -print)
This patch adds two new make targets to the profiles package: 'check' and 'check-install'. The 'check' target will attempt to run the profiles in the working subversion directory (both in enabled/ and extras/ directories) through the apparmor_parser as a means of sanity checking the profiles. The 'check-install' target will also run the 'check' target, only against the installed location, modifiable by DESTDIR and EXTRASDIR (to match the behavior of the 'install' target). It also will run logprof (with an empty logfile) on the installation location, as logprof and the parser have differing ideas of what is a valid profile :-( . Thus 'make install check-install DESTDIR=/some/path EXTRASDIR=/other/path' will install the profiles into a location and cycle the parser and logprof over the profiles in that The 'check' target cannot run logprof as the subversion layout does not conform to a hierarchy logprof can deal with. The limitations also mean that logprof will not check the profiles in the extras/ directory. There are other passable variables that impact the 'check' and 'check-install' targets: VERBOSE - setting this variable will emit the actual commands run, mostly useful for debugging where the implementation of 'check' has gone wrong. PARSER, LOGPROF - setting these with a path to a different parser or logprof location will have the check targets use those version rather than the system utilities; e.g. "make check-install LOGPROF=../utils/logprof" to test a modified logprof in our current forge svn layout.
2006-06-05 16:39:29 +00:00
.PHONY: check
check: check-parser check-logprof check-abstractions.d
.PHONY: check-parser
check-parser: test-dependencies local
@echo "*** Checking profiles from ${PROFILES_SOURCE} and ${EXTRAS_SOURCE} against apparmor_parser"
This patch adds two new make targets to the profiles package: 'check' and 'check-install'. The 'check' target will attempt to run the profiles in the working subversion directory (both in enabled/ and extras/ directories) through the apparmor_parser as a means of sanity checking the profiles. The 'check-install' target will also run the 'check' target, only against the installed location, modifiable by DESTDIR and EXTRASDIR (to match the behavior of the 'install' target). It also will run logprof (with an empty logfile) on the installation location, as logprof and the parser have differing ideas of what is a valid profile :-( . Thus 'make install check-install DESTDIR=/some/path EXTRASDIR=/other/path' will install the profiles into a location and cycle the parser and logprof over the profiles in that The 'check' target cannot run logprof as the subversion layout does not conform to a hierarchy logprof can deal with. The limitations also mean that logprof will not check the profiles in the extras/ directory. There are other passable variables that impact the 'check' and 'check-install' targets: VERBOSE - setting this variable will emit the actual commands run, mostly useful for debugging where the implementation of 'check' has gone wrong. PARSER, LOGPROF - setting these with a path to a different parser or logprof location will have the check targets use those version rather than the system utilities; e.g. "make check-install LOGPROF=../utils/logprof" to test a modified logprof in our current forge svn layout.
2006-06-05 16:39:29 +00:00
$(Q)for profile in ${CHECK_PROFILES} ; do \
[ -n "${VERBOSE}" ] && echo "Testing $${profile}" ; \
${PARSER} --config-file=../parser/tst/parser.conf -S -b ${PWD}/apparmor.d $${profile} > /dev/null || exit 1; \
This patch adds two new make targets to the profiles package: 'check' and 'check-install'. The 'check' target will attempt to run the profiles in the working subversion directory (both in enabled/ and extras/ directories) through the apparmor_parser as a means of sanity checking the profiles. The 'check-install' target will also run the 'check' target, only against the installed location, modifiable by DESTDIR and EXTRASDIR (to match the behavior of the 'install' target). It also will run logprof (with an empty logfile) on the installation location, as logprof and the parser have differing ideas of what is a valid profile :-( . Thus 'make install check-install DESTDIR=/some/path EXTRASDIR=/other/path' will install the profiles into a location and cycle the parser and logprof over the profiles in that The 'check' target cannot run logprof as the subversion layout does not conform to a hierarchy logprof can deal with. The limitations also mean that logprof will not check the profiles in the extras/ directory. There are other passable variables that impact the 'check' and 'check-install' targets: VERBOSE - setting this variable will emit the actual commands run, mostly useful for debugging where the implementation of 'check' has gone wrong. PARSER, LOGPROF - setting these with a path to a different parser or logprof location will have the check targets use those version rather than the system utilities; e.g. "make check-install LOGPROF=../utils/logprof" to test a modified logprof in our current forge svn layout.
2006-06-05 16:39:29 +00:00
done
@echo "*** Checking abstractions from ${ABSTRACTIONS_SOURCE} against apparmor_parser"
$(Q)for abstraction in ${CHECK_ABSTRACTIONS} ; do \
[ -n "${VERBOSE}" ] && echo "Testing $${abstraction}" ; \
echo "abi <abi/3.0>, #include <tunables/global> profile test { #include <$${abstraction}> }" \
| ${PARSER} --config-file=../parser/tst/parser.conf -S -b ${PWD}/apparmor.d -I ${PWD} > /dev/null \
|| exit 1; \
done
.PHONY: check-logprof
check-logprof: test-dependencies local
@echo "*** Checking profiles from ${PROFILES_SOURCE} against logprof"
$(Q)${LOGPROF} -d ${PROFILES_SOURCE} -f /dev/null || exit 1
.PHONY: check-abstractions.d
check-abstractions.d:
@echo "*** Checking if all abstractions (with a few exceptions) contain include if exists <abstractions/*.d>"
$(Q)cd apparmor.d/abstractions && for file in * ; do \
test -d "$$file" && continue ; \
test "$$file" = 'ubuntu-browsers' && continue ; \
test "$$file" = 'ubuntu-helpers' && continue ; \
grep -q "^ include if exists <abstractions/$${file}.d>$$" $$file || { echo "$$file does not contain 'include if exists <abstractions/$${file}.d>'"; exit 1; } ; \
done