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

Add sudo propagation check for azure #147

Conversation

GGonryun
Copy link
Contributor

@GGonryun GGonryun commented Nov 25, 2024

This PR implements Azure's preTestAccessPropagationArgs and adds a new parameter to the SSHProvider type to support valid access errors.

Sudo access to an azure node can sometimes take an unexpectedly long time to propagate fully and if a user connects before sudo access propagates then they'll need to restart their session in order to pick up the sudo access. Therefore it is necessary to validate sudo access before letting a user complete their connection.

We get an error code of 1 instead of an error code 0 after sudo access is granted when performing the pretest for an Azure instance. This means that we needed to extend the SSHProvider interface a little to include potentially valid error messages and override the error code of 1.

In the case a user doesn't have sudo access, sudo -nv will exit with code 1 and print Sorry, user ${username} may not run sudo on ${host}. to stderr.

If the user does have sudo access, sudo -nv will exit with code 1 (so, the same as the no access case) but print sudo: a password is required to stderr.

@GGonryun GGonryun self-assigned this Nov 25, 2024
@GGonryun GGonryun requested a review from gergas3 November 25, 2024 23:00
@GGonryun GGonryun changed the title add sudo propagation check for azure Add sudo propagation check for azure Nov 25, 2024
Copy link
Contributor

@gergas3 gergas3 left a comment

Choose a reason for hiding this comment

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

I had one optional suggestion about removing the notion of pre-test from the accessPropagationGuard, and hopefully that can simplify a bit.
(Haven't tested.)

src/plugins/ssh/index.ts Outdated Show resolved Hide resolved
src/plugins/ssh/index.ts Show resolved Hide resolved
@GGonryun GGonryun merged commit ace758a into main Dec 3, 2024
3 checks passed
@GGonryun GGonryun deleted the miguelcampos/eng-3149-azure-ssh-add-pretestaccesspropagationargs-for-sudo-access branch December 3, 2024 01:25
GGonryun added a commit that referenced this pull request Dec 5, 2024
We recently introduced `validAccessPatterns` in #147 which checks to
make sure a certain termination string exists when performing
propagation checks. Consequentially for Azure, when we exit the terminal
we're now always attempting to verify that an ephemeral access message
is valid and failing the check.

Two fixes were possible, 1) we either only check `isValidError` if we're
in a propagation check or 2) we default `isValidError` to true and we
only set it to false if we encounter an error.

We didn't go with the first option in #147 because we want to remove the
concept of `isAccessPropagationPreTest` from the
`accessPropagationGuard`, but checking for valid error messages should
only apply during the pretest phase. This PR instead only passes
`validAccessPatterns` if we're performing a pre-test to the propagation
guard.
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