From 43943e26128724aaf5516a596772a16afdae06ea Mon Sep 17 00:00:00 2001 From: Johannes Löthberg Date: Sat, 16 May 2015 01:09:00 +0200 Subject: Import git-credential-pass this is a barely functional python script to be able to use passwords stored in pass(1) with git. --- git-credential-pass | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 git-credential-pass diff --git a/git-credential-pass b/git-credential-pass new file mode 100755 index 0000000..0db00e9 --- /dev/null +++ b/git-credential-pass @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +from parse import search +from os import environ, path +from sys import stdin +from gnupg import GPG + + +if 'PASSWORD_STORE_DIR' in environ: + pass_dir = environ['PASSWORD_STORE_DIR'] +else: + pass_dir = path.join(path.expanduser('~'), '.password-store') + +file_path = path.join(pass_dir, 'git') + +data = stdin.read() +if 'username' in data: + (protocol, host, username) = search('protocol={}\nhost={}\nusername={}\n', data) + file_path = path.join(file_path, host, username) + '.gpg' +else: + (protocol, host) = search('protocol={}\nhost={}\n', data) + file_path = path.join(file_path, host, 'default') + '.gpg' + +with open(file_path, 'rb') as fp: + encrypted = fp.read() + +gpg = GPG() +gpg.use_agent = True +password = str(gpg.decrypt(encrypted)).splitlines()[0] + +output = ('protocol={}\n' + 'host={}\n' + 'username={}\n' + 'password={}').format(protocol, host, username, password) + +print(output) -- cgit v1.2.3-54-g00ecf