Skip to content

Commit 1832f58

Browse files
fix(osx): use stat -f%Su /dev/console to determine real user in postinstall script
Co-authored-by: marekzmyslowski <1062877+marekzmyslowski@users.noreply.github.com>
1 parent 618e259 commit 1832f58

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/osx/Installer.Mac/scripts/postinstall

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ mkdir -p /usr/local/bin
3131
/bin/ln -Fs "$INSTALL_DESTINATION/git-credential-manager" /usr/local/bin/git-credential-manager
3232

3333
# Configure GCM for the current user (running as the current user to avoid root
34-
# from taking ownership of ~/.gitconfig)
35-
sudo -u ${USER} "$INSTALL_DESTINATION/git-credential-manager" configure
34+
# from taking ownership of ~/.gitconfig).
35+
# Use stat to determine the console user since the installer may be invoked with
36+
# USER unset (e.g. when run via Homebrew which explicitly clears USER).
37+
REAL_USER=$(stat -f%Su /dev/console)
38+
sudo -u "${REAL_USER}" "$INSTALL_DESTINATION/git-credential-manager" configure
3639

3740
exit 0

0 commit comments

Comments
 (0)