mpw 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/ruby
2
2
  # MPW is a software to crypt and manage your passwords
3
- # Copyright (C) 2016 Adrien Waksberg <mpw@yae.im>
4
- #
3
+ # Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
4
+ #
5
5
  # This program is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU General Public License
7
7
  # as published by the Free Software Foundation; either version 2
8
8
  # of the License, or (at your option) any later version.
9
- #
9
+ #
10
10
  # This program is distributed in the hope that it will be useful,
11
11
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
13
  # GNU General Public License for more details.
14
- #
14
+ #
15
15
  # You should have received a copy of the GNU General Public License
16
16
  # along with this program; if not, write to the Free Software
17
17
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -24,47 +24,76 @@ require 'mpw/cli'
24
24
  # Options
25
25
  # --------------------------------------------------------- #
26
26
 
27
- options = {}
28
- options[:sync] = true
29
- values = {}
27
+ values = {}
28
+ search = {}
29
+ options = {}
30
+ options[:text_editor] = false
30
31
 
31
32
  OptionParser.new do |opts|
32
- opts.banner = "#{I18n.t('option.usage')}: mpw update [options]"
33
+ opts.banner = "#{I18n.t('option.usage')}: mpw update [options]"
33
34
 
34
- opts.on('-c', '--config PATH', I18n.t('option.config')) do |config|
35
- options[:config] = config
36
- end
35
+ opts.on('-c', '--config PATH', I18n.t('option.config')) do |config|
36
+ options[:config] = config
37
+ end
37
38
 
38
- opts.on('-g', '--group NAME', I18n.t('option.group')) do |group|
39
- values[:group] = group
40
- end
39
+ opts.on('-C', '--comment COMMENT', I18n.t('option.comment')) do |comment|
40
+ values[:comment] = comment
41
+ end
41
42
 
42
- opts.on('-h', '--help', I18n.t('option.help')) do
43
- puts opts
44
- exit 0
45
- end
43
+ opts.on('-g', '--group NAME', I18n.t('option.group')) do |group|
44
+ search[:group] = group
45
+ end
46
46
 
47
- opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do
48
- options[:sync] = false
49
- end
47
+ opts.on('-G', '--new-group NAME', I18n.t('option.new_group')) do |group|
48
+ values[:group] = group
49
+ end
50
50
 
51
- opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern|
52
- values[:pattern] = pattern
53
- end
51
+ opts.on('-h', '--help', I18n.t('option.help')) do
52
+ puts opts
53
+ exit 0
54
+ end
54
55
 
55
- opts.on('-r', '--random', I18n.t('option.random_password')) do
56
- options[:password] = true
57
- end
56
+ opts.on('-H', '--host HOST', I18n.t('option.host')) do |host|
57
+ values[:host] = host
58
+ end
58
59
 
59
- opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
60
- options[:wallet] = wallet
61
- end
60
+ opts.on('-o', '--otp-code CODE', I18n.t('option.otp_code')) do |otp|
61
+ values[:otp_key] = otp
62
+ end
63
+
64
+ opts.on('-O', '--protocol PROTOCOL', I18n.t('option.protocol')) do |protocol|
65
+ values[:protocol] = protocol
66
+ end
67
+
68
+ opts.on('-p', '--pattern PATTERN', I18n.t('option.pattern')) do |pattern|
69
+ search[:pattern] = pattern
70
+ end
71
+
72
+ opts.on('-P', '--port NUMBER', I18n.t('option.port')) do |port|
73
+ values[:port] = port
74
+ end
75
+
76
+ opts.on('-r', '--random', I18n.t('option.random_password')) do
77
+ options[:password] = true
78
+ end
79
+
80
+ opts.on('-t', '--text-editor', I18n.t('option.text_editor')) do
81
+ options[:text_editor] = true
82
+ end
83
+
84
+ opts.on('-u', '--user USER', I18n.t('option.user')) do |user|
85
+ values[:user] = user
86
+ end
87
+
88
+ opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
89
+ options[:wallet] = wallet
90
+ end
62
91
  end.parse!
63
92
 
64
93
  config = MPW::Config.new(options[:config])
65
- cli = MPW::Cli.new(config, options[:sync])
94
+ cli = MPW::Cli.new(config)
66
95
 
67
96
  cli.load_config
68
97
  cli.get_wallet(options[:wallet])
69
98
  cli.decrypt
70
- cli.update(options[:password], values)
99
+ cli.update(options[:password], options[:text_editor], search, values)
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/ruby
2
2
  # MPW is a software to crypt and manage your passwords
3
- # Copyright (C) 2016 Adrien Waksberg <mpw@yae.im>
4
- #
3
+ # Copyright (C) 2017 Adrien Waksberg <mpw@yae.im>
4
+ #
5
5
  # This program is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU General Public License
7
7
  # as published by the Free Software Foundation; either version 2
8
8
  # of the License, or (at your option) any later version.
9
- #
9
+ #
10
10
  # This program is distributed in the hope that it will be useful,
11
11
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
13
  # GNU General Public License for more details.
14
- #
14
+ #
15
15
  # You should have received a copy of the GNU General Public License
16
16
  # along with this program; if not, write to the Free Software
17
17
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -25,92 +25,67 @@ require 'mpw/cli'
25
25
  # --------------------------------------------------------- #
26
26
 
27
27
  options = {}
28
- options[:sync] = {}
29
28
  options[:delete] = false
30
- values = {}
31
29
 
32
30
  OptionParser.new do |opts|
33
- opts.banner = "#{I18n.t('option.usage')}: mpw wallet [options]"
31
+ opts.banner = "#{I18n.t('option.usage')}: mpw wallet [options]"
34
32
 
35
- opts.on('-a', '--add-gpg-key NAME', I18n.t('option.add_gpg_key')) do |gpg_key|
36
- options[:gpg_key] = gpg_key
37
- end
33
+ opts.on('-a', '--add-gpg-key NAME', I18n.t('option.add_gpg_key')) do |gpg_key|
34
+ options[:gpg_key] = gpg_key
35
+ end
38
36
 
39
- opts.on('-c', '--config PATH', I18n.t('option.config')) do |config|
40
- options[:config] = config
41
- end
37
+ opts.on('-c', '--config PATH', I18n.t('option.config')) do |config|
38
+ options[:config] = config
39
+ end
42
40
 
43
- opts.on('-d', '--delete-gpg-key NAME', I18n.t('option.delete_gpg_key')) do |gpg_key|
44
- options[:gpg_key] = gpg_key
45
- options[:delete] = true
46
- end
41
+ opts.on('-d', '--delete-gpg-key NAME', I18n.t('option.delete_gpg_key')) do |gpg_key|
42
+ options[:gpg_key] = gpg_key
43
+ options[:delete] = true
44
+ end
47
45
 
48
- opts.on('-h', '--help', I18n.t('option.help')) do
49
- puts opts
50
- exit 0
51
- end
46
+ opts.on('-h', '--help', I18n.t('option.help')) do
47
+ puts opts
48
+ exit 0
49
+ end
52
50
 
53
- opts.on('--host NAME', I18n.t('option.host')) do |host|
54
- values[:host] = host
55
- end
51
+ opts.on('-l', '--list', I18n.t('option.list')) do
52
+ options[:list] = true
53
+ end
56
54
 
57
- opts.on('-l', '--list', I18n.t('option.list')) do
58
- options[:list] = true
59
- end
55
+ opts.on('-L', '--list-keys', I18n.t('option.list_keys')) do
56
+ options[:list_keys] = true
57
+ end
60
58
 
61
- opts.on('-L', '--list-keys', I18n.t('option.list_keys')) do
62
- options[:list_keys] = true
63
- end
59
+ opts.on('-p', '--path PATH', I18n.t('option.path')) do |path|
60
+ options[:path] = path
61
+ end
64
62
 
65
- opts.on('-n', '--no-sync', I18n.t('option.no_sync')) do
66
- options[:sync] = false
67
- end
63
+ opts.on('-P', '--default-path', I18n.t('option.default_path')) do
64
+ options[:path] = 'default'
65
+ end
68
66
 
69
- opts.on('--password', I18n.t('option.password')) do
70
- values[:password] = true
71
- end
72
-
73
- opts.on('--path PATH', I18n.t('option.path')) do |path|
74
- values[:path] = path
75
- end
76
-
77
- opts.on('--port NUMBER', I18n.t('option.port')) do |port|
78
- values[:port] = port
79
- end
80
-
81
- opts.on('--protocol NAME', I18n.t('option.protocol')) do |protocol|
82
- values[:protocol] = protocol
83
- end
84
-
85
- opts.on('--user NAME', I18n.t('option.user')) do |user|
86
- values[:user] = user
87
- end
88
-
89
- opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
90
- options[:wallet] = wallet
91
- end
67
+ opts.on('-w', '--wallet NAME', I18n.t('option.wallet')) do |wallet|
68
+ options[:wallet] = wallet
69
+ end
92
70
  end.parse!
93
71
 
94
72
  config = MPW::Config.new(options[:config])
95
- cli = MPW::Cli.new(config, options[:sync])
73
+ cli = MPW::Cli.new(config)
96
74
 
97
75
  cli.load_config
98
76
 
99
- if not options[:list].nil?
100
- cli.list_wallet
77
+ if options.key?(:list)
78
+ cli.list_wallet
79
+ elsif options.key?(:path)
80
+ cli.get_wallet(options[:wallet])
81
+ cli.set_wallet_path(options[:path])
101
82
  else
102
- cli.get_wallet(options[:wallet])
103
- cli.decrypt
104
-
105
- if not options[:list_keys].nil?
106
- cli.list_keys
107
- elsif not options[:gpg_key].nil?
108
- if options[:delete]
109
- cli.delete_key(options[:gpg_key])
110
- else
111
- cli.add_key(options[:gpg_key])
112
- end
113
- elsif not values.empty?
114
- cli.setup_wallet_config(values)
115
- end
83
+ cli.get_wallet(options[:wallet])
84
+ cli.decrypt
85
+
86
+ if options.key?(:list_keys)
87
+ cli.list_keys
88
+ elsif options.key?(:gpg_key)
89
+ options[:delete] ? cli.delete_key(options[:gpg_key]) : cli.add_key(options[:gpg_key])
90
+ end
116
91
  end
@@ -23,15 +23,6 @@ en:
23
23
  import: "Can't import, unable to read %{file}!"
24
24
  update:
25
25
  host_empty: "You must define a host!"
26
- sync:
27
- general: "An error has appeared during the sync"
28
- connection: "Connection fail!"
29
- communication: "A communication problem with the server is appeared!"
30
- download: "Can't download the file!"
31
- not_authorized: "You haven't the access to remote file!"
32
- upload: "Can't upload the file on the server!"
33
- unknown: "An unknown error is occured!"
34
- unknown_type: "The sync type is unknown"
35
26
 
36
27
  warning:
37
28
  select: 'Your choice is not a valid element!'
@@ -52,12 +43,15 @@ en:
52
43
  add: "Add an item or key"
53
44
  add_gpg_key: "Share the wallet with an other GPG key"
54
45
  alpha: "Use letter to generate a password"
46
+ comment: "Specify a comment"
55
47
  config: "Specify the configuration file to use"
56
48
  clipboard: "Disable the clipboard feature"
49
+ default_path: "Move the wallet in default directory"
57
50
  default_wallet: "Specify the default wallet to use"
58
51
  delete_gpg_key: "Delete the wallet's share with an other GPG key"
59
52
  disable_alpha: "Don't use letter to generate a password"
60
53
  disable_numeric: "Don't use number to generate a password"
54
+ disable_pinmode: "Disable the pinentry mode"
61
55
  disable_special_chars: "Don't use special char to generate a password"
62
56
  export: "Export a wallet in an yaml file"
63
57
  file_export: "Specify the file where export data"
@@ -68,7 +62,7 @@ en:
68
62
  gpg_key: "Specify a GPG key (ex: user@example.com)"
69
63
  group: "Search the items with specified group"
70
64
  help: "Show this help message"
71
- host: "Specify the server for the synchronization"
65
+ host: "Specify a host or ip"
72
66
  init: "Initialize mpw"
73
67
  import: "Import item since a yaml file"
74
68
  key: "Specify the key name"
@@ -76,21 +70,23 @@ en:
76
70
  length: "Size of the password"
77
71
  list: "List the wallets"
78
72
  list_keys: "List the GPG keys in wallet"
79
- no_sync: "Disable synchronization with the server"
73
+ new_group: "Specify the group for the item"
80
74
  numeric: "Use number to generate a password"
81
- password: "Change the password for the synchronization"
82
- path: "Specify the remote path"
75
+ otp_code: "Set an otp key"
76
+ path: "Move the wallet in new specify directory"
83
77
  pattern: "Given search pattern"
84
- port: "Specify the connection port"
85
- protocol: "Specify the protocol for the connection"
78
+ pinmode: "Enable pinentry mode (available with gpg >= 2.1)"
79
+ port: "Set a port of connexion"
80
+ protocol: "Set a protocol of connexion"
86
81
  random_password: "Generate a random password"
87
82
  setup: "Create a new configuration file"
88
83
  setup_wallet: "Create a new configuration file for a wallet"
89
84
  special_chars: "Use special char to generate a password"
90
85
  show: "Search and show the items"
91
86
  show_all: "List all items"
87
+ text_editor: "Use text editor to edit the item"
92
88
  usage: "Usage"
93
- user: "Specify the user for the connection"
89
+ user: "Set an user"
94
90
  wallet: "Specify a wallet to use"
95
91
  wallet_dir: "Set the wallets folder"
96
92
 
@@ -134,6 +130,8 @@ en:
134
130
  not_valid: "No data to import!"
135
131
  set_config:
136
132
  valid: "The config file has been edited!"
133
+ set_wallet_path:
134
+ valid: "The wallet has well moved!"
137
135
  setup_config:
138
136
  title: "Setup a new config file"
139
137
  lang: "Choose your language (en, fr, ...) [default=%{lang}]: "
@@ -141,16 +139,6 @@ en:
141
139
  gpg_exe: "Enter the executable GPG path (optional): "
142
140
  wallet_dir: "Enter the wallets's folder path [default=%{home}/wallets]: "
143
141
  valid: "The config file has been created!"
144
- setup_wallet:
145
- password: "Sync password: "
146
- title: "Wallet setup"
147
- sync_type: "Synchronization type (ssh, ftp): "
148
- sync_host: "Synchronization server: "
149
- sync_port: "Port of the synchronization server: "
150
- sync_user: "Username for the synchronization: "
151
- sync_pwd: "Password for the synchronization: "
152
- sync_path: "File path for the synchronization : "
153
- valid: "The wallet config file has been created!"
154
142
  setup_gpg_key:
155
143
  title: "Setup a GPG key"
156
144
  ask: "Do you want create your GPG key ? (Y/n)"
@@ -179,6 +167,7 @@ en:
179
167
 
180
168
  display:
181
169
  comment: "Comment"
170
+ config: "Configuration"
182
171
  error: "ERROR"
183
172
  keys: "GPG keys"
184
173
  gpg_password: "GPG passphrase: "
@@ -23,15 +23,6 @@ fr:
23
23
  import: "Impossible d'importer le fichier %{file}, car il n'est pas lisible!"
24
24
  update:
25
25
  host_empty: "Vous devez définir un host!"
26
- sync:
27
- general: "Une erreur est survenue durant la synchronisation"
28
- connection: "La connexion n'a pu être établie!"
29
- communication: "Un problème de communication avec le serveur est apparu!"
30
- download: "Impossible de télécharger le fichier!"
31
- not_authorized: "Vous n'avez pas les autorisations d'accès au fichier distant!"
32
- upload: "Impossible d'envoyer le fichier sur le serveur!"
33
- unknown: "Une erreur inconnue est survenue!"
34
- unknown_type: "Le type de synchronisation est inconnu"
35
26
 
36
27
  warning:
37
28
  select: "Votre choix n'est pas un élément valide!"
@@ -53,11 +44,14 @@ fr:
53
44
  add_gpg_key: "Partage le portefeuille avec une autre clé GPG"
54
45
  alpha: "Utilise des lettres dans la génération d'un mot de passe"
55
46
  config: "Spécifie le fichier de configuration à utiliser"
47
+ comment: "Spécifie un commentaire"
56
48
  clipboard: "Désactive la fonction presse papier"
49
+ default_path: "Déplace le portefeuille dans le dossier par défaut"
57
50
  default_wallet: "Spécifie le porte-feuille à utiliser par défaut"
58
51
  delete_gpg_key: "Supprime le partage le portefeuille avec une autre clé GPG"
59
52
  disable_alpha: "Désactive l'utilisation des lettres dans la génération d'un mot de passe"
60
53
  disable_numeric: "Désactive l'utilisation des chiffre dans la génération d'un mot de passe"
54
+ disable_pinmode: "Désactive le mode pinentry"
61
55
  disable_special_chars: "Désactive l'utilisation des charactères speciaux dans la génération d'un mot de passe"
62
56
  export: "Exporte un portefeuille dans un fichier yaml"
63
57
  file_export: "Spécifie le fichier où exporter les données"
@@ -68,7 +62,7 @@ fr:
68
62
  gpg_key: "Spécifie une clé GPG (ex: user@example.com)"
69
63
  group: "Recherche les éléments appartenant au groupe spécifié"
70
64
  help: "Affiche ce message d'aide"
71
- host: "Spécifie le serveur pour la synchronisation"
65
+ host: "Spécifie le nom du serveur ou l'ip"
72
66
  import: "Importe des éléments depuis un fichier yaml"
73
67
  init: "Initialise mpw"
74
68
  key: "Spécifie le nom d'une clé"
@@ -76,21 +70,23 @@ fr:
76
70
  length: "Taille du mot de passe"
77
71
  list: "Liste les portefeuilles"
78
72
  list_keys: "Liste les clés GPG dans le portefeuille"
79
- no_sync: "Désactive la synchronisation avec le serveur"
73
+ new_group: "Spécifie le groupe de l'item"
80
74
  numeric: "Utilise des chiffre dans la génération d'un mot de passe"
81
- password: "Changer le mot de passe de connexion"
82
- path: "Spécifie le chemin distant"
75
+ otp_code: "Spécifie un code OTP"
76
+ path: "Déplace le portefeuille dans un nouveau dossier"
83
77
  pattern: "Motif de donnée à chercher"
84
- port: "Spécifie le port de connexion"
85
- protocol: "Spécifie le protocol utilisé pour la connexion"
78
+ pinmode: "Active le mode pinentry (valable avec gpg >= 2.1)"
79
+ port: "Spécifie un port de connexion"
80
+ protocol: "Spécifie un protocol de connexion"
86
81
  random_password: "Génére un mot de passe aléatoire"
87
82
  setup: "Création d'un nouveau fichier de configuration"
88
83
  setup_wallet: "Création d'un nouveau fichier de configuration pour un portefeuille"
89
84
  special_chars: "Utilise des charactères speciaux dans la génération d'un mot de passe"
90
85
  show: "Recherche et affiche les éléments"
91
86
  show_all: "Liste tous les éléments"
87
+ text_editor: "Active l'édition avec un éditeur de texte"
92
88
  usage: "Utilisation"
93
- user: "Spécifie l'identifiant de connection"
89
+ user: "Spécifie un utilisateur"
94
90
  wallet: "Spécifie le portefeuille à utiliser"
95
91
  wallet_dir: "Spécifie le répertoire des portefeuilles"
96
92
 
@@ -134,6 +130,8 @@ fr:
134
130
  not_valid: "Aucune donnée à importer!"
135
131
  set_config:
136
132
  valid: "Le fichier de configuration a bien été modifié!"
133
+ set_wallet_path:
134
+ valid: "Le portefeuille a bien été déplacé!"
137
135
  setup_config:
138
136
  title: "Création d'un nouveau fichier de configuration"
139
137
  lang: "Choisissez votre langue (en, fr, ...) [défaut=%{lang}]: "
@@ -141,16 +139,6 @@ fr:
141
139
  gpg_exe: "Entrez le chemin de l'exécutable GPG (optionnel): "
142
140
  wallet_dir: "Entrez le chemin du répertoire qui contiendra les porte-feuilles de mot de passe [défaut=%{home}/wallets]: "
143
141
  valid: "Le fichier de configuration a bien été créé!"
144
- setup_wallet:
145
- password: "Mot de passe de synchronisation: "
146
- title: "Configuration du porte-feuille"
147
- sync_type: "Type de synchronisation (ssh, ftp): "
148
- sync_host: "Serveur: "
149
- sync_port: "Port: "
150
- sync_user: "Utilisateur: "
151
- sync_pwd: "Mot de passe: "
152
- sync_path: "Chemin du fichier: "
153
- valid: "Le fichier de configuration du porte-feuille a bien été créé!"
154
142
  setup_gpg_key:
155
143
  title: "Configuration d'une nouvelle clé GPG"
156
144
  ask: "Voulez vous créer votre clé GPG ? (O/n)"
@@ -179,6 +167,7 @@ fr:
179
167
 
180
168
  display:
181
169
  comment: "Commentaire"
170
+ config: "Configuration"
182
171
  error: "ERREUR"
183
172
  keys: "Clés GPG"
184
173
  gpg_password: "Mot de passe GPG: "