Repository navigation
Conversation
brkozer
force-pushed
the
touch-utime-omit
branch
from
November 5, 2026 10:32
f7fea97 to
aeb23d7
Compare
Contributor
|
this is a lot of new code, could you please make it smaller? |
brkozer
force-pushed
the
touch-utime-omit
branch
from
November 5, 2026 23:10
aeb23d7 to
c50576c
Compare
Author
|
Okay, thanks. I reworked it around a |
sylvestre
reviewed
Nov 6, 2026
| return set_symlink_file_times(path, atime, mtime).map_err_context( | ||
| #[cfg(all(unix, not(target_os = "redox")))] | ||
| let result = rustix::fs::utimensat( | ||
| rustix::fs::CWD, |
Contributor
There was a problem hiding this comment.
almost the same code as set_times_by_path, could you add a flags param to it instead?
sylvestre
reviewed
Nov 6, 2026
| // read from the `/dev/stdout` symlink itself and written to the file. | ||
| #[uutests::wasi_ignore(NoStdoutFileRedirection)] | ||
| #[test] | ||
| #[cfg(target_os = "linux")] |
Contributor
There was a problem hiding this comment.
why only linux? UTIME_OMIT is used on every unix now
Author
There was a problem hiding this comment.
Right, it's not Linux specific anymore. It runs on all unix now, except Redox.
brkozer
force-pushed
the
touch-utime-omit
branch
from
November 6, 2026 09:02
c50576c to
89cc8c9
Compare
sylvestre
force-pushed
the
touch-utime-omit
branch
from
November 7, 2026 18:25
89cc8c9 to
e65c507
Compare
With -a or -m, touch read the other time by path and wrote it back, so the path could be swapped for a symlink in between and that file's time overwritten. Pass UTIME_OMIT instead, as utimensat allows. This also stops `touch -h -a -` and `touch -h -m -` from copying the times of the /dev/stdout symlink itself onto the file. Redox, Windows and WASI still read the other time back. Fixes uutils#15794
brkozer
force-pushed
the
touch-utime-omit
branch
from
November 8, 2026 22:52
e65c507 to
63cc56f
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
touch -a/-m read the other timestamp by path and wrote it back, so the path could be swapped for a symlink in between and the symlink target's time overwritten. Now the unchanged time is passed as UTIME_OMIT, following the suggested fix in the issue.
This also fixes
touch -h -a -andtouch -h -m -, which copied the times of the /dev/stdout symlink itself onto the file.Redox, Windows and WASI still read the other time back. The race is covered by a new check in util/check-toctou.sh.
Fixes #15794
Related: #14686 (a different race, not fixed here)