mirror of
https://github.com/kairos-io/packages.git
synced 2025-09-19 01:47:41 +00:00
Fix home dir ownership as a last step (#1036)
because users might be created in various stages (like "network") Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
committed by
GitHub
parent
99029b0705
commit
b4695722b4
@@ -1,4 +1,4 @@
|
||||
packages:
|
||||
- name: "kairos-overlay-files"
|
||||
category: "static"
|
||||
version: "1.1.48"
|
||||
version: "1.1.49"
|
||||
|
@@ -1,17 +1,6 @@
|
||||
name: "Fix home directory permissions (kairos issue #2797)"
|
||||
stages:
|
||||
initramfs.after:
|
||||
- name: "Fix permissions"
|
||||
if: '[ ! -f "/usr/local/.kairos/skip-home-directory-ownership-fix" ]'
|
||||
network.after:
|
||||
- name: "Fix home dir ownership"
|
||||
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
|
||||
echo "https://github.com/kairos-io/kairos/issues/2843" > /usr/local/.kairos/skip-home-directory-ownership-fix
|
||||
- "/usr/bin/fix-home-dir-ownership"
|
||||
|
24
packages/static/kairos-overlay-files/files/usr/bin/fix-home-dir-ownership
Executable file
24
packages/static/kairos-overlay-files/files/usr/bin/fix-home-dir-ownership
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
SENTINEL_FILE="/usr/local/.kairos/skip-home-directory-ownership-fix"
|
||||
|
||||
if [ -f $SENTINEL_FILE ]; then
|
||||
echo "Skipping ownership fix because sentinel file was found: $SENTINEL_FILE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
||||
# Write the sentinel file
|
||||
mkdir -p "$(dirname $SENTINEL_FILE)"
|
||||
echo "https://github.com/kairos-io/kairos/issues/2843" > $SENTINEL_FILE
|
Reference in New Issue
Block a user