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

[v16] Fix TestRootX11ForwardPermissions #50229

Open
wants to merge 1 commit into
base: branch/v16
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions lib/srv/regular/sshserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import (
"github.com/gravitational/teleport/lib/sshutils/x11"
"github.com/gravitational/teleport/lib/utils"
"github.com/gravitational/teleport/lib/utils/cert"
"github.com/gravitational/teleport/lib/utils/host"
)

// teleportTestUser is additional user used for tests
Expand Down Expand Up @@ -1071,15 +1072,19 @@ func TestX11Forward(t *testing.T) {
// TestRootX11ForwardPermissions tests that X11 forwarding sessions are set up
// with the connecting user's file permissions (where needed), rather than root.
func TestRootX11ForwardPermissions(t *testing.T) {
// TODO(Joerger): Fix CI issue related to github actions sometimes using
// UID 1001 - https://github.com/gravitational/teleport/pull/50176
t.Skip("This test is flaky")

utils.RequireRoot(t)
if os.Getenv("TELEPORT_XAUTH_TEST") == "" {
t.Skip("Skipping test as xauth is not enabled")
}

login := utils.GenerateLocalUsername(t)
_, err := host.UserAdd(login, nil, host.UserOpts{})
require.NoError(t, err)
t.Cleanup(func() {
_, err := host.UserDel(login)
require.NoError(t, err)
})

t.Parallel()
f := newFixtureWithoutDiskBasedLogging(t)
f.ssh.srv.x11 = &x11.ServerConfig{
Expand All @@ -1098,10 +1103,11 @@ func TestRootX11ForwardPermissions(t *testing.T) {
_, err = f.testSrv.Auth().UpsertRole(ctx, role)
require.NoError(t, err)

// Create a new X11 session as a non-root nonroot in the system.
nonroot, err := user.LookupId("1000")
// Create a new X11 session as a non-root user in the system.
nonroot, err := user.Lookup(login)
require.NoError(t, err)
client := f.newSSHClient(ctx, t, nonroot)
defer client.Close()
serverDisplay := x11EchoSession(ctx, t, client)

// Check that the xauth entry is readable for the connecting user.
Expand Down
Loading