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

[v10] Do not check os groups when user exits #22803

Merged
merged 1 commit into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/srv/ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ type ServerContext struct {

// JoinOnly is set if the connection was created using a join-only principal and may only be used to join other sessions.
JoinOnly bool

// UserCreatedByTeleport is true when the system user was created by Teleport user auto-provision.
UserCreatedByTeleport bool
}

// NewServerContext creates a new *ServerContext which is used to pass and
Expand Down Expand Up @@ -1060,6 +1063,7 @@ func (c *ServerContext) ExecCommand() (*ExecCommand, error) {
ClientAddress: c.ServerConn.RemoteAddr().String(),
RequestType: requestType,
PermitUserEnvironment: c.srv.PermitUserEnvironment(),
UserCreatedByTeleport: c.UserCreatedByTeleport,
Environment: buildEnvironment(c),
PAMConfig: pamConfig,
IsTestStub: c.IsTestStub,
Expand Down
15 changes: 12 additions & 3 deletions lib/srv/reexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ type ExecCommand struct {
// IsTestStub is used by tests to mock the shell.
IsTestStub bool `json:"is_test_stub"`

// UserCreatedByTeleport is true when the system user was created by Teleport user auto-provision.
UserCreatedByTeleport bool

// UaccMetadata contains metadata needed for user accounting.
UaccMetadata UaccMetadata `json:"uacc_meta"`

Expand Down Expand Up @@ -327,9 +330,15 @@ func RunCommand() (errw io.Writer, code int, err error) {
defer parkerCancel()

osPack := newOsWrapper()
if err := osPack.startNewParker(parkerCtx, cmd.SysProcAttr.Credential,
c.Login, &systemUser{u: localUser}); err != nil {
return errorWriter, teleport.RemoteCommandFailure, trace.Wrap(err)
if c.UserCreatedByTeleport {
// Parker is only needed when the user was created by Teleport.
err := osPack.startNewParker(
parkerCtx,
cmd.SysProcAttr.Credential,
c.Login, &systemUser{u: localUser})
if err != nil {
return errorWriter, teleport.RemoteCommandFailure, trace.Wrap(err)
}
}

if c.X11Config.XServerUnixSocket != "" {
Expand Down
4 changes: 4 additions & 0 deletions lib/srv/sess.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ func (s *SessionRegistry) TryCreateHostUser(ctx *ServerContext) (*user.User, err
if userCloser != nil {
ctx.AddCloser(userCloser)
}

// Indicate that the user was created by Teleport.
ctx.UserCreatedByTeleport = true

return tempUser, nil
}

Expand Down