-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpasswords.lua
More file actions
40 lines (22 loc) · 868 Bytes
/
Copy pathpasswords.lua
File metadata and controls
40 lines (22 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
lockbox_passwords={}
lockbox_passwords.items={}
lockbox_passwords.add=function(self, name, value)
self.items[name]=value
end
lockbox_passwords.get=function(self, name, hint)
local queried_password=false
local pass
if strutil.strlen(self.items[name]) > 0 then return self.items[name] end
pass=keyring:get(name)
if GlobalDebug == true then io.stderr:write("Using keyring: got "..tostring(pass).."\n") end
if strutil.strlen(pass) == 0
then
pass=ui:ask_password("Password for "..name..": ~>", hint)
queried_password=true
end
self:add(name, pass)
-- we cannot do this here, because we do not know that the password is correct. We can only do this after successfully
-- opening a lockbox file
-- if queried_password == true and strutil.strlen(pass) > 0 and config:get("keyring") ~= "n" then keyring:set(name, pass) end
return pass,queried_password
end