mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 00:49:03 +00:00
Update shell in host users when they exist (#3072)
This commit is contained in:
parent
028c2643f7
commit
4cd9dab577
3 changed files with 10 additions and 2 deletions
1
changes/update-host-user-shell
Normal file
1
changes/update-host-user-shell
Normal file
|
|
@ -0,0 +1 @@
|
|||
* Update shell as host users are updated
|
||||
|
|
@ -929,7 +929,13 @@ func saveHostUsersDB(ctx context.Context, tx sqlx.ExtContext, host *fleet.Host)
|
|||
|
||||
insertValues := strings.TrimSuffix(strings.Repeat("(?, ?, ?, ?, ?, ?),", len(host.Users)), ",")
|
||||
insertSql := fmt.Sprintf(
|
||||
`INSERT INTO host_users (host_id, uid, username, user_type, groupname, shell) VALUES %s ON DUPLICATE KEY UPDATE removed_at=NULL`,
|
||||
`INSERT INTO host_users (host_id, uid, username, user_type, groupname, shell)
|
||||
VALUES %s
|
||||
ON DUPLICATE KEY UPDATE
|
||||
user_type = VALUES(user_type),
|
||||
groupname = VALUES(groupname),
|
||||
shell = VALUES(shell),
|
||||
removed_at=NULL`,
|
||||
insertValues,
|
||||
)
|
||||
if _, err := tx.ExecContext(ctx, insertSql, insertArgs...); err != nil {
|
||||
|
|
|
|||
|
|
@ -1569,7 +1569,8 @@ func testHostsSaveUsers(t *testing.T, ds *Datastore) {
|
|||
require.Len(t, host.Users, 1)
|
||||
assert.Equal(t, host.Users[0].Uid, u2.Uid)
|
||||
|
||||
// readd u1
|
||||
// readd u1 but with a different shell
|
||||
u1.Shell = "/some/new/shell"
|
||||
host.Users = []fleet.HostUser{u1, u2}
|
||||
host.Modified = true
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue