From 18096b5440e0818605add32538751c6be38e8343 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Mon, 14 Oct 2019 16:00:48 +0100 Subject: Remove dead Ruby code --- bin/gitlab-shell-authorized-keys-check-ruby | 42 ----------------------- bin/gitlab-shell-authorized-principals-check-ruby | 36 ------------------- bin/gitlab-shell-ruby | 28 --------------- bin/test-logger | 10 ------ 4 files changed, 116 deletions(-) delete mode 100755 bin/gitlab-shell-authorized-keys-check-ruby delete mode 100755 bin/gitlab-shell-authorized-principals-check-ruby delete mode 100755 bin/gitlab-shell-ruby delete mode 100755 bin/test-logger (limited to 'bin') diff --git a/bin/gitlab-shell-authorized-keys-check-ruby b/bin/gitlab-shell-authorized-keys-check-ruby deleted file mode 100755 index 2ea1a74..0000000 --- a/bin/gitlab-shell-authorized-keys-check-ruby +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env ruby - -# -# GitLab shell authorized_keys helper. Query GitLab API to get the authorized -# command for a given ssh key fingerprint -# -# Ex. -# bin/gitlab-shell-authorized-keys-check -# -# Returns -# command="/bin/gitlab-shell key-#",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAA... -# -# Expects to be called by the SSH daemon, via configuration like: -# AuthorizedKeysCommandUser git -# AuthorizedKeysCommand /bin/gitlab-shell-authorized-keys-check git %u %k - -abort "# Wrong number of arguments. #{ARGV.size}. Usage: -# gitlab-shell-authorized-keys-check " unless ARGV.size == 3 - -expected_username = ARGV[0] -abort '# No username provided' if expected_username.nil? || expected_username == '' - -actual_username = ARGV[1] -abort '# No username provided' if actual_username.nil? || actual_username == '' - -# Only check access if the requested username matches the configured username. -# Normally, these would both be 'git', but it can be configured by the user -exit 0 unless expected_username == actual_username - -key = ARGV[2] -abort "# No key provided" if key.nil? || key == '' - -require_relative '../lib/gitlab_init' -require_relative '../lib/gitlab_net' -require_relative '../lib/gitlab_keys' - -authorized_key = GitlabNet.new.authorized_key(key) -if authorized_key.nil? - puts "# No key was found for #{key}" -else - puts GitlabKeys.key_line("key-#{authorized_key['id']}", authorized_key['key']) -end diff --git a/bin/gitlab-shell-authorized-principals-check-ruby b/bin/gitlab-shell-authorized-principals-check-ruby deleted file mode 100755 index 25ee612..0000000 --- a/bin/gitlab-shell-authorized-principals-check-ruby +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env ruby - -# -# GitLab shell authorized principals helper. Emits the same sort of -# command="..." line as gitlab-shell-authorized-principals-check, with -# the right options. -# -# Ex. -# bin/gitlab-shell-authorized-keys-check [...] -# -# Returns one line per principal passed in, e.g.: -# command="/bin/gitlab-shell username-{KEY_ID}",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty {PRINCIPAL} -# [command="/bin/gitlab-shell username-{KEY_ID}",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty {PRINCIPAL2}] -# -# Expects to be called by the SSH daemon, via configuration like: -# AuthorizedPrincipalsCommandUser root -# AuthorizedPrincipalsCommand /bin/gitlab-shell-authorized-principals-check git %i sshUsers - -abort "# Wrong number of arguments. #{ARGV.size}. Usage: -# gitlab-shell-authorized-principals-check [...]" unless ARGV.size >= 2 - -key_id = ARGV[0] -abort '# No key_id provided' if key_id.nil? || key_id == '' - -principals = ARGV[1..-1] -principals.each { |principal| - abort '# An invalid principal was provided' if principal.nil? || principal == '' -} - -require_relative '../lib/gitlab_init' -require_relative '../lib/gitlab_net' -require_relative '../lib/gitlab_keys' - -principals.each { |principal| - puts GitlabKeys.principal_line("username-#{key_id}", principal.dup) -} diff --git a/bin/gitlab-shell-ruby b/bin/gitlab-shell-ruby deleted file mode 100755 index 8d43cf1..0000000 --- a/bin/gitlab-shell-ruby +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env ruby - -unless ENV['SSH_CONNECTION'] - puts "Only ssh allowed" - exit -end - -original_cmd = ENV.delete('SSH_ORIGINAL_COMMAND') - -require_relative '../lib/gitlab_init' - -# -# -# GitLab shell, invoked from ~/.ssh/authorized_keys or from an -# AuthorizedPrincipalsCommand in the key-less SSH CERT mode. -# -# -require File.join(ROOT_PATH, 'lib', 'gitlab_shell') - -# 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)-[0-9]+|username-\S+)\b/.match(ARGV.join(' ')).to_s - -if GitlabShell.new(who).exec(original_cmd) - exit 0 -else - exit 1 -end diff --git a/bin/test-logger b/bin/test-logger deleted file mode 100755 index 11b2a55..0000000 --- a/bin/test-logger +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env ruby - -# The purpose of this executable is to test that gitlab-shell logging -# works correctly in combination with Kernel.exec. - -require_relative '../lib/gitlab_init' -require_relative '../lib/gitlab_logger' - -$logger.info(ARGV.first) -Kernel.exec('true') -- cgit v1.2.1