gtk2passwordapp 4.4.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +11 -9
- data/bin/gtk2pwdV +80 -0
- data/data/VERSION +1 -1
- data/lib/gtk2passwordapp.rb +2 -2
- data/lib/gtk2passwordapp/account.rb +1 -1
- data/lib/gtk2passwordapp/accounts.rb +2 -3
- data/lib/gtk2passwordapp/config.rb +6 -13
- data/lib/gtk2passwordapp/{gtk2passwordapp.rb → gtk2pwdv.rb} +9 -14
- data/lib/gtk2passwordapp/such_parts.rb +5 -5
- data/lib/gtk2passwordapp/version.rb +2 -2
- metadata +20 -61
- data/bin/gtk2passwordapp +0 -123
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3d02303c19a2fdb1438508acbab4d5dfdf158e7
|
4
|
+
data.tar.gz: 0e068062d1241c74f5a86ec81c6b541db64702c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e8b05f2a33c1a2b798ee735f0eb1076958324e11197a452ba73d5c7c08eba3568d18c7718b0cb1376bb66db6ea2f83ccfc6fcded706e53d12443ab3b9dbca0b
|
7
|
+
data.tar.gz: 6f6dad083904cccb777f1d18603387ae598eb6d3745a9010a18094b65a85d6dfdecc9389e59f16ff249bb4ee599f1d9073911f7efef020051deb16cec4f47276
|
data/README.rdoc
CHANGED
@@ -11,16 +11,21 @@ Features random password generator and clipboard use.
|
|
11
11
|
|
12
12
|
== INSTALL:
|
13
13
|
|
14
|
-
Note that you'll need gtk3app installed:
|
15
|
-
|
16
|
-
sudo gem install gtk3app
|
17
14
|
sudo gem install gtk2passwordapp
|
18
15
|
|
19
16
|
== HELP:
|
20
17
|
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
Usage:
|
19
|
+
gtk2pwdV [:options]
|
20
|
+
gtk2pwdV --nogui [<pattern>]
|
21
|
+
Options:
|
22
|
+
-v --version Show version and exit
|
23
|
+
-h --help Show help and exit
|
24
|
+
Notes:
|
25
|
+
With the --nogui option,
|
26
|
+
one can give a pattern to filter by account names.
|
27
|
+
On the first run, --nogui can be used to export
|
28
|
+
version's 4 password data into version's 5 password data.
|
24
29
|
|
25
30
|
== MORE:
|
26
31
|
|
@@ -32,7 +37,6 @@ See:
|
|
32
37
|
|
33
38
|
You may want to change the following settings:
|
34
39
|
|
35
|
-
[Help] Add any notes to yourself you want.
|
36
40
|
[SharedSecretFile] You may prefer it to be a file in some removable media.
|
37
41
|
[BackupFile] Although the GUI allows you to specify the file, this gives a default.
|
38
42
|
[TooOld] I have this set for a year (in seconds).
|
@@ -41,8 +45,6 @@ You may want to change the following settings:
|
|
41
45
|
|
42
46
|
If you're updating from a previous version,
|
43
47
|
you may need to edit the new config file to match you're previously edited changes.
|
44
|
-
Also, double check the requirements to ensure the versions of ruby and gems being used
|
45
|
-
(gtk3app, etc...) are compatible.
|
46
48
|
|
47
49
|
If you use a qrcode to enter your master password, and
|
48
50
|
the result is a multiline string,
|
data/bin/gtk2pwdV
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
if a0 = ARGV.shift
|
4
|
+
if ['-v', '--version'].include?(a0)
|
5
|
+
require 'gtk2passwordapp/version'
|
6
|
+
puts Gtk2PasswordApp::VERSION
|
7
|
+
exit 0
|
8
|
+
end
|
9
|
+
|
10
|
+
if ['-h', '--help'].include?(a0)
|
11
|
+
puts <<-HELP
|
12
|
+
Usage:
|
13
|
+
gtk2pwdV [:options]
|
14
|
+
gtk2pwdV --nogui [<pattern>]
|
15
|
+
Options:
|
16
|
+
-v --version \tShow version and exit
|
17
|
+
-h --help \tShow help and exit
|
18
|
+
Notes:
|
19
|
+
With the --nogui option,
|
20
|
+
one can give a pattern to filter by account names.
|
21
|
+
On the first run, --nogui can be used to export
|
22
|
+
version's 4 password data into version's 5 password data.
|
23
|
+
Expected file is:
|
24
|
+
~/.cache/gtk3app/gtk2passwordapp/gtk2pwdV.dat
|
25
|
+
HELP
|
26
|
+
exit 0
|
27
|
+
end
|
28
|
+
|
29
|
+
if a0 == '--nogui'
|
30
|
+
require 'pp'
|
31
|
+
require 'yaml_zlib_blowfish'
|
32
|
+
print "Enter password: "
|
33
|
+
PWD = $stdin.gets.strip
|
34
|
+
system('clear; clear')
|
35
|
+
F1 = File.expand_path('~/.cache/gtk3app/gtk2passwordapp/gtk2pwdV.dat')
|
36
|
+
unless File.exist?(F1)
|
37
|
+
F0 = File.expand_path('~/.cache/gtk3app/gtk2passwordapp/passwords.dat')
|
38
|
+
if File.exist?(F0)
|
39
|
+
class YZB < YamlZlibBlowfish
|
40
|
+
def initialize(passphrase)
|
41
|
+
key = Digest::SHA256.digest(passphrase)[0..15]
|
42
|
+
@cipher = OpenSSL::Cipher::BF.new(:CBC)
|
43
|
+
@cipher.key = key
|
44
|
+
end
|
45
|
+
end
|
46
|
+
begin
|
47
|
+
YamlZlibBlowfish.new(PWD).dump(F1, YZB.new(PWD).load(F0))
|
48
|
+
$stderr.puts "Auto-exported:"
|
49
|
+
$stderr.puts "\t#{F0} =>"
|
50
|
+
$stderr.puts "\t#{F1}"
|
51
|
+
rescue OpenSSL::Cipher::CipherError
|
52
|
+
$stderr.puts "Bad password"
|
53
|
+
exit 65
|
54
|
+
end
|
55
|
+
else
|
56
|
+
$stderr.puts "No passwords file found."
|
57
|
+
$stderr.puts "Expected: #{F1}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
begin
|
61
|
+
LIST = YamlZlibBlowfish.new(PWD).load(F1)
|
62
|
+
rescue OpenSSL::Cipher::CipherError
|
63
|
+
$stderr.puts "Bad password"
|
64
|
+
exit 65
|
65
|
+
end
|
66
|
+
if pattern = ARGV.shift
|
67
|
+
pattern = Regexp.new(pattern, Regexp::IGNORECASE)
|
68
|
+
end
|
69
|
+
unless ARGV.shift
|
70
|
+
pp (pattern)? LIST.select{|k,v|pattern.match(k)} : LIST
|
71
|
+
exit 0
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
$stderr.puts "Please match usage."
|
76
|
+
exit 64
|
77
|
+
end
|
78
|
+
|
79
|
+
require 'gtk2passwordapp'
|
80
|
+
Gtk3App.main(Gtk2PasswordApp)
|
data/data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
5.0.0
|
data/lib/gtk2passwordapp.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# This is a Gtk3App.
|
2
|
+
require 'gtk3app'
|
2
3
|
|
3
4
|
# Helper Gems.
|
4
5
|
require 'yaml_zlib_blowfish'
|
@@ -12,8 +13,7 @@ require_relative 'gtk2passwordapp/config.rb'
|
|
12
13
|
require_relative 'gtk2passwordapp/such_parts.rb'
|
13
14
|
require_relative 'gtk2passwordapp/account.rb'
|
14
15
|
require_relative 'gtk2passwordapp/accounts.rb'
|
15
|
-
require_relative 'gtk2passwordapp/
|
16
|
+
require_relative 'gtk2passwordapp/gtk2pwdv.rb'
|
16
17
|
|
17
18
|
# Requires:
|
18
19
|
#`ruby`
|
19
|
-
#`gtk3app`
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Gtk2PasswordApp
|
2
2
|
class Accounts
|
3
3
|
|
4
4
|
def reset(password)
|
@@ -6,8 +6,7 @@ class Accounts
|
|
6
6
|
end
|
7
7
|
|
8
8
|
attr_reader :data
|
9
|
-
|
10
|
-
def initialize(dumpfile=nil, password=nil)
|
9
|
+
def initialize(dumpfile, password=nil)
|
11
10
|
reset(password) if password # sets @yzb
|
12
11
|
@dumpfile = dumpfile
|
13
12
|
@data = {}
|
@@ -1,12 +1,6 @@
|
|
1
|
-
module
|
1
|
+
module Gtk2PasswordApp
|
2
2
|
using Rafini::String
|
3
3
|
|
4
|
-
help = <<-HELP
|
5
|
-
Usage:
|
6
|
-
gtk3app gtk2passwordapp [--help] [--version]
|
7
|
-
gtk2passwordapp [--no-gui [--dump [--verbose]]] [account]
|
8
|
-
HELP
|
9
|
-
|
10
4
|
APPDIR = File.dirname File.dirname __dir__
|
11
5
|
|
12
6
|
s0 = Rafini::Empty::STRING
|
@@ -14,14 +8,13 @@ Usage:
|
|
14
8
|
a0 = Rafini::Empty::ARRAY
|
15
9
|
|
16
10
|
CONFIG = {
|
17
|
-
Help: help,
|
18
11
|
|
19
12
|
# Password Data File
|
20
|
-
PwdFile: "#{XDG['CACHE']}/gtk3app/gtk2passwordapp/
|
13
|
+
PwdFile: "#{XDG['CACHE']}/gtk3app/gtk2passwordapp/gtk2pwdV.dat",
|
21
14
|
# Shared Secret File
|
22
15
|
# Consider using a file found in a removable flashdrive.
|
23
16
|
SharedSecretFile: "#{XDG['CACHE']}/gtk3app/gtk2passwordapp/key.ssss",
|
24
|
-
BackupFile: "#{ENV['HOME']}/Dropbox/
|
17
|
+
BackupFile: "#{ENV['HOME']}/Dropbox/gtk2pwdV.bak",
|
25
18
|
|
26
19
|
# Mark Recent Selections
|
27
20
|
Recent: 7,
|
@@ -30,7 +23,7 @@ Usage:
|
|
30
23
|
TooOld: 60*60*24*365, # Year
|
31
24
|
|
32
25
|
# Timeout for qr-code read.
|
33
|
-
QrcTimeOut:
|
26
|
+
QrcTimeOut: 15,
|
34
27
|
|
35
28
|
# Password Generators
|
36
29
|
Random: 'Random',
|
@@ -127,8 +120,8 @@ Usage:
|
|
127
120
|
},
|
128
121
|
],
|
129
122
|
|
130
|
-
reset!: [['Reset Master Password'], 'activate'],
|
131
|
-
backup!: [['Backup Passwords'], 'activate'],
|
123
|
+
reset!: [[label: 'Reset Master Password'], 'activate'],
|
124
|
+
backup!: [[label: 'Backup Passwords'], 'activate'],
|
132
125
|
|
133
126
|
about_dialog: {
|
134
127
|
set_program_name: 'Password Manager',
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Gtk2PasswordApp
|
2
2
|
using Rafini::Exception
|
3
3
|
using Rafini::Array
|
4
4
|
|
@@ -6,16 +6,8 @@ module Gtk2passwordapp
|
|
6
6
|
H2Q = BaseConvert::FromTo.new(:hex, :qgraph)
|
7
7
|
H2W = BaseConvert::FromTo.new(:hex, :word)
|
8
8
|
|
9
|
-
def self.options=(opts)
|
10
|
-
@@options=opts
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.options
|
14
|
-
@@options
|
15
|
-
end
|
16
|
-
|
17
9
|
def self.run(program)
|
18
|
-
|
10
|
+
Gtk2PwdV.new(program)
|
19
11
|
end
|
20
12
|
|
21
13
|
class DeleteDialog < Gtk3App::Dialog::CancelOk
|
@@ -28,7 +20,7 @@ end
|
|
28
20
|
class BackupDialog < Such::FileChooserDialog
|
29
21
|
def initialize(parent)
|
30
22
|
super([parent: parent], :backup_dialog)
|
31
|
-
set_action Gtk::
|
23
|
+
set_action Gtk::FileChooserAction::SAVE
|
32
24
|
add_button(Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL)
|
33
25
|
add_button(Gtk::Stock::OPEN, Gtk::ResponseType::ACCEPT)
|
34
26
|
if CONFIG[:BackupFile]
|
@@ -60,7 +52,7 @@ class ErrorDialog < Such::MessageDialog
|
|
60
52
|
end
|
61
53
|
end
|
62
54
|
|
63
|
-
class
|
55
|
+
class Gtk2PwdV
|
64
56
|
|
65
57
|
def initialize(program)
|
66
58
|
@program = program
|
@@ -125,7 +117,7 @@ class Gtk2PasswordApp
|
|
125
117
|
@accounts.names.sort{|a,b|a.upcase<=>b.upcase}.each do |name|
|
126
118
|
account = @accounts.get name
|
127
119
|
pwd, user, updated = account.password, account.username, account.updated
|
128
|
-
selected = Such::MenuItem.new([name], 'activate') do
|
120
|
+
selected = Such::MenuItem.new([label: name], 'activate') do
|
129
121
|
color_code selected
|
130
122
|
@combo.set_active @names.index name if @combo
|
131
123
|
copy2clipboard pwd, user
|
@@ -151,7 +143,10 @@ class Gtk2PasswordApp
|
|
151
143
|
end
|
152
144
|
|
153
145
|
def clear_page
|
154
|
-
@page.each
|
146
|
+
@page.each do |w|
|
147
|
+
w.text = '' if w.class == Such::Entry # Else gives warning.... :-??
|
148
|
+
w.destroy
|
149
|
+
end
|
155
150
|
end
|
156
151
|
|
157
152
|
def process_pwd_entries(entry1, entry2)
|
@@ -8,15 +8,15 @@ Such::Parts.make('PromptedCombo', 'Box', :prompt_Label, :prompted_ComboBoxText)
|
|
8
8
|
module Such
|
9
9
|
class AbButtons
|
10
10
|
def labels(a, b)
|
11
|
-
self.a_Button.label =
|
12
|
-
self.b_Button.label =
|
11
|
+
self.a_Button.label = Gtk2PasswordApp::CONFIG[a]
|
12
|
+
self.b_Button.label = Gtk2PasswordApp::CONFIG[b]
|
13
13
|
end
|
14
14
|
end
|
15
15
|
class AbcButtons
|
16
16
|
def labels(a, b, c)
|
17
|
-
self.a_Button.label =
|
18
|
-
self.b_Button.label =
|
19
|
-
self.c_Button.label =
|
17
|
+
self.a_Button.label = Gtk2PasswordApp::CONFIG[a]
|
18
|
+
self.b_Button.label = Gtk2PasswordApp::CONFIG[b]
|
19
|
+
self.c_Button.label = Gtk2PasswordApp::CONFIG[c]
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = '
|
1
|
+
module Gtk2PasswordApp
|
2
|
+
VERSION = '5.0.0'
|
3
3
|
end
|
metadata
CHANGED
@@ -1,115 +1,75 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gtk2passwordapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- carlosjhr64
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: gtk3app
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 1.2.0
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '1.2'
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 1.2.0
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: xdg
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '2.2'
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 2.2.3
|
43
|
-
type: :runtime
|
44
|
-
prerelease: false
|
45
|
-
version_requirements: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '2.2'
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 2.2.3
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: user_space
|
55
|
-
requirement: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '2.1'
|
19
|
+
version: '2.0'
|
60
20
|
- - ">="
|
61
21
|
- !ruby/object:Gem::Version
|
62
|
-
version: 2.
|
22
|
+
version: 2.0.0
|
63
23
|
type: :runtime
|
64
24
|
prerelease: false
|
65
25
|
version_requirements: !ruby/object:Gem::Requirement
|
66
26
|
requirements:
|
67
27
|
- - "~>"
|
68
28
|
- !ruby/object:Gem::Version
|
69
|
-
version: '2.
|
29
|
+
version: '2.0'
|
70
30
|
- - ">="
|
71
31
|
- !ruby/object:Gem::Version
|
72
|
-
version: 2.
|
32
|
+
version: 2.0.0
|
73
33
|
- !ruby/object:Gem::Dependency
|
74
34
|
name: yaml_zlib_blowfish
|
75
35
|
requirement: !ruby/object:Gem::Requirement
|
76
36
|
requirements:
|
77
37
|
- - "~>"
|
78
38
|
- !ruby/object:Gem::Version
|
79
|
-
version: '
|
39
|
+
version: '1.0'
|
80
40
|
- - ">="
|
81
41
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.0
|
42
|
+
version: 1.0.0
|
83
43
|
type: :runtime
|
84
44
|
prerelease: false
|
85
45
|
version_requirements: !ruby/object:Gem::Requirement
|
86
46
|
requirements:
|
87
47
|
- - "~>"
|
88
48
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
49
|
+
version: '1.0'
|
90
50
|
- - ">="
|
91
51
|
- !ruby/object:Gem::Version
|
92
|
-
version: 0.0
|
52
|
+
version: 1.0.0
|
93
53
|
- !ruby/object:Gem::Dependency
|
94
54
|
name: super_random
|
95
55
|
requirement: !ruby/object:Gem::Requirement
|
96
56
|
requirements:
|
97
57
|
- - "~>"
|
98
58
|
- !ruby/object:Gem::Version
|
99
|
-
version: '0
|
59
|
+
version: '1.0'
|
100
60
|
- - ">="
|
101
61
|
- !ruby/object:Gem::Version
|
102
|
-
version: 0.
|
62
|
+
version: 1.0.0
|
103
63
|
type: :runtime
|
104
64
|
prerelease: false
|
105
65
|
version_requirements: !ruby/object:Gem::Requirement
|
106
66
|
requirements:
|
107
67
|
- - "~>"
|
108
68
|
- !ruby/object:Gem::Version
|
109
|
-
version: '0
|
69
|
+
version: '1.0'
|
110
70
|
- - ">="
|
111
71
|
- !ruby/object:Gem::Version
|
112
|
-
version: 0.
|
72
|
+
version: 1.0.0
|
113
73
|
- !ruby/object:Gem::Dependency
|
114
74
|
name: base_convert
|
115
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,20 +117,20 @@ description: |
|
|
157
117
|
Features random password generator and clipboard use.
|
158
118
|
email: carlosjhr64@gmail.com
|
159
119
|
executables:
|
160
|
-
-
|
120
|
+
- gtk2pwdV
|
161
121
|
extensions: []
|
162
122
|
extra_rdoc_files:
|
163
123
|
- README.rdoc
|
164
124
|
files:
|
165
125
|
- README.rdoc
|
166
|
-
- bin/
|
126
|
+
- bin/gtk2pwdV
|
167
127
|
- data/VERSION
|
168
128
|
- data/logo.png
|
169
129
|
- lib/gtk2passwordapp.rb
|
170
130
|
- lib/gtk2passwordapp/account.rb
|
171
131
|
- lib/gtk2passwordapp/accounts.rb
|
172
132
|
- lib/gtk2passwordapp/config.rb
|
173
|
-
- lib/gtk2passwordapp/
|
133
|
+
- lib/gtk2passwordapp/gtk2pwdv.rb
|
174
134
|
- lib/gtk2passwordapp/such_parts.rb
|
175
135
|
- lib/gtk2passwordapp/version.rb
|
176
136
|
homepage: https://github.com/carlosjhr64/gtk2passwordapp
|
@@ -194,10 +154,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
154
|
- !ruby/object:Gem::Version
|
195
155
|
version: '0'
|
196
156
|
requirements:
|
197
|
-
- 'ruby: ruby 2.
|
198
|
-
- 'gtk3app: 1.5.2'
|
157
|
+
- 'ruby: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]'
|
199
158
|
rubyforge_project:
|
200
|
-
rubygems_version: 2.
|
159
|
+
rubygems_version: 2.6.11
|
201
160
|
signing_key:
|
202
161
|
specification_version: 4
|
203
162
|
summary: Ruby-Gnome Password Manager.
|
data/bin/gtk2passwordapp
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'rafini'
|
3
|
-
using Rafini::Exception
|
4
|
-
using Rafini::Array
|
5
|
-
using Rafini::String
|
6
|
-
|
7
|
-
begin
|
8
|
-
nogui = ARGV.include?('--no-gui')
|
9
|
-
hlp = ['-h', '--help'].any?{|_|ARGV.include?(_)}
|
10
|
-
vrs = ['-v', '--version'].any?{|_|ARGV.include?(_)}
|
11
|
-
if nogui or hlp or vrs
|
12
|
-
# Going to proceed on need only basis, which may break some conventions...
|
13
|
-
|
14
|
-
# Get the version.
|
15
|
-
require 'gtk2passwordapp/version'
|
16
|
-
mod = Gtk2passwordapp
|
17
|
-
version = mod::VERSION
|
18
|
-
if vrs
|
19
|
-
puts version
|
20
|
-
exit
|
21
|
-
end
|
22
|
-
|
23
|
-
vbs = ARGV.any?{|_|['-V', '--verbose'].include?(_)}
|
24
|
-
|
25
|
-
# Get the config.
|
26
|
-
require 'xdg'
|
27
|
-
require 'gtk2passwordapp/config'
|
28
|
-
config = mod::CONFIG
|
29
|
-
if hlp and !vbs
|
30
|
-
# Note that this will be the original help without any of the user's edit.
|
31
|
-
puts config[:Help]
|
32
|
-
exit
|
33
|
-
end
|
34
|
-
|
35
|
-
# Where are the user's data?
|
36
|
-
require 'user_space'
|
37
|
-
require 'yaml'
|
38
|
-
UserSpace::OPTIONS[:parser] = YAML
|
39
|
-
UserSpace::OPTIONS[:ext] = 'yml'
|
40
|
-
UserSpace::OPTIONS[:config] = "config-#{version.semantic(0..1)}"
|
41
|
-
appdir = mod::APPDIR
|
42
|
-
appname = File.join 'gtk3app', mod.name.downcase
|
43
|
-
user_space = UserSpace.new(appname: appname, appdir: appdir)
|
44
|
-
user_space.install unless user_space.version == version
|
45
|
-
user_space.configures(config)
|
46
|
-
|
47
|
-
if hlp # and vbs
|
48
|
-
# Presumably, the user may have edited the help and is requesting this version.
|
49
|
-
puts config[:Help]
|
50
|
-
exit
|
51
|
-
end
|
52
|
-
|
53
|
-
# It's possible that the password file it not there.
|
54
|
-
pwd_file = config[:PwdFile]
|
55
|
-
raise "Could not find passwords data file." unless File.exist? pwd_file
|
56
|
-
|
57
|
-
# Going to get and verify the password.
|
58
|
-
require 'io/console' # Standard library
|
59
|
-
pwd0 = nil
|
60
|
-
print 'Password: '
|
61
|
-
pwd = $stdin.noecho(&:gets).strip
|
62
|
-
while pwd != pwd0
|
63
|
-
exit if pwd == ''
|
64
|
-
pwd0 = pwd
|
65
|
-
puts
|
66
|
-
print 'Again: '
|
67
|
-
pwd = $stdin.noecho(&:gets).strip
|
68
|
-
end
|
69
|
-
puts
|
70
|
-
|
71
|
-
# Ready to read the passwords file.
|
72
|
-
require 'yaml_zlib_blowfish'
|
73
|
-
require 'gtk2passwordapp/account'
|
74
|
-
require 'gtk2passwordapp/accounts'
|
75
|
-
accounts = Gtk2passwordapp::Accounts.new(pwd_file, pwd)
|
76
|
-
accounts.load
|
77
|
-
|
78
|
-
# Does the user want a data dump?
|
79
|
-
if ARGV.include? '--dump'
|
80
|
-
puts
|
81
|
-
# Remember that ARGV is at least ['--no-gui'].
|
82
|
-
pattern = (ARGV.last[0]=='-')? nil : Regexp.new(ARGV.last)
|
83
|
-
now = Time.now.to_i
|
84
|
-
accounts.names.each do |name|
|
85
|
-
next if pattern and not pattern=~name
|
86
|
-
account = accounts.get(name)
|
87
|
-
puts [account.name, account.username, account.password].join("\n\t")
|
88
|
-
if vbs
|
89
|
-
puts "\t" + account.url
|
90
|
-
puts "\t" + account.note
|
91
|
-
using Rafini::Odometers
|
92
|
-
puts "\tUpdated " + (now - account.updated).sec2time.to_s + ' ago.'
|
93
|
-
end
|
94
|
-
puts
|
95
|
-
end
|
96
|
-
exit
|
97
|
-
end
|
98
|
-
|
99
|
-
# Looks like the user just wants a particular password.
|
100
|
-
# Get the account name.
|
101
|
-
unless name = (ARGV.last[0]=='-')? nil : ARGV.last
|
102
|
-
print 'Account Name: '
|
103
|
-
name = $stdin.gets.strip
|
104
|
-
end
|
105
|
-
# Does the given account exist?
|
106
|
-
raise "Could not find account \"#{name}\"." unless accounts.data[name]
|
107
|
-
|
108
|
-
# Put the password!
|
109
|
-
account = accounts.get(name)
|
110
|
-
password = account.password
|
111
|
-
puts password
|
112
|
-
|
113
|
-
# And we're done!
|
114
|
-
exit
|
115
|
-
end
|
116
|
-
rescue StandardError
|
117
|
-
$!.puts
|
118
|
-
exit 1
|
119
|
-
end
|
120
|
-
|
121
|
-
# Run gui!
|
122
|
-
ARGV.unshift 'gtk2passwordapp' # going to gtk3app
|
123
|
-
Process.detach spawn "gtk3app #{ARGV.join(' ')}"
|