Skip to content

Commit c7e328f

Browse files
nmeumanatol
authored andcommitted
generator: lookup executable paths using exec.LookPath
This fixes an issues I discovered on Alpine when attempting to use Booster's vconsole feature as the setfont executable is located in /usr/sbin on Alpine and hence the binary was not found successfully by the primitive lookup implementation previously provided by Booster.
1 parent ecd29d7 commit c7e328f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

generator/generator.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"net"
77
"os"
8+
"os/exec"
89
"path/filepath"
910
"time"
1011

@@ -248,8 +249,13 @@ func (img *Image) appendInitBinary(initBinary string) error {
248249
func (img *Image) appendExtraFiles(binaries []string) error {
249250
for _, f := range binaries {
250251
if !filepath.IsAbs(f) {
251-
// simple names like "strace" are resolved as binaries under /usr/bin
252-
f = "/usr/bin/" + f
252+
// If the given name is not an absolute path, assume that it refers
253+
// to an executable and lookup the path to the executable using $PATH.
254+
var err error
255+
f, err = exec.LookPath(f)
256+
if err != nil {
257+
return err
258+
}
253259
}
254260

255261
if err := img.AppendFile(f); err != nil {

0 commit comments

Comments
 (0)