diff options
| author | adeci <alex.decious@gmail.com> | 2025-08-09 12:33:43 -0700 |
|---|---|---|
| committer | Masum Reza <50095635+JohnRTitor@users.noreply.github.com> | 2025-08-11 03:05:43 +0530 |
| commit | aa822ab65720cdd8beb04a52bc60aae15d13d609 (patch) | |
| tree | ca09509d15d352b625d23ad76877ced84fccfc46 | |
| parent | shellhub-agent: 0.19.2 -> 0.20.0 (#432303) (diff) | |
| download | nixpkgs-aa822ab65720cdd8beb04a52bc60aae15d13d609.tar.gz | |
nixos-install: add root directory ownership check
Prevents installation when mount point is not owned by root:root, which can cause systemd warnings and session failures.
Fixes #432261
| -rwxr-xr-x | pkgs/by-name/ni/nixos-install/nixos-install.sh | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pkgs/by-name/ni/nixos-install/nixos-install.sh b/pkgs/by-name/ni/nixos-install/nixos-install.sh index 2a592223a921..b15103c5ce14 100755 --- a/pkgs/by-name/ni/nixos-install/nixos-install.sh +++ b/pkgs/by-name/ni/nixos-install/nixos-install.sh @@ -122,6 +122,14 @@ while [[ "$checkPath" != "/" ]]; do checkPath="$(dirname "$checkPath")" done +# Check if the mount point root directory is owned by root +if [[ "$(stat -c '%u:%g' "$mountPoint")" != "0:0" ]]; then + echo "$0: $mountPoint is not owned by root:root (owned by $(stat -c '%U:%G' "$mountPoint"))" + echo "$0: installation root directory must be owned by root to avoid system issues" + echo "$0: run 'sudo chown root:root $mountPoint' to fix this" + exit 1 +fi + # Verify that user is not trying to use attribute building and flake # at the same time if [[ -z $buildingAttribute && -n $flake ]]; then |
