Do not overwrite existing files when copying from /etc/skel/

Copy /etc/skel/ only for users with UID in range 1000–60000.
Correct user home directory permission after copying files.
Fixes all /etc/skel issues from https://bugs.archlinux.org/task/67729 .
This commit is contained in:
nl6720 2020-08-30 18:12:08 +03:00
parent 45a5d229b3
commit 486b1910dd
No known key found for this signature in database
GPG Key ID: 5CE88535E188D369

View File

@ -378,9 +378,11 @@ _make_customize_airootfs() {
if [[ -e "${profile}/airootfs/etc/passwd" ]]; then if [[ -e "${profile}/airootfs/etc/passwd" ]]; then
_msg_info "Copying /etc/skel/* to user homes..." _msg_info "Copying /etc/skel/* to user homes..."
while IFS=':' read -a passwd -r; do while IFS=':' read -a passwd -r; do
(( passwd[2] >= 1000 && passwd[2] < 60000 )) || continue
[[ "${passwd[5]}" == '/' ]] && continue [[ "${passwd[5]}" == '/' ]] && continue
[[ -z "${passwd[5]}" ]] && continue [[ -z "${passwd[5]}" ]] && continue
cp -RdT --preserve=mode,timestamps,links -- "${airootfs_dir}/etc/skel" "${airootfs_dir}${passwd[5]}" cp -dnRT --preserve=mode,timestamps,links -- "${airootfs_dir}/etc/skel" "${airootfs_dir}${passwd[5]}"
chmod -f 0750 -- "${airootfs_dir}${passwd[5]}"
chown -hR -- "${passwd[2]}:${passwd[3]}" "${airootfs_dir}${passwd[5]}" chown -hR -- "${passwd[2]}:${passwd[3]}" "${airootfs_dir}${passwd[5]}"
done < "${profile}/airootfs/etc/passwd" done < "${profile}/airootfs/etc/passwd"