mirror of
https://github.com/moul/sshportal.git
synced 2025-09-09 22:24:29 +08:00
fix: host inspect causes db errors with later operations
The most simple case with a fresh install of sshportal using the following commands put the shell into a unrecoverable state. config> host create test1@test1 1 config> host inspect 1 config> host create test2@test2 error: can't preload field Groups for dbmodels.SSHKey The issue is caused because the global db handle is replaced with the inspect command. Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
This commit is contained in:
parent
762736d622
commit
3c32177213
1 changed files with 7 additions and 5 deletions
|
@ -828,12 +828,14 @@ GLOBAL OPTIONS:
|
|||
}
|
||||
|
||||
var hosts []*dbmodels.Host
|
||||
db = db.Preload("Groups")
|
||||
if myself.HasRole("admin") {
|
||||
db = db.Preload("SSHKey")
|
||||
}
|
||||
if err := dbmodels.HostsByIdentifiers(db, c.Args()).Find(&hosts).Error; err != nil {
|
||||
return err
|
||||
if err := dbmodels.HostsByIdentifiers(db.Preload("Groups").Preload("SSHKey"), c.Args()).Find(&hosts).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := dbmodels.HostsByIdentifiers(db.Preload("Groups"), c.Args()).Find(&hosts).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if c.Bool("decrypt") {
|
||||
|
|
Loading…
Add table
Reference in a new issue