Zip decompression throws "permission denied" when archive directory does not have write permission #29

Open
opened 2025-04-09 14:58:22 +00:00 by tcsenpai · 0 comments
Owner

Originally created by @rcorre on 12/27/2024

Version

ouch 0.5.1

Description

ouch d fails to decmpress an archive where a folder does not have write permission. unzip is able to decompress the same archive.

❯ tree -p example
[drwx------]  example
└── [dr-x------]  foo
    └── [-rw-------]  bar

❯ ouch c example/ example.zip
[INFO] Compressing 'example'.
[INFO] Compressing 'example/foo'.
[INFO] Compressing 'example/foo/bar'.
[INFO] Successfully compressed 'example.zip'.

❯ ouch d example.zip -d out
[INFO] Directory out created.
[INFO] Created temporary directory /tmp/out/.tmpYlmrmN to hold decompressed elements.
[INFO] File 0 extracted to "/tmp/out/.tmpYlmrmN/example/"
[INFO] File 1 extracted to "/tmp/out/.tmpYlmrmN/example/foo/"
[INFO] "out/.tmpYlmrmN/example/foo/bar" extracted. (0 B)
[ERROR] failed to create file `out/.tmpYlmrmN/example/foo/bar`
 - Permission denied

❯ unzip example.zip -d out
Archive:  example.zip
   creating: out/example/
   creating: out/example/foo/
  inflating: out/example/foo/bar     

example.zip

Note that unzip does mirror the permissions in the resulting directory:

❯ tree -p out/
[drwx------]  out/
└── [drwx------]  example
    └── [dr-x------]  foo
        └── [-rw-------]  bar

I'm guessing that unzip unpacks everything in a directory before setting that directory's permisions, whereas ouch is setting permissions on a directory before it tries to write that directory's children.

Current Behavior

No response

Expected Behavior

No response

Additional Information

No response

*Originally created by @rcorre on 12/27/2024* ### Version ouch 0.5.1 ### Description `ouch d` fails to decmpress an archive where a folder does not have write permission. `unzip` is able to decompress the same archive. ``` ❯ tree -p example [drwx------] example └── [dr-x------] foo └── [-rw-------] bar ❯ ouch c example/ example.zip [INFO] Compressing 'example'. [INFO] Compressing 'example/foo'. [INFO] Compressing 'example/foo/bar'. [INFO] Successfully compressed 'example.zip'. ❯ ouch d example.zip -d out [INFO] Directory out created. [INFO] Created temporary directory /tmp/out/.tmpYlmrmN to hold decompressed elements. [INFO] File 0 extracted to "/tmp/out/.tmpYlmrmN/example/" [INFO] File 1 extracted to "/tmp/out/.tmpYlmrmN/example/foo/" [INFO] "out/.tmpYlmrmN/example/foo/bar" extracted. (0 B) [ERROR] failed to create file `out/.tmpYlmrmN/example/foo/bar` - Permission denied ❯ unzip example.zip -d out Archive: example.zip creating: out/example/ creating: out/example/foo/ inflating: out/example/foo/bar ``` [example.zip](https://github.com/user-attachments/files/18260654/example.zip) Note that `unzip` does mirror the permissions in the resulting directory: ``` ❯ tree -p out/ [drwx------] out/ └── [drwx------] example └── [dr-x------] foo └── [-rw-------] bar ``` I'm guessing that `unzip` unpacks everything in a directory before setting that directory's permisions, whereas `ouch` is setting permissions on a directory before it tries to write that directory's children. ### Current Behavior _No response_ ### Expected Behavior _No response_ ### Additional Information _No response_
tcsenpai added the
bug
bug
bug
bug
bug
labels 2025-04-09 14:58:22 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/ouch#29
No description provided.