From dd1a740350b97bd9b3123403f26b7549d686b389 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Wed, 2 Mar 2022 20:03:01 +0100 Subject: [PATCH] Fix inherited transients in actions, quote passwords by default --- bitwarden.el | 47 +++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/bitwarden.el b/bitwarden.el index 44b6d29..7870501 100644 --- a/bitwarden.el +++ b/bitwarden.el @@ -244,18 +244,19 @@ By order of preference, retrieve the password from the user if designated by the variable `bitwarden--login-passwordenv', by the file designated by the variable `bitwarden--login-passwordfile', or from the authinfo source." - (cond - (bitwarden--login-password - (read-passwd "Bitwarden Password: ")) - ((not (bitwarden--empty-or-nil bitwarden--login-passwordenv)) - `("--passwordenv" ,bitwarden--login-passwordenv)) - ((not (bitwarden--empty-or-nil bitwarden--login-passwordfile)) - `("--passwordfile" ,bitwarden--login-passwordfile)) - (t (funcall - (plist-get - (car (auth-source-search :max 1 - :host bitwarden--config-server)) - :secret))))) + (bitwarden--quote-string + (cond + (bitwarden--login-password + (read-passwd "Bitwarden Password: ")) + ((not (bitwarden--empty-or-nil bitwarden--login-passwordenv)) + `("--passwordenv" ,bitwarden--login-passwordenv)) + ((not (bitwarden--empty-or-nil bitwarden--login-passwordfile)) + `("--passwordfile" ,bitwarden--login-passwordfile)) + (t (funcall + (plist-get + (car (auth-source-search :max 1 + :host bitwarden--config-server)) + :secret)))))) ;;; Transient Actions @@ -276,13 +277,13 @@ This function is meant to be called by a transient.") (bitwarden--def-action "set-server" "Set the Bitwarden server." - 'bitwarden--login-server + 'bitwarden-config (bitwarden--run-cli "config" "server" bitwarden--config-server)) (bitwarden--def-action "get-server" "Get the URL of the on-premises hosted installation." - 'bitwarden--config-server + 'bitwarden-config (bitwarden--run-cli "config" "server")) ;; Login @@ -290,27 +291,17 @@ This function is meant to be called by a transient.") (bitwarden--def-action "login" "Log in Bitwarden." - 'bitwarden--login + 'bitwarden-login (if bitwarden--login-sso (bitwarden--run-cli "login" "--raw" "--sso") (bitwarden--run-cli "login" "--raw" - (format "\"%s\"" (bitwarden--get-username)) - (cond - ((not (bitwarden--empty-or-nil bitwarden--login-password)) - (bitwarden--quote-string bitwarden--login-password)) - ((not (bitwarden--empty-or-nil bitwarden--login-passwordenv)) - `("--passwordenv" ,(bitwarden--quote-string bitwarden--login-passwordenv))) - ((not (bitwarden--empty-or-nil bitwarden--login-passwordfile)) - `("--paswordfile" ,(bitwarden--quote-string bitwarden--login-passwordfile))) - (t - (funcall (plist-get (car (auth-source-search :max 1 - :host bitwarden--config-server)) - :secret))))))) + (format "'%s'" (bitwarden--get-username)) + (bitwarden--get-password)))) (bitwarden--def-action "logout" "Log out of Bitwarden." - 'bitwarden--login + 'bitwarden-login (shell-command (concat bitwarden-cli-executable " logout"))))