diff --git a/docs/README.adoc b/docs/README.adoc index a597e66..776a0a3 100644 --- a/docs/README.adoc +++ b/docs/README.adoc @@ -445,6 +445,20 @@ configuration can be either specified in the < flags/switches to subcommands. **Some** configuration directives/behaviour may be overridden by environment variables where supported by Vault/Pass upstream configuration. +=== Vault Paths Don't Match VaultPass' Paths +=== Issue Description +Pass and Vault have fundamentally different storage ideas. Pass secrets/passwords are, once decrypted, just plaintext +blobs. Vault, on the other hand, uses a key/value type of storage. As a result, this means two things: + +* The last item in a path in VaultPass is the key name (e.g. the path `foo/bar/baz` in VaultPass would be a Vault path +of `foo/bar`, which would then have a **key** named `baz`), and +* The **`line-number`** sub-argument is completely irrelevant for things like copying to the clipboard and generating a +QR code (e.g. as in `pass show --clip`**`=line-number`**). + +==== Workaround(s) +None, aside from not using the `line-number` sub-argument since it's no longer relevant. (You'll get an error if you +do.) + == Submitting a Bug Report/Feature Request Please use https://bugs.square-r00t.net/index.php?do=newtask&project=13[my bugtracker^]. diff --git a/vaultpass/__init__.py b/vaultpass/__init__.py index c0a94fd..4c8911e 100644 --- a/vaultpass/__init__.py +++ b/vaultpass/__init__.py @@ -246,15 +246,18 @@ class VaultPass(object): 'seconds': seconds, 'printme': printme} data = self.getSecret(**args) - if qr is not None: - data, has_x = QR.genQr(data, image = True) + if qr not in (False, None): + qrdata, has_x = QR.genQr(data, image = True) if has_x: fpath = tempfile.mkstemp(prefix = '.vaultpass.qr.', suffix = '.svg', dir = '/dev/shm')[1] _logger.debug('Writing to {0} so it can be displayed'.format(fpath)) with open(fpath, 'wb') as fh: - fh.write(data.read()) + fh.write(qrdata.read()) if printme: _logger.debug('Opening {0} in the default image viwer application'.format(fpath)) + # We intentionally want this to block, as most image viewers will + # unload the image once the file is deleted and we can probably + # elete it before the user can save it elsewhere or scan it with their phone. cmd = subprocess.run(['xdg-open', fpath], stdout = subprocess.PIPE, stderr = subprocess.PIPE) if cmd.returncode != 0: _logger.error('xdg-open returned non-zero status code') @@ -267,10 +270,10 @@ class VaultPass(object): _logger.debug('{0}: {1}'.format(x.upper(), o)) os.remove(fpath) elif printme: - print(data.read()) - data.seek(0, 0) - # TODO: clip, etc. - clipboard.pasteClipboard(printme = printme) + print(qrdata.read()) + qrdata.seek(0, 0) + if clip not in (False, None): + clipboard.pasteClipboard(data, seconds = seconds, clipboard = clipboard, printme = printme) return(data) def initVault(self, *args, **kwargs): diff --git a/vaultpass/args.py b/vaultpass/args.py index e96f1a2..abd422e 100644 --- a/vaultpass/args.py +++ b/vaultpass/args.py @@ -337,7 +337,7 @@ def parseArgs(): dest = 'path', help = ('(Dummy option; kept for compatibility reasons)')) initvault.add_argument('gpg_id', - dest = 'gpg_id', + metavar = 'GPG_KEY_ID', help = ('(Dummy option; kept for compatibility reasons)')) # INSERT # vp.insertSecret() @@ -411,22 +411,14 @@ def parseArgs(): # vp.getSecret(printme = True) # TODO: does the default overwrite the None if not specified? show.add_argument('-c', '--clip', - nargs = '?', - type = int, - default = None, - metavar = 'LINE_NUMBER', + action = 'store_true', dest = 'clip', - help = ('If specified, do not print the secret but instead copy it to the clipboard. ' - 'LINE_NUMBER has no effect and is kept for compatibility reasons')) + help = ('If specified, do not print the secret but instead copy it to the clipboard')) show.add_argument('-q', '--qrcode', dest = 'qr', - nargs = '?', - type = int, - metavar = 'LINE_NUMBER', - default = None, + action = 'store_true', help = ('If specified, do not print the secret but instead generate a QR code of it (either ' - 'graphically or in-terminal depending on environment). ' - 'LINE_NUMBER has no effect and is kept for compatibility reasons')) + 'graphically or in-terminal depending on environment)')) show.add_argument('-s', '--seconds', dest = 'seconds', type = int,