2006-04-11 21:52:54 +00:00
# ------------------------------------------------------------------
#
2010-08-05 15:10:33 -05:00
# Copyright (C) 2002-2009 Novell/SUSE
2016-12-10 10:25:31 -08:00
# Copyright (C) 2010-2016 Canonical Ltd.
2006-04-11 21:52:54 +00:00
#
# 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.
#
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.
#
2006-04-11 21:52:54 +00:00
# ------------------------------------------------------------------
2010-08-05 15:10:33 -05:00
# Makefile for LSM-based AppArmor profiles
2006-04-11 21:52:54 +00:00
NAME = apparmor-profiles
2016-12-10 10:25:31 -08:00
all : local docs
2006-04-12 20:35:41 +00:00
COMMONDIR = ../common/
2006-04-11 21:52:54 +00:00
2015-01-23 15:52:09 -08:00
i n c l u d e $( COMMONDIR ) / M a k e . r u l e s
2006-04-11 21:52:54 +00:00
DESTDIR = /
2007-05-16 18:51:46 +00:00
PROFILES_DEST = ${ DESTDIR } /etc/apparmor.d
2012-09-27 23:57:21 +02:00
EXTRAS_DEST = ${ DESTDIR } /usr/share/apparmor/extra-profiles/
2007-05-16 18:51:46 +00:00
PROFILES_SOURCE = ./apparmor.d
2018-10-13 15:41:15 +03:00
ABSTRACTIONS_SOURCE = ./apparmor.d/abstractions
2007-05-16 18:51:46 +00:00
EXTRAS_SOURCE = ./apparmor/profiles/extras/
2012-11-21 07:39:40 -08:00
SUBDIRS = $( shell find ${ PROFILES_SOURCE } -type d -print)
TOPLEVEL_PROFILES = $( filter-out ${ SUBDIRS } , $( wildcard ${ PROFILES_SOURCE } /*) )
2006-04-11 21:52:54 +00:00
2018-03-18 17:13:18 +01:00
# $(PWD) is wrong when using "make -C profiles" - explicitely set it here to get the right value
PWD = $( shell pwd )
2010-08-05 15:10:33 -05:00
local :
2012-11-21 07:39:40 -08:00
for profile in ${ TOPLEVEL_PROFILES } ; do \
2010-08-05 15:10:33 -05:00
fn = $$ ( basename $$ profile) ; \
echo " # Site-specific additions and overrides for ' $$ fn' " > ${ PROFILES_SOURCE } /local/$$ fn; \
2014-03-25 10:45:20 -07:00
grep " include[[:space:]]\\+<local/ $$ fn> " " $$ profile " >/dev/null || { echo " $$ profile doesn't contain #include <local/ $$ fn> " ; exit 1; } ; \
2010-08-05 15:10:33 -05:00
done ; \
2006-04-11 21:52:54 +00:00
.PHONY : install
2010-08-05 15:10:33 -05:00
install : local
2007-05-16 18:51:46 +00:00
install -m 755 -d ${ PROFILES_DEST }
2012-11-21 07:39:40 -08:00
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
2007-05-16 18:51:46 +00:00
install -m 755 -d ${ EXTRAS_DEST }
install -m 644 ${ EXTRAS_SOURCE } /* ${ EXTRAS_DEST }
2006-04-11 21:52:54 +00:00
2010-08-05 16:00:23 -05:00
LOCAL_ADDITIONS = $( filter-out ${ PROFILES_SOURCE } /local/README, $( wildcard ${ PROFILES_SOURCE } /local/*) )
2006-04-11 21:52:54 +00:00
.PHONY : clean
clean :
2015-01-23 15:52:09 -08:00
-rm -f ${ LOCAL_ADDITIONS }
2006-06-05 16:39:29 +00:00
i f n d e f V E R B O S E
Q = @
e l s e
Q =
e n d i f
i f n d e f P A R S E R
# use system parser
2011-03-18 22:31:26 -07:00
PARSER = ../parser/apparmor_parser
2006-06-05 16:39:29 +00:00
e n d i f
i f n d e f L O G P R O F
2011-03-18 22:31:26 -07:00
# use ../utils logprof
2014-12-02 08:03:09 -08:00
LOGPROF = PYTHONPATH = ../utils $( PYTHON) ../utils/aa-logprof
2006-06-05 16:39:29 +00:00
e n d i f
2016-12-10 10:25:31 -08:00
.PHONY : docs
# docs: should we have some here?
docs :
2011-03-18 22:31:26 -07:00
IGNORE_FILES = ${ EXTRAS_SOURCE } /README
2012-12-21 22:43:11 -08:00
CHECK_PROFILES = $( filter-out ${ IGNORE_FILES } ${ SUBDIRS } , $( wildcard ${ PROFILES_SOURCE } /*) $( wildcard ${ EXTRAS_SOURCE } /*) )
2018-10-13 15:41:15 +03:00
# use find because Make wildcard is not recursive:
CHECK_ABSTRACTIONS = $( shell find ${ ABSTRACTIONS_SOURCE } -type f -print)
2006-06-05 16:39:29 +00:00
.PHONY : check
2019-01-27 19:13:50 +01:00
check : check -parser check -logprof check -abstractions .d
2013-01-02 14:33:12 -08:00
.PHONY : check -parser
2015-06-19 21:05:49 +02:00
check-parser : local
2011-03-18 22:31:26 -07:00
@echo " *** Checking profiles from ${ PROFILES_SOURCE } and ${ EXTRAS_SOURCE } against apparmor_parser "
2006-06-05 16:39:29 +00:00
$( Q) for profile in ${ CHECK_PROFILES } ; do \
2012-12-21 22:43:11 -08:00
[ -n " ${ VERBOSE } " ] && echo " Testing $$ {profile} " ; \
2018-09-16 22:06:46 +02:00
${ PARSER } --config-file= ../parser/tst/parser.conf -S -b ${ PWD } /apparmor.d $$ { profile} > /dev/null || exit 1; \
2006-06-05 16:39:29 +00:00
done
2013-01-02 14:33:12 -08:00
2018-10-13 15:41:15 +03:00
@echo " *** Checking abstractions from ${ ABSTRACTIONS_SOURCE } against apparmor_parser "
$( Q) for abstraction in ${ CHECK_ABSTRACTIONS } ; do \
[ -n " ${ VERBOSE } " ] && echo " Testing $$ {abstraction} " ; \
echo " #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
2013-01-02 14:33:12 -08:00
.PHONY : check -logprof
2015-06-18 22:58:59 +02:00
check-logprof : local
2007-05-16 18:51:46 +00:00
@echo " *** Checking profiles from ${ PROFILES_SOURCE } against logprof "
2011-03-18 22:31:26 -07:00
$( Q) ${ LOGPROF } -d ${ PROFILES_SOURCE } -f /dev/null || exit 1
2019-01-27 19:13:50 +01:00
.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 ; \
2020-01-27 23:44:59 +01:00
test " $$ file " = 'ubuntu-browsers' && continue ; \
test " $$ file " = 'ubuntu-helpers' && continue ; \
2019-01-27 19:13:50 +01:00
grep -q " ^ #include if exists <abstractions/ $$ {file}.d> $$ " $$ file || { echo " $$ file does not contain '#include if exists <abstractions/ $$ {file}.d>' " ; exit 1; } ; \
done