Set up custom user home directories and their permissions

This commit is contained in:
nl6720 2020-07-20 12:18:16 +03:00
parent 78fe656042
commit b922e8bc9c
No known key found for this signature in database
GPG Key ID: 5CE88535E188D369
2 changed files with 28 additions and 1 deletions

View File

@ -39,6 +39,20 @@ make_custom_airootfs() {
cp -af --no-preserve=ownership -- "${script_path}/airootfs/." "${_airootfs}" cp -af --no-preserve=ownership -- "${script_path}/airootfs/." "${_airootfs}"
[[ -e "${_airootfs}/etc/shadow" ]] && chmod -f 0400 -- "${_airootfs}/etc/shadow" [[ -e "${_airootfs}/etc/shadow" ]] && chmod -f 0400 -- "${_airootfs}/etc/shadow"
[[ -e "${_airootfs}/etc/gshadow" ]] && chmod -f 0400 -- "${_airootfs}/etc/gshadow" [[ -e "${_airootfs}/etc/gshadow" ]] && chmod -f 0400 -- "${_airootfs}/etc/gshadow"
# Set up user home directories and permissions
if [[ -e "${_airootfs}/etc/passwd" ]]; then
while IFS=':' read -a passwd -r; do
[[ "${passwd[5]}" == '/' ]] && continue
if [[ -d "${_airootfs}${passwd[5]}" ]]; then
chown -hR -- "${passwd[2]}:${passwd[3]}" "${_airootfs}${passwd[5]}"
chmod -f 0750 -- "${_airootfs}${passwd[5]}"
else
install -d -m 0750 -o "${passwd[2]}" -g "${passwd[3]}" -- "${_airootfs}${passwd[5]}"
fi
done < "${_airootfs}/etc/passwd"
fi
fi fi
} }

View File

@ -69,7 +69,20 @@ make_custom_airootfs() {
[[ -e "${_airootfs}/etc/shadow" ]] && chmod -f 0400 -- "${_airootfs}/etc/shadow" [[ -e "${_airootfs}/etc/shadow" ]] && chmod -f 0400 -- "${_airootfs}/etc/shadow"
[[ -e "${_airootfs}/etc/gshadow" ]] && chmod -f 0400 -- "${_airootfs}/etc/gshadow" [[ -e "${_airootfs}/etc/gshadow" ]] && chmod -f 0400 -- "${_airootfs}/etc/gshadow"
[[ -e "${_airootfs}/root" ]] && chmod -f 0750 -- "${_airootfs}/root"
# Set up user home directories and permissions
if [[ -e "${_airootfs}/etc/passwd" ]]; then
while IFS=':' read -a passwd -r; do
[[ "${passwd[5]}" == '/' ]] && continue
if [[ -d "${_airootfs}${passwd[5]}" ]]; then
chown -hR -- "${passwd[2]}:${passwd[3]}" "${_airootfs}${passwd[5]}"
chmod -f 0750 -- "${_airootfs}${passwd[5]}"
else
install -d -m 0750 -o "${passwd[2]}" -g "${passwd[3]}" -- "${_airootfs}${passwd[5]}"
fi
done < "${_airootfs}/etc/passwd"
fi
fi fi
} }