dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit fbce7e2ed8aad2cbd611bf2962b41e173ba12075
parent b91e84b469b773704193c08c5511781fcc018f4e
Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date:   Wed, 24 Feb 2016 14:56:20 -0800

use python script to read password from OSX keychain

Diffstat:
A.mutt/offlineimap.py | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/.mutt/offlineimap.py b/.mutt/offlineimap.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +import re +import subprocess + + +def get_keychain_pass(account=None, server=None): + params = { + 'security': '/usr/bin/security', + 'command': 'find-internet-password', + 'account': account, + 'server': server, + 'keychain': '/Users/adamsgaard/Library/Keychains/login.keychain', + } + command = "sudo -u sjl %(security)s -v %(command)s -g -a %(account)s -s %(server)s %(keychain)s" % params + output = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT) + outtext = [l for l in output.splitlines() + if l.startswith('password: ')][0] + + return re.match(r'password: "(.*)"', outtext).group(1)