1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-11-23 05:47:53 +00:00

switch gpg2 to gpg1

This commit is contained in:
nishiki 2016-07-05 22:03:55 +02:00
parent ac3b7b1dde
commit 8e4027c822
5 changed files with 17 additions and 5 deletions

View file

@ -86,6 +86,7 @@ en:
title: "Setup a new config file"
lang: "Choose your language (en, fr, ...) [default=%{lang}]: "
gpg_key: "Enter the GPG key [ex: test@host.local]: "
gpg_exe: "Enter the executable GPG path (optional): "
wallet_dir: "Enter the wallets's folder path [default=%{home}/wallets]: "
valid: "The config file has been created!"
setup_wallet:

View file

@ -86,6 +86,7 @@ fr:
title: "Création d'un nouveau fichier de configuration"
lang: "Choisissez votre langue (en, fr, ...) [défaut=%{lang}]: "
gpg_key: "Entrez la clé GPG [ex: test@host.local]: "
gpg_exe: "Entrez le chemin de l'exécutable GPG (optionnel): "
wallet_dir: "Entrez le chemin du répertoire qui contiendra les porte-feuilles de mot de passe [défaut=%{home}/wallets]: "
valid: "Le fichier de configuration a bien été créé!"
setup_wallet:

View file

@ -30,6 +30,7 @@ class Config
attr_accessor :lang
attr_accessor :config_dir
attr_accessor :wallet_dir
attr_accessor :gpg_exe
# Constructor
# @args: config_file -> the specify config file
@ -53,8 +54,9 @@ class Config
# @args: key -> the gpg key to encrypt
# lang -> the software language
# wallet_dir -> the directory where are the wallets password
# gpg_exe -> the path of gpg executable
# @rtrn: true if le config file is create
def setup(key, lang, wallet_dir)
def setup(key, lang, wallet_dir, gpg_exe)
if not key =~ /[a-zA-Z0-9.-_]+\@[a-zA-Z0-9]+\.[a-zA-Z]+/
raise I18n.t('error.config.key_bad_format')
@ -67,6 +69,7 @@ class Config
config = {'config' => {'key' => key,
'lang' => lang,
'wallet_dir' => wallet_dir,
'gpg_exe' => gpg_exe,
}
}
@ -118,6 +121,7 @@ class Config
@key = config['config']['key']
@lang = config['config']['lang']
@wallet_dir = config['config']['wallet_dir']
@gpg_exe = config['config']['gpg_exe']
raise if @key.empty? or @wallet_dir.empty?

View file

@ -28,10 +28,15 @@ module MPW
class MPW
# Constructor
def initialize(key, wallet_file, gpg_pass=nil)
def initialize(key, wallet_file, gpg_pass=nil, gpg_exe=nil)
@key = key
@gpg_pass = gpg_pass
@gpg_exe = gpg_exe
@wallet_file = wallet_file
if @gpg_exe
GPGME::Engine.set_info(GPGME::PROTOCOL_OpenPGP, @gpg_exe, "#{Dir.home}/.gnupg")
end
end
# Read mpw file
@ -331,7 +336,7 @@ class MPW
sync.connect
sync.get(tmp_file)
remote = MPW.new(@key, tmp_file, @gpg_pass)
remote = MPW.new(@key, tmp_file, @gpg_pass, @gpg_exe)
remote.read_data
File.unlink(tmp_file) if File.exist?(tmp_file)

View file

@ -44,13 +44,14 @@ class Cli
language = ask(I18n.t('form.setup_config.lang', lang: lang)).to_s
key = ask(I18n.t('form.setup_config.gpg_key')).to_s
wallet_dir = ask(I18n.t('form.setup_config.wallet_dir', home: "#{@config.config_dir}")).to_s
gpg_exe = ask(I18n.t('form.setup_config.gpg_exe')).to_s
if language.nil? or language.empty?
language = lang
end
I18n.locale = language.to_sym
@config.setup(key, lang, wallet_dir)
@config.setup(key, lang, wallet_dir, gpg_exe)
raise I18n.t('error.config.check') if not @config.is_valid?
@ -122,7 +123,7 @@ class Cli
def decrypt
if not defined?(@mpw)
@password = ask(I18n.t('display.gpg_password')) {|q| q.echo = false}
@mpw = MPW.new(@config.key, @wallet_file, @password)
@mpw = MPW.new(@config.key, @wallet_file, @password, @config.gpg_exe)
end
@mpw.read_data