2022-10-05 00:17:52 +02:00
|
|
|
#!/usr/bin/make -f
|
2022-10-16 00:11:31 +02:00
|
|
|
# apparmor.d - Full set of apparmor profiles
|
2024-02-07 00:16:21 +01:00
|
|
|
# Copyright (C) 2022-2024 Alexandre Pujol <alexandre@pujol.io>
|
2022-10-16 00:11:31 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
2022-10-05 00:17:52 +02:00
|
|
|
|
2022-10-16 00:11:31 +02:00
|
|
|
DESTDIR ?= /
|
2024-10-06 16:39:21 +02:00
|
|
|
BUILD ?= .build
|
2024-10-09 14:31:57 +02:00
|
|
|
PKGDEST ?= ${PWD}/.pkg
|
2022-10-05 00:17:52 +02:00
|
|
|
PKGNAME := apparmor.d
|
2023-04-19 19:58:50 +02:00
|
|
|
P = $(filter-out dpkg,$(notdir $(wildcard ${BUILD}/apparmor.d/*)))
|
2022-10-05 00:17:52 +02:00
|
|
|
|
2024-10-06 16:39:21 +02:00
|
|
|
.PHONY: all build enforce full install local $(P) dev package pkg dpkg rpm tests lint check manual docs serve clean
|
2022-10-05 00:17:52 +02:00
|
|
|
|
2023-04-16 22:25:52 +02:00
|
|
|
all: build
|
2024-06-04 20:52:06 +02:00
|
|
|
@./${BUILD}/prebuild --complain
|
2023-04-16 22:25:52 +02:00
|
|
|
|
|
|
|
build:
|
2022-10-16 00:11:31 +02:00
|
|
|
@go build -o ${BUILD}/ ./cmd/aa-log
|
2023-04-19 19:53:54 +02:00
|
|
|
@go build -o ${BUILD}/ ./cmd/prebuild
|
2022-10-05 00:17:52 +02:00
|
|
|
|
2023-04-16 22:25:52 +02:00
|
|
|
enforce: build
|
|
|
|
@./${BUILD}/prebuild
|
|
|
|
|
|
|
|
full: build
|
|
|
|
@./${BUILD}/prebuild --complain --full
|
|
|
|
|
2024-10-11 23:31:06 +02:00
|
|
|
SHARE = $(shell find "${BUILD}/share" -type f -not -name "*.md" -printf "%P\n")
|
2022-10-16 00:11:31 +02:00
|
|
|
PROFILES = $(shell find "${BUILD}/apparmor.d" -type f -printf "%P\n")
|
2024-06-04 20:52:06 +02:00
|
|
|
DISABLES = $(shell find "${BUILD}/apparmor.d" -type l -printf "%P\n")
|
2022-10-05 00:17:52 +02:00
|
|
|
install:
|
2024-10-11 23:31:06 +02:00
|
|
|
@install -Dm0755 ${BUILD}/aa ${DESTDIR}/usr/bin/aa
|
2024-03-17 22:34:06 +01:00
|
|
|
@install -Dm0755 ${BUILD}/aa-log ${DESTDIR}/usr/bin/aa-log
|
2024-10-11 23:31:06 +02:00
|
|
|
@for file in ${SHARE}; do \
|
|
|
|
install -Dm0644 "${BUILD}/share/$${file}" "${DESTDIR}/usr/share/$${file}"; \
|
2022-10-16 00:11:31 +02:00
|
|
|
done;
|
|
|
|
@for file in ${PROFILES}; do \
|
|
|
|
install -Dm0644 "${BUILD}/apparmor.d/$${file}" "${DESTDIR}/etc/apparmor.d/$${file}"; \
|
|
|
|
done;
|
2024-06-04 20:52:06 +02:00
|
|
|
@for file in ${DISABLES}; do \
|
|
|
|
mkdir -p "${DESTDIR}/etc/apparmor.d/disable"; \
|
|
|
|
cp -d "${BUILD}/apparmor.d/$${file}" "${DESTDIR}/etc/apparmor.d/$${file}"; \
|
|
|
|
done;
|
2023-11-19 15:34:42 +01:00
|
|
|
@for file in ${BUILD}/systemd/system/*; do \
|
2022-10-16 00:11:31 +02:00
|
|
|
service="$$(basename "$$file")"; \
|
|
|
|
install -Dm0644 "$${file}" "${DESTDIR}/usr/lib/systemd/system/$${service}.d/apparmor.conf"; \
|
|
|
|
done;
|
2023-11-19 15:34:42 +01:00
|
|
|
@for file in ${BUILD}/systemd/user/*; do \
|
2022-10-16 00:11:31 +02:00
|
|
|
service="$$(basename "$$file")"; \
|
|
|
|
install -Dm0644 "$${file}" "${DESTDIR}/usr/lib/systemd/user/$${service}.d/apparmor.conf"; \
|
|
|
|
done
|
2022-10-05 00:17:52 +02:00
|
|
|
|
2023-02-11 19:59:08 +01:00
|
|
|
local:
|
|
|
|
@make
|
|
|
|
@sudo make install
|
|
|
|
@sudo systemctl restart apparmor || sudo systemctl status apparmor
|
|
|
|
|
2023-01-28 23:29:33 +01:00
|
|
|
ABSTRACTIONS = $(shell find ${BUILD}/apparmor.d/abstractions/ -type f -printf "%P\n")
|
|
|
|
TUNABLES = $(shell find ${BUILD}/apparmor.d/tunables/ -type f -printf "%P\n")
|
|
|
|
$(P):
|
2024-09-26 00:17:44 +02:00
|
|
|
@install -Dm0755 ${BUILD}/aa-log ${DESTDIR}/usr/bin/aa-log
|
2023-01-28 23:29:33 +01:00
|
|
|
@for file in ${ABSTRACTIONS}; do \
|
|
|
|
install -Dm0644 "${BUILD}/apparmor.d/abstractions/$${file}" "${DESTDIR}/etc/apparmor.d/abstractions/$${file}"; \
|
|
|
|
done;
|
|
|
|
@for file in ${TUNABLES}; do \
|
|
|
|
install -Dm0644 "${BUILD}/apparmor.d/tunables/$${file}" "${DESTDIR}/etc/apparmor.d/tunables/$${file}"; \
|
|
|
|
done;
|
2023-02-11 19:59:08 +01:00
|
|
|
@echo "Warning: profile dependencies fallback to unconfined."
|
2023-01-28 23:29:33 +01:00
|
|
|
@for file in ${@}; do \
|
2023-02-11 19:59:08 +01:00
|
|
|
grep 'rPx' "${BUILD}/apparmor.d/$${file}"; \
|
|
|
|
sed -i -e "s/rPx/rPUx/g" "${BUILD}/apparmor.d/$${file}"; \
|
2023-01-28 23:29:33 +01:00
|
|
|
install -Dvm0644 "${BUILD}/apparmor.d/$${file}" "${DESTDIR}/etc/apparmor.d/$${file}"; \
|
|
|
|
done;
|
|
|
|
@systemctl restart apparmor || systemctl status apparmor
|
|
|
|
|
2024-10-02 20:49:21 +02:00
|
|
|
name ?=
|
|
|
|
dev:
|
|
|
|
@go run ./cmd/prebuild --complain --file $(shell find apparmor.d -iname ${name})
|
2024-10-02 22:25:01 +02:00
|
|
|
@sudo install -Dm644 ${BUILD}/apparmor.d/${name} /etc/apparmor.d/${name}
|
2024-10-02 20:49:21 +02:00
|
|
|
@sudo systemctl restart apparmor || systemctl status apparmor
|
|
|
|
|
2023-04-16 22:25:52 +02:00
|
|
|
dist ?= archlinux
|
|
|
|
package:
|
2023-09-18 18:26:28 +02:00
|
|
|
@bash dists/docker.sh ${dist}
|
2022-10-05 00:17:52 +02:00
|
|
|
|
2023-04-16 22:25:52 +02:00
|
|
|
pkg:
|
|
|
|
@makepkg --syncdeps --install --cleanbuild --force --noconfirm
|
2022-10-05 00:17:52 +02:00
|
|
|
|
2023-04-16 22:25:52 +02:00
|
|
|
dpkg:
|
2023-09-19 20:04:12 +02:00
|
|
|
@bash dists/build.sh dpkg
|
2024-03-18 00:20:05 +01:00
|
|
|
@sudo dpkg -i ${PKGDEST}/${PKGNAME}_*.deb
|
2022-10-05 00:17:52 +02:00
|
|
|
|
2023-04-16 22:25:52 +02:00
|
|
|
rpm:
|
2023-09-19 20:04:12 +02:00
|
|
|
@bash dists/build.sh rpm
|
2024-03-18 00:20:05 +01:00
|
|
|
@sudo rpm -ivh --force ${PKGDEST}/${PKGNAME}-*.rpm
|
2022-10-05 00:17:52 +02:00
|
|
|
|
2023-04-20 00:16:53 +02:00
|
|
|
tests:
|
2023-06-18 12:40:32 +02:00
|
|
|
@go test ./cmd/... -v -cover -coverprofile=coverage.out
|
|
|
|
@go test ./pkg/... -v -cover -coverprofile=coverage.out
|
2023-04-20 00:16:53 +02:00
|
|
|
@go tool cover -func=coverage.out
|
|
|
|
|
2023-04-16 22:25:52 +02:00
|
|
|
lint:
|
2023-08-19 22:55:48 +02:00
|
|
|
@golangci-lint run
|
2023-09-19 19:35:24 +02:00
|
|
|
@make --directory=tests lint
|
2023-04-16 22:25:52 +02:00
|
|
|
@shellcheck --shell=bash \
|
2024-10-06 16:39:21 +02:00
|
|
|
PKGBUILD dists/build.sh dists/docker.sh tests/check.sh \
|
2023-04-24 16:28:33 +02:00
|
|
|
tests/packer/init/init.sh tests/packer/src/aa-update tests/packer/init/clean.sh \
|
2023-04-16 22:25:52 +02:00
|
|
|
debian/${PKGNAME}.postinst debian/${PKGNAME}.postrm
|
2022-10-05 00:17:52 +02:00
|
|
|
|
2024-10-06 16:39:21 +02:00
|
|
|
check:
|
|
|
|
@bash tests/check.sh
|
|
|
|
|
|
|
|
manual:
|
|
|
|
@pandoc -t man -s -o root/usr/share/man/man8/aa-log.8 root/usr/share/man/man8/aa-log.md
|
2024-09-26 00:17:44 +02:00
|
|
|
|
|
|
|
docs:
|
2024-10-06 16:39:21 +02:00
|
|
|
@ENABLED_GIT_REVISION_DATE=false MKDOCS_OFFLINE=true mkdocs build --strict
|
2024-09-26 00:17:44 +02:00
|
|
|
|
|
|
|
serve:
|
2024-10-06 16:39:21 +02:00
|
|
|
@ENABLED_GIT_REVISION_DATE=false MKDOCS_OFFLINE=false mkdocs serve
|
2024-09-26 00:17:44 +02:00
|
|
|
|
2022-10-05 00:17:52 +02:00
|
|
|
clean:
|
|
|
|
@rm -rf \
|
2023-01-28 23:29:33 +01:00
|
|
|
debian/.debhelper debian/debhelper* debian/*.debhelper debian/${PKGNAME} \
|
2024-10-07 15:05:40 +02:00
|
|
|
.pkg/${PKGNAME}* ${BUILD} coverage.out
|