-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix nuget config not being honored #20930
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel suspicious about the hardcoded /tmp/dotnet_sudo_home/
— what if that directory has been maliciously created by a different, unprivileged user, who still has write access — but perhaps that was discussed in another PR.
Environment.SetEnvironmentVariable("HOME", SudoHomeDirectory); | ||
|
||
CopyUserNuGetConfigToOverridenHome(homeBeforeOverride); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spelling is "overridden".
@@ -33,7 +37,57 @@ public static void OverrideEnvironmentVariableToTmp(ParseResult parseResult) | |||
if (!OperatingSystem.IsWindows() && IsRunningUnderSudo() && IsRunningWorkloadCommand(parseResult)) | |||
{ | |||
Directory.CreateDirectory(SudoHomeDirectory); | |||
|
|||
var homeBeforeOverride = Path.Combine(Environment.GetEnvironmentVariable("HOME")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I must have missed this in the first check in of this change, but directly using the HOME env var doesn't match the logic we use for calculating the home dir here: https://github.com/dotnet/sdk/blob/release/6.0.1xx/src/Common/CliFolderPathCalculatorCore.cs#L35, should we be taking those other env vars into account?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine. If the user override the home directory, they are in control of the situation. We just need to make sure the default make sense.
Copy user level nuget config to override folder
4e53840
to
d38e558
Compare
@sfoslund looks good? |
@KalleOlaviNiemitalo thank you. I added logic to ensure the owner is root |
01d5f50
to
cb31351
Compare
@wli3 |
private static bool IsOtherUserWritable(StatInterop.FileStatus fileStat) | ||
{ | ||
return (fileStat.Mode & (int) StatInterop.Permissions.S_IWOTH) == 0; | ||
} | ||
|
||
private static bool IsGroupWritable(StatInterop.FileStatus fileStat) | ||
{ | ||
return (fileStat.Mode & (int) StatInterop.Permissions.S_IWGRP) == 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The names of these methods are misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you give me more detail? Any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joeloff @KalleOlaviNiemitalo now I get it. Rename to "...CannotWrite"
cb31351
to
d239c27
Compare
d239c27
to
e4cce51
Compare
b508d9d
to
ce76b1d
Compare
@joeloff could I get an approval if the change looks good? |
ce76b1d
to
54f18e9
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Copy user level nuget config to override folder
Tested end to end locally. Pretty hard to add unit test for permission code