diff --git a/actions/run_action.go b/actions/run_action.go index c70ebfbd..987615cf 100644 --- a/actions/run_action.go +++ b/actions/run_action.go @@ -45,6 +45,8 @@ package actions import ( "errors" "github.com/go-debos/fakemachine" + "fmt" + "os" "path" "strings" @@ -68,6 +70,22 @@ func (run *RunAction) Verify(context *debos.DebosContext) error { if run.Script == "" && run.Command == "" { return errors.New("Script and Command both cannot be empty") } + + if run.Script != "" { + argv := strings.SplitN(run.Script, " ", 2) + script := debos.CleanPathAt(argv[0], context.RecipeDir) + + stat, err := os.Stat(script) + if err != nil { + return err + } + + /* check the script is executable */ + if stat.IsDir() || stat.Mode()&0111 == 0 { + return fmt.Errorf("Script %s is not executable", script) + } + } + return nil }