gtk2passwordapp 0.0.8 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +46 -3
- data/bin/gtk2passwordapp +25 -36
- data/gtk2passwordapp/appconfig.rb +29 -0
- data/gtk2passwordapp/edit_box.rb +328 -0
- data/gtk2passwordapp/iocrypt.rb +30 -0
- data/gtk2passwordapp/passwords.rb +93 -0
- data/{lib → gtk2passwordapp}/passwords_data.rb +5 -14
- data/pngs/logo.png +0 -0
- metadata +25 -18
- data/bin/gtk2passwordmenu +0 -43
- data/gifs/logo.gif +0 -0
- data/lib/configuration.rb +0 -54
- data/lib/global_options_variables.rb +0 -40
- data/lib/gtk2passwordapp.rb +0 -623
- data/lib/gtk2passwordmenu.rb +0 -145
- data/lib/iocrypt.rb +0 -40
- data/lib/setup_user_space.rb +0 -37
data/lib/gtk2passwordmenu.rb
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
# $Date: 2009/02/26 00:26:57 $
|
2
|
-
require 'lib/passwords_data'
|
3
|
-
require 'find'
|
4
|
-
|
5
|
-
class Gtk2PasswordMenu
|
6
|
-
include Configuration
|
7
|
-
|
8
|
-
def get_salt(title='Short Password')
|
9
|
-
dialog = Gtk::Dialog.new(
|
10
|
-
title,
|
11
|
-
nil, nil,
|
12
|
-
[ Gtk::Stock::QUIT, 0 ],
|
13
|
-
[ Gtk::Stock::OK, 1 ])
|
14
|
-
|
15
|
-
label = Gtk::Label.new(title)
|
16
|
-
label.justify = Gtk::JUSTIFY_LEFT
|
17
|
-
label.wrap = true
|
18
|
-
label.modify_font(FONT)
|
19
|
-
dialog.vbox.add(label)
|
20
|
-
entry = Gtk::Entry.new
|
21
|
-
entry.visibility = false
|
22
|
-
entry.modify_font(FONT)
|
23
|
-
dialog.vbox.add(entry)
|
24
|
-
dialog.show_all
|
25
|
-
|
26
|
-
entry.signal_connect('activate'){
|
27
|
-
dialog.response(1)
|
28
|
-
}
|
29
|
-
|
30
|
-
ret = nil
|
31
|
-
dialog.run {|response|
|
32
|
-
ret = entry.text.strip if response == 1
|
33
|
-
}
|
34
|
-
dialog.destroy
|
35
|
-
|
36
|
-
return ret
|
37
|
-
end
|
38
|
-
|
39
|
-
def get_passphrase
|
40
|
-
passphrase = ''
|
41
|
-
|
42
|
-
pfile = USER_CONF_DIR+'/passphrase.txt'
|
43
|
-
raise "Need passphrase file" if !File.exist?(pfile)
|
44
|
-
File.open(pfile,'r'){|fh| passphrase = fh.read }
|
45
|
-
|
46
|
-
return passphrase
|
47
|
-
end
|
48
|
-
|
49
|
-
def has_datafile?
|
50
|
-
Find.find(USER_CONF_DIR){|fn|
|
51
|
-
Find.prune if !(fn==USER_CONF_DIR) && File.directory?(fn)
|
52
|
-
if fn =~/[0123456789abcdef]{32}\.dat$/ then
|
53
|
-
return true
|
54
|
-
end
|
55
|
-
}
|
56
|
-
return false
|
57
|
-
end
|
58
|
-
|
59
|
-
def initialize
|
60
|
-
@updated = false # only saves data if data updated
|
61
|
-
@editing = nil # when editor window is up, this is set.
|
62
|
-
@verified = Time.now.to_i
|
63
|
-
|
64
|
-
@pwd = get_salt || exit
|
65
|
-
@pph = get_passphrase
|
66
|
-
@passwords = PasswordsData.new(@pwd+@pph)
|
67
|
-
# Password file exist?
|
68
|
-
if @passwords.online? || @passwords.exist? # then
|
69
|
-
# Yes, load passwords file.
|
70
|
-
@passwords.load
|
71
|
-
else
|
72
|
-
# No, check if there is a file....
|
73
|
-
if has_datafile? # then
|
74
|
-
# Yes, it's got a datafile. Ask for password again.
|
75
|
-
while !@passwords.exist? do
|
76
|
-
@pwd = get_salt('Try again!') || exit
|
77
|
-
@passwords = PasswordsData.new(@pwd+@pph)
|
78
|
-
end
|
79
|
-
@passwords.load
|
80
|
-
else
|
81
|
-
raise "Need passwords data file"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
# Off to the races...
|
85
|
-
end
|
86
|
-
|
87
|
-
def verify_user
|
88
|
-
now = Time.now.to_i
|
89
|
-
if now - @verified > VERIFIED_EXPIRED then
|
90
|
-
pwd0 = get_salt('Current Password')
|
91
|
-
return false if !pwd0
|
92
|
-
tries = 1
|
93
|
-
while !(pwd0==@pwd) do
|
94
|
-
tries += 1
|
95
|
-
pwd0 = get_salt('CURRENT PASSWORD???')
|
96
|
-
return false if !pwd0 || tries > 2
|
97
|
-
end
|
98
|
-
end
|
99
|
-
@verified = now
|
100
|
-
return true
|
101
|
-
end
|
102
|
-
|
103
|
-
def main_quit(icon)
|
104
|
-
icon.set_visible(false)
|
105
|
-
icon = nil
|
106
|
-
Gtk.main_quit
|
107
|
-
end
|
108
|
-
|
109
|
-
def status_icon
|
110
|
-
icon = Gtk::StatusIcon.new
|
111
|
-
icon.set_icon_name(Gtk::Stock::DIALOG_AUTHENTICATION)
|
112
|
-
icon.tooltip = 'Password Menu'
|
113
|
-
unlocked = true
|
114
|
-
icon.signal_connect('activate') {
|
115
|
-
if unlocked then
|
116
|
-
unlocked = false
|
117
|
-
if verify_user then
|
118
|
-
menu = Gtk::Menu.new
|
119
|
-
@passwords.accounts.each {|account|
|
120
|
-
menuitem = Gtk::MenuItem.new(account)
|
121
|
-
menuitem.child.modify_fg(Gtk::STATE_NORMAL, RED) if @passwords.expired?(account)
|
122
|
-
menu.append(menuitem)
|
123
|
-
menuitem.signal_connect('activate'){|b|
|
124
|
-
primary = Gtk::Clipboard.get(Gdk::Selection::PRIMARY)
|
125
|
-
clipboard = Gtk::Clipboard.get(Gdk::Selection::CLIPBOARD)
|
126
|
-
primary.text = clipboard.text = @passwords.password_of(b.child.text.strip)
|
127
|
-
}
|
128
|
-
}
|
129
|
-
menu.append( Gtk::SeparatorMenuItem.new )
|
130
|
-
|
131
|
-
menuitem = Gtk::MenuItem.new('Quit')
|
132
|
-
menuitem.signal_connect('activate'){ main_quit(icon) }
|
133
|
-
menu.append(menuitem)
|
134
|
-
|
135
|
-
menu.show_all
|
136
|
-
menu.popup(nil, nil, 0, 0)
|
137
|
-
unlocked = true
|
138
|
-
else
|
139
|
-
main_quit(icon)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
}
|
143
|
-
Gtk.main
|
144
|
-
end
|
145
|
-
end
|
data/lib/iocrypt.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# $Date: 2009/02/26 00:43:37 $
|
2
|
-
require 'yaml'
|
3
|
-
require 'rubygems'
|
4
|
-
require 'crypt/blowfish'
|
5
|
-
|
6
|
-
class IOCrypt
|
7
|
-
HTTPX = Regexp.new('^https?:\/\/')
|
8
|
-
|
9
|
-
def initialize(passphrase)
|
10
|
-
@blowfish = Crypt::Blowfish.new(passphrase[0..55])
|
11
|
-
end
|
12
|
-
|
13
|
-
def load(dumpfile)
|
14
|
-
data = nil
|
15
|
-
|
16
|
-
if dumpfile =~ HTTPX then
|
17
|
-
require 'open-uri'
|
18
|
-
open(dumpfile){|fh|
|
19
|
-
data = YAML.load( @blowfish.decrypt_string( fh.read ) )
|
20
|
-
}
|
21
|
-
else
|
22
|
-
File.open(dumpfile,'r'){|fh|
|
23
|
-
data = YAML.load( @blowfish.decrypt_string( fh.read ) )
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
return data
|
28
|
-
end
|
29
|
-
|
30
|
-
def dump(dumpfile, data)
|
31
|
-
count = nil
|
32
|
-
raise "Http PUT not supported" if dumpfile =~ HTTPX
|
33
|
-
|
34
|
-
File.open(dumpfile,'w') do |fh|
|
35
|
-
count = fh.write( @blowfish.encrypt_string( YAML.dump( data ) ) )
|
36
|
-
end
|
37
|
-
|
38
|
-
return count
|
39
|
-
end
|
40
|
-
end
|
data/lib/setup_user_space.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# $Date: 2009/02/19 15:49:32 $
|
2
|
-
module UserSpace
|
3
|
-
# provided by caller (global_options_variables):
|
4
|
-
# USER_CONF_DIR
|
5
|
-
# GEM_LIB_DIR
|
6
|
-
# CONF_FILE
|
7
|
-
|
8
|
-
def self.mkdir(subdir='')
|
9
|
-
dir = USER_CONF_DIR+subdir
|
10
|
-
Dir.mkdir(dir) if !File.exist?(dir)
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.cp(rfile,wfile)
|
14
|
-
if !File.exist?(wfile) then
|
15
|
-
File.open(rfile, 'r'){|fhr|
|
16
|
-
File.open(wfile, 'w'){|fhw|
|
17
|
-
fhr.each{|ln| fhw.puts ln}
|
18
|
-
}
|
19
|
-
}
|
20
|
-
File.chmod(0600, wfile) # rw to user only
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.copy(rfile, wfile=nil)
|
25
|
-
wfile = rfile if !wfile
|
26
|
-
self.cp(GEM_ROOT_DIR+rfile, USER_CONF_DIR+wfile)
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.cp_conf
|
30
|
-
self.cp(GEM_LIB_DIR+CONF_FILE, USER_CONF_DIR+CONF_FILE)
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.setup
|
34
|
-
self.mkdir
|
35
|
-
self.cp_conf
|
36
|
-
end
|
37
|
-
end
|