Merge pull request #2316 from MilhouseVH/le90_fix_shadow_is_garbage

shadow: detect corrupt content
This commit is contained in:
Christian Hewitt 2017-12-12 06:07:33 +04:00 committed by GitHub
commit d4b12d4ff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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