mirror of
https://git.launchpad.net/livecd-rootfs
synced 2025-02-10 12:47:30 +00:00
/etc/shadow, /etc/group and /etc/gshadow PRIOR to package installation to guarantee user/group ordering on the image and then to check for any unexpected change to those files. (LP: #1332538) Any change to either the initial set of users and groups or to the post-package-install set will now be fatal to the image and will require a manual update of the hardcoded user/group list contained in this new chroot_early hook. * Bump dependency on live-build accordingly. * Update the setup_user hook to also take care of gshadow.
38 lines
1.2 KiB
Bash
Executable File
38 lines
1.2 KiB
Bash
Executable File
#!/bin/sh -eu
|
|
|
|
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
|
|
diff -Nrup /etc/passwd.orig /etc/passwd >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$shadow_hash" != "$shadow_orig_hash" ]; then
|
|
echo "/etc/shadow has changed during setup." >&2
|
|
diff -Nrup /etc/shadow.orig /etc/shadow >&2
|
|
exit 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
|
|
exit 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
|
|
exit 1
|
|
fi
|
|
|
|
rm /etc/passwd.orig /etc/shadow.orig /etc/group.orig /etc/gshadow.orig
|