From ebb7684dd86b62e340044f3d5a9e6943411fa7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Wed, 4 Feb 2015 13:46:17 +0100 Subject: [PATCH] Add live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot, copy of live-build/ubuntu-touch/hooks/99zz-check-uid-gid.chroot with just the error message changed. Currently, the passwd/group checks weren't run. --- debian/changelog | 8 +++ .../hooks/99zz-check-uid-gid.chroot | 52 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100755 live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot diff --git a/debian/changelog b/debian/changelog index 1dae2a81..6d6aeddb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +livecd-rootfs (2.278) UNRELEASED; urgency=medium + + * Add live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot, copy of + live-build/ubuntu-touch/hooks/99zz-check-uid-gid.chroot with just the + error message changed. Currently, the passwd/group checks weren't run. + + -- Loïc Minier Wed, 04 Feb 2015 13:39:26 +0100 + livecd-rootfs (2.277) vivid; urgency=medium * live-build/ubuntu-core/hooks/00-uid-gid-fix.chroot_early: add new "input" diff --git a/live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot b/live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot new file mode 100755 index 00000000..4d7b807d --- /dev/null +++ b/live-build/ubuntu-core/hooks/99zz-check-uid-gid.chroot @@ -0,0 +1,52 @@ +#!/bin/sh -eu + +ERRCNT="" + +passwd_hash=$(set -- $(md5sum /etc/passwd) && echo $1) +shadow_hash=$(set -- $(cat /etc/shadow | sed "s/:.*:0:99999:/:0:99999:/g" | md5sum) && echo $1) +group_length=$(cat /etc/group | wc -l) +gshadow_length=$(cat /etc/gshadow | wc -l) + +passwd_orig_hash=$(set -- $(md5sum /etc/passwd.orig) && echo $1) +shadow_orig_hash=$(set -- $(cat /etc/shadow.orig | sed "s/:.*:0:99999:/:0:99999:/g" | md5sum) && echo $1) +group_orig_length=$(cat /etc/group.orig | wc -l) +gshadow_orig_length=$(cat /etc/gshadow.orig | wc -l) + +if [ "$passwd_hash" != "$passwd_orig_hash" ]; then + echo "/etc/passwd has changed during setup." >&2 + echo "The new /etc/passwd md5sum is: $passwd_hash" >&2 + diff -Nrup /etc/passwd.orig /etc/passwd >&2 || true + ERRCNT=1 +fi + +if [ "$shadow_hash" != "$shadow_orig_hash" ]; then + echo "/etc/shadow has changed during setup." >&2 + echo "The new /etc/shadow md5sum is: $shadow_hash" >&2 + diff -Nrup /etc/shadow.orig /etc/shadow >&2 || true + ERRCNT=1 +fi + +if [ "$group_length" != "$group_orig_length" ]; then + echo "/etc/group has changed during setup." >&2 + diff -Nrup /etc/group.orig /etc/group >&2 || true + ERRCNT=1 +fi + +if [ "$gshadow_length" != "$gshadow_orig_length" ]; then + echo "/etc/gshadow has changed during setup." >&2 + diff -Nrup /etc/gshadow.orig /etc/gshadow >&2 || true + ERRCNT=1 +fi + +if [ -n "$ERRCNT" ]; then + echo "There were changes to the password database," >&2 + echo "please adjust the values in the livecd-rootfs source in the file:" >&2 + echo "live-build/ubuntu-core/hooks/00-uid-gid-fix.chroot_early" >&2 + echo >&2 + echo "Please check also if a maintainer script of the package" >&2 + echo "that added these entries perhaps created a home directory and," >&2 + echo "if needed, add code for creation of it to the above hook" >&2 + exit 1 +fi + +rm /etc/passwd.orig /etc/shadow.orig /etc/group.orig /etc/gshadow.orig