#!/bin/sh -eu # Known good post-debootstrap values passwd_bootstrap="9738946debbc125bd6cf3f197582a8a5" shadow_bootstrap="4d299751999cae6de045390dd568812c" group_bootstrap="dd4a0ebdd3f5d170d5a46e6bade5c6c3" gshadow_bootstrap="42025e85925432105b429b7c801a50a4" # Current post-debootstrap values 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_hash=$(set -- $(md5sum /etc/group) && echo $1) gshadow_hash=$(set -- $(md5sum /etc/gshadow) && echo $1) # /etc/passwd if [ "$passwd_bootstrap" = "$passwd_hash" ]; then cat > /etc/passwd <&2 exit 1 fi # /etc/shadow if [ "$shadow_bootstrap" = "$shadow_hash" ]; then cat > /etc/shadow <&2 exit 1 fi # /etc/group if [ "$group_bootstrap" = "$group_hash" ]; then cat > /etc/group <&2 exit 1 fi # /etc/gshadow if [ "$gshadow_bootstrap" = "$gshadow_hash" ]; then cat > /etc/gshadow <&2 exit 1 fi # Record the current state for later comparison for file in /etc/passwd /etc/shadow /etc/group /etc/gshadow; do rm -f ${file}- cp ${file} ${file}.orig done