Fix home directory ownership (#1011)

Fixes https://github.com/kairos-io/kairos/issues/2797

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
Dimitris Karakasilis 2024-08-26 16:10:05 +03:00 committed by GitHub
parent 1c02ec8660
commit 6c61ee8fae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -1,4 +1,4 @@
packages:
- name: "kairos-overlay-files"
category: "static"
version: "1.1.45"
version: "1.1.46"

View File

@ -0,0 +1,15 @@
name: "Fix home directory permissions (kairos issue #2797)"
stages:
initramfs.after:
- name: "Fix permissions"
commands:
- |
# Iterate over users in /etc/passwd and chown their directories
awk -F: '$3 >= 1000 && $6 ~ /^\/home\// {print $1, $6}' /etc/passwd | while read -r user homedir; do
if [ -d "$homedir" ]; then # Check if the home directory exists
echo "Changing ownership of $homedir to $user"
chown -R "$user":"$user" "$homedir"
else
echo "Directory $homedir does not exist for user $user"
fi
done