Sha256: c67a0bcce4c3e4030c952b31e3c4b2d8fbc80a3d22271e2bb91572a31a6ad916
Contents?: true
Size: 1019 Bytes
Versions: 18
Compression:
Stored size: 1019 Bytes
Contents
module Brightbox module Config module GpgEncryptedPasswords attr_writer :gpg_password def gpg_encrypted_password_filename file_name = "#{client_name}.password.gpg" @gpg_encrypted_password_filename ||= File.join(config_directory, file_name) end # Return the password from gpg if it's possible def gpg_password if defined?(@gpg_password) && !@gpg_password.nil? return @gpg_password end @gpg_password = if File.exist?(gpg_encrypted_password_filename) gpg_decrypt_password end end private # Use gpg to decrypt the password def gpg_decrypt_password info "INFO: Decrypting #{gpg_encrypted_password_filename} to obtain password" begin IO.popen(["gpg", "--decrypt", gpg_encrypted_password_filename], "r") do |io| io.read.chomp end rescue Errno::ENOENT nil end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems