Skip to content

Set Owner Permissions on extracted files - #26

Merged
emilypi merged 4 commits into
haskell:masterfrom
tmortiboy:master
Apr 12, 2021
Merged

emilypi merged 4 commits into
haskell:masterfrom
tmortiboy:master

Conversation

@tmortiboy

Copy link
Copy Markdown
Contributor

Fixes Issue 25: Extracted executable files do not have the executable flag set.

I've used setPermission from System.Directory as this is a portable way to set the owner permissions and requires no extra dependencies.

Even before I made my changes, I cant get the property tests to pass and not sure whats broken there.

@hvr

hvr commented Mar 9, 2018

Copy link
Copy Markdown
Member

@tmortiboy if you rebase this to master, the test-suite should work again

@tmortiboy

Copy link
Copy Markdown
Contributor Author

@hvr tests are now passing.

@hvr
hvr requested a review from dcoutts March 9, 2018 14:42
@hvr hvr added this to the 0.6 milestone Mar 9, 2018
@hvr

hvr commented Mar 9, 2018 •

Copy link
Copy Markdown
Member

One thing I'm not sure about is that tar is currently advertised as

It provides support for packing and unpacking portable archives. This makes it suitable for distribution but not backup because details like file ownership and exact permissions are not preserved.

which seems to imply this was a deliberate design choice to omit restoring permissions. So maybe a compromise would be to make this behaviour configurable.

I'm waiting for @dcoutts to chime in...

@mikemckibben

Copy link
Copy Markdown
Contributor

As a user of the tar package, I find this patch useful (which is why I looked into fixing the test suite). Can the setOwnerPermissions also be called for the extractDir case to handle directories?

@hasufell

hasufell commented Feb 19, 2020 •

Copy link
Copy Markdown
Member

Why is this PR still not merged (or declined)? It's been 2 years.

which seems to imply this was a deliberate design choice to omit restoring permissions. So maybe a compromise would be to make this behaviour configurable.

It says "exact permissions are not preserved", not that none are preserved. tar (the cli tool) does preserve the executable bit.

https://hackage.haskell.org/package/tar-bytestring-0.6.1.3/docs/Codec-Archive-Tar.html#v:create specifically talks about the executable bit for creating tars. But then extract throws it away, which doesn't make sense.

hasufell added a commit to hasufell/tar-bytestring that referenced this pull request Feb 19, 2020
This fixes haskell#26
from upstream, but cleaner, since we don't need to use directory package.
@tmortiboy

Copy link
Copy Markdown
Contributor Author

@dcoutts I think @hvr was waiting for your thoughts on my proposal please.

@hasufell

hasufell commented Apr 2, 2021

Copy link
Copy Markdown
Member

@Bodigrim @emilypi

Comment thread Codec/Archive/Tar/Unpack.hs Outdated
unpackEntries links Done = return links
unpackEntries links (Next entry es) = case entryContent entry of
NormalFile file _ -> extractFile path file mtime
NormalFile file _ -> extractFile entry path file mtime

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If extractFile uses only entryPermissions entry, could we please make it explicit by passing this field only instead of whole entry?

where
#if MIN_VERSION_directory(1,1,0)
ownerPermissions =
setOwnerReadable (testBit permissions 8) $

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. Let's float parsing permissions out of CPP conditions.
  2. It would be nice to quote a source of magic numbers in comments. Not sure which is the best one, maybe https://www.gnu.org/software/libc/manual/html_node/Permission-Bits.html.

@hasufell

hasufell commented Apr 4, 2021

Copy link
Copy Markdown
Member

@Bodigrim I suggest to just fix up the existing PRs (#42 as well) and merge them. Most PR authors have probably moved on after that time. This doesn't look like it needs major intervention from the author.

@Bodigrim

Bodigrim commented Apr 4, 2021 •

Copy link
Copy Markdown
Contributor

@hasufell Unfortunately I have a limited bandwidth to do work myself, but yes, if @tmortiboy has lost interest (which is quite understandable after all this time), we should make amends from our side next week.

I'm pretty nervous about testing, to be honest. This PR is probably reasonably simple to proceed as is, but stuff like #42 needs regression tests.

@tmortiboy

Copy link
Copy Markdown
Contributor Author

Happy to make the requested changes. Just need a few days to find some time. Thanks!

@Bodigrim
Bodigrim requested a review from emilypi April 9, 2021 17:31
@emilypi
emilypi merged commit 602dfc0 into haskell:master Apr 12, 2021
@Bodigrim

Copy link
Copy Markdown
Contributor

Thanks @tmortiboy!

SamirTalwar added a commit to SamirTalwar/smoke that referenced this pull request Aug 7, 2022
This was a bug in the `tar` package that is fixed in
haskell/tar#26. However, this code has not been
released, so we need to grab the latest commit instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

extract/unpack does not preserve executable files

6 participants