Skip to content

Commit

Permalink
daemon: update.go/reconcilable block deleting users
Browse files Browse the repository at this point in the history
Previously we allowed users to fully delete Passwd.Users
but correctly though silently did not clear the authorized_keys on disk.
This should have been unreconcilable since it violates the
MCO rules for ssh updates instead of silently failing.
  • Loading branch information
kikisdeliveryservice committed Feb 5, 2021
1 parent 5205078 commit 6cf8b95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pkg/daemon/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,8 @@ func reconcilable(oldConfig, newConfig *mcfgv1.MachineConfig) (*machineConfigDif
if err := verifyUserFields(newIgn.Passwd.Users[len(newIgn.Passwd.Users)-1]); err != nil {
return nil, err
}
} else if len(oldIgn.Passwd.Users) > 0 && len(newIgn.Passwd.Users) == 0 {
return nil, errors.New("ignition passwd user section contains unsupported changes: user core may not be deleted")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/daemon/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,11 @@ func TestReconcilableSSH(t *testing.T) {
_, errMsg = reconcilable(oldMcfg, newMcfg)
checkIrreconcilableResults(t, "SSH", errMsg)

//check that empty Users does not generate error/degrade node
//check that empty Users does not cause panic
newIgnCfg.Passwd.Users = nil
newMcfg = helpers.CreateMachineConfigFromIgnition(newIgnCfg)
_, errMsg = reconcilable(oldMcfg, newMcfg)
checkReconcilableResults(t, "SSH", errMsg)
checkIrreconcilableResults(t, "SSH", errMsg)
}

func TestUpdateSSHKeys(t *testing.T) {
Expand Down

0 comments on commit 6cf8b95

Please sign in to comment.