Skip to content

[v16] MWI: Fix missing O_CLOEXEC in botfs.openSecure() and other issues (#55411)#55504

Merged
timothyb89 merged 1 commit intobranch/v16from
timothyb89/v16/botfs-cloexec
Jun 10, 2025
Merged

[v16] MWI: Fix missing O_CLOEXEC in botfs.openSecure() and other issues (#55411)#55504
timothyb89 merged 1 commit intobranch/v16from
timothyb89/v16/botfs-cloexec

Conversation

@timothyb89
Copy link
Copy Markdown
Contributor

@timothyb89 timothyb89 commented Jun 6, 2025

Backport of #55411 for branch/v16

changelog: The tbot client now ensures the O_CLOEXEC flag is used when opening files on Linux hosts


  • MWI: Fix missing O_CLOEXEC in botfs.openSecure() and other issues

This fixes various issues in botfs's openSecure implementation for Linux, particularly:

  • Added missing O_CLOEXEC flag to openat2() flags
  • Added EINTR retry loop to follow the stdlib's OpenFile() implementation.
  • Remove O_CREATE from ReadFlags, and convert it to a pseudo-enum so we can accurately predict intent (see next item)
  • Pass 0 mode to openat2() when reading (see above)
  • Renamed confusingly named OpenMode to OpenFlags, because it corresponds to flags, not file modes.
  • Fixed coincidentally correct misuse of unix.O_RDONLY

Note that while removing O_CREATE from read flags is technically a breaking change, we still automatically files downstream as needed. This results in a "new" debug-level log, but not any actual behavior change.

  • Fix lint

  • Simplify mode conditional, fix comments

  • Handle potentially nil file returns from os.OpenFile

…sues (#55411)

Backport of #55411 for branch/v16

---

* MWI: Fix missing O_CLOEXEC in `botfs.openSecure()` and other issues

This fixes various issues in botfs's `openSecure` implementation for
Linux, particularly:
- Added missing `O_CLOEXEC` flag to `openat2()` flags
- Added EINTR retry loop to follow the stdlib's `OpenFile()`
  implementation.
- Remove `O_CREATE` from `ReadFlags`, and convert it to a pseudo-enum
  so we can accurately predict intent (see next item)
- Pass `0` mode to `openat2()` when reading (see above)
- Renamed confusingly named `OpenMode` to `OpenFlags`, because it
  corresponds to flags, not file modes.
- Fixed coincidentally correct misuse of `unix.O_RDONLY`

Note that while removing `O_CREATE` from read flags is technically a
breaking change, we still automatically files downstream as needed.
This results in a "new" debug-level log, but not any actual behavior
change.

* Fix lint

* Simplify mode conditional, fix comments

* Handle potentially nil file returns from `os.OpenFile`
@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from zmb3 June 6, 2025 09:06
@timothyb89 timothyb89 added this pull request to the merge queue Jun 10, 2025
Merged via the queue into branch/v16 with commit e77863e Jun 10, 2025
40 of 41 checks passed
@timothyb89 timothyb89 deleted the timothyb89/v16/botfs-cloexec branch June 10, 2025 02:01
@fheinecke fheinecke mentioned this pull request Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants