shadow: detect corrupt content

This commit is contained in:
MilhouseVH 2017-12-12 00:59:14 +00:00
parent de76520d9c
commit 130b602a6d

View File

@ -25,8 +25,13 @@ if [ -f /storage/.cache/shadow -a -f /usr/cache/shadow ]; then
# Get existing root details (possibly user defined)
userroot="$(grep "^root:" /storage/.cache/shadow)"
# Overwrite users shadow file with default details, but replacing root with any existing value
[ -n "${userroot}" ] && sed -e "s ^root:.* ${userroot} " /usr/cache/shadow >/storage/.cache/shadow
# Overwrite users shadow file with default details, replacing root with any existing value
# If current file is garbage (ie. missing root) then replace it
if [ -n "${userroot}" ]; then
sed -e "s ^root:.* ${userroot} " /usr/cache/shadow >/storage/.cache/shadow
else
cp -fp /usr/cache/shadow /storage/.cache/shadow
fi
# Make sure we have the correct permission
chmod 000 /storage/.cache/shadow