Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hook for clearing modifications made by apt #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
BIN = $(DESTDIR)/usr/bin
ETC = $(DESTDIR)/etc
DEFAULT = $(DESTDIR)/etc/default
PROFILED = $(DESTDIR)/etc/profile.d
LIB = $(DESTDIR)/usr/lib
Expand All @@ -20,8 +21,12 @@ install-pacman: install
install -D -m644 pacman-hooks/80-chkboot-check.hook $(SHARE)/libalpm/hooks/80-chkboot-check.hook
install -D -m644 pacman-hooks/99-chkboot-update.hook $(SHARE)/libalpm/hooks/99-chkboot-update.hook

install-apt: install
install -D -m644 apt-hooks/05chkboot $(ETC)/apt/apt.conf.d/05chkboot
install -D -m755 apt-hooks/chkboot-update $(LIB)/chkboot/chkboot-update

install-systemd: install
install -D -m644 chkboot.service $(LIB)/systemd/system/chkboot.service
install -D -m755 chkboot-bootcheck $(LIB)/systemd/scripts/chkboot-bootcheck

.PHONY: all install install-initcpio install-pacman install-systemd
.PHONY: all install install-initcpio install-pacman install-systemd install-apt
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ make install-initcpio
make install-systemd
```

### To install apt components:

```
make install-apt
```

Manual Installation
-------------------

Expand Down
1 change: 1 addition & 0 deletions apt-hooks/05chkboot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DPkg::Post-Invoke { "if [ -x /usr/lib/chkboot/chkboot-update ]; then /usr/lib/chkboot/chkboot-update; fi"; };
29 changes: 29 additions & 0 deletions apt-hooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Apt Hooks for chkboot

Hooks required to clear any modification made to /boot by apt.

## How it works?

On first install, chkboot Debian package take the following actions:
- register a trigger on /boot and initramfs update (stored in
`/var/lib/dpkg/triggers/`)
- install a function to create a flag file on trigger activation in
`/var/lib/dpkg/info/chkboot.postinst`
- install an apt hook in `/etc/apt/apt.conf.d/05chkboot` to run the update
script
- install an update script in `/usr/lib/chkboot/chkboot-update`

Then, on trigger activation:
- flag file is created in `/var/lib/chkboot/needs-update`
- apt hook calls the update script
- update script clear modifications

Note: The hook and update script are actually called at every apt invocation.
Clearing the modification is only done if the flag file exists, from when the
trigger is activated.

## Files

The update script and the apt hook are installed alongside chkboot. The trigger
and the function to create the flag files are located in the Debian packaging
files.
24 changes: 24 additions & 0 deletions apt-hooks/chkboot-update
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Post apt hook that clear valid modification with chkboot -u
# Author: Baptiste BEAUPLAT <[email protected]>
# license: GPLv2

TRIGGER="/var/lib/chkboot/needs-update"

# Only run if needed
[[ -f "${TRIGGER}" ]] || exit 0
rm -f "${TRIGGER}"

echo "Updating chkboot hashes of your boot files..."

# TEST TO SEE IF BOOT FILES WERE MODIFIED WITHOUT THE USER'S ACKNOWLEDGEMENT (BY
# RUNNING 'chkboot') AND ALERT THEM IF IT HAS BEEN
chkboot-check
if [ "$?" = 1 ]; then
echo -e "\n### WARNING: Previously modified files were not acknowledged ###"
echo "### Check the issues log at ${CHANGES_LOG} for details ###"
fi

# RUN CHKBOOT TO UPDATE THE HASHES WITHOUT CREATING THE ALERT FILE
chkboot -u
sync