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

[v9] Improve error handling in tbot start (#11756) #12012

Merged

Conversation

timothyb89
Copy link
Contributor

Backport of #11756 for branch/v9.


  • Improve error handling in tbot start

This attempts to improve a number of error handling issues while
loading the bot identity from storage in tbot start:

  1. Identity loading errors are silently ignored and the bot
    always attempts to generate a new identity from token. This isn't
    always correct and is impossible to debug as the true error is
    never logged. We now debug log these errors.
  2. LoadIdentity() doesn't properly account for existing-but-empty
    identity files and happily tries to load empty identities from
    tbot init. This isn't hugely harmful, but produces nonsensical
    error logs once Implement a prototype for a proxying SSH server that implements concepts expressed in readme #1 is fixed.
  • Use O_RDWR instead of O_WRONLY in botfs.openStandard()

This behaves the same as the fs_linux secure implementation in
all cases, and moves the open mode to a shared constant for good
measure.

  • Add a small unit test for symlinks mode read/write.

  • Fail on non-NotFound errors while reading an Identity.

  • Add small unit test for empty identities.

  • Remove outdated TODO comment

  • Apply suggestions from code review

Co-authored-by: Zac Bergquist zmb3@users.noreply.github.com

  • Address review feedback

Co-authored-by: Zac Bergquist zmb3@users.noreply.github.com

* Improve error handling in `tbot start`

This attempts to improve a number of error handling issues while
loading the bot identity from storage in `tbot start`:
1. Identity loading errors are silently ignored and the bot
   always attempts to generate a new identity from token. This isn't
   always correct and is impossible to debug as the true error is
   never logged. We now debug log these errors.
2. `LoadIdentity()` doesn't properly account for existing-but-empty
   identity files and happily tries to load empty identities from
   `tbot init`. This isn't hugely harmful, but produces nonsensical
   error logs once #1 is fixed.

* Use `O_RDWR` instead of `O_WRONLY` in `botfs.openStandard()`

This behaves the same as the fs_linux secure implementation in
all cases, and moves the open mode to a shared constant for good
measure.

* Add a small unit test for symlinks mode read/write.

* Fail on non-NotFound errors while reading an Identity.

* Add small unit test for empty identities.

* Remove outdated TODO comment

* Apply suggestions from code review

Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>

* Address review feedback

Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>
@github-actions github-actions bot requested review from probakowski, r0mant and zmb3 April 15, 2022 20:58
@timothyb89 timothyb89 enabled auto-merge (squash) April 18, 2022 21:17
@timothyb89 timothyb89 merged commit dd6825c into branch/v9 Apr 20, 2022
@timothyb89 timothyb89 deleted the timothyb89/v9/machineid-improve-identity-loading-errors branch April 20, 2022 15:49
@webvictim webvictim mentioned this pull request Jun 8, 2022
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.

4 participants