Skip to content

Commit b6ab60c

Browse files
committed
nar: add note for permissions logic on macos
1 parent 7215ce8 commit b6ab60c

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

hnix-store-nar/src/System/Nix/Nar/Effects.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,20 @@ streamStringOutIO f executable getChunk =
123123
"Failed to stream string to " <> f <> ": " <> show e
124124

125125
-- | Check whether the file is executable by the owner.
126+
--
127+
-- Matches the logic used by Nix.
128+
--
129+
-- access() should not be used for this purpose on macOS.
130+
-- It returns false for executables when placed in certain directories.
131+
-- For example, when in an app bundle: App.app/Contents/Resources/en.lproj/myexecutable.strings
126132
isExecutable :: FileStatus -> Bool
127133
isExecutable st =
128134
isRegularFile st
129135
&& fileMode st `intersectFileModes` ownerExecuteMode /= nullFileMode
130136

131137
-- | Set the file to be executable by the owner, group, and others.
138+
--
139+
-- Matches the logic used by Nix.
132140
setExecutable :: FilePath -> IO ()
133141
setExecutable f = do
134142
st <- getSymbolicLinkStatus f

hnix-store-nar/tests/NarFormat.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ unit_nixStoreDirectory' :: HU.Assertion
145145
unit_nixStoreDirectory' = filesystemNixStore "directory'" (Nar sampleDirectory')
146146

147147
-- | Test that the executable permissions are handled correctly in app bundles on macOS.
148+
-- In this case, access() returns false for a file under this specific path, even when the executable bit is set.
149+
-- NAR implementations should avoid this syscall on macOS.
148150
test_nixStoreMacOSAppBundle :: TestTree
149151
test_nixStoreMacOSAppBundle = packThenExtract "App.app" $ \ baseDir -> do
150152
let testDir = baseDir </> "App.app" </> "Resources" </> "en.lproj"

0 commit comments

Comments
 (0)