Skip to content

ZipFile.ExtractToDirectory causes faulty permissions with pinned files #94465

Open
@BaerMitUmlaut

Description

@BaerMitUmlaut

Description

When unpacking certain ZIP files on Linux that were packed on Windows and had the "pinned" attribute set (example file), ZipFile.ExtractToDirectory will cause the file to only have execute permissions (------x---).

Reproduction Steps

  • Pick any file
  • Set the "pinned" attribute through cmd: attrib +p filename
  • Pack as a ZIP file using 7zip (packing through Windows does not preserve the "pinned" attribute)
  • Unpack the file on Linux (or in a WSL owned folder like /tmp) using the following code:
    public class Program
    {
        private static void Main(string[] args)
        {
            ZipFile.ExtractToDirectory(args[0], args[0].Replace(".zip", ""), Encoding.UTF8);
        }
    }
  • Verify the files permissions using ls -l:
    $ ls -l /tmp/dotnet
    total 28
    ------x--- 1 foobar foobar 24783 Nov  7 13:41 dotnet.jpg
    

Expected behavior

The permissions should be -rw-r--r--, like any file that did not have the "pinned" attribute set when it was packed.

Actual behavior

Read and write permissions are missing and an excutable permission is set (------x---).

Regression?

No response

Known Workarounds

Repacking the ZIP through the Windows packing tools or unsetting the "pinned" flag fixes the problem but cannot be done through code.

Configuration

  • .NET 6.0
  • Windows 10 / Ubuntu 20.04 in WSL

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions