mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(cli): check if dotfiles install script is executable (#8588)
* feat(cli): check if dotfiles install script is executable * feat(docs): add section for dotfiles setup and document executable fix --------- Co-authored-by: Mathias Fredriksson <mafredri@gmail.com> Co-authored-by: Muhammad Atif Ali <matifali@live.com>
This commit is contained in:
co-authored by
Mathias Fredriksson
Muhammad Atif Ali
parent
7f67000b90
commit
65583eca47
@@ -193,6 +193,18 @@ func (r *RootCmd) dotfiles() *clibase.Cmd {
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintf(inv.Stdout, "Running %s...\n", script)
|
||||
|
||||
// Check if the script is executable and notify on error
|
||||
scriptPath := filepath.Join(dotfilesDir, script)
|
||||
fi, err := os.Stat(scriptPath)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("stat %s: %w", scriptPath, err)
|
||||
}
|
||||
|
||||
if fi.Mode()&0o111 == 0 {
|
||||
return xerrors.Errorf("script %q is not executable. See https://coder.com/docs/v2/latest/dotfiles for information on how to resolve the issue.", script)
|
||||
}
|
||||
|
||||
// it is safe to use a variable command here because it's from
|
||||
// a filtered list of pre-approved install scripts
|
||||
// nolint:gosec
|
||||
|
||||
Reference in New Issue
Block a user