diff options
author | Nick Thomas <nick@gitlab.com> | 2019-09-24 15:31:39 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-09-24 15:31:39 +0000 |
commit | 659ad7f7cedab56ff48abe4d6fb8eb25a644a2a8 (patch) | |
tree | 6b23eff8993050c82e4fd472a846591e1773909c /go/internal/command/fallback/fallback.go | |
parent | e9481821f14b894b9d1752161b0c3c4d2679b55e (diff) | |
parent | 9237ac094a060dbb31c1ee4d37ad7ef38e17e878 (diff) | |
download | gitlab-shell-659ad7f7cedab56ff48abe4d6fb8eb25a644a2a8.tar.gz |
Merge branch '173-remove-go-fallback-and-feature-flags' into 'master'
Remove feature flags and the fallback command
See merge request gitlab-org/gitlab-shell!336
Diffstat (limited to 'go/internal/command/fallback/fallback.go')
-rw-r--r-- | go/internal/command/fallback/fallback.go | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/go/internal/command/fallback/fallback.go b/go/internal/command/fallback/fallback.go deleted file mode 100644 index 781eda1..0000000 --- a/go/internal/command/fallback/fallback.go +++ /dev/null @@ -1,57 +0,0 @@ -package fallback - -import ( - "errors" - "fmt" - "os" - "path/filepath" - "syscall" - - "gitlab.com/gitlab-org/gitlab-shell/go/internal/command/commandargs" - "gitlab.com/gitlab-org/gitlab-shell/go/internal/executable" -) - -type Command struct { - Executable *executable.Executable - RootDir string - Args commandargs.CommandArgs -} - -var ( - // execFunc is overridden in tests - execFunc = syscall.Exec - whitelist = []string{ - executable.GitlabShell, - executable.AuthorizedKeysCheck, - executable.AuthorizedPrincipalsCheck, - } -) - -func (c *Command) Execute() error { - if !c.isWhitelisted() { - return errors.New("Failed to execute unknown executable") - } - - rubyCmd := c.fallbackProgram() - - // Ensure rubyArgs[0] is the full path to gitlab-shell-ruby - rubyArgs := append([]string{rubyCmd}, c.Args.GetArguments()...) - - return execFunc(rubyCmd, rubyArgs, os.Environ()) -} - -func (c *Command) isWhitelisted() bool { - for _, item := range whitelist { - if c.Executable.Name == item { - return true - } - } - - return false -} - -func (c *Command) fallbackProgram() string { - fileName := fmt.Sprintf("%s-ruby", c.Executable.Name) - - return filepath.Join(c.RootDir, "bin", fileName) -} |