gtk2passwordapp 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/gtk2passwordapp +2 -2
- data/bin/gtk2passwordmenu +44 -0
- data/lib/gtk2passwordmenu.rb +151 -0
- metadata +4 -2
data/bin/gtk2passwordapp
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# $Date: 2009/02/22
|
2
|
+
# $Date: 2009/02/22 21:43:54 $
|
3
3
|
##########################################################
|
4
4
|
require 'lib/global_options_variables'
|
5
|
-
GlobalOptionsVariables.set('0.0.
|
5
|
+
GlobalOptionsVariables.set('0.0.6',
|
6
6
|
<<EOT
|
7
7
|
Usage: #{$0.sub(/^.*\//,'')} [options]
|
8
8
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# $Date: 2009/02/22 21:43:54 $
|
3
|
+
##########################################################
|
4
|
+
require 'lib/global_options_variables'
|
5
|
+
GlobalOptionsVariables.set('0.0.6',
|
6
|
+
<<EOT
|
7
|
+
Usage: gtk2passwordmenu [options]
|
8
|
+
|
9
|
+
gtk2passwordmenu will only present the icon's menu.
|
10
|
+
For the complete application, use gtk2passwordapp.
|
11
|
+
|
12
|
+
Options:
|
13
|
+
-h, --help print this help text and exit
|
14
|
+
-v, --version print program version and exit
|
15
|
+
-t, --test test
|
16
|
+
-T, --trace trace
|
17
|
+
EOT
|
18
|
+
)
|
19
|
+
require 'lib/setup_user_space'
|
20
|
+
UserSpace.setup
|
21
|
+
UserSpace.mkdir('/gifs')
|
22
|
+
UserSpace.copy('/gifs/logo.gif')
|
23
|
+
require USER_CONF_DIR+CONF_FILE
|
24
|
+
##########################################################
|
25
|
+
require 'lib/gtk2passwordmenu'
|
26
|
+
|
27
|
+
lock = USER_CONF_DIR+'/lock'
|
28
|
+
if File.exist?(lock) then
|
29
|
+
$stderr.puts "process already running?"
|
30
|
+
# user should then notice it's already running, but
|
31
|
+
# let's remove the lock in case it's not and user
|
32
|
+
# tries again....
|
33
|
+
File.unlink(lock)
|
34
|
+
else
|
35
|
+
begin
|
36
|
+
File.open(lock,'w'){|fh| fh.puts $$ }
|
37
|
+
gpa = Gtk2PasswordMenu.new
|
38
|
+
gpa.status_icon
|
39
|
+
rescue Exception
|
40
|
+
puts_bang!
|
41
|
+
ensure
|
42
|
+
File.unlink(lock) if File.exist?(lock)
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
# $Date: 2009/02/22 21:40:43 $
|
2
|
+
require 'lib/passwords_data'
|
3
|
+
require 'gtk2'
|
4
|
+
require 'find'
|
5
|
+
|
6
|
+
class Gtk2PasswordMenu
|
7
|
+
include Configuration
|
8
|
+
|
9
|
+
FONT = Pango::FontDescription.new(FONT_NAME)
|
10
|
+
RED = Gdk::Color.parse("#A00000")
|
11
|
+
BLACK = Gdk::Color.parse("#000000")
|
12
|
+
|
13
|
+
def get_salt(title='Short Password')
|
14
|
+
dialog = Gtk::Dialog.new(
|
15
|
+
title,
|
16
|
+
nil, nil,
|
17
|
+
[ Gtk::Stock::QUIT, 0 ],
|
18
|
+
[ Gtk::Stock::OK, 1 ])
|
19
|
+
|
20
|
+
label = Gtk::Label.new(title)
|
21
|
+
label.justify = Gtk::JUSTIFY_LEFT
|
22
|
+
label.wrap = true
|
23
|
+
label.modify_font(FONT)
|
24
|
+
dialog.vbox.add(label)
|
25
|
+
entry = Gtk::Entry.new
|
26
|
+
entry.visibility = false
|
27
|
+
entry.modify_font(FONT)
|
28
|
+
dialog.vbox.add(entry)
|
29
|
+
dialog.show_all
|
30
|
+
|
31
|
+
entry.signal_connect('activate'){
|
32
|
+
dialog.response(1)
|
33
|
+
}
|
34
|
+
|
35
|
+
ret = nil
|
36
|
+
dialog.run {|response|
|
37
|
+
ret = entry.text.strip if response == 1
|
38
|
+
}
|
39
|
+
dialog.destroy
|
40
|
+
|
41
|
+
return ret
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_passphrase
|
45
|
+
passphrase = ''
|
46
|
+
|
47
|
+
pfile = USER_CONF_DIR+'/passphrase.txt'
|
48
|
+
raise "Need passphrase file" if !File.exist?(pfile)
|
49
|
+
File.open(pfile,'r'){|fh| passphrase = fh.read }
|
50
|
+
|
51
|
+
return passphrase
|
52
|
+
end
|
53
|
+
|
54
|
+
def has_datafile?
|
55
|
+
Find.find(USER_CONF_DIR){|fn|
|
56
|
+
Find.prune if !(fn==USER_CONF_DIR) && File.directory?(fn)
|
57
|
+
if fn =~/[0123456789abcdef]{32}\.dat$/ then
|
58
|
+
return true
|
59
|
+
end
|
60
|
+
}
|
61
|
+
return false
|
62
|
+
end
|
63
|
+
|
64
|
+
def initialize
|
65
|
+
@updated = false # only saves data if data updated
|
66
|
+
@editing = nil # when editor window is up, this is set.
|
67
|
+
@verified = Time.now.to_i
|
68
|
+
|
69
|
+
@pwd = get_salt || exit
|
70
|
+
@pph = get_passphrase
|
71
|
+
@passwords = PasswordsData.new(@pwd+@pph)
|
72
|
+
# Password file exist?
|
73
|
+
if @passwords.exist? # then
|
74
|
+
# Yes, load passwords file.
|
75
|
+
@passwords.load
|
76
|
+
else
|
77
|
+
# No, check if there is a file....
|
78
|
+
if has_datafile? # then
|
79
|
+
# Yes, it's got a datafile. Ask for password again.
|
80
|
+
while !@passwords.exist? do
|
81
|
+
@pwd = get_salt('Try again!') || exit
|
82
|
+
@passwords = PasswordsData.new(@pwd+@pph)
|
83
|
+
end
|
84
|
+
@passwords.load
|
85
|
+
else
|
86
|
+
raise "Need passwords data file"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
# Off to the races...
|
90
|
+
end
|
91
|
+
|
92
|
+
def verify_user
|
93
|
+
now = Time.now.to_i
|
94
|
+
if now - @verified > VERIFIED_EXPIRED then
|
95
|
+
pwd0 = get_salt('Current Password')
|
96
|
+
return false if !pwd0
|
97
|
+
tries = 1
|
98
|
+
while !(pwd0==@pwd) do
|
99
|
+
tries += 1
|
100
|
+
pwd0 = get_salt('CURRENT PASSWORD???')
|
101
|
+
return false if !pwd0 || tries > 2
|
102
|
+
end
|
103
|
+
end
|
104
|
+
@verified = now
|
105
|
+
return true
|
106
|
+
end
|
107
|
+
|
108
|
+
def main_quit(icon)
|
109
|
+
icon.set_visible(false)
|
110
|
+
icon = nil
|
111
|
+
Gtk.main_quit
|
112
|
+
end
|
113
|
+
|
114
|
+
def status_icon
|
115
|
+
icon = Gtk::StatusIcon.new
|
116
|
+
icon.set_icon_name(Gtk::Stock::DIALOG_AUTHENTICATION)
|
117
|
+
icon.tooltip = 'Password Menu'
|
118
|
+
unlocked = true
|
119
|
+
icon.signal_connect('activate') {
|
120
|
+
if unlocked then
|
121
|
+
unlocked = false
|
122
|
+
if verify_user then
|
123
|
+
menu = Gtk::Menu.new
|
124
|
+
@passwords.accounts.each {|account|
|
125
|
+
menuitem = Gtk::MenuItem.new(account)
|
126
|
+
menuitem.child.modify_fg(Gtk::STATE_NORMAL, RED) if @passwords.expired?(account)
|
127
|
+
menu.append(menuitem)
|
128
|
+
menuitem.signal_connect('activate'){|b|
|
129
|
+
primary = Gtk::Clipboard.get(Gdk::Selection::PRIMARY)
|
130
|
+
clipboard = Gtk::Clipboard.get(Gdk::Selection::CLIPBOARD)
|
131
|
+
primary.text = clipboard.text = @passwords.password_of(b.child.text.strip)
|
132
|
+
}
|
133
|
+
}
|
134
|
+
menu.append( Gtk::SeparatorMenuItem.new )
|
135
|
+
|
136
|
+
menuitem = Gtk::MenuItem.new('Quit')
|
137
|
+
menuitem.signal_connect('activate'){ main_quit(icon) }
|
138
|
+
menu.append(menuitem)
|
139
|
+
|
140
|
+
menu.show_all
|
141
|
+
menu.popup(nil, nil, 0, 0)
|
142
|
+
unlocked = true
|
143
|
+
else
|
144
|
+
main_quit(icon)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
}
|
148
|
+
run if !@passwords.exist?
|
149
|
+
Gtk.main
|
150
|
+
end
|
151
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gtk2passwordapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- carlosjhr64@gmail.com
|
@@ -22,10 +22,11 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
|
-
description: A Ruby-Gtk2 application to keep passwords. Uses gem crypt/
|
25
|
+
description: A Ruby-Gtk2 application to keep passwords. Uses gem crypt/blowfish to encrypt data. Requires crypt and gtk2.
|
26
26
|
email: carlosjhr64@gmail.com
|
27
27
|
executables:
|
28
28
|
- gtk2passwordapp
|
29
|
+
- gtk2passwordmenu
|
29
30
|
extensions: []
|
30
31
|
|
31
32
|
extra_rdoc_files: []
|
@@ -34,6 +35,7 @@ files:
|
|
34
35
|
- lib/configuration.rb
|
35
36
|
- lib/global_options_variables.rb
|
36
37
|
- lib/gtk2passwordapp.rb
|
38
|
+
- lib/gtk2passwordmenu.rb
|
37
39
|
- lib/iocrypt.rb
|
38
40
|
- lib/passwords_data.rb
|
39
41
|
- lib/setup_user_space.rb
|