gtk2passwordapp 3.0.1 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3096d8cac3f08f0bd5b4080070e0f0437cd5b3b
4
- data.tar.gz: f86ceb9ba53ad2482651ab5a4c6e9f28aa9fe13c
3
+ metadata.gz: 11308200b5ab1b17d64fd64f83b5bbe177ec33c1
4
+ data.tar.gz: 4d9f900382dce5734a19422ef93c6bbe92f0ca99
5
5
  SHA512:
6
- metadata.gz: 914bf9cd39e506449050959f2dbcf47ab305d427bcd8235d492c89b21a0085796bf56b1f88332a4c55663896e0aa54f6b21cf375e9c47e7783d09fcd5e3de9e8
7
- data.tar.gz: 8bfb6364e43931b1d41cecefc8569049d6e51d3174407915959861a2981039fa5d8db6bbe28479a981888141cc2035ed777cd6cb4661abc5ee0226c06af70632
6
+ metadata.gz: 332511e71e750647a1aa29f2fc34282fd0e301f2cbf3d43f00868d715891df66fb6649c8abf1fb6a8548bf58f1c39dbfab5766b7d807f831d35099a140967921
7
+ data.tar.gz: 2e0de2bb39953fd6403e803d223d5d1e9b57d093665b4d4937848458cac087935d6d7c74fca55620659e021fb1a8bd3583134c83bf52ea4f6cea0fed50fb9dac
data/README.rdoc ADDED
@@ -0,0 +1,63 @@
1
+ = Gtk2passwordapp
2
+
3
+ {<img src="https://badge.fury.io/rb/gtk2passwordapp.svg" alt="Gem Version" />}[http://badge.fury.io/rb/gtk2passwordapp]
4
+
5
+ == DESCRIPTION:
6
+
7
+ Ruby-Gnome Password Manager.
8
+
9
+ Uses Blowfish to encrypt the datafile.
10
+ Features random password generator and clipboard use.
11
+
12
+ == INSTALL:
13
+
14
+ sudo gem install gtk2passwordapp
15
+
16
+ == HELP:
17
+
18
+ Usage:
19
+ gtk3app gtk2passwordapp [--help] [--version]
20
+ gtk2passwordapp [--no-gui [--dump [--verbose]]] [account]
21
+
22
+ == MORE:
23
+
24
+ I think the GUI is very intuitive.
25
+ "Mouse Left Click" on window to get the application menu.
26
+ Anything I thought could be customized I made configurable.
27
+ See:
28
+
29
+ ~/.config/gtk3app/gtk2passwordapp/config.yml
30
+
31
+ You may want to change the following settings:
32
+
33
+ [Help] Add any notes to yourself you want.
34
+ [SharedSecretFile] You may prefer it to be a file in some removable media.
35
+ [BackupFile] Although the GUI allows you to specify the file, this gives a default.
36
+ [TooOld] I have this set for a year (in seconds).
37
+ [CustomDigits] I have this as "ABC...XYZ" for CAPS.
38
+ [Custom] I have this as CAPS. Describes CustomDigits.
39
+
40
+ == LICENSE:
41
+
42
+ (The MIT License)
43
+
44
+ Copyright (c) 2014
45
+
46
+ Permission is hereby granted, free of charge, to any person obtaining
47
+ a copy of this software and associated documentation files (the
48
+ 'Software'), to deal in the Software without restriction, including
49
+ without limitation the rights to use, copy, modify, merge, publish,
50
+ distribute, sublicense, and/or sell copies of the Software, and to
51
+ permit persons to whom the Software is furnished to do so, subject to
52
+ the following conditions:
53
+
54
+ The above copyright notice and this permission notice shall be
55
+ included in all copies or substantial portions of the Software.
56
+
57
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
58
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
59
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
60
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
61
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
62
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
63
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rafini'
3
+ using Rafini::Exception
4
+ using Rafini::Array
5
+
6
+ begin
7
+ nogui, hlp, vrs = ARGV.any?('--no-gui'), ARGV.any?('-h', '--help'), ARGV.any?('-v', '--version')
8
+ if nogui or hlp or vrs
9
+ # Going to proceed on need only basis, which may break some conventions...
10
+
11
+ # Get the version.
12
+ require 'gtk2passwordapp/version'
13
+ mod = Gtk2passwordapp
14
+ version = mod::VERSION
15
+ if vrs
16
+ puts version
17
+ exit
18
+ end
19
+
20
+ vbs = ARGV.any?('-V', '--verbose')
21
+
22
+ # Get the config.
23
+ require 'xdg'
24
+ require 'gtk2passwordapp/config'
25
+ config = mod::CONFIG
26
+ if hlp and !vbs
27
+ # Note that this will be the original help without any of the user's edit.
28
+ puts config[:Help]
29
+ exit
30
+ end
31
+
32
+ # Where are the user's data?
33
+ require 'user_space'
34
+ require 'yaml'
35
+ UserSpace::OPTIONS[:parser] = YAML
36
+ UserSpace::OPTIONS[:ext] = 'yml'
37
+ appdir = mod::APPDIR
38
+ appname = File.join 'gtk3app', mod.name.downcase
39
+ user_space = UserSpace.new(appname: appname, appdir: appdir)
40
+ user_space.install unless user_space.version == version
41
+ user_space.configures(config)
42
+
43
+ if hlp # and vbs
44
+ # Presumably, the user may have edited the help and is requesting this version.
45
+ puts config[:Help]
46
+ exit
47
+ end
48
+
49
+ # It's possible that the password file it not there.
50
+ pwd_file = config[:PwdFile]
51
+ raise "Could not find passwords data file." unless File.exist? pwd_file
52
+
53
+ # Going to get and verify the password.
54
+ require 'io/console' # Standard library
55
+ pwd0 = nil
56
+ print 'Password: '
57
+ pwd = $stdin.noecho(&:gets).strip
58
+ while pwd != pwd0
59
+ exit if pwd == ''
60
+ pwd0 = pwd
61
+ puts
62
+ print 'Again: '
63
+ pwd = $stdin.noecho(&:gets).strip
64
+ end
65
+ puts
66
+
67
+ # Ready to read the passwords file.
68
+ require 'yaml_zlib_blowfish'
69
+ require 'gtk2passwordapp/account'
70
+ require 'gtk2passwordapp/accounts'
71
+ accounts = Gtk2passwordapp::Accounts.new(pwd_file, pwd)
72
+ accounts.load
73
+
74
+ # Does the user want a data dump?
75
+ if ARGV.include? '--dump'
76
+ puts
77
+ # Remember that ARGV is at least ['--no-gui'].
78
+ pattern = (ARGV.last[0]=='-')? nil : Regexp.new(ARGV.last)
79
+ now = Time.now.to_i
80
+ accounts.names.each do |name|
81
+ next if pattern and not pattern=~name
82
+ account = accounts.get(name)
83
+ puts [account.name, account.username, account.password].join("\n\t")
84
+ if vbs
85
+ puts "\t" + account.url
86
+ puts "\t" + account.note
87
+ using Rafini::Odometers
88
+ puts "\tUpdated " + (now - account.updated).sec2time.to_s + ' ago.'
89
+ end
90
+ puts
91
+ end
92
+ exit
93
+ end
94
+
95
+ # Looks like the user just wants a particular password.
96
+ # Get the account name.
97
+ unless name = (ARGV.last[0]=='-')? nil : ARGV.last
98
+ print 'Account Name: '
99
+ name = $stdin.gets.strip
100
+ end
101
+ # Does the given account exist?
102
+ raise "Could not find account \"#{name}\"." unless accounts.include?(name)
103
+
104
+ # Put the password!
105
+ account = accounts.get(name)
106
+ password = account.password
107
+ puts password
108
+
109
+ # And we're done!
110
+ exit
111
+ end
112
+ rescue StandardError
113
+ $!.puts
114
+ exit 1
115
+ end
116
+
117
+ # Run gui!
118
+ require 'gtk3app'
119
+ ARGV.unshift 'gtk2passwordapp' # going to pretend to be gtk3app
120
+ Gtk3App.main
data/data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 4.0.1
data/data/logo.png ADDED
Binary file
@@ -1,305 +1,19 @@
1
- require 'gtk2passwordapp/passwords'
2
- require 'gtk2passwordapp/rnd'
3
-
4
- module Gtk2Password
5
-
6
- ABOUT = {
7
- 'name' => 'Ruby-Gnome Password Manager III',
8
- 'authors' => ['carlosjhr64@gmail.com'],
9
- 'website' => 'https://sites.google.com/site/gtk2applib/home/gtk2applib-applications/gtk2passwordapp',
10
- 'website-label' => 'Ruby-Gnome Password Manager',
11
- 'license' => 'GPL',
12
- 'copyright' => '2014-07-29 17:00:00',
13
- }
14
-
15
- PRIMARY = Gtk::Clipboard.get((Configuration::SWITCH_CLIPBOARDS)? Gdk::Selection::CLIPBOARD: Gdk::Selection::PRIMARY)
16
- CLIPBOARD = Gtk::Clipboard.get((Configuration::SWITCH_CLIPBOARDS)? Gdk::Selection::PRIMARY: Gdk::Selection::CLIPBOARD)
17
-
18
- @@thread = nil
19
- def self.clear_clipboard
20
- @@thread.kill if !@@thread.nil?
21
- @@thread = Thread.new do
22
- sleep Configuration::CLIPBOARD_TIMEOUT
23
- PRIMARY.text = ''
24
- CLIPBOARD.text = ''
25
- end
26
- end
27
-
28
- Passwords::PROMPT[:password] = Configuration::PASSWORD
29
- Passwords::PROMPT[:again] = Configuration::AGAIN
30
- Passwords::PROMPT[:retry] = Configuration::RETRY
31
-
32
- Configuration::GUI.each do |clss,spr,keys|
33
- code = Gtk2AppLib::Component.define(clss,spr,keys)
34
- $stderr.puts "<<<START CODE EVAL>>>\n#{code}\n<<<END CODE EVAL>>>" if $trace && $verbose
35
- eval( code )
36
- end
37
-
38
- # App is an App is an App...
39
- class App
40
- @@index = 0
41
-
42
- def initialize(program)
43
- @program = program
44
- @passwords = Gtk2Password::Passwords.new(Configuration::PASSWORDS_FILE) do |prompt|
45
- Gtk2Password.get_password(prompt,prompt) || exit
46
- end
47
- @passwords.expired = Configuration::PASSWORD_EXPIRED
48
- @modified = false
49
- self.build_menu
50
- program.window do |window|
51
- @window = window
52
- self.pre_gui
53
- @gui = self.build_gui
54
- self.post_gui
55
- end
56
- end
57
-
58
- def menu_item(account)
59
- item = @program.append_dock_menu(account) do
60
- @@index = @passwords.accounts.index(account)
61
- PRIMARY.text = @passwords.password_of(account)
62
- CLIPBOARD.text = @passwords.username_of(account)
63
- Gtk2Password.clear_clipboard
64
- end
65
- item.child.modify_fg(Gtk::STATE_NORMAL, Configuration::EXPIRED_COLOR) if @passwords.expired?(account)
66
- end
67
-
68
- def build_menu
69
- if @program.icon? then
70
- @program.clear_dock_menu
71
- @program.append_dock_menu(Gtk::SeparatorMenuItem.new)
72
- @passwords.accounts.each{|account| menu_item(account)}
73
- end
74
- end
75
-
76
- def _save
77
- @passwords.save
78
- Gtk2Password.passwords_updated
79
- build_menu
80
- end
81
-
82
- def save
83
- if @modified then
84
- _save
85
- @modified = false
86
- else
87
- Gtk2AppLib::DIALOGS.quick_message(*Gtk2Password::Configuration::NO_UPDATES)
88
- end
89
- end
90
-
91
- def finalyze
92
- if @modified then
93
- if Gtk2AppLib::DIALOGS.question?(*Gtk2Password::Configuration::WANT_TO_SAVE) then
94
- save
95
- @modified = false
96
- end
97
- end
98
- if @modified then
99
- @passwords.load # revert
100
- @modified = false
101
- end
102
- end
103
-
104
- def post_gui
105
- @gui[:password_spinbutton].value = Gtk2Password::Configuration::DEFAULT_PASSWORD_LENGTH
106
- @gui[:account_comboboxentry].active = @@index
107
- @window.signal_connect('destroy'){ finalyze }
108
- @window.show_all
109
- end
110
-
111
- def pre_gui
112
- Gtk2AppLib::Configuration::PARAMETERS[:Account_ComboBoxEntry][0] = @passwords.accounts
113
- Gtk2AppLib::Dialogs::DIALOG[:Window] = @window
114
- end
115
-
116
- def close
117
- if !@modified || Gtk2AppLib::DIALOGS.question?(*Gtk2Password::Configuration::ARE_YOU_SURE) then
118
- @passwords.load # revert
119
- @modified = false
120
- @program.close
121
- end
122
- end
123
-
124
- def method_call(is,signal)
125
- self.method(signal).call(is) do |action|
126
- case action
127
- when :modified then @modified ||= true
128
- when :save then save
129
- when :close then close
130
- end
131
- end
132
- end
133
-
134
- def build_gui
135
- Gtk2Password::Gui.new(@window) do |is,signal,*emits|
136
- $stderr.puts "#{is},#{signal}:\t#{emits}" if $trace
137
- method_call(is,signal)
138
- end
139
- end
140
-
141
- def self.get_account(account)
142
- if !account.nil? then
143
- account.strip!
144
- account = nil if account.length<1
145
- end
146
- return account
147
- end
148
- def get_account
149
- App.get_account( @gui[:account_comboboxentry].active_text )
150
- end
151
-
152
- def clicked(is)
153
-
154
- pwdlength = @gui[:password_spinbutton]
155
- account = get_account
156
-
157
- case is
158
-
159
- when @gui[:url_button]
160
- url = @gui[:url_entry].text.strip
161
- Gtk2AppLib.run(url) if url =~ Configuration::URL_PATTERN
162
-
163
- when @gui[:random_button]
164
- suggestion = ''
165
- pwdlength.value.to_i.times do
166
- suggestion += (Rnd::RND.random(94)+33).chr
167
- end
168
- @gui[:password_entry].text = suggestion
169
-
170
- when @gui[:alpha_button]
171
- suggestion = ''
172
- while suggestion.length < pwdlength.value.to_i do
173
- chr = (Rnd::RND.random(75)+48).chr
174
- suggestion += chr if chr =~/\w/
175
- end
176
- @gui[:password_entry].text = suggestion
177
-
178
- when @gui[:numeric_button]
179
- suggestion = ''
180
- pwdlength.value.to_i.times do
181
- chr = (Rnd::RND.random(10)+48).chr
182
- suggestion += chr
183
- end
184
- @gui[:password_entry].text = suggestion
185
-
186
- when @gui[:letters_button]
187
- suggestion = ''
188
- while suggestion.length < pwdlength.value.to_i do
189
- chr = (Rnd::RND.random(58)+65).chr
190
- suggestion += chr if chr =~/[A-Z]/i
191
- end
192
- @gui[:password_entry].text = suggestion
193
-
194
- when @gui[:caps_button]
195
- suggestion = ''
196
- pwdlength.value.to_i.times do
197
- chr = (Rnd::RND.random(26)+65).chr
198
- suggestion += chr
199
- end
200
- @gui[:password_entry].text = suggestion
201
-
202
- when @gui[:delete_button]
203
- # MODIFIES!!!
204
- if account then
205
- i = @passwords.accounts.index(account)
206
- if i then
207
- @passwords.delete(account)
208
- @gui[:account_comboboxentry].remove_text(i)
209
- @@index = (@gui[:account_comboboxentry].active = (i > 0)? i - 1: 0)
210
- yield(:modified)
211
- end
212
- end
213
-
214
- when @gui[:update_button]
215
- # MODIFIES!!!
216
- if account then
217
- url = @gui[:url_entry].text.strip
218
- if url.length == 0 || url =~ Configuration::URL_PATTERN then
219
- yield(:modified)
220
- if !@passwords.include?(account) then
221
- @passwords.add(account)
222
- @@index = i = @passwords.accounts.index(account)
223
- @gui[:account_comboboxentry].insert_text(i,account)
224
- end
225
- @passwords.url_of(account, url)
226
- @passwords.note_of(account, @gui[:note_entry].text.strip)
227
- @passwords.username_of(account, @gui[:username_entry].text.strip)
228
- password = @gui[:password_entry].text.strip
229
- @passwords.password_of(account, password) if !@passwords.verify?(account, password)
230
- Gtk2AppLib::DIALOGS.quick_message(*Configuration::UPDATED)
231
- else
232
- Gtk2AppLib::DIALOGS.quick_message(*Configuration::BAD_URL)
233
- end
234
- end
235
-
236
- when @gui[:datafile_button]
237
- if pwd1 = Gtk2Password.get_password(Passwords::PROMPT[:password]) then
238
- if pwd2 = Gtk2Password.get_password(Passwords::PROMPT[:again]) then
239
- while !(pwd1==pwd2) do
240
- pwd1 = Gtk2Password.get_password(Passwords::PROMPT[:retry])
241
- return if !pwd1
242
- pwd2 = Gtk2Password.get_password(Passwords::PROMPT[:again])
243
- return if !pwd2
244
- end
245
- @passwords.save!(pwd1)
246
- Gtk2Password.passwords_updated(pwd1)
247
- end
248
- end
249
-
250
- when @gui[:current_button]
251
- if account then
252
- PRIMARY.text = @passwords.password_of(account)
253
- CLIPBOARD.text = @passwords.username_of(account)
254
- Gtk2Password.clear_clipboard
255
- end
256
-
257
- when @gui[:previous_button]
258
- if account then
259
- PRIMARY.text = @passwords.previous_password_of(account)
260
- CLIPBOARD.text = @passwords.username_of(account)
261
- Gtk2Password.clear_clipboard
262
- end
263
-
264
- when @gui[:save_button] then yield(:save)
265
- when @gui[:cancel_button] then yield(:close)
266
- else $stderr.puts "What? #{is} in #{is.parent.class}."
267
- end
268
-
269
- end
270
-
271
- def _changed_clear
272
- @gui[:url_entry].text = ''
273
- @gui[:note_entry].text = ''
274
- @gui[:username_entry].text = ''
275
- end
276
-
277
- def _changed_set(account)
278
- @gui[:url_entry].text = @passwords.url_of(account)
279
- @gui[:note_entry].text = @passwords.note_of(account)
280
- @gui[:username_entry].text = @passwords.username_of(account)
281
- @gui[:password_entry].text = @passwords.password_of(account)
282
- end
283
-
284
- def _changed(is,account)
285
- @gui[:password_entry].text = ''
286
- (@passwords.include?(account))? _changed_set(account) : _changed_clear
287
- @@index = is.active
288
- $stderr.puts "Index: #{@@index}" if $trace
289
- end
290
-
291
- def changed(is)
292
- if account = get_account then
293
- _changed(is,account)
294
- end
295
- end
296
-
297
- def self.toggled(pwd)
298
- pwd.visibility = !pwd.visibility?
299
- end
300
- def toggled(is)
301
- App.toggled(@gui[:password_entry])
302
- end
303
-
304
- end
305
- end
1
+ # This is a Gtk3App.
2
+ require 'gtk3app'
3
+
4
+ # Helper Gems.
5
+ require 'yaml_zlib_blowfish'
6
+ require 'super_random'
7
+ require 'base_convert'
8
+ require 'helpema'
9
+
10
+ # This Gem.
11
+ require_relative 'gtk2passwordapp/version.rb'
12
+ require_relative 'gtk2passwordapp/config.rb'
13
+ require_relative 'gtk2passwordapp/such_parts.rb'
14
+ require_relative 'gtk2passwordapp/account.rb'
15
+ require_relative 'gtk2passwordapp/accounts.rb'
16
+ require_relative 'gtk2passwordapp/gtk2passwordapp.rb'
17
+
18
+ # Requires:
19
+ #`ruby`