Check if there are rctl rules before calling removeRctlRules()
This commit is contained in:
parent
b5faac0705
commit
d8c78cfd34
62
cmd/stop.go
62
cmd/stop.go
@ -34,53 +34,6 @@ func removeRctlRules(jail string, rules []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
/* Moved into cmd/utils.go
|
||||
func executeCommand(cmdline string) (string, error) {
|
||||
var cmd []string
|
||||
var out []byte
|
||||
var err error
|
||||
|
||||
if gUseSudo {
|
||||
cmd = append(cmd, "sudo")
|
||||
}
|
||||
cs := strings.Split(cmdline, " ")
|
||||
|
||||
cmd = append(cmd, cs...)
|
||||
|
||||
if len (cmd) > 1 {
|
||||
out, err = exec.Command(cmd[0], cmd[1:]...).Output()
|
||||
} else {
|
||||
out, err = exec.Command(cmd[0]).Output()
|
||||
}
|
||||
|
||||
return string(out), err
|
||||
}
|
||||
|
||||
|
||||
func executeCommandInJail(jail *Jail, cmdline string) (string, error) {
|
||||
var cmd []string
|
||||
|
||||
if gUseSudo {
|
||||
cmd = append(cmd, "sudo")
|
||||
}
|
||||
|
||||
cmd = append(cmd, "setfib")
|
||||
if len(jail.Config.Exec_fib) > 0 {
|
||||
cmd = append(cmd, jail.Config.Exec_fib)
|
||||
} else {
|
||||
cmd = append(cmd, "0")
|
||||
}
|
||||
|
||||
cmd = append(cmd, "jexec", jail.InternalName)
|
||||
|
||||
cs := strings.Split(cmdline, " ")
|
||||
cmd = append(cmd, cs...)
|
||||
|
||||
out, err := exec.Command(cmd[0], cmd[1:]...).Output()
|
||||
|
||||
return string(out), err
|
||||
}
|
||||
*/
|
||||
|
||||
// TODO
|
||||
func umountJailedZFS(jail *Jail) error {
|
||||
@ -128,12 +81,15 @@ func stopJail(args []string) {
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Printf(" > Remove RCTL rules: ")
|
||||
err := removeRctlRules(cj.InternalName, []string{""})
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: %s\n", err.Error())
|
||||
} else {
|
||||
fmt.Printf("OK\n")
|
||||
out, err := executeCommand(fmt.Sprintf("rctl jail:%s", cj.InternalName))
|
||||
if err == nil && len(out) > 0 {
|
||||
fmt.Printf(" > Remove RCTL rules: ")
|
||||
err := removeRctlRules(cj.InternalName, []string{""})
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: %s\n", err.Error())
|
||||
} else {
|
||||
fmt.Printf("OK\n")
|
||||
}
|
||||
}
|
||||
|
||||
if len (cj.Config.Exec_prestop) > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user