Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Commit

Permalink
Fixed upgrade process for groups/users add
Browse files Browse the repository at this point in the history
  • Loading branch information
kayrus committed Oct 9, 2015
1 parent 3b740f1 commit 8f7a6ca
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions scripts/coreos-tmpfiles
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,32 @@ COPY_GROUPS="docker|rkt|sudo|wheel"
umask 022
if [[ ! -e "${ROOT}/etc/passwd" ]]; then
grep -E -e "^(${COPY_USERS}):" "${BASE}/passwd" > "${ROOT}/etc/passwd"
else
# Append users
grep -Fxv -f "${ROOT}/etc/passwd" "${BASE}/passwd" | grep -E -e "^(${COPY_USERS}):" >> "${ROOT}/etc/passwd" || true
fi
if [[ ! -e "${ROOT}/etc/group" ]]; then
grep -E -e "^(${COPY_GROUPS}):" "${BASE}/group" > "${ROOT}/etc/group"
else
# Append groups and take into consideration existing users in groups
for i in $(grep -Fxv -f "${ROOT}/etc/group" "${BASE}/group" | grep -E -e "^(${COPY_GROUPS}):"); do
grep -Fq "$i" "${ROOT}/etc/group" || echo "$i" >> "${ROOT}/etc/group"
done
fi

# secure files
umask 027
if [[ ! -e "${ROOT}/etc/shadow" ]]; then
grep -E -e "^(${COPY_USERS}):" "${BASE}/shadow" > "${ROOT}/etc/shadow"
else
# Append users
grep -Fxv -f "${ROOT}/etc/shadow" "${BASE}/shadow" | grep -E -e "^(${COPY_USERS}):" >> "${ROOT}/etc/shadow" || true
fi
if [[ ! -e "${ROOT}/etc/gshadow" ]]; then
grep -E -e "^(${COPY_GROUPS}):" "${BASE}/gshadow" > "${ROOT}/etc/gshadow"
else
# Append groups and take into consideration existing users in groups
for i in $(grep -Fxv -f "${ROOT}/etc/gshadow" "${BASE}/gshadow" | grep -E -e "^(${COPY_GROUPS}):"); do
grep -Fq "$i" "${ROOT}/etc/gshadow" || echo "$i" >> "${ROOT}/etc/gshadow"
done
fi

0 comments on commit 8f7a6ca

Please sign in to comment.