package cmd import ( "os/exec" "strings" ) 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 }