Repository navigation
Don't require global Powershell execution policy change - #54
Conversation
|
tag @eerhardt |
|
What's going on with linux build? |
| call "%DeveloperCommandPrompt%" || goto :BuildFailed | ||
|
|
||
| powershell -NoProfile -NoLogo -Command "& \"%~dp0build.ps1\" %*; exit $LastExitCode;" | ||
| powershell -NoProfile -NoLogo -ExecutionPolicy RemoteSigned -Command "& \"%~dp0build.ps1\" %*; exit $LastExitCode;" |
There was a problem hiding this comment.
-ExecutionPolicy Bypass is better, as it doesn't require the user to have explicitly set the execution policy to RemoteSigned first.
There was a problem hiding this comment.
My (possibly wrong) understanding is that this is slightly safer than because build.ps1 still couldn't pull a remote unsigned script.
I'm not understanding what user intervention is required with the way I have it.
There was a problem hiding this comment.
build.ps1 does pull a remote script. See:
# Install a stage 0
$DOTNET_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/dotnet/cli/feature/msbuild/scripts/obtain/dotnet-install.ps1"
Invoke-WebRequest $DOTNET_INSTALL_SCRIPT_URL -OutFile "$env:DOTNET_INSTALL_DIR\dotnet-install.ps1"
& "$env:DOTNET_INSTALL_DIR\dotnet-install.ps1" -Version $DotnetCLIVersion -Verbose
There was a problem hiding this comment.
The user has to call Set-ExecutionPolicy RemoteSigned before they can run Build.cmd (most, but not all developers, seem to do this if they work with Powershell frequently).
There was a problem hiding this comment.
The user has to call Set-ExecutionPolicy RemoteSigned
I don't think so. That's exactly what I'm trying to fix. I have not set anything on my machine. This is setting the policy to remotesigned for the execution of the script without affecting the global registry setting.
>powershell .\build.ps1
.\build.ps1 : File D:\Src\sdk\build.ps1 cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ .\build.ps1
+ ~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
>powershell -ExecutionPolicy RemoteSigned .\build.ps1
VERBOSE: dotnet-install: Get-Azure-Channel-From-Channel -Channel "rel-1.0.0"
VERBOSE: dotnet-install: Get-CLIArchitecture-From-Architecture -Architecture "<auto>"
VERBOSE: dotnet-install: Get-Machine-Architecture
<snip>
build.ps1 does pull a remote script. See:
Lol. AFAICT, it does so by copying it to a local file and then executing it as a local script, so RemoteSigned doesn't impede it.
There was a problem hiding this comment.
If that's the case, then I am fine with RemoteSigned. @jaredpar might have some better knowledge, I know he recently changed one of our scripts to use Bypass due to a customer issue filed.
There was a problem hiding this comment.
Hmm, I see dotnet/roslyn#13121. I guess I'll go ahead and use bypass because (1) like @jaredpar I've already spent too much time on this 😁 and (2) this particular script actually does download ps1 from the internet so any lesser privilege that happens to work is just cheating anyhow.
It has never worked. @livarcocc is going to look into it. |
|
Can we disable it until fixed? |
|
We had a similar PR in a separate repo: dotnet/core-setup#91, but it was rejected. /cc @brthor I'm not an expert in powershell. If this is common practice to run with this switch, I think it is fine. |
|
This is done quite a bit in other dotnet repos: |
|
We should probably standardize on one or the other. |
In general, I would favor a "least privilege" approach. Bypass just disables all checks, and I think it's best not to disable checks that you don't expect to trigger. Mind you, build.ps1 is getting script from the internet in a way that powershell can't spot so bypass might be more honest in this specific case. 😁 I do not think we should change RemoteSigned to Bypass everywhere. |
|
Changed to bypass to be more honest about this specific script's required privileges. |
|
I don't have a preference here. Anyone running the build has already opted into running the arbitrary code of the repo. 👍 |
Powershell's job is to run scripts. The fact that by default it's incapable of doing it's job by default is a rather confusing decision. I've spent all the time I care to figuring out what combination of switches will actually cause Powershell to run scripts. At the moment ByPass seems to be the way to go. |
|
For context when is the last time you had to make a change to enable a batch script to run? Or bash? The answer is never. Powershell though, hit this problem all the time. Insanely frustrating. |
|
I'm persuaded by the fact that RemoteSigned mysteriously didn't work on a customer's box. This PR ended up using Bypass before being merged and I'm indifferent now if we want to go ahead and use bypass throughout. Never having seen RemoteSigned not do the trick myself, it seemed prudent to use the least privilege that scratched my itch, and it hadn't failed me before. I agree that this probably shouldn't even be something that PowerShell tries to solve. I'm just always cautious when I'm disabling any check that someone, somewhere thought was worthwhile. |
Don't require global Powershell execution policy change
Removing the call to dotnet restore3 from prepublish target
Advance WORKLOAD_BUNDLE_SHA256 from 031ba342 (kit dotnet#53) to 09326398, the kit dotnet#54 repack of openharmony-workload-1.0.0-preview.28: the Sdk pack carries the FINAL-BATCH shell (ui abc 623,784/58c5829b with the MEDIAELEMENT wave - ArkWeb media element service + child-window media + vendored hls.js 1.7.3/MSE + the popup gesture opt-out and /__src__ single-range Range/206 - the modal overlay visibility fix (OpenHarmonyOverlaySuspension) and the managed subwindow default 2->4; headless 24,324/798b2477 unchanged), the media rawfile assets (templates/resources/rawfile/media.html + hls.min.js + hls.LICENSE.txt), pages/Index.ets and pages/SubWindow.ets at the merged sources, and the host at the same fingerprint (367,520/ad7ab986, exports 164/164). The kit haps were rebuilt with the FINAL-BATCH MAUI slice (36da77cba492) and the Ref/Runtime managed packs were rebuilt from the same sources (PE metadata-only diffs). Installer tests: 43/43 + 10/10 + 5/5; fetch-nativeaot --local content check OK.
Makes it so I can run build.cmd without any global changes to my box.
@srivatsn @davkean