execKeytool will execute a "keytool" command and if needed re-execute the command with commandWithSudo to work around file permissions.
(cmd *exec.Cmd)
| 141 | // execKeytool will execute a "keytool" command and if needed re-execute |
| 142 | // the command with commandWithSudo to work around file permissions. |
| 143 | func (s *Java) execKeytool(cmd *exec.Cmd) ([]byte, error) { |
| 144 | out, err := s.SysFS.Exec(cmd) |
| 145 | if err != nil && bytes.Contains(out, []byte("java.io.FileNotFoundException")) && runtime.GOOS != "windows" { |
| 146 | cmd = s.SysFS.Command(cmd.Args[0], cmd.Args[1:]...) |
| 147 | cmd.Env = []string{ |
| 148 | "JAVA_HOME=" + s.JavaHomeDir, |
| 149 | } |
| 150 | return s.SysFS.SudoExec(cmd) |
| 151 | } |
| 152 | return out, err |
| 153 | } |
no test coverage detected