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

Figure out how to deal with inaccessible parent directories #40

Open
Stebalien opened this issue Feb 7, 2018 · 3 comments
Open

Figure out how to deal with inaccessible parent directories #40

Stebalien opened this issue Feb 7, 2018 · 3 comments

Comments

@Stebalien
Copy link
Owner

So, unix really is lovely...

> mkdir -p /foo/bar
> cd /foo/bar
> chmod a-x /foo
> touch first
> touch /foo/bar/second
touch: cannot touch '/foo/bar/second': Permission denied

As written, this library has the same problem as the second case. We use the absolute path when creating temporary files instead of the relative path. I believe this can actually be an issue in practice with some jails.

Fixing this on linux is doable with openat and unlinkat. Fixing this on osx is possible using per-thread CWDs (at the cost of two extra syscalls to set/unset the thread-local CWD).

@tbu-
Copy link

tbu- commented Jul 21, 2018

According to What non-Linux Unixes support openat? from StackOverflow:

[…], all major BSDs and Apple's OS X seem to support [openat] as of today:

  • DragonFly since DragonFly 2.3.
  • FreeBSD since FreeBSD 8.0.
  • Linux since Linux 2.6.16 (for completeness).
  • NetBSD since NetBSD 7.0.
  • OpenBSD since OpenBSD 5.0.
  • OS X since OS X 10.10.
  • Solaris.

@Stebalien
Copy link
Owner Author

Ah. The information I was looking at was from 2011. Good to know.

@rbtcollins
Copy link
Contributor

fs_at is a new crate I created as part of fixing the TOCTOU remove_dir_all inherited from the std::fs::remove_dir_all it was based on years ago; it uses NTCreateFile on windows and openat on unix - my intent for it is to be a medium-level crate: no sophisticated features or policy choices, just convenient access to 'at' style syscalls. If its not suitable for solving this bug, I'd like to know why so I can fix it.

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

No branches or pull requests

3 participants