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

On windows there can be problems with Tools that do not support Unicode #9232

Merged
merged 2 commits into from
Oct 5, 2023

Conversation

hknielsen
Copy link
Contributor

@hknielsen hknielsen commented Sep 19, 2023

Having a Username containing unicode chars, and tools that does not handle that well, makes it difficult when ToolTask are defined from NuGet Packages.

Fixes #9229

Context

Tmp folder can be changed by updating the User env vars, but Username are not possible. Not prepending the Username makes it possible for Users to handle these rare cases.

Changes Made

Changed to not append Username on Windows to tmp rsp file location.

Testing

Tests already for ToolTasks using this.

Notes

@hknielsen hknielsen changed the title On windows there can be problems with Tools that do not support Unico… On windows there can be problems with Tools that do not support Unicode Sep 19, 2023
@KalleOlaviNiemitalo
Copy link

KalleOlaviNiemitalo commented Sep 19, 2023

On Linux, you have to include the user name or something equally unique. Otherwise, MSBuild processes of a different user could attempt to use the same directory in tmp and fail because they don't have access to the directory.

Omit the user name only on Windows where the Unicode problem occurs.

On macOS, I think it could be implemented either way, but I'd prefer keeping the current behavior if no actual problem has been reported with it.

@hknielsen
Copy link
Contributor Author

@KalleOlaviNiemitalo is it Runtime check for windows are used on MsBuild or do we have preprocessors for it?

@KalleOlaviNiemitalo
Copy link

There is a NativeMethodsShared.IsLinux check right below the code you changed.

if (NativeMethodsShared.IsLinux && NativeMethodsShared.mkdir(basePath, userRWX) != 0)
global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods;

I expect that Windows would be checked in a similar way. There is already a property for that.

internal static bool IsWindows

@hknielsen hknielsen marked this pull request as ready for review September 19, 2023 14:20
@hknielsen
Copy link
Contributor Author

@KalleOlaviNiemitalo pushed new change, thanks!
Now we just need to determine if we should use the SecurityIdentifier - not sure how important it is

@rainersigwald
Copy link
Member

I think this is a reasonable approach, and we'll check with security folks. Another option would be "on Windows, coerce the username to ANSI".

That said, I think there's room for #9229 to be fixed in ToolTask itself too, since the "change TEMP then call task" dance is pretty awkward.

@hknielsen
Copy link
Contributor Author

hknielsen commented Sep 19, 2023

I think this is a reasonable approach, and we'll check with security folks. Another option would be "on Windows, coerce the username to ANSI".

Sound good, let me know. we can do the conversion to ANSI or use SecurityIdentifier depending on that.

That said, I think there's room for #9229 to be fixed in ToolTask itself too, since the "change TEMP then call task" dance is pretty awkward.

I agree :) Lets discuss possible solutions on that Issue.

Copy link
Member

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

Looks good to me! Approval is pending security review as rainersigwald mentioned.

src/Shared/TempFileUtilities.cs Outdated Show resolved Hide resolved
by review cleanup

Co-authored-by: Forgind <12969783+Forgind@users.noreply.github.com>
@KalleOlaviNiemitalo
Copy link

The following do not mention "MSBuildTemp" and thus would not need to be updated for this change:

copybara-service bot pushed a commit to protocolbuffers/protobuf that referenced this pull request Sep 27, 2023
Using none ASCII chars for protoc on Windows are not handled well.
This adresses argument file at a location where either directory, or filename contains Unicode chars.

Specifically because MsBuild tool saves argument file in with the UserName appended to the .rsp file.
dotnet/msbuild#9232

But in general we should really handle if none ascii chars are in the path.

Closes #14197

COPYBARA_INTEGRATE_REVIEW=#14197 from hknielsen:support-non-ascii-commandline-args 673d575
PiperOrigin-RevId: 568722987
Copy link
Member

@JanKrivanek JanKrivanek left a comment

Choose a reason for hiding this comment

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

LGTM

@JanKrivanek JanKrivanek merged commit 10d39e9 into dotnet:main Oct 5, 2023
bulatgrzegorz pushed a commit to bulatgrzegorz/selective-condition-evaluator that referenced this pull request Oct 16, 2023
On windows there can be problems with Tools that do not support Unicode
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.

[Feature Request]: Make it easier for overriding ToolTask temp rsp location
6 participants