PR: ports/172916 Submitted by: milki <milki@rescomp.berkeley.edu> (maintainer) Feature safe: yes
321 lines
12 KiB
Diff
321 lines
12 KiB
Diff
diff --git README README
|
|
index 47ed64b..496c37f 100644
|
|
--- README
|
|
+++ README
|
|
@@ -19,8 +19,6 @@ Depends on:
|
|
http://www.gnupg.org/
|
|
- git
|
|
http://www.git-scm.com/
|
|
-- xclip
|
|
- http://sourceforge.net/projects/xclip/
|
|
- pwgen
|
|
http://sourceforge.net/projects/pwgen/
|
|
- tree
|
|
diff --git contrib/pass.bash-completion contrib/pass.bash-completion
|
|
index d0ef012..7b3c149 100644
|
|
--- contrib/pass.bash-completion
|
|
+++ contrib/pass.bash-completion
|
|
@@ -59,7 +59,6 @@ _pass()
|
|
_pass_complete_entries
|
|
;;
|
|
show|-*)
|
|
- COMPREPLY+=($(compgen -W "-c --clip" -- ${cur}))
|
|
_pass_complete_entries 1
|
|
;;
|
|
insert)
|
|
@@ -67,7 +66,7 @@ _pass()
|
|
_pass_complete_entries
|
|
;;
|
|
generate)
|
|
- COMPREPLY+=($(compgen -W "-n --no-symbols -c --clip -f --force" -- ${cur}))
|
|
+ COMPREPLY+=($(compgen -W "-n --no-symbols -f --force" -- ${cur}))
|
|
_pass_complete_entries
|
|
;;
|
|
rm|remove|delete)
|
|
diff --git contrib/pass.fish-completion contrib/pass.fish-completion
|
|
index 9130d1f..8998d96 100644
|
|
--- contrib/pass.fish-completion
|
|
+++ contrib/pass.fish-completion
|
|
@@ -76,7 +76,6 @@ complete -c $PROG -f -A -n '__fish_pass_uses_command insert' -a "(__fish_pass_pr
|
|
|
|
complete -c $PROG -f -A -n '__fish_pass_needs_command' -a generate -d 'Command: generate new password'
|
|
complete -c $PROG -f -A -n '__fish_pass_uses_command generate' -s n -l no-symbols -d 'Do not use special symbols'
|
|
-complete -c $PROG -f -A -n '__fish_pass_uses_command generate' -s c -l clip -d 'Put the password in clipboard'
|
|
complete -c $PROG -f -A -n '__fish_pass_uses_command generate' -s f -l force -d 'Do not prompt before overwritting'
|
|
complete -c $PROG -f -A -n '__fish_pass_uses_command generate' -a "(__fish_pass_print_entry_dirs)"
|
|
|
|
@@ -89,13 +88,10 @@ complete -c $PROG -f -A -n '__fish_pass_needs_command' -a edit -d 'Command: edit
|
|
complete -c $PROG -f -A -n '__fish_pass_uses_command edit' -a "(__fish_pass_print_entries)"
|
|
|
|
complete -c $PROG -f -A -n '__fish_pass_needs_command' -a show -d 'Command: show existing password'
|
|
-complete -c $PROG -f -A -n '__fish_pass_uses_command show' -s c -l clip -d 'Put password in clipboard'
|
|
complete -c $PROG -f -A -n '__fish_pass_uses_command show' -a "(__fish_pass_print_entries)"
|
|
# When no command is given, `show` is defaulted.
|
|
-complete -c $PROG -f -A -n '__fish_pass_needs_command' -s c -l clip -d 'Put password in clipboard'
|
|
complete -c $PROG -f -A -n '__fish_pass_needs_command' -a "(__fish_pass_print_entries)"
|
|
complete -c $PROG -f -A -n '__fish_pass_uses_command -c' -a "(__fish_pass_print_entries)"
|
|
-complete -c $PROG -f -A -n '__fish_pass_uses_command --clip' -a "(__fish_pass_print_entries)"
|
|
|
|
complete -c $PROG -f -A -n '__fish_pass_needs_command' -a git -d 'Command: execute a git command'
|
|
complete -c $PROG -f -A -n '__fish_pass_uses_command git' -a 'init' -d 'Initialize git repository'
|
|
diff --git contrib/pass.zsh-completion contrib/pass.zsh-completion
|
|
index 848bc67..9855ac0 100644
|
|
--- contrib/pass.zsh-completion
|
|
+++ contrib/pass.zsh-completion
|
|
@@ -39,8 +39,6 @@ _pass () {
|
|
_arguments : \
|
|
"-n[don't include symbols in password]" \
|
|
"--no-symbols[don't include symbols in password]" \
|
|
- "-c[copy password to the clipboard]" \
|
|
- "--clip[copy password to the clipboard]"
|
|
_pass_complete_entries_with_subdirs
|
|
;;
|
|
rm)
|
|
@@ -90,9 +88,6 @@ _pass () {
|
|
}
|
|
|
|
_pass_cmd_show () {
|
|
- _arguments : \
|
|
- "-c[put it on the clipboard]" \
|
|
- "--clip[put it on the clipboard]"
|
|
_pass_complete_entries
|
|
}
|
|
_pass_complete_entries_helper () {
|
|
diff --git man/pass.1 man/pass.1
|
|
index efb5d9b..bc65a54 100644
|
|
--- man/pass.1
|
|
+++ man/pass.1
|
|
@@ -68,12 +68,8 @@ by using the
|
|
.BR tree (1)
|
|
program. This command is alternatively named \fBlist\fP.
|
|
.TP
|
|
-\fBshow\fP [ \fI--clip\fP, \fI-c\fP ] \fIpass-name\fP
|
|
-Decrypt and print a password named \fIpass-name\fP. If \fI--clip\fP or \fI-c\fP
|
|
-is specified, do not print the password but instead copy the first line to the
|
|
-clipboard using
|
|
-.BR xclip (1)
|
|
-and then restore the clipboard after 45 seconds.
|
|
+\fBshow\fP \fIpass-name\fP
|
|
+Decrypt and print a password named \fIpass-name\fP.
|
|
.TP
|
|
\fBinsert\fP [ \fI--echo\fP, \fI-e\fP | \fI--multiline\fP, \fI-m\fP ] [ \fI--force\fP, \fI-f\fP ] \fIpass-name\fP
|
|
Insert a new password into the password store called \fIpass-name\fP. This will
|
|
@@ -92,15 +88,12 @@ ensure that temporary files are created in \fI/dev/shm\fP in order to avoid writ
|
|
difficult-to-erase disk sectors. If \fI/dev/shm\fP is not accessible, fallback to
|
|
the ordinary \fITMPDIR\fP location, and print a warning.
|
|
.TP
|
|
-\fBgenerate\fP [ \fI--no-symbols\fP, \fI-n\fP ] [ \fI--clip\fP, \fI-c\fP ] [ \fI--force\fP, \fI-f\fP ] \fIpass-name pass-length\fP
|
|
+\fBgenerate\fP [ \fI--no-symbols\fP, \fI-n\fP ] [ \fI--force\fP, \fI-f\fP ] \fIpass-name pass-length\fP
|
|
Generate a new password using
|
|
.BR pwgen (1)
|
|
of length \fIpass-length\fP and insert into \fIpass-name\fP. If \fI--no-symbols\fP or \fI-n\fP
|
|
is specified, do not use any non-alphanumeric characters in the generated password.
|
|
-If \fI--clip\fP or \fI-c\fP is specified, do not print the password but instead copy
|
|
-it to the clipboard using
|
|
-.BR xclip (1)
|
|
-and then restore the clipboard after 45 seconds. Prompt before overwriting an existing password,
|
|
+Prompt before overwriting an existing password,
|
|
unless \fI--force\fP or \fI-f\fP is specified.
|
|
.TP
|
|
\fBrm\fP [ \fI--recursive\fP, \fI-r\fP ] [ \fI--force\fP, \fI-f\fP ] \fIpass-name\fP
|
|
@@ -166,11 +159,6 @@ Show existing password
|
|
.br
|
|
sup3rh4x3rizmynam3
|
|
.TP
|
|
-Copy existing password to clipboard
|
|
-.B zx2c4@laptop ~ $ pass -c Email/zx2c4.com
|
|
-.br
|
|
-Copied Email/jason@zx2c4.com to clipboard. Will clear in 45 seconds.
|
|
-.TP
|
|
Add password to store
|
|
.B zx2c4@laptop ~ $ pass insert Business/cheese-whiz-factory
|
|
.br
|
|
@@ -209,10 +197,8 @@ The generated password to Email/jasondonenfeld.com is:
|
|
.br
|
|
YqFsMkBeO6di
|
|
.TP
|
|
-Generate new password and copy it to the clipboard
|
|
-.B zx2c4@laptop ~ $ pass -c generate Email/jasondonenfeld.com 19
|
|
-.br
|
|
-Copied Email/jasondonenfeld.com to clipboard. Will clear in 45 seconds.
|
|
+Generate new password
|
|
+.B zx2c4@laptop ~ $ pass generate Email/jasondonenfeld.com 19
|
|
.TP
|
|
Remove password from store
|
|
.B zx2c4@laptop ~ $ pass remove Business/cheese-whiz-factory
|
|
@@ -345,7 +331,6 @@ The location of the text editor used by \fBedit\fP.
|
|
.BR gpg2 (1),
|
|
.BR pwgen (1),
|
|
.BR git (1),
|
|
-.BR xclip (1).
|
|
|
|
.SH AUTHOR
|
|
.B pass
|
|
diff --git src/password-store.sh src/password-store.sh
|
|
index 26a4bd0..fe79c82 100755
|
|
--- src/password-store.sh
|
|
+++ src/password-store.sh
|
|
@@ -1,4 +1,4 @@
|
|
-#!/bin/bash
|
|
+#!/usr/local/bin/bash
|
|
|
|
# Copyright (C) 2012 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
|
# This file is licensed under the GPLv2+. Please see COPYING for more information.
|
|
@@ -35,18 +35,18 @@ Usage:
|
|
Optionally reencrypt existing passwords using new gpg-id.
|
|
$program [ls] [subfolder]
|
|
List passwords.
|
|
- $program [show] [--clip,-c] pass-name
|
|
- Show existing password and optionally put it on the clipboard.
|
|
- If put on the clipboard, it will be cleared in 45 seconds.
|
|
+ $program [show] pass-name
|
|
+ Show existing password
|
|
$program insert [--echo,-e | --multiline,-m] [--force,-f] pass-name
|
|
Insert new password. Optionally, the console can be enabled echo
|
|
the password back. Or, optionally, it may be multiline. Prompt
|
|
+ Insert new password. Optionally, the console can be enabled to not
|
|
+ echo the password back. Or, optionally, it may be multiline. Prompt
|
|
before overwriting existing password unless forced.
|
|
$program edit pass-name
|
|
Insert a new password or edit an existing password using ${EDITOR:-vi}.
|
|
- $program generate [--no-symbols,-n] [--clip,-c] [--force,-f] pass-name pass-length
|
|
+ $program generate [--no-symbols,-n] [--force,-f] pass-name pass-length
|
|
Generate a new password of pass-length with optionally no symbols.
|
|
- Optionally put it on the clipboard and clear board after 45 seconds.
|
|
Prompt before overwriting existing password unless forced.
|
|
$program rm [--recursive,-r] [--force,-f] pass-name
|
|
Remove existing password or directory, optionally forcefully.
|
|
@@ -80,48 +80,21 @@ yesno() {
|
|
#
|
|
# BEGIN Platform definable
|
|
#
|
|
-clip() {
|
|
- # This base64 business is a disgusting hack to deal with newline inconsistancies
|
|
- # in shell. There must be a better way to deal with this, but because I'm a dolt,
|
|
- # we're going with this for now.
|
|
-
|
|
- before="$(xclip -o -selection clipboard | base64)"
|
|
- echo -n "$1" | xclip -selection clipboard
|
|
- (
|
|
- sleep 45
|
|
- now="$(xclip -o -selection clipboard | base64)"
|
|
- if [[ $now != $(echo -n "$1" | base64) ]]; then
|
|
- before="$now"
|
|
- fi
|
|
-
|
|
- # It might be nice to programatically check to see if klipper exists,
|
|
- # as well as checking for other common clipboard managers. But for now,
|
|
- # this works fine -- if qdbus isn't there or if klipper isn't running,
|
|
- # this essentially becomes a no-op.
|
|
- #
|
|
- # Clipboard managers frequently write their history out in plaintext,
|
|
- # so we axe it here:
|
|
- qdbus org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardHistory &>/dev/null
|
|
-
|
|
- echo "$before" | base64 -d | xclip -selection clipboard
|
|
- ) & disown
|
|
- echo "Copied $2 to clipboard. Will clear in 45 seconds."
|
|
-}
|
|
tmpdir() {
|
|
- if [[ -d /dev/shm && -w /dev/shm && -x /dev/shm ]]; then
|
|
- tmp_dir="$(TMPDIR=/dev/shm mktemp -t "$template" -d)"
|
|
+ ramdisk="/var/tmp/password-store.ramdisk"
|
|
+ if [[ -d $ramdisk && -d $ramdisk && -d $ramdisk ]]; then
|
|
+ tmp_dir="$(TMPDIR=$ramdisk mktemp -t "$template" -d)"
|
|
else
|
|
- yesno "$(echo "Your system does not have /dev/shm, which means that it may"
|
|
- echo "be difficult to entirely erase the temporary non-encrypted"
|
|
- echo "password file after editing. Are you sure you would like to"
|
|
- echo -n "continue?")"
|
|
+ yesno "$(echo "A ramdisk does not exist at $ramdisk, which means that it may"
|
|
+ echo "be difficult to entirely erase the temporary non-encrypted"
|
|
+ echo "password file after editing. Are you sure you would like to"
|
|
+ echo -n "continue?")"
|
|
+
|
|
tmp_dir="$(mktemp -t "$template" -d)"
|
|
fi
|
|
-
|
|
}
|
|
-GETOPT="getopt"
|
|
|
|
-# source /path/to/platform-defined-functions
|
|
+GETOPT="/usr/local/bin/getopt"
|
|
#
|
|
# END Platform definable
|
|
#
|
|
@@ -191,18 +164,8 @@ fi
|
|
|
|
case "$command" in
|
|
show|ls|list)
|
|
- clip=0
|
|
-
|
|
- opts="$($GETOPT -o c -l clip -n "$program" -- "$@")"
|
|
- err=$?
|
|
- eval set -- "$opts"
|
|
- while true; do case $1 in
|
|
- -c|--clip) clip=1; shift ;;
|
|
- --) shift; break ;;
|
|
- esac done
|
|
-
|
|
if [[ $err -ne 0 ]]; then
|
|
- echo "Usage: $program $command [--clip,-c] [pass-name]"
|
|
+ echo "Usage: $program $command [pass-name]"
|
|
exit 1
|
|
fi
|
|
|
|
@@ -220,13 +183,8 @@ case "$command" in
|
|
echo "$path is not in the password store."
|
|
exit 1
|
|
fi
|
|
- if [[ $clip -eq 0 ]]; then
|
|
- exec gpg2 -d $GPG_OPTS "$passfile"
|
|
- else
|
|
- pass="$(gpg2 -d $GPG_OPTS "$passfile" | head -n 1)"
|
|
- [[ -n $pass ]] || exit 1
|
|
- clip "$pass" "$path"
|
|
- fi
|
|
+
|
|
+ gpg2 -d $GPG_OPTS "$passfile"
|
|
fi
|
|
;;
|
|
insert)
|
|
@@ -307,22 +265,20 @@ case "$command" in
|
|
git_add_file "$passfile" "$action password for $path using ${EDITOR:-vi}."
|
|
;;
|
|
generate)
|
|
- clip=0
|
|
force=0
|
|
symbols="-y"
|
|
|
|
- opts="$($GETOPT -o ncf -l no-symbols,clip,force -n "$program" -- "$@")"
|
|
+ opts="$($GETOPT -o ncf -l no-symbols,force -n "$program" -- "$@")"
|
|
err=$?
|
|
eval set -- "$opts"
|
|
while true; do case $1 in
|
|
-n|--no-symbols) symbols=""; shift ;;
|
|
- -c|--clip) clip=1; shift ;;
|
|
-f|--force) force=1; shift ;;
|
|
--) shift; break ;;
|
|
esac done
|
|
|
|
if [[ $err -ne 0 || $# -ne 2 ]]; then
|
|
- echo "Usage: $program $command [--no-symbols,-n] [--clip,-c] [--force,-f] pass-name pass-length"
|
|
+ echo "Usage: $program $command [--no-symbols,-n] [--force,-f] pass-name pass-length"
|
|
exit 1
|
|
fi
|
|
path="$1"
|
|
@@ -341,12 +297,8 @@ case "$command" in
|
|
gpg2 -e -r "$ID" -o "$passfile" $GPG_OPTS <<<"$pass"
|
|
git_add_file "$passfile" "Added generated password for $path to store."
|
|
|
|
- if [[ $clip -eq 0 ]]; then
|
|
- echo "The generated password to $path is:"
|
|
- echo "$pass"
|
|
- else
|
|
- clip "$pass" "$path"
|
|
- fi
|
|
+ echo "The generated password to $path is:"
|
|
+ echo "$pass"
|
|
;;
|
|
delete|rm|remove)
|
|
recursive=""
|