Update Running, JID and InternalName values by ref so API will get fresh values

This commit is contained in:
yo 2024-09-05 09:28:05 +02:00
parent 3b548e4c85
commit 0e0ab8c653

View File

@ -1421,6 +1421,25 @@ func StartJail(args []string) {
}
}
// Get a reference to current jail, to update its properties in RAM so API will get fresh data
for i, j := range gJails {
if strings.EqualFold(j.Name, cj.Name) && strings.EqualFold(j.Datastore, cj.Datastore) {
if err = setStructFieldValue(&gJails[i], "Running", "true"); err != nil {
fmt.Printf("ERROR: setting Running property to true: %s\n", err.Error())
}
if err = setStructFieldValue(&gJails[i], "JID", fmt.Sprintf("%d", cj.JID)); err != nil {
fmt.Printf("ERROR: setting JID property to %d: %s\n", cj.JID, err.Error())
}
if err = setStructFieldValue(&gJails[i], "InternalName", cj.InternalName); err != nil {
fmt.Printf("ERROR: Setting InternalName property: %s\n", err.Error())
}
// FIXME: this value of devfs_ruleset should not go in Config, it should reside in Jail root properties as it is volatile (only valid while jail is running)
/*if err = setStructFieldValue(&gJails[i], "Devfs_ruleset", "0"); err != nil {
fmt.Printf("ERROR: setting Devfs_ruleset property to 0: %s\n", err.Error())
}*/
}
}
hostInt, err := gJailHost.GetInterfaces()
if err != nil {
fmt.Printf("Error listing jail host interfaces: %v\n", err)