Check if there are rctl rules before calling removeRctlRules()
This commit is contained in:
		
							
								
								
									
										50
									
								
								cmd/stop.go
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								cmd/stop.go
									
									
									
									
									
								
							@ -34,53 +34,6 @@ func removeRctlRules(jail string, rules []string) error {
 | 
				
			|||||||
	return nil
 | 
						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
 | 
					// TODO
 | 
				
			||||||
func umountJailedZFS(jail *Jail) error {
 | 
					func umountJailedZFS(jail *Jail) error {
 | 
				
			||||||
@ -128,6 +81,8 @@ func stopJail(args []string) {
 | 
				
			|||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							out, err := executeCommand(fmt.Sprintf("rctl jail:%s", cj.InternalName))
 | 
				
			||||||
 | 
							if err == nil && len(out) > 0 {
 | 
				
			||||||
			fmt.Printf("  > Remove RCTL rules: ")
 | 
								fmt.Printf("  > Remove RCTL rules: ")
 | 
				
			||||||
			err := removeRctlRules(cj.InternalName, []string{""})
 | 
								err := removeRctlRules(cj.InternalName, []string{""})
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
@ -135,6 +90,7 @@ func stopJail(args []string) {
 | 
				
			|||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				fmt.Printf("OK\n")
 | 
									fmt.Printf("OK\n")
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if len (cj.Config.Exec_prestop) > 0 {
 | 
							if len (cj.Config.Exec_prestop) > 0 {
 | 
				
			||||||
			fmt.Printf("  > Execute prestop: ")
 | 
								fmt.Printf("  > Execute prestop: ")
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user