-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Adding better error logging when roles block host user creation #46091
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1264,20 +1264,22 @@ func (s *Server) HandleNewConn(ctx context.Context, ccx *sshutils.ConnectionCont | |||||
| } | ||||||
|
|
||||||
| // Create host user. | ||||||
| created, userCloser, err := s.termHandlers.SessionRegistry.TryCreateHostUser(identityContext) | ||||||
| created, userCloser, err := s.termHandlers.SessionRegistry.UpsertHostUser(identityContext) | ||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dropping the |
||||||
| if err != nil { | ||||||
| return ctx, trace.Wrap(err) | ||||||
| log.Infof("error while creating host users: %s", err) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest making the function only return unexpected errors and returning them here
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The intent with logging errors here is to try and always permit access. Even if the users session is degraded in some way, I think that would be preferred over some error in host user creation completly preventing access to hosts. We really want to avoid forcing users to use their break glass mechanism if they don't need to because something went wrong here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment would apply here too
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm operating under the assumption that nobody is ever going to see these logs, especially if they don't have access to the box. But I agree that we should try to allow access if we can. Hopefully we can add some visibility in a later PR if the SSH connection does fail |
||||||
| } | ||||||
|
|
||||||
| // Indicate that the user was created by Teleport. | ||||||
| ccx.UserCreatedByTeleport = created | ||||||
| if userCloser != nil { | ||||||
| ccx.AddCloser(userCloser) | ||||||
| } | ||||||
|
|
||||||
| sudoersCloser, err := s.termHandlers.SessionRegistry.TryWriteSudoersFile(identityContext) | ||||||
| sudoersCloser, err := s.termHandlers.SessionRegistry.WriteSudoersFile(identityContext) | ||||||
| if err != nil { | ||||||
| return ctx, trace.Wrap(err) | ||||||
| log.Warnf("error while writing sudoers: %s", err) | ||||||
|
nklaassen marked this conversation as resolved.
|
||||||
| } | ||||||
|
|
||||||
| if sudoersCloser != nil { | ||||||
| ccx.AddCloser(sudoersCloser) | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any concern around exposing the role that blocked an action like this? It was requested in the original issue and it definitely makes troubleshooting a lot simpler, but I'm not 100% sure if it's wise to write the role back to the client? Nothing bad immediately comes to mind, but just calling it out in case someone else can think of a good reason not to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that users have the ability retrieve and view their own roles, so I don't know that this poses any problems.