Add some error-handling when adding SSH keyfiles
This commit is contained in:
parent
45c3b61476
commit
1ec3dd24e6
|
@ -840,13 +840,18 @@ This is `db-light' and `solarized-light'."
|
||||||
"Synchronously add key in KEY-FILE to currently running ssh-agent.
|
"Synchronously add key in KEY-FILE to currently running ssh-agent.
|
||||||
|
|
||||||
PASSWORD-FN is supposed to be a function returning the password
|
PASSWORD-FN is supposed to be a function returning the password
|
||||||
for KEY-FILE; PASSWORD-FN is called on demand.
|
for KEY-FILE; PASSWORD-FN is called on demand. If KEY-FILE is
|
||||||
|
not readable, this function errors out.
|
||||||
|
|
||||||
This function uses ssh-add to add the key to the currently
|
This function uses ssh-add to add the key to the currently
|
||||||
running ssh-agent and waits for the process to finish."
|
running ssh-agent and waits for the process to finish."
|
||||||
|
(let ((key-file (expand-file-name key-file)))
|
||||||
|
|
||||||
|
(unless (file-readable-p key-file)
|
||||||
|
(user-error "SSH key %s does not exist, aborting" key-file))
|
||||||
|
|
||||||
(with-environment-variables (("SSH_ASKPASS_REQUIRE" "never"))
|
(with-environment-variables (("SSH_ASKPASS_REQUIRE" "never"))
|
||||||
(let* ((key-file (expand-file-name key-file))
|
(let ((proc (make-process :name "ssh-add"
|
||||||
(proc (make-process :name "ssh-add"
|
|
||||||
:buffer nil
|
:buffer nil
|
||||||
:command (list "ssh-add" key-file)
|
:command (list "ssh-add" key-file)
|
||||||
:filter #'(lambda (process output)
|
:filter #'(lambda (process output)
|
||||||
|
@ -875,7 +880,7 @@ running ssh-agent and waits for the process to finish."
|
||||||
;; intermingle with others. XXX: is there a more standard way to wait for
|
;; intermingle with others. XXX: is there a more standard way to wait for
|
||||||
;; a process to finish?
|
;; a process to finish?
|
||||||
(while (process-live-p proc)
|
(while (process-live-p proc)
|
||||||
(sit-for 0.2)))))
|
(sit-for 0.2))))))
|
||||||
|
|
||||||
(defun db/ssh-key-hash-from-filename (key-file)
|
(defun db/ssh-key-hash-from-filename (key-file)
|
||||||
"Return the SHA256 hash value of the SSH key located in KEY-FILE.
|
"Return the SHA256 hash value of the SSH key located in KEY-FILE.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user