mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-26 23:33:03 +00:00
switch gpg2 to gpg1
This commit is contained in:
parent
ac3b7b1dde
commit
8e4027c822
5 changed files with 17 additions and 5 deletions
|
@ -86,6 +86,7 @@ en:
|
||||||
title: "Setup a new config file"
|
title: "Setup a new config file"
|
||||||
lang: "Choose your language (en, fr, ...) [default=%{lang}]: "
|
lang: "Choose your language (en, fr, ...) [default=%{lang}]: "
|
||||||
gpg_key: "Enter the GPG key [ex: test@host.local]: "
|
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]: "
|
wallet_dir: "Enter the wallets's folder path [default=%{home}/wallets]: "
|
||||||
valid: "The config file has been created!"
|
valid: "The config file has been created!"
|
||||||
setup_wallet:
|
setup_wallet:
|
||||||
|
|
|
@ -86,6 +86,7 @@ fr:
|
||||||
title: "Création d'un nouveau fichier de configuration"
|
title: "Création d'un nouveau fichier de configuration"
|
||||||
lang: "Choisissez votre langue (en, fr, ...) [défaut=%{lang}]: "
|
lang: "Choisissez votre langue (en, fr, ...) [défaut=%{lang}]: "
|
||||||
gpg_key: "Entrez la clé GPG [ex: test@host.local]: "
|
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]: "
|
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éé!"
|
valid: "Le fichier de configuration a bien été créé!"
|
||||||
setup_wallet:
|
setup_wallet:
|
||||||
|
|
|
@ -30,6 +30,7 @@ class Config
|
||||||
attr_accessor :lang
|
attr_accessor :lang
|
||||||
attr_accessor :config_dir
|
attr_accessor :config_dir
|
||||||
attr_accessor :wallet_dir
|
attr_accessor :wallet_dir
|
||||||
|
attr_accessor :gpg_exe
|
||||||
|
|
||||||
# Constructor
|
# Constructor
|
||||||
# @args: config_file -> the specify config file
|
# @args: config_file -> the specify config file
|
||||||
|
@ -53,8 +54,9 @@ class Config
|
||||||
# @args: key -> the gpg key to encrypt
|
# @args: key -> the gpg key to encrypt
|
||||||
# lang -> the software language
|
# lang -> the software language
|
||||||
# wallet_dir -> the directory where are the wallets password
|
# wallet_dir -> the directory where are the wallets password
|
||||||
|
# gpg_exe -> the path of gpg executable
|
||||||
# @rtrn: true if le config file is create
|
# @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]+/
|
if not key =~ /[a-zA-Z0-9.-_]+\@[a-zA-Z0-9]+\.[a-zA-Z]+/
|
||||||
raise I18n.t('error.config.key_bad_format')
|
raise I18n.t('error.config.key_bad_format')
|
||||||
|
@ -67,6 +69,7 @@ class Config
|
||||||
config = {'config' => {'key' => key,
|
config = {'config' => {'key' => key,
|
||||||
'lang' => lang,
|
'lang' => lang,
|
||||||
'wallet_dir' => wallet_dir,
|
'wallet_dir' => wallet_dir,
|
||||||
|
'gpg_exe' => gpg_exe,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +121,7 @@ class Config
|
||||||
@key = config['config']['key']
|
@key = config['config']['key']
|
||||||
@lang = config['config']['lang']
|
@lang = config['config']['lang']
|
||||||
@wallet_dir = config['config']['wallet_dir']
|
@wallet_dir = config['config']['wallet_dir']
|
||||||
|
@gpg_exe = config['config']['gpg_exe']
|
||||||
|
|
||||||
raise if @key.empty? or @wallet_dir.empty?
|
raise if @key.empty? or @wallet_dir.empty?
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,15 @@ module MPW
|
||||||
class MPW
|
class MPW
|
||||||
|
|
||||||
# Constructor
|
# Constructor
|
||||||
def initialize(key, wallet_file, gpg_pass=nil)
|
def initialize(key, wallet_file, gpg_pass=nil, gpg_exe=nil)
|
||||||
@key = key
|
@key = key
|
||||||
@gpg_pass = gpg_pass
|
@gpg_pass = gpg_pass
|
||||||
|
@gpg_exe = gpg_exe
|
||||||
@wallet_file = wallet_file
|
@wallet_file = wallet_file
|
||||||
|
|
||||||
|
if @gpg_exe
|
||||||
|
GPGME::Engine.set_info(GPGME::PROTOCOL_OpenPGP, @gpg_exe, "#{Dir.home}/.gnupg")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Read mpw file
|
# Read mpw file
|
||||||
|
@ -331,7 +336,7 @@ class MPW
|
||||||
sync.connect
|
sync.connect
|
||||||
sync.get(tmp_file)
|
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
|
remote.read_data
|
||||||
|
|
||||||
File.unlink(tmp_file) if File.exist?(tmp_file)
|
File.unlink(tmp_file) if File.exist?(tmp_file)
|
||||||
|
|
|
@ -44,13 +44,14 @@ class Cli
|
||||||
language = ask(I18n.t('form.setup_config.lang', lang: lang)).to_s
|
language = ask(I18n.t('form.setup_config.lang', lang: lang)).to_s
|
||||||
key = ask(I18n.t('form.setup_config.gpg_key')).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
|
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?
|
if language.nil? or language.empty?
|
||||||
language = lang
|
language = lang
|
||||||
end
|
end
|
||||||
I18n.locale = language.to_sym
|
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?
|
raise I18n.t('error.config.check') if not @config.is_valid?
|
||||||
|
|
||||||
|
@ -122,7 +123,7 @@ class Cli
|
||||||
def decrypt
|
def decrypt
|
||||||
if not defined?(@mpw)
|
if not defined?(@mpw)
|
||||||
@password = ask(I18n.t('display.gpg_password')) {|q| q.echo = false}
|
@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
|
end
|
||||||
|
|
||||||
@mpw.read_data
|
@mpw.read_data
|
||||||
|
|
Loading…
Reference in a new issue