Detect hg command
For Git SSH support, GitLab Shell receives the key id in Actor format (e.g., key-123
) directly as first argument, imposed from the authorized_keys
file. The subsequent arguments are a command (e.g, git-upload-pack
for a fetch) followed by the specific command arguments. The latter needed to be validated thoroughly for security reasons before the actual Git command could be exec
ed.
In the case of Mercurial SSH support (Ruby version), things are simpler, because there's only one command (hg
) and only one valid combination of arguments: hg serve --stdio
. All Mercurial commands are then handled inside the resulting pipe as part of the "wire protocol". Instead of painfully validating subsequent arguments, we just ignore them.
In the Golang version, there's also a list of features
in config.yml
, used to choose between the Golang version or "fallback" to the Ruby version. By default, in GitLab Shell v10.0.0, the feature list is empty, hence the Ruby version is used for all the commands.
Also, in the Golang version, the exec
logic has probably (needs to be verified) replaced by Gitaly calls. For the time being, an exec
is still the way to go with Mercurial.
For the Golang port, we need to
-
register a new hg
command if needed in the feature list options -
detect that the command is hg
-
call the Rails application internal API (see #3 (closed)) -
be ready for the final exec
, but no perform it right away. For the present issue, just outputting the API response payload is enough.