Skip to content

Support readLinkAt and openFileEnsureBeneathNoSymlinks on Windows too#15060

Merged
Ericson2314 merged 1 commit intomasterfrom
read-link-at
Feb 4, 2026
Merged

Support readLinkAt and openFileEnsureBeneathNoSymlinks on Windows too#15060
Ericson2314 merged 1 commit intomasterfrom
read-link-at

Conversation

@Ericson2314
Copy link
Member

Motivation

This means that RestoreSink can work in the TOCTOU-resilliant way on Windows too. And it also bodes will for the upcoming OS source accessor improvements.

A few misc little refactors around error handling and whatnot are done along the way too. (No more attempt to support pre Windows Vista! lol.)

Context

This cannot be reliably automatically tested until we have a newer version of Wine, but it does build, so I am inclined to say we just try it for now.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

… too

This means that `RestoreSink` can work in the TOCTOU-resilliant way on
Windows too. And it also bodes will for the upcoming OS source accessor
improvements.

A few misc little refactors around error handling and whatnot are done
along the way too. (No more attempt to support pre Windows Vista! lol.)

This cannot be realiably automatically tested until we have a newer
version of Wine, but it does build, so I am inclined to say we just try
it for now.
@xokdvium
Copy link
Contributor

FWIW I can poke at wine 10.20

Ericson2314 added a commit to obsidiansystems/nix that referenced this pull request Jan 30, 2026
…em meta data

This should not happen now, but instead happen after

- NixOS#15119
- NixOS#15060
- Sergei's upcoming new `Descriptor`-based `SourceAccessor`

I suspect what we'll want to do is expose that source accessor after
all, so we can have some extra methods to get at the underlying file
descriptors. (Or, conversely, maybe this won't be necessary, because enough of the
underlying logic will be factored into `file-descriptor.hh` functions
that the `SourceAccessor` itself will be a small wrapper.)

Either way, at that point we'll not be duplicating stuff here, nor will
be lacking a foundation on Windows, and we can then finish the job.
@Ericson2314 Ericson2314 added this pull request to the merge queue Feb 4, 2026
Merged via the queue into master with commit a4c0295 Feb 4, 2026
18 checks passed
@Ericson2314 Ericson2314 deleted the read-link-at branch February 4, 2026 21:27
Comment on lines +172 to +180
/**
* Get the path associated with a file handle.
*
* @note One MUST only use this for error handling, because it creates
* TOCTOU issues. We don't mind if error messages point to out of date
* paths (that is a rather trivial TOCTOU --- the error message is best
* effort) but for anything else we do.
*/
std::filesystem::path handleToPath(Descriptor handle);
Copy link
Contributor

Choose a reason for hiding this comment

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

Btw we could implement it for Linux/macos too and improve error messages when working with FDs

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I agree we should do that.

Ericson2314 added a commit to obsidiansystems/nix that referenced this pull request Feb 5, 2026
…em meta data

This should not happen now, but instead happen after

- NixOS#15119
- NixOS#15060
- Sergei's upcoming new `Descriptor`-based `SourceAccessor`

I suspect what we'll want to do is expose that source accessor after
all, so we can have some extra methods to get at the underlying file
descriptors. (Or, conversely, maybe this won't be necessary, because enough of the
underlying logic will be factored into `file-descriptor.hh` functions
that the `SourceAccessor` itself will be a small wrapper.)

Either way, at that point we'll not be duplicating stuff here, nor will
be lacking a foundation on Windows, and we can then finish the job.
Ericson2314 added a commit to obsidiansystems/nix that referenced this pull request Feb 5, 2026
…em meta data

This should not happen now, but instead happen after

- NixOS#15119
- NixOS#15060
- Sergei's upcoming new `Descriptor`-based `SourceAccessor`

I suspect what we'll want to do is expose that source accessor after
all, so we can have some extra methods to get at the underlying file
descriptors. (Or, conversely, maybe this won't be necessary, because enough of the
underlying logic will be factored into `file-descriptor.hh` functions
that the `SourceAccessor` itself will be a small wrapper.)

Either way, at that point we'll not be duplicating stuff here, nor will
be lacking a foundation on Windows, and we can then finish the job.
Ericson2314 added a commit to obsidiansystems/nix that referenced this pull request Feb 16, 2026
…em meta data

This should not happen now, but instead happen after

- NixOS#15119
- NixOS#15060
- Sergei's upcoming new `Descriptor`-based `SourceAccessor`

I suspect what we'll want to do is expose that source accessor after
all, so we can have some extra methods to get at the underlying file
descriptors. (Or, conversely, maybe this won't be necessary, because enough of the
underlying logic will be factored into `file-descriptor.hh` functions
that the `SourceAccessor` itself will be a small wrapper.)

Either way, at that point we'll not be duplicating stuff here, nor will
be lacking a foundation on Windows, and we can then finish the job.
Ericson2314 added a commit to obsidiansystems/nix that referenced this pull request Feb 16, 2026
…em meta data

This should not happen now, but instead happen after

- NixOS#15119
- NixOS#15060
- Sergei's upcoming new `Descriptor`-based `SourceAccessor`

I suspect what we'll want to do is expose that source accessor after
all, so we can have some extra methods to get at the underlying file
descriptors. (Or, conversely, maybe this won't be necessary, because enough of the
underlying logic will be factored into `file-descriptor.hh` functions
that the `SourceAccessor` itself will be a small wrapper.)

Either way, at that point we'll not be duplicating stuff here, nor will
be lacking a foundation on Windows, and we can then finish the job.
Ericson2314 added a commit to obsidiansystems/nix that referenced this pull request Feb 16, 2026
…em meta data

This should not happen now, but instead happen after

- NixOS#15119
- NixOS#15060
- Sergei's upcoming new `Descriptor`-based `SourceAccessor`

I suspect what we'll want to do is expose that source accessor after
all, so we can have some extra methods to get at the underlying file
descriptors. (Or, conversely, maybe this won't be necessary, because enough of the
underlying logic will be factored into `file-descriptor.hh` functions
that the `SourceAccessor` itself will be a small wrapper.)

Either way, at that point we'll not be duplicating stuff here, nor will
be lacking a foundation on Windows, and we can then finish the job.
Ericson2314 added a commit to obsidiansystems/nix that referenced this pull request Feb 18, 2026
…em meta data

This should not happen now, but instead happen after

- NixOS#15119
- NixOS#15060
- Sergei's upcoming new `Descriptor`-based `SourceAccessor`

I suspect what we'll want to do is expose that source accessor after
all, so we can have some extra methods to get at the underlying file
descriptors. (Or, conversely, maybe this won't be necessary, because enough of the
underlying logic will be factored into `file-descriptor.hh` functions
that the `SourceAccessor` itself will be a small wrapper.)

Either way, at that point we'll not be duplicating stuff here, nor will
be lacking a foundation on Windows, and we can then finish the job.
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.

3 participants