diff options
author | Philip Hands <phil@hands.com> | 2016-05-11 17:11:01 +0200 |
---|---|---|
committer | Philip Hands <phil@hands.com> | 2016-05-11 17:11:01 +0200 |
commit | a5d56e3b5443263b53b0487c81125123411bd0cf (patch) | |
tree | 71b1bdafc0a5978bca9073609eff33e228e29a12 /features/support/helpers/sshd_helper.rb | |
parent | 555d9414f758cc0062eff700a0352ae177fd9be5 (diff) | |
download | jenkins.debian.net-a5d56e3b5443263b53b0487c81125123411bd0cf.tar.xz |
move cucumber things under cucumber/
Diffstat (limited to 'features/support/helpers/sshd_helper.rb')
-rw-r--r-- | features/support/helpers/sshd_helper.rb | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/features/support/helpers/sshd_helper.rb b/features/support/helpers/sshd_helper.rb deleted file mode 100644 index 2e0069c0..00000000 --- a/features/support/helpers/sshd_helper.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'tempfile' - -class SSHServer - def initialize(sshd_host, sshd_port, authorized_keys = nil) - @sshd_host = sshd_host - @sshd_port = sshd_port - @authorized_keys = authorized_keys - @pid = nil - end - - def start - @sshd_key_file = Tempfile.new("ssh_host_rsa_key", $config["TMPDIR"]) - # 'hack' to prevent ssh-keygen from prompting to overwrite the file - File.delete(@sshd_key_file.path) - cmd_helper(['ssh-keygen', '-t', 'rsa', '-N', "", '-f', "#{@sshd_key_file.path}"]) - @sshd_key_file.close - - sshd_config =<<EOF -Port #{@sshd_port} -ListenAddress #{@sshd_host} -UsePrivilegeSeparation no -HostKey #{@sshd_key_file.path} -Pidfile #{$config['TMPDIR']}/ssh.pid -EOF - - @sshd_config_file = Tempfile.new("sshd_config", $config["TMPDIR"]) - @sshd_config_file.write(sshd_config) - - if @authorized_keys - @authorized_keys_file = Tempfile.new("authorized_keys", $config['TMPDIR']) - @authorized_keys_file.write(@authorized_keys) - @authorized_keys_file.close - @sshd_config_file.write("AuthorizedKeysFile #{@authorized_keys_file.path}") - end - - @sshd_config_file.close - - cmd = ["/usr/sbin/sshd", "-4", "-f", @sshd_config_file.path, "-D"] - - job = IO.popen(cmd) - @pid = job.pid - end - - def stop - File.delete("#{@sshd_key_file.path}.pub") - File.delete("#{$config['TMPDIR']}/ssh.pid") - begin - Process.kill("TERM", @pid) - rescue - # noop - end - end - - def active? - begin - ret = Process.kill(0, @pid) - rescue Errno::ESRCH => e - if e.message == "No such process" - return false - else - raise e - end - end - assert_equal(1, ret, "This shouldn't happen") - return true - end -end |