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

Use absolute paths #80

Merged
merged 2 commits into from
Feb 11, 2019
Merged

Use absolute paths #80

merged 2 commits into from
Feb 11, 2019

Conversation

Stebalien
Copy link
Owner

When looking into #40, I realized we weren't actually doing what I claimed. Except for never-named tempfiles on Linux and auto-removed temporary files on Windows, we need to use absolute path names to guard against changes in the current working directory.

Unfortunately, this is a [breaking change] on some unix-like OSs. It's possible to:

  1. Chdir to a directory.
  2. Chmod the parent directory to remove the search (x) permission.

This will break any uses of absolute path names. The solution is the one described in #40: open the current directory, use openat on the relative path, and then close the current directory. However:

  1. This will only help with unnamed temporary files unless we're willing to hold the file directory open (probably not the best idea).
  2. This will require two filesystem extra syscalls (instead of one as with getcwd).

Otherwise, we can end up deleting the wrong file when we change directories.
Otherwise, a concurrent (in a different thread) cwd change could cause us to
unlink the wrong file.
@Stebalien
Copy link
Owner Author

I snuck in two other small fixes while I was at it (second two commits).

@Stebalien Stebalien requested a review from KodrAus February 10, 2019 23:39
@Stebalien
Copy link
Owner Author

I snuck in two other small fixes while I was at it (second two commits).

@Stebalien Stebalien closed this Feb 10, 2019
@Stebalien Stebalien reopened this Feb 10, 2019
@Stebalien Stebalien mentioned this pull request Feb 11, 2019
@Stebalien Stebalien force-pushed the fix/absolute-tempfile branch from 0525e36 to 951d1c6 Compare February 11, 2019 03:16
Copy link
Collaborator

@KodrAus KodrAus left a comment

Choose a reason for hiding this comment

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

This looks good to me!

@Stebalien Stebalien merged commit 3d5f762 into master Feb 11, 2019
@Stebalien Stebalien deleted the fix/absolute-tempfile branch February 11, 2019 22:13
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

Successfully merging this pull request may close these issues.

2 participants