From 53933f9612cca81511231e3edc2a276101fac78e Mon Sep 17 00:00:00 2001 From: riccardom Date: Wed, 29 Jul 2026 16:15:28 +0200 Subject: [PATCH] [client] validate console user uid/home and set HOME on macOS UI launch Address CodeRabbit review on the pkg postinstall: resolve and validate the console user's uid and home dir before launching, skip visibly instead of masking with `|| true`, and set HOME to the resolved home so the GUI reads the user's real ui-preferences.json. --- release_files/darwin_pkg/postinstall | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/release_files/darwin_pkg/postinstall b/release_files/darwin_pkg/postinstall index 431ff48d2..a633d4d5c 100755 --- a/release_files/darwin_pkg/postinstall +++ b/release_files/darwin_pkg/postinstall @@ -40,9 +40,16 @@ mkdir -p /usr/local/bin/ echo "No active GUI user session (console user: '${console_user:-none}'); skipping UI launch." ;; *) - uid=$(id -u "$console_user") - echo "Launching NetBird UI as console user $console_user (uid $uid)." - launchctl asuser "$uid" open "$APP" || true + uid=$(id -u "$console_user" 2>/dev/null) + home_dir=$(dscl . -read "/Users/$console_user" NFSHomeDirectory 2>/dev/null | awk '{print $2}') + if [ -z "$uid" ] || [ -z "$home_dir" ]; then + echo "Could not resolve uid/home for console user '$console_user' (uid='$uid', home='$home_dir'); skipping UI launch." + else + echo "Launching NetBird UI as console user $console_user (uid $uid, home $home_dir)." + if ! HOME="$home_dir" launchctl asuser "$uid" open "$APP"; then + echo "Failed to launch NetBird UI; it will start at next login via the per-user LaunchAgent." + fi + fi ;; esac