From vadyalex at gmail.com Wed Nov 15 20:07:52 2023 From: vadyalex at gmail.com (vadyalex) Date: Wed, 15 Nov 2023 21:07:52 +0100 Subject: pass show --pipe Message-ID: Hello there! First of all thank you for this wonderful project! I mostly use pass on laptop either via `pass show --clip ..` or via `pass show ..` then selecting and copying directly from terminal and pasting to the target place, - mostly browser. Recently I needed to extract copy of the password and encrypted it with gpg for CI system and then paste result inside yaml file; In order to produce encrypted message I did: `pass show the_password_file | gpg -a -e -r ci` After long hours of investigation I understood that `pass show --clip the_password_file` and `pass show the_password_file` as well as `$(pass show the_password_file)` are not equal (given that the_password_file was produced via: `echo -n 'the_password' | pass insert --echo the_password_file `pass show --clip the_password_file` copies password to clipboard - i.e. copies content of the first line <-- does not include trailing new line `pass show the_password_file` - send content to standard output <-- includes trailing new line `$(pass show the_password_file)` - send content to standard output <-- command substitution removes trailing new line [https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html] My confusion was due to fact the I assumed since I produced the content for `the_password` without new line characters I would consume it as such.. It is in the retrospect I understand that in order to store password on the first line one must indicate new line and store for further encryption. If I would produce `the_password` via temporary file and insert multi-line option: `echo -n 'the_password' > /tmp/the_password_file.tmp && pass insert -m the_password_file < /tmp/the_password_file.tmp` That way `pass show the_password_file` would produce equal result as `pass show --clip the_password_file` but this approach is heavily restricted by the way how it was created. In order to remove trailing new line one could use command substitution: `echo -n $(pass show the_password_file)` and for So what I think I want is the way to output the password without trailing new line to standard output exactly like `--clip`; introducing new `--pipe` option along with `--clip` and `--qrcode` Here is my proposed patch: diff --git a/src/password-store.sh b/src/password-store.sh index 22e818f..bcc44cc 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -366,24 +366,25 @@ cmd_init() { } cmd_show() { - local opts selected_line clip=0 qrcode=0 - opts="$($GETOPT -o q::c:: -l qrcode::,clip:: -n "$PROGRAM" -- "$@")" + local opts selected_line clip=0 qrcode=0 pipe=0 + opts="$($GETOPT -o q::c::p:: -l qrcode::,clip::,pipe:: -n "$PROGRAM" -- "$@")" local err=$? eval set -- "$opts" while true; do case $1 in -q|--qrcode) qrcode=1; selected_line="${2:-1}"; shift 2 ;; -c|--clip) clip=1; selected_line="${2:-1}"; shift 2 ;; + -p|--pipe) pipe=1; selected_line="${2:-1}"; shift 2 ;; --) shift; break ;; esac done - [[ $err -ne 0 || ( $qrcode -eq 1 && $clip -eq 1 ) ]] && die "Usage: $PROGRAM $COMMAND [--clip[=line-number],-c[line- number]] [--qrcode[=line-number],-q[line-number]] [pass-name]" + [[ $err -ne 0 || ( $qrcode -eq 1 && $clip -eq 1 && $pipe -eq 1 ) ]] && die "Usage: $PROGRAM $COMMAND [--clip[=line-number],-c[line-number]] [--qrcode[=line-number],-q[line-number]] [--pipe[=line-number],-p[line-number]] [pass-name]" local pass local path="$1" local passfile="$PREFIX/$path.gpg" check_sneaky_paths "$path" if [[ -f $passfile ]]; then - if [[ $clip -eq 0 && $qrcode -eq 0 ]]; then + if [[ $clip -eq 0 && $qrcode -eq 0 && $pipe -eq 0 ]]; then pass="$($GPG -d "${GPG_OPTS[@]}" "$passfile" | $BASE64)" || exit $? echo "$pass" | $BASE64 -d else @@ -394,6 +395,8 @@ cmd_show() { clip "$pass" "$path" elif [[ $qrcode -eq 1 ]]; then qrcode "$pass" "$path" + elif [[ $pipe -eq 1 ]]; then + echo -n "$pass" fi fi elif [[ -d $PREFIX/$path ]]; then From dooleyn at gmail.com Wed Nov 22 17:40:52 2023 From: dooleyn at gmail.com (doolio) Date: Wed, 22 Nov 2023 18:40:52 +0100 Subject: [PATCH emacs] Minor miscellaneous changes Message-ID: <20231122174052.60177-1-dooleyn@gmail.com> - Update header information. - Correct some docstrings. - Use emacs standard fill-column of 65 for docstrings. - Update URL and add some others. --- contrib/emacs/README.md | 5 +- contrib/emacs/password-store.el | 113 ++++++++++++++++++-------------- 2 files changed, 66 insertions(+), 52 deletions(-) diff --git a/contrib/emacs/README.md b/contrib/emacs/README.md index 8269c35..a3d3207 100644 --- a/contrib/emacs/README.md +++ b/contrib/emacs/README.md @@ -3,12 +3,12 @@ This package provides functions for working with pass ("the standard Unix password manager"). -http://www.zx2c4.com/projects/password-store +https://www.passwordstore.org/ ## Setup The pass application must be installed and set up. See the pass -website for instructions +website for instructions. ## Example usage @@ -38,7 +38,6 @@ Interactive: Copied username for foo-account to the kill ring. Will clear in 45 seconds. Field url cleared. - Lisp: (password-store-insert "foo-account" "password") diff --git a/contrib/emacs/password-store.el b/contrib/emacs/password-store.el index 280aee5..8965683 100644 --- a/contrib/emacs/password-store.el +++ b/contrib/emacs/password-store.el @@ -4,32 +4,34 @@ ;; Author: Svend Sorensen ;; Maintainer: Tino Calancha -;; Version: 2.3.1 +;; Version: 2.3.2 ;; URL: https://www.passwordstore.org/ -;; Package-Requires: ((emacs "26") (with-editor "2.5.11")) -;; Keywords: tools pass password password-store +;; Package-Requires: ((emacs "26.1") (with-editor "2.5.11")) +;; SPDX-License-Identifier: GPL-3.0-or-later +;; Keywords: tools pass password password-store gpg ;; This file is not part of GNU Emacs. -;; This program is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. +;; This program is free software: you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation, either version 3 of +;; the License, or (at your option) any later version. -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. +;; This program is distributed in the hope that it will be +;; useful, but WITHOUT ANY WARRANTY; without even the implied +;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +;; PURPOSE. See the GNU General Public License for more details. -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . +;; You should have received a copy of the GNU General Public +;; License along with this program. If not, see +;; . ;;; Commentary: -;; This package provides functions for working with pass ("the -;; standard Unix password manager"). -;; -;; http://www.passwordstore.org/ +;; This package provides and Emacs interface for working with +;; pass ("the standard Unix password manager"). + +;; https://www.passwordstore.org/ ;;; Code: @@ -37,9 +39,17 @@ (require 'auth-source-pass) (defgroup password-store '() - "Emacs mode for password-store." + "Emacs mode for password-store. +The standard Unix password manager" :prefix "password-store-" - :group 'password-store) + :group 'password-store + :link '(url-link :tag "Description" "https://www.passwordstore.org/") + :link '(url-link :tag "Download" "https://melpa.org/#/password-store") + :link `(url-link :tag "Send Bug Report" + ,(concat "mailto:" "password-store" "@" "lists.zx2c4" ".com?subject= +password-store.el bug: \ +&body=Describe bug here, starting with `emacs -q'. \ +Don't forget to mention your Emacs and library versions."))) (defcustom password-store-password-length 25 "Default password length." @@ -55,7 +65,7 @@ :type 'number) (defcustom password-store-url-field "url" - "Field name used in the files to indicate an url." + "Field name used in the files to indicate a URL." :group 'password-store :type 'string) @@ -67,17 +77,18 @@ "Timer for clearing clipboard.") (defun password-store-timeout () - "Number of seconds to wait before clearing the password. + "Number of seconds to wait before restoring the clipboard. -This function just returns `password-store-time-before-clipboard-restore'. -Kept for backward compatibility with other libraries." - password-store-time-before-clipboard-restore) +This function just returns +`password-store-time-before-clipboard-restore'. Kept for +backward compatibility with other libraries." +password-store-time-before-clipboard-restore) (defun password-store--run-1 (callback &rest args) "Run pass with ARGS. -Nil arguments are ignored. Calls CALLBACK with the output on success, -or outputs error message on failure." +Nil arguments are ignored. Calls CALLBACK with the output on +success, or outputs error message on failure." (let ((output "")) (make-process :name "password-store-gpg" @@ -230,8 +241,8 @@ ENTRY is the name of a password-store entry." (defun password-store-get (entry &optional callback) "Return password for ENTRY. -Returns the first line of the password data. -When CALLBACK is non-`NIL', call CALLBACK with the first line instead." +Returns the first line of the password data. When CALLBACK is +non-`NIL', call CALLBACK with the first line instead." (let* ((inhibit-message t) (secret (auth-source-pass-get 'secret entry))) (if (not callback) secret @@ -242,9 +253,10 @@ When CALLBACK is non-`NIL', call CALLBACK with the first line instead." ;;;###autoload (defun password-store-get-field (entry field &optional callback) "Return FIELD for ENTRY. -FIELD is a string, for instance \"url\". -When CALLBACK is non-`NIL', call it with the line associated to FIELD instead. -If FIELD equals to symbol secret, then this function reduces to `password-store-get'." +FIELD is a string, for instance \"url\". When CALLBACK is +non-`NIL', call it with the line associated to FIELD instead. If +FIELD equals to symbol secret, then this function reduces to +`password-store-get'." (let* ((inhibit-message t) (secret (auth-source-pass-get field entry))) (if (not callback) secret @@ -257,10 +269,10 @@ If FIELD equals to symbol secret, then this function reduces to `password-store- (defun password-store-clear (&optional field) "Clear secret in the kill ring. -Optional argument FIELD, a symbol or a string, describes -the stored secret to clear; if nil, then set it to 'secret. -Note, FIELD does not affect the function logic; it is only used -to display the message: +Optional argument FIELD, a symbol or a string, describes the +stored secret to clear; if nil, then set it to 'secret. Note, +FIELD does not affect the function logic; it is only used to +display the message: \(message \"Field %s cleared.\" field)." (interactive "i") @@ -287,9 +299,10 @@ to display the message: (defun password-store-copy (entry) "Add password for ENTRY into the kill ring. -Clear previous password from the kill ring. Pointer to the kill ring -is stored in `password-store-kill-ring-pointer'. Password is cleared -after `password-store-time-before-clipboard-restore' seconds." +Clear previous password from the kill ring. Pointer to the kill +ring is stored in `password-store-kill-ring-pointer'. Password +is cleared after `password-store-time-before-clipboard-restore' +seconds." (interactive (list (password-store--completing-read t))) (password-store-get entry @@ -300,10 +313,12 @@ after `password-store-time-before-clipboard-restore' seconds." (defun password-store-copy-field (entry field) "Add FIELD for ENTRY into the kill ring. -Clear previous secret from the kill ring. Pointer to the kill ring is -stored in `password-store-kill-ring-pointer'. Secret field is cleared -after `password-store-timeout' seconds. -If FIELD equals to symbol secret, then this function reduces to `password-store-copy'." +Clear previous secret from the kill ring. Pointer to the kill +ring is stored in `password-store-kill-ring-pointer'. Secret +field is cleared after +`password-store-time-before-clipboard-restore' seconds. If FIELD +equals to symbol secret, then this function reduces to +`password-store-copy'." (interactive (let ((entry (password-store--completing-read))) (list entry (password-store-read-field entry)))) @@ -344,8 +359,8 @@ Default PASSWORD-LENGTH is `password-store-password-length'." (interactive (list (password-store--completing-read) (and current-prefix-arg (abs (prefix-numeric-value current-prefix-arg))))) - ;; A message with the output of the command is not printed because - ;; the output contains the password. + ;; A message with the output of the command is not printed + ;; because the output contains the password. (password-store--run-generate entry (or password-length password-store-password-length) @@ -361,8 +376,8 @@ Default PASSWORD-LENGTH is `password-store-password-length'." (and current-prefix-arg (abs (prefix-numeric-value current-prefix-arg))))) - ;; A message with the output of the command is not printed because - ;; the output contains the password. + ;; A message with the output of the command is not printed + ;; because the output contains the password. (password-store--run-generate entry (or password-length password-store-password-length) @@ -371,7 +386,7 @@ Default PASSWORD-LENGTH is `password-store-password-length'." ;;;###autoload (defun password-store-remove (entry) - "Remove existing password for ENTRY." + "Remove ENTRY." (interactive (list (password-store--completing-read t))) (message "%s" (password-store--run-remove entry t))) @@ -384,13 +399,13 @@ Default PASSWORD-LENGTH is `password-store-password-length'." ;;;###autoload (defun password-store-version () - "Show version of pass executable." + "Show version of `password-store-executable'." (interactive) (message "%s" (password-store--run-version))) ;;;###autoload (defun password-store-url (entry) - "Browse URL stored in ENTRY." + "Load URL for ENTRY." (interactive (list (password-store--completing-read t))) (let ((url (password-store-get-field entry password-store-url-field))) (if url (browse-url url) -- 2.30.2 From mail at ralphptorr.es Sun Nov 26 08:26:29 2023 From: mail at ralphptorr.es (Ralph Torres) Date: Sun, 26 Nov 2023 08:26:29 +0000 Subject: [PATCH 1/2] tests: unset POSIXLY_CORRECT Message-ID: <20231126082737.447451-1-mail@ralphptorr.es> The tests understandably fail when the env var POSIXLY_CORRECT is set. Fix the failing tests by preemptively unsetting the said variable. --- tests/setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/setup.sh b/tests/setup.sh index 058ce0ab3b5d..516f5a41f159 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -21,6 +21,7 @@ unset PASSWORD_STORE_CHARACTER_SET_NO_SYMBOLS unset PASSWORD_STORE_ENABLE_EXTENSIONS unset PASSWORD_STORE_EXTENSIONS_DIR unset PASSWORD_STORE_SIGNING_KEY +unset POSIXLY_CORRECT unset EDITOR # We must be called from tests/ -- 2.43.0 From mail at ralphptorr.es Sun Nov 26 08:26:31 2023 From: mail at ralphptorr.es (Ralph Torres) Date: Sun, 26 Nov 2023 08:26:31 +0000 Subject: [PATCH 2/2] tests: use --file option for git config In-Reply-To: <20231126082737.447451-1-mail@ralphptorr.es> References: <20231126082737.447451-1-mail@ralphptorr.es> Message-ID: <20231126082737.447451-3-mail@ralphptorr.es> Running the tests would hijack the user.name and user.email vars of the global git config file via tests/setup.sh. Prevent that by replacing the --global option with --file ensuring that tests utilize a local file instead of the global config file. --- tests/setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/setup.sh b/tests/setup.sh index 516f5a41f159..fd1170963145 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -39,8 +39,8 @@ fi export GIT_DIR="$PASSWORD_STORE_DIR/.git" export GIT_WORK_TREE="$PASSWORD_STORE_DIR" -git config --global user.email "Pass-Automated-Testing-Suite at zx2c4.com" -git config --global user.name "Pass Automated Testing Suite" +git config --file .gitconfig user.email "Pass-Automated-Testing-Suite at zx2c4.com" +git config --file .gitconfig user.name "Pass Automated Testing Suite" PASS="$TEST_HOME/../src/password-store.sh" -- 2.43.0 From dooleyn at gmail.com Mon Nov 27 14:36:43 2023 From: dooleyn at gmail.com (Niall Dooley) Date: Mon, 27 Nov 2023 15:36:43 +0100 Subject: [PATCH v2] emacs: Minor miscellaneous changes Message-ID: <20231127143643.38233-1-dooleyn@gmail.com> - Update header information. - Correct some docstrings. - Use emacs standard fill-column of 65 for docstrings. - Update URL and add some others. --- contrib/emacs/README.md | 5 +- contrib/emacs/password-store.el | 113 ++++++++++++++++++-------------- 2 files changed, 66 insertions(+), 52 deletions(-) diff --git a/contrib/emacs/README.md b/contrib/emacs/README.md index 8269c35..a3d3207 100644 --- a/contrib/emacs/README.md +++ b/contrib/emacs/README.md @@ -3,12 +3,12 @@ This package provides functions for working with pass ("the standard Unix password manager"). -http://www.zx2c4.com/projects/password-store +https://www.passwordstore.org/ ## Setup The pass application must be installed and set up. See the pass -website for instructions +website for instructions. ## Example usage @@ -38,7 +38,6 @@ Interactive: Copied username for foo-account to the kill ring. Will clear in 45 seconds. Field url cleared. - Lisp: (password-store-insert "foo-account" "password") diff --git a/contrib/emacs/password-store.el b/contrib/emacs/password-store.el index 280aee5..8965683 100644 --- a/contrib/emacs/password-store.el +++ b/contrib/emacs/password-store.el @@ -4,32 +4,34 @@ ;; Author: Svend Sorensen ;; Maintainer: Tino Calancha -;; Version: 2.3.1 +;; Version: 2.3.2 ;; URL: https://www.passwordstore.org/ -;; Package-Requires: ((emacs "26") (with-editor "2.5.11")) -;; Keywords: tools pass password password-store +;; Package-Requires: ((emacs "26.1") (with-editor "2.5.11")) +;; SPDX-License-Identifier: GPL-3.0-or-later +;; Keywords: tools pass password password-store gpg ;; This file is not part of GNU Emacs. -;; This program is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. +;; This program is free software: you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation, either version 3 of +;; the License, or (at your option) any later version. -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. +;; This program is distributed in the hope that it will be +;; useful, but WITHOUT ANY WARRANTY; without even the implied +;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +;; PURPOSE. See the GNU General Public License for more details. -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . +;; You should have received a copy of the GNU General Public +;; License along with this program. If not, see +;; . ;;; Commentary: -;; This package provides functions for working with pass ("the -;; standard Unix password manager"). -;; -;; http://www.passwordstore.org/ +;; This package provides and Emacs interface for working with +;; pass ("the standard Unix password manager"). + +;; https://www.passwordstore.org/ ;;; Code: @@ -37,9 +39,17 @@ (require 'auth-source-pass) (defgroup password-store '() - "Emacs mode for password-store." + "Emacs mode for password-store. +The standard Unix password manager" :prefix "password-store-" - :group 'password-store) + :group 'password-store + :link '(url-link :tag "Description" "https://www.passwordstore.org/") + :link '(url-link :tag "Download" "https://melpa.org/#/password-store") + :link `(url-link :tag "Send Bug Report" + ,(concat "mailto:" "password-store" "@" "lists.zx2c4" ".com?subject= +password-store.el bug: \ +&body=Describe bug here, starting with `emacs -q'. \ +Don't forget to mention your Emacs and library versions."))) (defcustom password-store-password-length 25 "Default password length." @@ -55,7 +65,7 @@ :type 'number) (defcustom password-store-url-field "url" - "Field name used in the files to indicate an url." + "Field name used in the files to indicate a URL." :group 'password-store :type 'string) @@ -67,17 +77,18 @@ "Timer for clearing clipboard.") (defun password-store-timeout () - "Number of seconds to wait before clearing the password. + "Number of seconds to wait before restoring the clipboard. -This function just returns `password-store-time-before-clipboard-restore'. -Kept for backward compatibility with other libraries." - password-store-time-before-clipboard-restore) +This function just returns +`password-store-time-before-clipboard-restore'. Kept for +backward compatibility with other libraries." +password-store-time-before-clipboard-restore) (defun password-store--run-1 (callback &rest args) "Run pass with ARGS. -Nil arguments are ignored. Calls CALLBACK with the output on success, -or outputs error message on failure." +Nil arguments are ignored. Calls CALLBACK with the output on +success, or outputs error message on failure." (let ((output "")) (make-process :name "password-store-gpg" @@ -230,8 +241,8 @@ ENTRY is the name of a password-store entry." (defun password-store-get (entry &optional callback) "Return password for ENTRY. -Returns the first line of the password data. -When CALLBACK is non-`NIL', call CALLBACK with the first line instead." +Returns the first line of the password data. When CALLBACK is +non-`NIL', call CALLBACK with the first line instead." (let* ((inhibit-message t) (secret (auth-source-pass-get 'secret entry))) (if (not callback) secret @@ -242,9 +253,10 @@ When CALLBACK is non-`NIL', call CALLBACK with the first line instead." ;;;###autoload (defun password-store-get-field (entry field &optional callback) "Return FIELD for ENTRY. -FIELD is a string, for instance \"url\". -When CALLBACK is non-`NIL', call it with the line associated to FIELD instead. -If FIELD equals to symbol secret, then this function reduces to `password-store-get'." +FIELD is a string, for instance \"url\". When CALLBACK is +non-`NIL', call it with the line associated to FIELD instead. If +FIELD equals to symbol secret, then this function reduces to +`password-store-get'." (let* ((inhibit-message t) (secret (auth-source-pass-get field entry))) (if (not callback) secret @@ -257,10 +269,10 @@ If FIELD equals to symbol secret, then this function reduces to `password-store- (defun password-store-clear (&optional field) "Clear secret in the kill ring. -Optional argument FIELD, a symbol or a string, describes -the stored secret to clear; if nil, then set it to 'secret. -Note, FIELD does not affect the function logic; it is only used -to display the message: +Optional argument FIELD, a symbol or a string, describes the +stored secret to clear; if nil, then set it to 'secret. Note, +FIELD does not affect the function logic; it is only used to +display the message: \(message \"Field %s cleared.\" field)." (interactive "i") @@ -287,9 +299,10 @@ to display the message: (defun password-store-copy (entry) "Add password for ENTRY into the kill ring. -Clear previous password from the kill ring. Pointer to the kill ring -is stored in `password-store-kill-ring-pointer'. Password is cleared -after `password-store-time-before-clipboard-restore' seconds." +Clear previous password from the kill ring. Pointer to the kill +ring is stored in `password-store-kill-ring-pointer'. Password +is cleared after `password-store-time-before-clipboard-restore' +seconds." (interactive (list (password-store--completing-read t))) (password-store-get entry @@ -300,10 +313,12 @@ after `password-store-time-before-clipboard-restore' seconds." (defun password-store-copy-field (entry field) "Add FIELD for ENTRY into the kill ring. -Clear previous secret from the kill ring. Pointer to the kill ring is -stored in `password-store-kill-ring-pointer'. Secret field is cleared -after `password-store-timeout' seconds. -If FIELD equals to symbol secret, then this function reduces to `password-store-copy'." +Clear previous secret from the kill ring. Pointer to the kill +ring is stored in `password-store-kill-ring-pointer'. Secret +field is cleared after +`password-store-time-before-clipboard-restore' seconds. If FIELD +equals to symbol secret, then this function reduces to +`password-store-copy'." (interactive (let ((entry (password-store--completing-read))) (list entry (password-store-read-field entry)))) @@ -344,8 +359,8 @@ Default PASSWORD-LENGTH is `password-store-password-length'." (interactive (list (password-store--completing-read) (and current-prefix-arg (abs (prefix-numeric-value current-prefix-arg))))) - ;; A message with the output of the command is not printed because - ;; the output contains the password. + ;; A message with the output of the command is not printed + ;; because the output contains the password. (password-store--run-generate entry (or password-length password-store-password-length) @@ -361,8 +376,8 @@ Default PASSWORD-LENGTH is `password-store-password-length'." (and current-prefix-arg (abs (prefix-numeric-value current-prefix-arg))))) - ;; A message with the output of the command is not printed because - ;; the output contains the password. + ;; A message with the output of the command is not printed + ;; because the output contains the password. (password-store--run-generate entry (or password-length password-store-password-length) @@ -371,7 +386,7 @@ Default PASSWORD-LENGTH is `password-store-password-length'." ;;;###autoload (defun password-store-remove (entry) - "Remove existing password for ENTRY." + "Remove ENTRY." (interactive (list (password-store--completing-read t))) (message "%s" (password-store--run-remove entry t))) @@ -384,13 +399,13 @@ Default PASSWORD-LENGTH is `password-store-password-length'." ;;;###autoload (defun password-store-version () - "Show version of pass executable." + "Show version of `password-store-executable'." (interactive) (message "%s" (password-store--run-version))) ;;;###autoload (defun password-store-url (entry) - "Browse URL stored in ENTRY." + "Load URL for ENTRY." (interactive (list (password-store--completing-read t))) (let ((url (password-store-get-field entry password-store-url-field))) (if url (browse-url url) -- 2.30.2 From dooleyn at gmail.com Mon Nov 27 14:38:14 2023 From: dooleyn at gmail.com (Niall Dooley) Date: Mon, 27 Nov 2023 15:38:14 +0100 Subject: [PATCH] emacs: Group similar expressions together Message-ID: <20231127143814.38520-1-dooleyn@gmail.com> Variables, functions and commands. --- contrib/emacs/password-store.el | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/contrib/emacs/password-store.el b/contrib/emacs/password-store.el index 280aee5..3843f22 100644 --- a/contrib/emacs/password-store.el +++ b/contrib/emacs/password-store.el @@ -63,6 +63,9 @@ (executable-find "pass") "Pass executable.") +(defvar password-store-kill-ring-pointer nil + "The tail of of the kill ring ring whose car is the password.") + (defvar password-store-timeout-timer nil "Timer for clearing clipboard.") @@ -176,9 +179,6 @@ Nil arguments are ignored. Output is discarded." (defun password-store--run-version () (password-store--run "version")) -(defvar password-store-kill-ring-pointer nil - "The tail of of the kill ring ring whose car is the password.") - (defun password-store-dir () "Return password store directory." (or (bound-and-true-p auth-source-pass-filename) @@ -193,6 +193,15 @@ Nil arguments are ignored. Output is discarded." "Return entry name corresponding to FILE." (file-name-sans-extension (file-relative-name file (password-store-dir)))) +(defun password-store-list (&optional subdir) + "List password entries under SUBDIR." + (unless subdir (setq subdir "")) + (let ((dir (expand-file-name subdir (password-store-dir)))) + (if (file-directory-p dir) + (delete-dups + (mapcar 'password-store--file-to-entry + (directory-files-recursively dir ".+\\.gpg\\'")))))) + (defun password-store--completing-read (&optional require-match) "Read a password entry in the minibuffer, with completion. @@ -211,21 +220,6 @@ ENTRY is the name of a password-store entry." (valid-fields (mapcar #'car (password-store-parse-entry entry)))) (completing-read "Field: " valid-fields nil 'match))) -(defun password-store-list (&optional subdir) - "List password entries under SUBDIR." - (unless subdir (setq subdir "")) - (let ((dir (expand-file-name subdir (password-store-dir)))) - (if (file-directory-p dir) - (delete-dups - (mapcar 'password-store--file-to-entry - (directory-files-recursively dir ".+\\.gpg\\'")))))) - -;;;###autoload -(defun password-store-edit (entry) - "Edit password for ENTRY." - (interactive (list (password-store--completing-read t))) - (password-store--run-edit entry)) - ;;;###autoload (defun password-store-get (entry &optional callback) "Return password for ENTRY. @@ -336,6 +330,12 @@ Separate multiple IDs with spaces." (message "Cannot insert entry for %s" entry)) nil)) +;;;###autoload +(defun password-store-edit (entry) + "Edit password for ENTRY." + (interactive (list (password-store--completing-read t))) + (password-store--run-edit entry)) + ;;;###autoload (defun password-store-generate (entry &optional password-length) "Generate a new password for ENTRY with PASSWORD-LENGTH. -- 2.30.2 From dooleyn at gmail.com Mon Nov 27 14:45:17 2023 From: dooleyn at gmail.com (Niall Dooley) Date: Mon, 27 Nov 2023 15:45:17 +0100 Subject: [PATCH emacs] Minor miscellaneous changes In-Reply-To: <20231122174052.60177-1-dooleyn@gmail.com> References: <20231122174052.60177-1-dooleyn@gmail.com> Message-ID: I've sent a v2 of this patch that places "emacs" outside the subject line [PATCH] prefix and resets the author to use my real name. From dooleyn at gmail.com Mon Nov 27 17:52:59 2023 From: dooleyn at gmail.com (Niall Dooley) Date: Mon, 27 Nov 2023 18:52:59 +0100 Subject: [PATCH] emacs: Update defvar Message-ID: <20231127175259.1870-1-dooleyn@gmail.com> This will check for the pass executable and if not found advise the user what they need to do. --- contrib/emacs/password-store.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/emacs/password-store.el b/contrib/emacs/password-store.el index 280aee5..a5c7029 100644 --- a/contrib/emacs/password-store.el +++ b/contrib/emacs/password-store.el @@ -60,7 +60,8 @@ :type 'string) (defvar password-store-executable - (executable-find "pass") + (or (executable-find "pass") + "Depending on your system install pass or password-store") "Pass executable.") (defvar password-store-timeout-timer nil -- 2.30.2 From dooleyn at gmail.com Mon Nov 27 17:54:44 2023 From: dooleyn at gmail.com (Niall Dooley) Date: Mon, 27 Nov 2023 18:54:44 +0100 Subject: [PATCH] emacs: Indicate function is obsolete Message-ID: <20231127175444.2553-1-dooleyn@gmail.com> I believe it was v2.0.4 of password-store.el when this function was first considered obsolete. --- contrib/emacs/password-store.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/emacs/password-store.el b/contrib/emacs/password-store.el index 280aee5..1b01492 100644 --- a/contrib/emacs/password-store.el +++ b/contrib/emacs/password-store.el @@ -73,6 +73,8 @@ This function just returns `password-store-time-before-clipboard-restore'. Kept for backward compatibility with other libraries." password-store-time-before-clipboard-restore) +(make-obsolete 'password-store-timeout 'password-store-time-before-clipboard-restore "2.0.4") + (defun password-store--run-1 (callback &rest args) "Run pass with ARGS. -- 2.30.2 From dooleyn at gmail.com Mon Nov 27 17:55:29 2023 From: dooleyn at gmail.com (Niall Dooley) Date: Mon, 27 Nov 2023 18:55:29 +0100 Subject: [PATCH] emacs: Change argument name Message-ID: <20231127175529.2711-1-dooleyn@gmail.com> The argument value could be a subdirectory. Pass itself uses subfolder. Used subdir as that is used as an argument name in other functions. --- contrib/emacs/password-store.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/emacs/password-store.el b/contrib/emacs/password-store.el index 280aee5..1005c74 100644 --- a/contrib/emacs/password-store.el +++ b/contrib/emacs/password-store.el @@ -118,9 +118,9 @@ Nil arguments are ignored. Output is discarded." (cons password-store-executable (delq nil args)) " ")))) -(defun password-store--run-init (gpg-ids &optional folder) +(defun password-store--run-init (gpg-ids &optional subdir) (apply 'password-store--run "init" - (if folder (format "--path=%s" folder)) + (if subdir (format "--path=%s" subdir)) gpg-ids)) (defun password-store--run-list (&optional subdir) -- 2.30.2 From dooleyn at gmail.com Mon Nov 27 17:57:17 2023 From: dooleyn at gmail.com (Niall Dooley) Date: Mon, 27 Nov 2023 18:57:17 +0100 Subject: [PATCH] emacs: Fix bug in clipboard management Message-ID: <20231127175717.2984-1-dooleyn@gmail.com> Prior to this the password/secret was cleared from the kill ring but remained in the system clipboard after the timeout expired. This ensures the system clipboard is cleared as well. --- contrib/emacs/password-store.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contrib/emacs/password-store.el b/contrib/emacs/password-store.el index 280aee5..c28bc7d 100644 --- a/contrib/emacs/password-store.el +++ b/contrib/emacs/password-store.el @@ -262,7 +262,7 @@ the stored secret to clear; if nil, then set it to 'secret. Note, FIELD does not affect the function logic; it is only used to display the message: -\(message \"Field %s cleared.\" field)." +\(message \"Field %s cleared from kill ring and system clipboard.\" field)." (interactive "i") (unless field (setq field 'secret)) (when password-store-timeout-timer @@ -270,14 +270,15 @@ to display the message: (setq password-store-timeout-timer nil)) (when password-store-kill-ring-pointer (setcar password-store-kill-ring-pointer "") + (kill-new "") (setq password-store-kill-ring-pointer nil) - (message "Field %s cleared." field))) + (message "Field %s cleared from kill ring and system clipboard." field))) (defun password-store--save-field-in-kill-ring (entry secret field) (password-store-clear field) (kill-new secret) (setq password-store-kill-ring-pointer kill-ring-yank-pointer) - (message "Copied %s for %s to the kill ring. Will clear in %s seconds." + (message "Copied %s for %s to the kill ring and system clipboard. Will clear in %s seconds." field entry password-store-time-before-clipboard-restore) (setq password-store-timeout-timer (run-at-time password-store-time-before-clipboard-restore nil -- 2.30.2