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

Set execute permission when extracting files. #1346

Merged
merged 1 commit into from
May 2, 2017

Conversation

tmds
Copy link
Contributor

@tmds tmds commented Apr 28, 2017

@tmds
Copy link
Contributor Author

tmds commented Apr 28, 2017

CC @rrelyea @eerhardt

@@ -85,5 +87,23 @@ public static void UpdateFileTimeFromEntry(this ZipArchiveEntry entry, string fi
}
}
}

public static void UpdateFilePermissionsFromEntry(this ZipArchiveEntry entry, string fileFullPath, ILogger logger)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I gave it the same visibility as UpdateFileTimeFromEntry. Should I make it internal or leave it public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eerhardt bump -^

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not really my call. @emgarten?

Copy link
Member

Choose a reason for hiding this comment

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

There are a lot of public APIs like this in the nuget libraries so I think this is fine.

Copy link
Contributor

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

Looks great to me.

Thanks for the contribution!

// The default on .NET Core 2.x has changed to 666.
// To avoid breaking executable files in existing packages (which don't have the x-bit set)
// we force the .NET Core 1.x default permissions.
chmod(fileFullPath, 0x1f6); // 0766
Copy link
Member

Choose a reason for hiding this comment

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

Should all files get this or should it be limited to .dll extensions only? Was this previously being set for everything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was set for all files. Not having the execute bit breaks native executables and scripts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually .dll .net libraries don't need the 'x' flag at all since the OS doesn't execute them. What is needed is things like apphost which doesn't have an extension and somescript.sh which does have an extension. Honestly I don't think we should be doing extension based checking, it would be very hard to get it right.

Was this previously being set for everything?

Yes. See https://github.com/dotnet/corefx/blob/release/1.1.0/src/System.IO.FileSystem/src/System/IO/UnixFileStream.cs#L116-L123

In 2.0, the code now lives here: https://github.com/dotnet/coreclr/blob/532c45a27aa2f804ed43448ef1666beeef6c96ae/src/mscorlib/shared/System/IO/FileStream.Unix.cs#L50-L57

@eerhardt
Copy link
Contributor

eerhardt commented May 1, 2017

@rrelyea @emgarten - thoughts?

@emgarten
Copy link
Member

emgarten commented May 2, 2017

Looks great to me, thanks for the PR @tmds!

I'll run this on the Linux and OSX CIs to verify there are no issues and then I'll merge this into dev for NuGet 4.3.0.

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.

4 participants