monotone

monotone Mtn Source Tree

Root/contrib/get_passphrase_from_file.lua

1-- This hook reads the 'passphrases' file from the confdir. It expects the
2-- file to be formatted as follows:
3--
4-- key@domain.tld "passphrase here"
5--
6-- One entry per line. The quotes are required.
7--
8-- Note: Because the file contains passphrases it should only be readable by
9-- select users.
10function get_passphrase (keypair_id)
11 local permfile = io.open(get_confdir() .. "/passphrases", "r")
12 if (permfile == nil) then return false end
13 local line = permfile:read()
14 while (line ~= nil) do
15 local _, _, key, passphrase = string.find(line, "%s*([^%s]*)%s*\"(.*)\"%s*")
16 if keypair_id == key then return passphrase end
17 line = permfile:read()
18 end
19 io.close(permfile)
20 return false
21end

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status