286 Commits

Author SHA1 Message Date
Marius Bakke
eea24967a0 Ensure compatibility with tree 2.0
Tree 2.0 and later will unconditionally ignore all options and write
JSON data on file descriptor 3 when available, which causes problems
for the test harness and other scripts that use FD 3.  Work around by
closing descriptor 3 for the 'tree' command.
2022-01-17 17:55:06 +01:00
Sam W
04cd3023f4 Fix unecessary reencryptions on MacOS
POSIX sed doesn't support \+ in BREs which causes the regex that
extracts a file's current keys to return nothing, meaning that files
are unecessarily reencrypted.
This converts the regex in question to use ERE.
2021-09-23 15:31:03 -06:00
Axel Tripier
fde8baea4c Exclude */.extensions from grep/reencrypt
The `.extensions` directory can contain extensions code, for example as
git submodules, that have `.gpg` files as part of their code but that
are not files encrypted with the PGP keys of our password store.

One example is `pass-tomb`, that contains `.gpg` files in `tests/gnupg`,
but there are more, like `pass-update`, `pass-otp`, etc.

However those `.gpg` files in the `.extensions` directory are currently
processed by the `grep` and `reencrypt` functions of `pass`.

At best this can cause errors to be shown to the user when
grepping/reencrypting, and at worst it can cause files in the
`.extensions` directory to be decrypted and returned as part of a
search, or reencrypted with the incorrect PGP keys.

This patch tries to mitigate that issue by removing the `*/.extensions`
directories from the list of processed `.gpg` files for the
grep/reencrypt functions.

However this patch is not perfect as it does not take into account the
fact that the `.extensions` directory can be renamed to something else
using `PASSWORD_STORE_EXTENSIONS_DIR`. But knowing if this
`PASSWORD_STORE_EXTENSIONS_DIR` is inside the `PREFIX` or not and
formatting the path exclusion for `find` accordingly could require a
fair bit of additional logic that I am not sure how you want to
implement.
2021-09-23 15:28:59 -06:00
Axel Tripier
ba454e41f6 Add missing local variable declaration 2021-09-23 15:27:29 -06:00
Ayush Agarwal
a80a318945 Replace 'which' with POSIX equivalent 'command -v'
The 'which' command is an external command that must be called each and
every time pass is used. 'which' is also not mentioned in the README as
one of the dependencies that might be needed to run pass.

Instead of 'which', we can use the POSIX compatible and shell built-in
'command -v'. It saves pass from making an external call and is,
arguably, more reliable than using 'which' as mentioned in the following
link.
2021-09-23 15:25:28 -06:00
Santiago Zarate
85bb62f47a Default to xclip if wl-clip is not found
In the strange case that the user is jumping back and forth from X11 to
Wayland and viceversa, xclip might be installed but wl-clip might not,
and in such combination user might end up with the -c opion not working.
2021-09-23 15:22:24 -06:00
Dan Čermák
3dd14690c7 Remove shebang from fish completion
Afaik fish shell completions don't need a shebang
(plus the script is not executable anyway)
2021-06-15 00:13:46 +02:00
Jason A. Donenfeld
1078f2514d version: bump 2021-06-11 18:49:06 +02:00
Rémi Lapeyre
a60b7ec4dc Ignore non-printable characters in calls to tree
In MacOS Catalina, pass fails on accents with 'sed: RE error: illegal
byte sequence'.
2021-06-11 18:47:43 +02:00
vnctdj
d4db24bfc3 Use GPG_OPTS when verifying .gpg-id signature
I use a pass-specific gpg home directory. I tell pass about it by using
PASSWORD_STORE_GPG_OPTS="--homedir dir".
I also tell pass to sign files with PASSWORD_STORE_SIGNING_KEY.

However "pass init" returns "Signing of .gpg_id unsuccessful." because
we forgot to hand it GPG_OPTS. This patch fixes that oversight.
2021-06-11 18:44:09 +02:00
Richard Towers
a271b43cbd Strip comments in gpg-id files 2021-06-11 18:39:37 +02:00
Guido Cella
ff5ac38f79 Escape colons in zsh completion to show url ports
zsh completion cuts filenames after colons, for example port numbers.
This is fixed by escaping colons.
This will also escape backslashes after the first.
2021-06-11 18:33:29 +02:00
Johannes Altmanninger
4e73cdc4c3 fish-completion: don't print full path when PASSWORD_STORE_DIR is set
"__fish_pass_print" enumerates all files in the password store and
uses sed to strip their common prefix - the password store directory.
If $PASSWORD_STORE_DIR had a trailing slash, sed would fail to remove
the prefix. Fix this by canonicalizing $PASSWORD_STORE_DIR.
2021-05-18 23:03:08 +02:00
Johannes Altmanninger
06f4999940 fish-completion: reuse "git" and "grep" completions
This makes fish complete commands starting with "pass git" as if they were
starting with "git".
2020-06-25 15:43:30 -06:00
Johannes Altmanninger
e50b18a049 fish-completion: don't erase existing completions for pass
fish only loads pass.fish once, so there is no point to erasing them.
2020-06-25 15:43:20 -06:00
Johannes Altmanninger
3439edd8e6 fish-completion: force some variables to be script-local
Unfortunately, a command "set x" without explicit scope overwrites the variable
"x" in the innermost scope it is defined in, if any.  This can cause problems
if the user defines the variable "x" as global or universal variable (which is
visible in all fishes).  Make sure to define a local variable so we use that.
2020-06-25 15:43:10 -06:00
Johannes Altmanninger
9ec2990e96 fish-completion: support completions for wrapper commands
There is no point to checking the command name, fish already does that.
Additionally fish knows about commands that "wrap" pass; those commands
should inherit pass's completions.

This commit enables fish>=3.1.0 to provide proper completions for this function:

	alias p="PASSWORD_STORE_DIR=$HOME/.my-passwords pass"

or, equivalently,

	function p --wraps "PASSWORD_STORE_DIR=$HOME/.my-passwords pass"
		PASSWORD_STORE_DIR=$HOME/.my-passwords pass $argv
	end
2020-06-25 15:43:00 -06:00
Johannes Altmanninger
3be8496c74 fish-completion: remove obsolete flag
The -A/--authoritative flag no longer has an effect since fish 2.5 which
was released in 2017.
2020-06-25 15:42:42 -06:00
Johannes Altmanninger
46d26994d0 fish-completion: avoid printing errors with an empty password store
Reproduce by typing "pass <TAB>" in a shell launched like: HOME=`mktemp -d` fish

Fish prints an error on failing globs - except when used in one of the commands
"set", "for" or "count". Also quotes are unnecessary here.
2020-06-25 15:42:32 -06:00
Filippo Valsorda
07b169ec32 platform/darwin: don't invoke brew for the default prefix
"brew --prefix gnu-getopt" takes 2.125s on my very default setup (I
don't even want to know why), dominating the pass wall time.

If the default brew prefix is in use, just detect the getopt binary with
a cheap "test -x" instead.
2020-04-19 23:36:59 -06:00
Filippo Valsorda
8d267c480e platform/darwin: drop using "display" to show QR codes
This doesn't detect if XQuartz is installed and running, so it's broken
in most setups, the experience is poor regardless, since it's not
displayed inline in the terminal, but leaves a window that requires
closing, and anyway the the utf8 mode works perfectly on both iTerm2 and
Terminal.app.
2020-04-19 23:36:59 -06:00
Martin F. Krafft
88936b11af Unset variables messing with Git use
This patch makes sure that variables from the environment cannot
override e.g. the Git directory to operate on, as well as other critical
parts of Git operations. These variables are:

  - GIT_DIR
  - GIT_WORK_TREE
  - GIT_NAMESPACE
  - GIT_INDEX_FILE
  - GIT_INDEX_VERSION
  - GIT_OBJECT_DIRECTORY
  - GIT_COMMON_DIR

If any of those are set, pass might end up operating on another
repository, and things would break.

I caught this having GIT_DIR set, but fortunately the other repository
had a .gitignore that would have ignored the file:

```
fishbowl~% echo $GIT_DIR
/home/madduck/.config/vcsh/repo.d/zsh.git

fishbowl~% pass generate test
The following paths are ignored by one of your .gitignore files:
.password-store/test.gpg
Use -f if you really want to add them.
The generated password for test is:
…
```

The result was an orphan file `test.gpg` in the password-store root.

Signed-off-by: Martin F. Krafft <madduck@madduck.net>
2019-11-28 12:18:25 +01:00
Daniel Janus
c22cdbd467 Account for missing [:graph:] on Busybox by using [:alnum:][:punct:]
Some implementations of tr (notably the ones in Busybox and Toybox) do
not support the [:graph:] character class, but they do support
[:punct:] and [:alnum:]. This makes pass generate sane passwords
in such environments.

Discussed-on: https://lists.zx2c4.com/pipermail/password-store/2019-July/003702.html
2019-07-17 14:26:45 +02:00
Aaron Jones
5a52772156 Exclude invalid, disabled and revoked subkeys from subkey selection
When rotating encryption subkeys, and revoking the old one,
`pass init keyid` would re-encrypt your stored credentials to the
(now revoked) old subkey(s) in addition to the new one too.

It would also mistakenly encrypt to keys that have been disabled,
and keys that were never validly signed by their master (certify) key.

Fix all of these cases. It was decided NOT to also exclude expired
subkeys.

Signed-off-by: Aaron Jones <aaronmdjones@gmail.com>
2019-06-16 21:59:52 +02:00
Brett Cornwall
b0b784b1a5 clip: Add support for wl-clipboard 2019-02-27 15:15:25 +01:00
Elan Ruusamäe
5ef311735c bash-completion: detect whether to use gpg/gpg2 binary for complete keys
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
2018-10-19 02:47:06 +02:00
Elan Ruusamäe
e43b019042 bash_completion: do not leak variables to globals scope
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
2018-10-19 02:45:56 +02:00
Aldis Berjoza
d68d9c50db Do not reencrypt symbolic links 2018-08-09 19:37:50 -07:00
Jason A. Donenfeld
74fdfb5022 version: bump 2018-08-03 05:32:48 +02:00
Jason A. Donenfeld
44f54f0b02 show: do not store binary data in bash vars
Instead we're forced to base64 it, like we do with the clipboard.
2018-08-01 04:12:04 +02:00
Lars Flitter
6a6222eef2 Add custom bash completion for extensions
Bash completion now allows usage of extension commands.
(see pass.bash-completion for details)
2018-07-26 22:45:59 +02:00
Lukas Fleischer
e70b264c5b Do not set foreground color for generated password
Since commit 63ef32a (generate: use nice ansi colors instead.,
2014-05-08), generated passwords are highlighted to make them
distinguishable from the Git output.

However, setting the foreground color to white makes the password hardly
readable when a "black on white" color scheme is used. Drop the
hardcoded foreground color and use the bold attribute only instead.

Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
2018-07-26 19:57:47 +02:00
Jason A. Donenfeld
367efa5846 Do not put passwords in herestrings
Bash sometimes writes these into temporary files, which isn't okay.
2018-06-25 19:48:16 +02:00
Jason A. Donenfeld
8d46049230 version: bump 2018-06-14 16:58:28 +02:00
Jason A. Donenfeld
8446a40fbc show: buffer output before displaying, in case decryption fails
For the line-choosing case, this is actually a big deal since we weren't
passing the error code back to the user either.
2018-06-14 16:58:28 +02:00
Allan Odgaard
f97cf971d8 Close stdout for background task that restores clipboard
While we do not expect any output on stdout from the background task,
keeping the file handle open means that anyone calling `pass` and
waiting for stdout to be closed, will have to wait (by default) for 45
seconds.
2018-06-14 16:58:28 +02:00
Nick Kousu
4a6fa5cbdf Don't trap INT or TERM; they are redundant and can break pass edit.
Some EDITORs, notably Linux vi(1), which is the fallback default in pass,
apparently send INT when they exit, and when pass is run under bash
(which is also its default)--if you have /dev/shm/ available--bash catches
this and cleans up your edited password file *before* it can be reencrypted
and saved.

This only happens with `pass edit`; none of the other commands combine
tmpdir and $EDITOR.
2018-06-14 16:58:28 +02:00
Norbert Buchmueller
8732213db4 Add tests and documentation of passing options to grep(1) 2018-06-14 16:58:28 +02:00
Jason A. Donenfeld
8683403b77 Ensure signature regexes are anchored
Fixes CVE-2018-12356.

Reported-by: Marcus Brinkmann <marcus.brinkmann@ruhr-uni-bochum.de>
2018-06-14 16:58:28 +02:00
Sitaram Chamarty
dda2ecce34 grep: allow grep options and arguments
Allow grep options and arguments.  Typical uses may be, for instance,
wanting to ignore case ('-i'), print a few lines of context around the
matched line, multiple patterns with '-e', etc.

(background: grep is deprecating GREP_OPTIONS, so eventually that will
stop working).
2018-05-24 13:26:23 +02:00
Mathis Antony
fab65bda88 fish: reduce completion runtimes
Fish completion spends most of the time in calls to `sed` in for loops over
entries and directories. This patch removes the repeated calls to `sed`.

Signed-off-by: Mathis Antony <sveitser@gmail.com>
2018-02-19 16:06:47 +01:00
Jason A. Donenfeld
ffef92ee0e generate: disallow zero length generated passwords 2018-02-08 23:17:40 +01:00
Jason A. Donenfeld
94ac2ba2c6 generate: in-place should work when file is empty 2018-02-01 11:57:38 +01:00
Jason A. Donenfeld
bd1cadd562 Quote array specifier
Otherwise this expands to a filename if one exists.

Suggested-by: izaberina@gmail.com
2017-12-18 16:01:22 +01:00
Stacey Sheldon
7252e8b3cf protect dirname calls from pass-names that look like command-line options
With the $path variable being passed directly to dirname, any pass-names
provided by the user that happened to look like options to dirname would
be processed as options rather than as the path to be split.

This results in a real mess when you happen to run one of:

  pass edit --help
  pass generate --help
  pass insert --help

then in the cmd_foo() function, you have:

   mkdir -p -v "$PREFIX/$(dirname --help)"

which (due to the -p option to mkdir) results in the creation of an
entire directory hierarchy made up of the slash-separated help text from
dirname.
2017-10-13 20:21:40 +02:00
Jason A. Donenfeld
38ec1c72e2 Bump version 2017-04-13 12:11:14 +02:00
Jason A. Donenfeld
a09d6685e6 init: match only the public key 2017-04-13 12:11:13 +02:00
Jason A. Donenfeld
caaa5f0f85 Use $GPG variable 2017-03-28 18:36:43 +02:00
Andreas Stieger
6f86767427 Fix compatibility with GnuPG 2.2.19
GnuPG 2.2.19 added a warning when no command was given.

* src/password-store.sh (reencrypt_path): Add --decrypt to --list-only
* tests/t0300-reencryption.sh (gpg_keys_from_encrypted_file): same

https://bugs.gnupg.org/gnupg/msg9873
http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=commit;h=810adfd47801fc01e45fb71af9f05c91f7890cdb
https://bugzilla.suse.com/show_bug.cgi?id=1028867
2017-03-20 15:46:50 +01:00
Jason A. Donenfeld
20081b546f Bump version 2017-02-26 18:52:16 +01:00