blob: 3b893496c9fd3343da8fa20f5ce3dcdec378d00f (
plain) (
blame)
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
|
import os
import subprocess
def mailpasswd(acct):
acct = os.path.basename(acct)
path = "/home/amin/.passwd/%s.gpg" % acct
args = ["gpg", "--use-agent", "--quiet", "--batch", "-d", path]
try:
return subprocess.check_output(args).strip()
except subprocess.CalledProcessError:
return ""
def mailuser(acct):
acct = os.path.basename(acct)
path = "/home/amin/.passwd/%s" % acct
args = ["cat", path]
try:
return subprocess.check_output(args).strip()
except subprocess.CalledProcessError:
return ""
def prime_gpg_agent():
ret = False
i = 1
while not ret:
ret = (mailpasswd("prime") == "prime")
if i > 2:
from offlineimap.ui import getglobalui
sys.stderr.write("Error reading in passwords. Terminating.\n")
getglobalui().terminate()
i += 1
return ret
prime_gpg_agent()
|