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

adding missing GID value when fetching Hostuser #48245

Merged
merged 1 commit into from
Nov 5, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions integration/hostuser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,28 @@ func TestRootHostUsers(t *testing.T) {
require.NoError(t, err)
require.False(t, hasExpirations)
})

t.Run("Test migrate unmanaged user", func(t *testing.T) {
t.Cleanup(func() { cleanupUsersAndGroups([]string{testuser}, []string{types.TeleportKeepGroup}) })

users := srv.NewHostUsers(context.Background(), presence, "host_uuid")
_, err := host.UserAdd(testuser, nil, host.UserOpts{})
require.NoError(t, err)

closer, err := users.UpsertUser(testuser, services.HostUsersInfo{Mode: services.HostUserModeKeep, Groups: []string{types.TeleportKeepGroup}})
require.NoError(t, err)
require.Nil(t, closer)

u, err := user.Lookup(testuser)
require.NoError(t, err)

gids, err := u.GroupIds()
require.NoError(t, err)

keepGroup, err := user.LookupGroup(types.TeleportKeepGroup)
require.NoError(t, err)
require.Contains(t, gids, keepGroup.Gid)
})
}

type hostUsersBackendWithExp struct {
Expand Down
1 change: 1 addition & 0 deletions lib/srv/usermgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ func (u *HostUserManagement) getHostUser(username string) (*HostUser, error) {
return &HostUser{
Name: username,
UID: usr.Uid,
GID: usr.Gid,
Home: usr.HomeDir,
Groups: groups,
}, trace.NewAggregate(groupErrs...)
Expand Down
Loading