Repository navigation
Closed
Milestone
Description
The tarball generated by cabal new-sdist comes with several *.txt files having a +x file permission set even though these files don't have that bit set in the source directory they were pulled from. See the permissions of README.txt for example:
/tmp $ gcl git://github.com/Deewiant/glob.git
Cloning into 'glob'...
remote: Enumerating objects: 54, done.
remote: Counting objects: 100% (54/54), done.
remote: Compressing objects: 100% (35/35), done.
remote: Total 1939 (delta 19), reused 41 (delta 13), pack-reused 1885
Receiving objects: 100% (1939/1939), 248.79 KiB | 683.00 KiB/s, done.
Resolving deltas: 100% (1037/1037), done.
/tmp $ cd glob
/tmp/glob $ cabal new-sdist
Wrote tarball sdist to /tmp/glob/dist-newstyle/sdist/Glob-0.10.0.tar.gz
/tmp/glob $ tar tfv dist-newstyle/sdist/Glob-0.10.0.tar.gz
drwxr-xr-x 0/0 0 2001-09-09 03:46 Glob-0.10.0/
-rwxr-xr-x 0/0 9294 2001-09-09 03:46 Glob-0.10.0/CHANGELOG.txt
-rwxr-xr-x 0/0 112 2001-09-09 03:46 Glob-0.10.0/CREDITS.txt
-rw-r--r-- 0/0 2933 2001-09-09 03:46 Glob-0.10.0/Glob.cabal
-rw-r--r-- 0/0 1651 2001-09-09 03:46 Glob-0.10.0/LICENSE.txt
-rwxr-xr-x 0/0 746 2001-09-09 03:46 Glob-0.10.0/README.txt
-rw-r--r-- 0/0 46 2001-09-09 03:46 Glob-0.10.0/Setup.hs
drwxr-xr-x 0/0 0 2001-09-09 03:46 Glob-0.10.0/System/FilePath/
-rw-r--r-- 0/0 2378 2001-09-09 03:46 Glob-0.10.0/System/FilePath/Glob.hs
drwxr-xr-x 0/0 0 2001-09-09 03:46 Glob-0.10.0/System/FilePath/Glob/
-rw-r--r-- 0/0 25538 2001-09-09 03:46 Glob-0.10.0/System/FilePath/Glob/Base.hs
-rw-r--r-- 0/0 16160 2001-09-09 03:46 Glob-0.10.0/System/FilePath/Glob/Directory.hs
-rw-r--r-- 0/0 7260 2001-09-09 03:46 Glob-0.10.0/System/FilePath/Glob/Match.hs
-rw-r--r-- 0/0 2183 2001-09-09 03:46 Glob-0.10.0/System/FilePath/Glob/Primitive.hs
-rw-r--r-- 0/0 1477 2001-09-09 03:46 Glob-0.10.0/System/FilePath/Glob/Simplify.hs
-rw-r--r-- 0/0 4911 2001-09-09 03:46 Glob-0.10.0/System/FilePath/Glob/Utils.hs
drwxr-xr-x 0/0 0 2001-09-09 03:46 Glob-0.10.0/tests/
-rw-r--r-- 0/0 890 2001-09-09 03:46 Glob-0.10.0/tests/Main.hs
drwxr-xr-x 0/0 0 2001-09-09 03:46 Glob-0.10.0/tests/Tests/
-rw-r--r-- 0/0 2462 2001-09-09 03:46 Glob-0.10.0/tests/Tests/Base.hs
-rw-r--r-- 0/0 1221 2001-09-09 03:46 Glob-0.10.0/tests/Tests/Compiler.hs
-rw-r--r-- 0/0 5553 2001-09-09 03:46 Glob-0.10.0/tests/Tests/Directory.hs
-rw-r--r-- 0/0 2290 2001-09-09 03:46 Glob-0.10.0/tests/Tests/Instances.hs
-rw-r--r-- 0/0 2702 2001-09-09 03:46 Glob-0.10.0/tests/Tests/Matcher.hs
-rw-r--r-- 0/0 1724 2001-09-09 03:46 Glob-0.10.0/tests/Tests/Optimizer.hs
-rw-r--r-- 0/0 5534 2001-09-09 03:46 Glob-0.10.0/tests/Tests/Regression.hs
-rw-r--r-- 0/0 1034 2001-09-09 03:46 Glob-0.10.0/tests/Tests/Simplifier.hs
-rw-r--r-- 0/0 1632 2001-09-09 03:46 Glob-0.10.0/tests/Tests/Utils.hs
/tmp/glob $ ls -l *.txt
-rw-r--r-- 1 simons users 9294 Dec 22 21:36 CHANGELOG.txt
-rw-r--r-- 1 simons users 112 Dec 22 21:36 CREDITS.txt
-rw-r--r-- 1 simons users 1651 Dec 22 21:36 LICENSE.txt
-rw-r--r-- 1 simons users 746 Dec 22 21:36 README.txt
/tmp/glob $ cabal --version
cabal-install version 2.4.1.0
compiled using version 2.4.1.0 of the Cabal library
Metadata
Metadata
Assignees
Labels
No labels
Activity
typedrat commentedon Dec 22, 2018
That's just down to how it works internally, and I believe that
v1-sdistdoes the same.peti commentedon Dec 22, 2018
Making
README.txtan executable file doesn't seem like a good idea, though. Does it?typedrat commentedon Dec 22, 2018
It only matters if the user actually runs it... I suggest not running random
.txtfiles in temp directories because you see they have the executable permission.peti commentedon Dec 22, 2018
Many Linux distributions have sophisticated QA mechanisms that prevent packages from doing stuff like installing executable files into
/usr/share, etc. This weird feature breaks all those Haskell builds in openSUSE: https://build.opensuse.org/package/live_build_log/devel:languages:haskell:ghc-8.6.x/ghc-Glob/openSUSE_Tumbleweed/x86_64. That can't be a good thing, no?typedrat commentedon Dec 23, 2018
The patch is trivial, anyway. Instead of setting every potentially executable file as executable, check the current execute permissions and continue those forward.
RyanGlScott commentedon Dec 12, 2019
Humorously enough, using
cabal getto obtain a Hackage tarball "works around" this issue. This is because using thetarlibrary'sunpackfunction to unpack a tarball (ascabal-installdoes) causes executable permissions to be stripped away as a result of haskell/tar#25.asr commentedon Dec 21, 2019
No,
v1-sdist(oncabal-install 2.4.1.0) doesn't add executable permission to *.txt files.RyanGlScott commentedon Dec 21, 2019
Nor does
v1-sdistadd executable permissions oncabal-install-3.0.1.0.v1-sdistandv2-sdistappear to have very different code paths. Here is howv1-sdistwrites a tarball:cabal/Cabal/Distribution/Simple/SrcDist.hs
Lines 430 to 438 in 787b1f2
And here is how
v2-sdistwrites a tarball:cabal/cabal-install/Distribution/Client/CmdSdist.hs
Line 287 in f580d39
So
v1-distshells out to thetarprogram whilev2-sdistuses the Haskelltarlibrary. Perhaps the use of thetarlibrary is why this code has to go through so much trouble to try and manually set file permissions in the first place? (Especially in light of haskell/tar#25.)asr commentedon Dec 21, 2019
cabal-install-3.0.1.0? Did you meancabal-install-3.0.0.0?typedrat commentedon Dec 21, 2019
@RyanGlScott it's not optional, sadly. Relying on whatever
tarprogram is to hand does not give us the level of control we require forv2-sdist. Like I said in a comment last year(!), there's an easy fix, I can try and get a PR in this weekend.Fix `v2-sdist` permissions
RyanGlScott commentedon Dec 21, 2019
@asr:
No, I meant
cabal-install-3.0.1.0:I'm using
cabal-install-3.0obtained from https://launchpad.net/~hvr/+archive/ubuntu/ghc.@typedrat:
I'm not sure I understand how the fix works. From , you say:
However, looking at the implementation:
cabal/cabal-install/Distribution/Client/CmdSdist.hs
Lines 259 to 261 in f580d39
It looks like
v2-sdistalways sets each file to have eitherexecutableFilePermissions(i.e.,rwxr-xr-x) orordinaryFilePermissions(i.e.,rw-r--r--). What happens to files that don't use either of these two predefined sets of permissions?phadej commentedon Dec 21, 2019
Note,
Cabaldoesn't usetarlibrary because it cannot depend on it due build system reasons.Does we have tests that
Cabalsdist andcabal-installsdist produce the same tarballs (module something irrelevant)?Ultimately, this should be also checked on upload on Hackage, so no tarballs with executable bits are uploaded at all, as whoever can package
.tar.gzand upload it. (E.g.Cabalis manually assembled, I have no idea whatstackdoes etc.)I.e. omitting the file permissions on unpack sounds very right thing to do.
In that light, as I commented on the PR, I don't see a reason from not setting any permissions at all, just 644 for files and 655 for directories unconditionally. Bundling native binaries is just wrong, and scripts can be run by invoking their interpreter (like is done with
configure).juhp commentedon Dec 26, 2019
I tend to disagree: I don't see a reason to strip intended executable permissions from scripts: though I certainly prefer everything 644 to everything 755...
I think distros don't use
cabal-installbuttarto unpack.Fix `v2-sdist` permissions
Fix `v2-sdist` permissions
juhp commentedon Apr 14, 2020
Thank you
So I was trying to reproduce this to test the fix (but I need to work slightly harder to backport it to 2.4 for Fedora), and so far I found that the original problem occurs for
Extra-Source-Files(maybe they were assumed to be scripts?) but notExtra-Doc-Files.Spec: fix permissions of extra-source-files (haskell/cabal#5813)
juhp commentedon Jun 1, 2020
I finally tested this and can confirm that the issue is fixed, thank you!
juhp commentedon Jun 4, 2020
Also if it helps others I backported the fix to cabal-install-2.4.1.0 in Fedora:
https://src.fedoraproject.org/rpms/cabal-install/blob/master/f/cabal-install-sdist-file-permissions.patch
juhp commentedon Feb 1, 2021
(It is a little sad that this didn't even get into cabal-install-3.2.)