Skip to content

Commit

Permalink
adding missing GID value when fetching Hostuser (#48245)
Browse files Browse the repository at this point in the history
  • Loading branch information
eriktate authored Nov 5, 2024
1 parent 16a6116 commit 83b1d23
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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

0 comments on commit 83b1d23

Please sign in to comment.