Prohibit running under sudo unless explicitly forced to do so #3265
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We occasionally see people doing this which frankly messes everything up (they end up with a bunch of files owned by root which can't be removed, which they then complain about later). It's also terrible from a security perspective to invoke a tool like Please as root which will execute a heap of other commands and download files etc.
Sudo sets several env vars, so we can just refuse to run if they are set. I've added a flag to force working around it but I assume this shouldn't be necessary.
I guess you could consider this a breaking change, I'd like to not on the basis that this was a terrible idea all along. We can't have this as a config setting because it's effectively too late (by that point we've already done some stuff, e.g. written a log file)