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

extracting tar.gz archive doesn't preserve permissions #1864

Closed
3 tasks done
xfzv opened this issue Oct 30, 2024 · 5 comments
Closed
3 tasks done

extracting tar.gz archive doesn't preserve permissions #1864

xfzv opened this issue Oct 30, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@xfzv
Copy link

xfzv commented Oct 30, 2024

What system are you running Yazi on?

Linux X11

What terminal are you running Yazi in?

kitty 0.36.4

yazi --debug output

Yazi
    Version: 0.3.3 (c668723 2024-10-30)
    Debug  : false
    OS     : linux-x86_64 (unix)

Ya
    Version: 0.3.3 (c668723 2024-10-30)

Emulator
    Emulator.via_env: ("xterm-kitty", "")
    Emulator.via_csi: Ok(Kitty)
    Emulator.detect : Kitty

Adapter
    Adapter.matches: Kgp

Desktop
    XDG_SESSION_TYPE           : Some("tty")
    WAYLAND_DISPLAY            : None
    DISPLAY                    : Some(":0")
    SWAYSOCK                   : None
    HYPRLAND_INSTANCE_SIGNATURE: None
    WAYFIRE_SOCKET             : None

SSH
    shared.in_ssh_connection: false

WSL
    WSL: false

Variables
    SHELL              : Some("/bin/zsh")
    EDITOR             : Some("nvim")
    VISUAL             : Some("nvim")
    YAZI_FILE_ONE      : None
    YAZI_CONFIG_HOME   : None

Text Opener
    default     : Some(Opener { run: "${EDITOR} \"$@\"", block: true, orphan: false, desc: "Neovim", for_: None, spread: true })
    block-create: Some(Opener { run: "${EDITOR} \"$@\"", block: true, orphan: false, desc: "Neovim", for_: None, spread: true })
    block-rename: Some(Opener { run: "${EDITOR} \"$@\"", block: true, orphan: false, desc: "Neovim", for_: None, spread: true })

Multiplexers
    TMUX               : false
    tmux version       : No such file or directory (os error 2)
    tmux build flags   : enable-sixel=Unknown
    ZELLIJ_SESSION_NAME: None
    Zellij version     : No such file or directory (os error 2)

Dependencies
    file             : 5.45
    ueberzugpp       : No such file or directory (os error 2)
    ffmpegthumbnailer: 2.2.2
    magick           : 7.1.1-38
    fzf              : 0.54.3
    fd               : 10.2.0
    rg               : 14.1.1
    chafa            : No such file or directory (os error 2)
    zoxide           : 0.9.6
    7z               : 17.05
    7zz              : No such file or directory (os error 2)
    jq               : 1.7.1


--------------------------------------------------
When reporting a bug, please also upload the `yazi.log` log file - only upload the most recent content by time.
You can find it in the "/home/xfzv/.local/state/yazi" directory.

Describe the bug

When extracting a .tar.gz archive, directories and files permissions from the archive aren't preserved. After extraction, directories all have 700 permissions and files all have 644 permissions.

This could be avoided by using tar -p, --preserve-permissions option.

Minimal reproducer

  1. Compress any directory with at least e.g an executable (755 permissions) and any other kind of file with 600 permissions to a tar.gz archive
  2. Hover the archive and extract it with <Enter>
  3. Go to the extracted directory
  4. All directories have 700 permissions instead of 755 ; all files have 644 permissions
  5. Delete the extracted directory and extract the archive again with tar -p, --preserve-permissions option: tar -pxvzf or with Ark
  6. Go to the extracted directory
  7. All permissions are identical to those inside the archive

Anything else?

No response

Validations

  • I tried the latest nightly build, and the issue is still reproducible
  • I updated the debug information (yazi --debug) input box to the nightly that I tried
  • I can reproduce it after disabling all custom configs/plugins (mv ~/.config/yazi ~/.config/yazi-backup)
@xfzv xfzv added the bug Something isn't working label Oct 30, 2024
@sxyazi
Copy link
Owner

sxyazi commented Oct 30, 2024

Yazi uses 7zip instead of tar to extract tar.gz files to avoid adding new dependencies. I did a quick search, and it seems like there's no switch to preserve this information during extraction, which likely means that 7zip doesn't support it. Let me know if I'm wrong!

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label Oct 30, 2024
@xfzv
Copy link
Author

xfzv commented Oct 30, 2024

Indeed, 7zip cannot preserve permissions. Quoting Wikipedia 7z page - Limitations:

The 7z format does not store filesystem permissions (such as UNIX owner/group permissions or NTFS ACLs), and hence can be inappropriate for backup/archival purposes.

I guess this also applies when extracting tar.gz archives, hence the issue.

Yazi uses 7zip instead of tar to extract tar.gz files to avoid adding new dependencies.

tar is installed by default on pretty much any Linux distro and also on macOS. It seems that it's also available in recent Microsoft Windows versions so I guess it wouldn't hurt using it over 7zip for all tar archives?

What about using tar if available and 7zip as fallback if it's not?

@github-actions github-actions bot removed the waiting on op Waiting for more information from the original poster label Oct 30, 2024
@sxyazi
Copy link
Owner

sxyazi commented Oct 30, 2024

My main concern about doing this is that they're not interchangeable alternatives; tar and 7zip don't behave the same way, which adds more uncertainty and confusion.

For example, when users report a problem with tar.gz files, we'd have to ask them every time which one they used. Or when users use Yazi on a new system, they might forget to install tar and fall back to 7zip, only to be surprised by the inconsistent behavior.

Plus, since I plan to eventually implement my own extraction tool to replace 7zip (along with the feature of "open archives as directories" listed in feature requests) and right now 7zip is just a temporary solution, I'm not too keen on spending too much time adding new features, especially if those features are just for something that will eventually be discarded.

@xfzv
Copy link
Author

xfzv commented Oct 30, 2024

Plus, since I plan to eventually implement my own extraction tool to replace 7zip and right now 7zip is just a temporary solution, I'm not too keen on spending too much time adding new features, especially if those features are just for something that will eventually be discarded.

I didn't know about that upcoming extraction tool, I completely agree with you in this case. I assume it will handle permissions correctly.

Feel free to close this. In the meantime, I'll just extract manually with tar.

Thanks!

@sxyazi
Copy link
Owner

sxyazi commented Oct 31, 2024

OK close for now. If I still don't have enough time to finish my own extraction tool this year, I'll reconsider the idea of using tar

@sxyazi sxyazi closed this as not planned Won't fix, can't repro, duplicate, stale Oct 31, 2024
@sxyazi sxyazi added enhancement New feature or request and removed bug Something isn't working labels Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants