我测试从gitlab 6.9.2升级到了最新版本,但是clone总是提示输入密码,
发现gitlab没办法产生 authorized_keys文件内容,获得lock文件的时候超时了
由于没用过ruby,索性把
/gitlab/apps/gitlab/gitlab-shell/lib/gitlab_keys.rb
里面关于lock的调用删了:变成如下文件,问题解决了,就是不要人多的时候不要同时操作sshkey
临时fix一下。
require 'tempfile'
require_relative 'gitlab_config'
require_relative 'gitlab_logger'
class GitlabKeys
attr_accessor :auth_file, :key
def initialize
@command = ARGV.shift
@key_id = ARGV.shift
@key = ARGV.shift
@auth_file = GitlabConfig.new.auth_file
end
def exec
case @command
when 'add-key'; add_key
when 'batch-add-keys'; batch_add_keys
when 'rm-key'; rm_key
when 'clear'; clear
else
$logger.warn "Attempt to execute invalid gitlab-keys command #{@command.inspect}."
puts 'not allowed'
false
end
end
protected
def add_key
$logger.info "Adding key #{@key_id} => #{@key.inspect}"
auth_line = key_line(@key_id, @key)
open(auth_file, 'a') { |file| file.puts(auth_line) }
true
end
def batch_add_keys
open(auth_file, 'a') do |file|
stdin.each_line do |input|
tokens = input.strip.split("\t")
abort("#{$0}: invalid input #{input.inspect}") unless tokens.count == 2
key_id, public_key = tokens
$logger.info "Adding key #{key_id} => #{public_key.inspect}"
file.puts(key_line(key_id, public_key))
end
end
true
end
def stdin
$stdin
end
def key_line(key_id, public_key)
auth_line = "command=\"#{ROOT_PATH}/bin/gitlab-shell #{key_id}\",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty #{public_key}"
end
def rm_key
$logger.info "Removing key #{@key_id}"
Tempfile.open('authorized_keys') do |temp|
open(auth_file, 'r+') do |current|
current.each do |line|
temp.puts(line) unless line.include?("/bin/gitlab-shell #{@key_id}\"")
end
end
temp.close
FileUtils.cp(temp.path, auth_file)
end
true
end
def clear
open(auth_file, 'w') { |file| file.puts '# Managed by gitlab-shell' }
true
end
def lock(timeout = 10)
File.open(lock_file, "w+") do |f|
begin
f.flock File::LOCK_EX
Timeout::timeout(timeout) { yield }
ensure
f.flock File::LOCK_UN
end
end
end
def lock_file
@lock_file ||= auth_file + '.lock'
end
end
相关推荐
文本批量处理工具npp_6.9.2
编辑器/开发技术 Notepad++ Installer for Windows 7, 8 and 10 npp.6.9.2.Installer.exe
node-6.9.2-win64
node6.9.2资源
精易模块V6.9.2 what's new:(20181220)。一、新增。1、新增“外部超级列表框_置行列颜色”“外部超级列表框_删除行列颜色”“外部超级列表框_清空列颜色”增强超级列表框显示;。2、新增“窗口_取点标题”取出...
notepad++ 6.9.2,功能强大,直接安装使用,简洁方便。
node-v6.9.2-x64.msi
2023最新 子比主题V6.9.2 开心版源码下载 | Wordpress主题 | 亲测可用
Notepad++中文版 v6.9.2 仅用于学习研究. 不得用于商业用处.
npp_6.9.2_Installer(修改代码必备)
Notepad++ Installer for Windows 7, 8 and 10
6.9.2_1 Package size: 44.59 MB Package type: DEB MD5 signature: 86fe9a0f9ee06ee6fce41aa36674f727 For: Debian GNU Linux 4.0 Etch/5.0 Lenny/6.0 Squeeze/7.0 Wheezy/8.0 Jessie/9.0 Stretch/10.0 ...
otepad++ 内置支持多达27种语法高亮度显示(包括各种常见的源代码、脚本,能够很好地支持。nfo文件查看),还支持自定义语言。 可自动检测文件类型,根据关键字显示节点,节点可自由折叠/打开,还可显示缩进引导线...
NPM是随同NodeJS一起安装的包管理工具,能解决NodeJS代码部署上的很多问题,常见的使用场景有以下几种: 允许用户从NPM服务器下载别人编写的第三方包到本地使用。 允许用户从NPM服务器下载并安装别人编写的命令行...
ImageMagick-6.9.2-1-Q16-x64-dll.exe
NFC Tools.6.9.2.apk
DDCash_v6.9.2.apk
精易模块V6.9.2 what's new:(20181220)一、新增1、新增“外部超级列表框_置行列颜色”“外部超级列表框_删除行列颜色”“外部超级列表框_清空列颜色”增强超级列表框显示;2、新增“窗口_取点标题”取出指定坐标...