* add gpaste support

* remove call to qtpass
* minor changes
This commit is contained in:
Jonathan Lestrelin 2017-03-15 18:24:51 +01:00
parent 52dbea0e9e
commit bed2f59052
3 changed files with 30 additions and 39 deletions

View File

@ -11,10 +11,7 @@ Names of passwords will show up in GNOME Shell searches, choosing one will copy
## Manual ## Manual
Ensure that python-gobject is installed on your system (probably already the case): Ensure that python>=3.5 and python-gobject are installed on your system and that pass is setup.
```shell
$PACKAGE_MANAGER install python-gobject
```
Download or clone this repository: Download or clone this repository:
```shell ```shell
@ -31,36 +28,28 @@ If you need to you can change the installation paths to suit your system:
sudo SYSCONFDIR=/etc DATADIR=/usr/share LIBDIR=/usr/lib LIBEXECDIR=/usr/lib ./install.sh sudo SYSCONFDIR=/etc DATADIR=/usr/share LIBDIR=/usr/lib LIBEXECDIR=/usr/lib ./install.sh
``` ```
Recommended : set gpg agent to use pinentry-gnome3 by adding `pinentry-program /usr/bin/pinentry-gnome3` to `~/.gnupg/.gpg-agent.conf`.
Close and reopen your GNOME session or (if not on Wayland) just restart the Shell (alt + f2, r). Close and reopen your GNOME session or (if not on Wayland) just restart the Shell (alt + f2, r).
The search provider should show up and be enabled in Gnome search preferences and be autoloaded by GNOME Shell. The search provider should show up and be enabled in GNOME search preferences and started on demand by GNOME Shell.
# Environment variables # Environment variables
If you are configuring pass through environment variables, such as `PASSWORD_STORE_DIR`, make sure to set them in a way that will propagate to the search provider executable. If you are configuring pass through environment variables, such as `PASSWORD_STORE_DIR`, make sure to set them in a way that will propagate to the search provider executable, not just in your shell.
If you are on a systemd-based system, you can set them in the unit file : Setting them in `~/.profile` should be sufficient.
```shell # Clipboard managers
systemctl --user edit org.gnome.Pass.SearchProvider.service
```
Add your variables like this : If you are using GPaste, passwords will be sent to it marked as passwords, thus ensuring they are not visible.
```ini Otherwise they are sent to the clipboard using `pass -c` which defaults to expiration after 45 seconds.
[Service]
Environment=PASSWORD_STORE_DIR=/my/passwords/path
```
Then restart the service :
```shell
systemctl --user restart org.gnome.Pass.SearchProvider.service
```
# Compatibility # Compatibility
This implements the `org.gnome.Shell.SearchProvider2` D-Bus API. This implements the `org.gnome.Shell.SearchProvider2` D-Bus API.
I'm not sure since when this has been in Gnome nor until when it will stay. I'm not sure since when this has been in GNOME nor until when it will stay.
This works fine on Gnome 3.22 and I expect it will continue to work for some time with ulterior versions. This works fine on GNOME 3.22 and I expect it will continue to work for some time with ulterior versions.
# Troubleshooting # Troubleshooting
If this does not work for you, make sure to look to wherever Gnome and D-Bus are logging for error messages (in the journal on systemd-using systems). If this does not work for you, make sure to look to wherever GNOME and D-Bus are logging for error messages (in the journal on systemd-using systems).
Don't hesitate to open an issue.

View File

@ -1,7 +1,3 @@
* Add a configuration dialog so that passing environment variables to pass is easier.
* Fix the problem of pinentry unable to show up if not called from pass before.
* Make packages. * Make packages.
* Find a good way of implementing LaunchSearch. * Find something to do when LaunchSearch is called.
* Make the daemon exit after some time.
* Call into GPaste if present to mark item as password.
* Change icon to one that is present in GNOME default theme. * Change icon to one that is present in GNOME default theme.

View File

@ -25,10 +25,10 @@
# Copyright (C) 2012 Red Hat, Inc. # Copyright (C) 2012 Red Hat, Inc.
# Author: Luke Macken <lmacken@redhat.com> # Author: Luke Macken <lmacken@redhat.com>
from subprocess import call import subprocess
import re
from os import walk, getenv from os import walk, getenv
from os.path import expanduser from os.path import expanduser
import re
from gi.repository import GLib from gi.repository import GLib
@ -50,13 +50,8 @@ class SearchPassService(dbus.service.Object):
""" """
bus_name = 'org.gnome.Pass.SearchProvider' bus_name = 'org.gnome.Pass.SearchProvider'
enabled = False
_search_cache = {}
_request_cache = {}
_object_path = '/' + bus_name.replace('.', '/') _object_path = '/' + bus_name.replace('.', '/')
__name__ = 'SearchPassService'
def __init__(self): def __init__(self):
self.session_bus = dbus.SessionBus() self.session_bus = dbus.SessionBus()
@ -83,8 +78,7 @@ class SearchPassService(dbus.service.Object):
@dbus.service.method(in_signature='asu', terms='as', timestamp='u', **sbn) @dbus.service.method(in_signature='asu', terms='as', timestamp='u', **sbn)
def LaunchSearch(self, terms, timestamp): def LaunchSearch(self, terms, timestamp):
# FIXME: unstable pass
call(['qtpass'] + terms)
def get_result_set(self, terms): def get_result_set(self, terms):
names = [] names = []
@ -105,7 +99,19 @@ class SearchPassService(dbus.service.Object):
return names return names
def send_password_to_clipboard(self, name): def send_password_to_clipboard(self, name):
call(['pass', 'show', '-c', name]) try:
pass_cmd = subprocess.run(['pass', 'show', name],
stdout=subprocess.PIPE)
password = re.sub(b'\n$', b'', pass_cmd.stdout)
if not pass_cmd.returncode:
session_bus = dbus.SessionBus()
gpaste_dbus = session_bus.get_object('org.gnome.GPaste.Daemon',
'/org/gnome/GPaste')
gpaste_dbus.AddPassword(name,
password,
dbus_interface='org.gnome.GPaste1')
except dbus.DBusException:
subprocess.run(['pass', 'show', '-c', name])
def main(): def main():
service = SearchPassService() service = SearchPassService()