Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/osx/Installer.Mac/scripts/postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ mkdir -p /usr/local/bin
/bin/ln -Fs "$INSTALL_DESTINATION/git-credential-manager" /usr/local/bin/git-credential-manager

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if someone is installing GCM (either via Homebrew or the installer command line) from an SSH session where there is no console user? We need to make sure this works for remote/multi-user scenarios.

sudo -u "${REAL_USER}" "$INSTALL_DESTINATION/git-credential-manager" configure

exit 0
Loading