rustup.sh icon indicating copy to clipboard operation
rustup.sh copied to clipboard

Make rustup.sh run sudo itself

Open brson opened this issue 10 years ago • 3 comments

There's a lot of code here that would not need to run as root if rustup.sh did the sudo invocation itself, and ~/.rustup would not need to be owned by root.

Some considerations:

  • How to detect when sudo is needed
  • What to do when there's no tty
  • Needs to accommodate non-interactive tools

brson avatar Apr 11 '15 19:04 brson

This would be great. One downside: even if the script pre-authorizes itself with sudo -v, the download might take long enough (or the timeout set short enough) that the timeout expires before it tries to use sudo to run the actual install.

An alternative approach might instead be instead to simply detect when the script is run with sudo and do most of the work in a child process that has its privileges revoked (sudo -u "#$SUDO_UID" ...), then perform the actual install in the parent once the child indicates that it's performed all of the previous steps.

lilyball avatar Apr 14 '15 21:04 lilyball

I want to install rust into home folder and do not give rustup.sh root rights at all (using --prefix option) Can I do this after such change?

PetrGlad avatar Jun 03 '15 15:06 PetrGlad

@PetrGlad rustup has already adopted this change, and there's a --disable-sudo flag to skip running sudo.

lilyball avatar Jun 03 '15 18:06 lilyball