Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed non-building without ExecutionPolicy Bypass #86

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ivan-Alone
Copy link

Spent a lot of time trying to figure out why sudo wasn't building - cargo was just spitting out a vague error with no reason for the build to fail.

As a result, I found out that this is happening because... Running PowerShell scripts is disabled on the system by default. And the error message issued by PowerShell is simply lost somewhere in the PS subroutine call in build.rs.

This change automatically enables scripts to run in the current build session, so the program builds correctly.

.arg("Bypass")
.arg("-Scope")
.arg("Process")
.arg("-Force;")
Copy link
Member

@lhecker lhecker Jun 4, 2024

Choose a reason for hiding this comment

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

Huh, now that I'm thinking about this, couldn't we just sign the script? I'm not sure who to ask for this internally, but I bet there's a chance we could do that.

Apropos, instead of a lot of args (even before your PR) I feel like anything past the -c should just be a single string, wrapped in single quotes. It's the command to be executed after all.

Copy link

Choose a reason for hiding this comment

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

PowerShell is optional and may not be present on the box, disabled, locked down, etc. and the user may not have permission to use that execution policy.

I would instead call out to Get-ExecutionPolicy and throw an error if the state is not a desirable one.

Comment on lines +226 to +229
.arg("Bypass")
.arg("-Scope")
.arg("Process")
.arg("-Force;")
Copy link
Member

Choose a reason for hiding this comment

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

FWIW, we should prefer powershell -NoProfile -ExecutionPolicy Bypass -c foo-bar-baz instead of trying to set-executionpolicy as an inline script 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants