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

way to prevent openDirStream from following symlinks #134

Closed
joeyh opened this issue Jun 24, 2019 · 6 comments · Fixed by #110
Closed

way to prevent openDirStream from following symlinks #134

joeyh opened this issue Jun 24, 2019 · 6 comments · Fixed by #110

Comments

@joeyh
Copy link

joeyh commented Jun 24, 2019

haskell/directory#97 needs a way to list the content of a directory that avoids following a symlink. The unix way to do that is open with O_NOFOLLOW and then passing the fd to fdopendir. This library does not provide a way to do that; could it?


One way would be to add

openDirStreamFromFd :: Fd -> IO DirStream

But that is fairly low-level. The user needs to take care to avoid reusing the Fd after calling it. Also, while some of the OpenFileFlags may make sense for opening a directory, most of them probably don't. And the user would need to take care to set O_CLOEXEC to avoid a possible fd leak.

This interface would avoid those problems (pass O_CLOEXEC always):

data OpenDirFlags = OpenDirFlags { dir_nofollow :: Bool, ... }

openDirStream' :: OpenDirFlags -> IO DirStream

Assuming this is exported from the same module as OpenFileFlags, the fields in OpenDirFlags need to be qualified to avoid name conflicts. Or OpenFileFlags could be used for openDirStream', but a number of those flags don't make sense for opening a directory.

Also openDirStream could be changed to take such an OpenDirFlags, if an API bump appeals.

I'd be happy to implement whichever of these you prefer.

@hasufell
Copy link
Member

hasufell commented Jan 5, 2020

Seems there already is a PR: #110

@Rufflewind
Copy link
Member

Rufflewind commented Jan 5, 2020

Sorry, posted on the wrong thread. Moved to: haskell/directory#97 (comment)

@Bodigrim Bodigrim linked a pull request Apr 11, 2022 that will close this issue
@hs-viktor
Copy link
Contributor

With #110 merged, can we close this?

@Rufflewind
Copy link
Member

Are there plans to release #110 any time soon? directory is unable to use the new functionality to resolve haskell/directory#97 if the changes aren't released.

@Bodigrim
Copy link
Contributor

Yes, we are likely to make a release soon (but not immediately).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants