diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2018-08-08 11:39:04 +0200 |
---|---|---|
committer | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2018-08-08 21:07:50 +0200 |
commit | c4b5a076040a6f6156c26f66cdc47610fc267db2 (patch) | |
tree | 8bd3bf0e70bc4e0301f066c1c6d166b8957e4fa4 /bin | |
parent | c6577e0d75f51b017f2f332838b97c3ca5b497c0 (diff) | |
download | gitlab-shell-c4b5a076040a6f6156c26f66cdc47610fc267db2.tar.gz |
Fix two regressions in SSH certificate support
Fix two regressions in my 2e8b670 ("Add support for SSH certificate
authentication", 2018-06-14) merged in gitlab-org/gitlab-shell!207.
This fixes the issue noted in gitlab-org/gitlab-shell#145 where the
command-line contains things other than the key/user/username, and
also a regression where SSH certificates are being used, and the
username presented in the key is unknown to GitLab.
In that case, we should log the user in as "Anonymous" (on an instance
that allows public access), but because of how the error checking
around api.discover() was implemented we ended up erroring out
instead.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/gitlab-shell | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bin/gitlab-shell b/bin/gitlab-shell index 1016570..ae751d7 100755 --- a/bin/gitlab-shell +++ b/bin/gitlab-shell @@ -17,7 +17,11 @@ require_relative '../lib/gitlab_init' # require File.join(ROOT_PATH, 'lib', 'gitlab_shell') -if GitlabShell.new(ARGV.join).exec(original_cmd) +# We must match e.g. "key-12345" anywhere on the command-line. See +# https://gitlab.com/gitlab-org/gitlab-shell/issues/145 +who = /\b(?:(?:key|user)-[0-9]+|username-\S+)\b/.match(ARGV.join).to_s; + +if GitlabShell.new(who).exec(original_cmd) exit 0 else exit 1 |