Fix permissions when packaging artifacts
The file permissions in our cross platform packages were all over the place. Problems included: - Executable text files - Executable MSIL files - Files not readable by world or group In addition to just looking bad, it could cause problems in cases where someone takes the tarballs and copies them to a global location (as root) because now the deps file was not readable by non root users. Add an additional step when setting everything up to put sensible permissions on everything before building os specific packages and tarballs. Fixes #2004
This commit is contained in:
parent
156f83c3bc
commit
d343519567
1 changed files with 17 additions and 0 deletions
|
@ -61,6 +61,8 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
Directory.CreateDirectory(cliSdkRoot);
|
||||
Utils.CopyDirectoryRecursively(Path.Combine(Dirs.Stage2, "sdk"), cliSdkRoot, true);
|
||||
FixPermissions(cliSdkRoot);
|
||||
|
||||
c.BuildContext["CLISDKRoot"] = cliSdkRoot;
|
||||
return c.Success();
|
||||
}
|
||||
|
@ -81,6 +83,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
var destFile = file.Replace(Dirs.Stage2, sharedHostRoot);
|
||||
File.Copy(file, destFile, true);
|
||||
}
|
||||
FixPermissions(sharedHostRoot);
|
||||
|
||||
c.BuildContext["SharedHostPublishRoot"] = sharedHostRoot;
|
||||
return c.Success();
|
||||
|
@ -97,6 +100,8 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
Directory.CreateDirectory(sharedFxRoot);
|
||||
Utils.CopyDirectoryRecursively(Path.Combine(Dirs.Stage2, "shared"), sharedFxRoot, true);
|
||||
FixPermissions(sharedFxRoot);
|
||||
|
||||
c.BuildContext["SharedFrameworkPublishRoot"] = sharedFxRoot;
|
||||
return c.Success();
|
||||
}
|
||||
|
@ -242,5 +247,17 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
}
|
||||
|
||||
private static void FixPermissions(string directory)
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
// Reset everything to user readable/writeable and group and world readable.
|
||||
FS.ChmodAll(directory, "*", "644");
|
||||
|
||||
// Now make things that should be executable, executable.
|
||||
FS.FixModeFlags(directory);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue