From 6c61ee8faef3e60f1c468dfa6d340d4e3fd34afb Mon Sep 17 00:00:00 2001 From: Dimitris Karakasilis Date: Mon, 26 Aug 2024 16:10:05 +0300 Subject: [PATCH] Fix home directory ownership (#1011) Fixes https://github.com/kairos-io/kairos/issues/2797 Signed-off-by: Dimitris Karakasilis --- .../static/kairos-overlay-files/collection.yaml | 2 +- .../files/system/oem/00_home_dir_owner_fix.yaml | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 packages/static/kairos-overlay-files/files/system/oem/00_home_dir_owner_fix.yaml diff --git a/packages/static/kairos-overlay-files/collection.yaml b/packages/static/kairos-overlay-files/collection.yaml index a148c2b6c..76c012e63 100644 --- a/packages/static/kairos-overlay-files/collection.yaml +++ b/packages/static/kairos-overlay-files/collection.yaml @@ -1,4 +1,4 @@ packages: - name: "kairos-overlay-files" category: "static" - version: "1.1.45" + version: "1.1.46" diff --git a/packages/static/kairos-overlay-files/files/system/oem/00_home_dir_owner_fix.yaml b/packages/static/kairos-overlay-files/files/system/oem/00_home_dir_owner_fix.yaml new file mode 100644 index 000000000..b8cc4cb3d --- /dev/null +++ b/packages/static/kairos-overlay-files/files/system/oem/00_home_dir_owner_fix.yaml @@ -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