diff --git a/src/osx/Installer.Mac/scripts/postinstall b/src/osx/Installer.Mac/scripts/postinstall index 86922a7a53..6b50c54bd8 100755 --- a/src/osx/Installer.Mac/scripts/postinstall +++ b/src/osx/Installer.Mac/scripts/postinstall @@ -30,7 +30,11 @@ fi mkdir -p /usr/local/bin /bin/ln -Fs "$INSTALL_DESTINATION/git-credential-manager-core" /usr/local/bin/git-credential-manager-core -# Configure GCM for the current user -"$INSTALL_DESTINATION/git-credential-manager-core" configure +# Configure GCM for the current user (running as the current user to avoid root +# from taking ownership of ~/.gitconfig) +if [ "${COMMAND_LINE_INSTALL}" = "" ] +then + sudo -u ${USER} "$INSTALL_DESTINATION/git-credential-manager-core" configure +fi exit 0 diff --git a/src/osx/Installer.Mac/uninstall.sh b/src/osx/Installer.Mac/uninstall.sh index 2657046d03..a87b05d992 100755 --- a/src/osx/Installer.Mac/uninstall.sh +++ b/src/osx/Installer.Mac/uninstall.sh @@ -10,9 +10,9 @@ then exit $? fi -# Unconfigure +# Unconfigure (as the current user) echo "Unconfiguring credential helper..." -"$GCMBIN" unconfigure +sudo -u `logname` "$GCMBIN" unconfigure # Remove symlink if [ -L /usr/local/bin/git-credential-manager-core ]