CreateExecutableCopy makes a temporary copy of a plugin binary and makes it executable. config.PluginHome() + /temp is used as the temp dir instead of the system temp for security reasons.
(path string, tempPluginDir string)
| 32 | // config.PluginHome() + /temp is used as the temp dir instead of the system |
| 33 | // temp for security reasons. |
| 34 | func (actor Actor) CreateExecutableCopy(path string, tempPluginDir string) (string, error) { |
| 35 | tempFile, err := makeTempFile(tempPluginDir) |
| 36 | if err != nil { |
| 37 | return "", err |
| 38 | } |
| 39 | |
| 40 | // add '.exe' to the temp file if on Windows |
| 41 | executablePath := generic.ExecutableFilename(tempFile.Name()) |
| 42 | err = os.Rename(tempFile.Name(), executablePath) |
| 43 | if err != nil { |
| 44 | return "", err |
| 45 | } |
| 46 | |
| 47 | err = fileutils.CopyPathToPath(path, executablePath) |
| 48 | if err != nil { |
| 49 | return "", err |
| 50 | } |
| 51 | |
| 52 | err = os.Chmod(executablePath, 0700) |
| 53 | if err != nil { |
| 54 | return "", err |
| 55 | } |
| 56 | |
| 57 | return executablePath, nil |
| 58 | } |
| 59 | |
| 60 | // DownloadExecutableBinaryFromURL fetches a plugin binary from the specified |
| 61 | // URL, if it exists. |
nothing calls this directly
no test coverage detected