Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added some keychain lock management.
  • Loading branch information
icculus committed Dec 24, 2013
1 parent d1bd522 commit 02b0e1e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions 1pass.lua
Expand Up @@ -257,13 +257,25 @@ local function prepItems()
end
end

local passwordUnlockTime = nil

function keyhookPressed() -- not local! Called from C!
if keyhookRunning then
return
end

keyhookRunning = true

if passwordUnlockTime ~= nil then
local now = os.time()
local maxTime = (15 * 60) -- !!! FIXME: don't hardcode.
if os.difftime(now, passwordUnlockTime) > maxTime then
-- lose the existing password and key, prompt user again.
password = argv[2] -- might be nil, don't reset if on command line.
keys["SL5"] = nil
end
end

while password == nil do
password = runGuiPasswordPrompt(getHint())
if password == nil then
Expand All @@ -277,12 +289,23 @@ function keyhookPressed() -- not local! Called from C!
while os.difftime(now, start) < 3 do
now = os.time()
end
else
passwordUnlockTime = os.time()
end
end

prepItems()

local topmenu = makeGuiMenu()

local lock_callback = function()
password = argv[2] -- might be nil, don't reset if on command line.
keys["SL5"] = nil
passwordUnlockTime = nil
keyhookRunning = false
end
appendGuiMenuItem(topmenu, "Lock keychain", lock_callback)

for orderi,type in ipairs(passwordTypeOrdering) do
local bucket = items[type]
local realname = passwordTypeNameMap[type]
Expand Down

0 comments on commit 02b0e1e

Please sign in to comment.