Add use of sequence number switch
When dealing with an unknown label, creating a new label or adding a label to the label file, ask for a sequence number and pass it to DisPass. Only the `dispass2' algorithm uses this, but the `dispass1' algorithm ignores it, so it shouldn't be a problem to just always send it. Eventually the capabilities of each algorithm should be gathered from DisPass itself.
This commit is contained in:
parent
fb3a9ab978
commit
eaad8736a1
1 changed files with 22 additions and 14 deletions
36
dispass.el
36
dispass.el
|
@ -111,7 +111,8 @@ an eye out for LABEL."
|
||||||
(clipboard-kill-ring-save (point-min) (point-max))
|
(clipboard-kill-ring-save (point-min) (point-max))
|
||||||
(message "Password copied to clipboard.")))))))
|
(message "Password copied to clipboard.")))))))
|
||||||
|
|
||||||
(defun dispass-start-process (label create length &optional algo args)
|
(defun dispass-start-process (label create length
|
||||||
|
&optional algo seqno args)
|
||||||
"Start dispass process. When CREATE is non-nil send along the
|
"Start dispass process. When CREATE is non-nil send along the
|
||||||
-c switch to make it ask for a password twice. When LENGTH is
|
-c switch to make it ask for a password twice. When LENGTH is
|
||||||
an integer and greater than 0, send along the -l switch with
|
an integer and greater than 0, send along the -l switch with
|
||||||
|
@ -128,6 +129,9 @@ an eye out for LABEL."
|
||||||
(member algo dispass-algorithms))
|
(member algo dispass-algorithms))
|
||||||
(setq args (append `("-a" ,algo) args)))
|
(setq args (append `("-a" ,algo) args)))
|
||||||
|
|
||||||
|
(when (and seqno (> seqno 0))
|
||||||
|
(setq args (append `("-n" ,(number-to-string seqno)) args)))
|
||||||
|
(prin1 args)
|
||||||
(setq proc (apply 'start-process "dispass" "*dispass*"
|
(setq proc (apply 'start-process "dispass" "*dispass*"
|
||||||
dispass-executable args))
|
dispass-executable args))
|
||||||
(set-process-sentinel proc 'dispass-process-sentinel)
|
(set-process-sentinel proc 'dispass-process-sentinel)
|
||||||
|
@ -175,34 +179,37 @@ an eye out for LABEL."
|
||||||
(goto-char (point-min)))
|
(goto-char (point-min)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun dispass-create (label &optional length algo)
|
(defun dispass-create (label &optional length algo seqno)
|
||||||
"Create a new password for LABEL."
|
"Create a new password for LABEL."
|
||||||
(interactive (list
|
(interactive (list
|
||||||
(read-from-minibuffer "Label: ")
|
(read-from-minibuffer "Label: ")
|
||||||
current-prefix-arg
|
current-prefix-arg
|
||||||
(completing-read "Algorithm: " dispass-algorithms)))
|
(completing-read "Algorithm: " dispass-algorithms)
|
||||||
|
(read-from-minibuffer
|
||||||
|
"Sequence no. (1): " nil nil t nil "1")))
|
||||||
(let ((length (or length dispass-default-length)))
|
(let ((length (or length dispass-default-length)))
|
||||||
(dispass-start-process label t length algo)))
|
(dispass-start-process label t length algo seqno)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun dispass (label &optional length algo)
|
(defun dispass (label &optional length algo seqno)
|
||||||
"Recreate a password previously used."
|
"Recreate a password previously used."
|
||||||
(interactive (list
|
(interactive (list
|
||||||
(completing-read
|
(completing-read
|
||||||
"Label: " (dispass-get-labels))
|
"Label: " (dispass-get-labels))
|
||||||
current-prefix-arg))
|
current-prefix-arg))
|
||||||
(if (called-interactively-p 'any)
|
(when (and (called-interactively-p 'any)
|
||||||
(unless (member label (dispass-get-labels))
|
(not (member label (dispass-get-labels))))
|
||||||
(setq algo (completing-read
|
(setq algo (completing-read "Algorithm: " dispass-algorithms))
|
||||||
"Algorithm: " dispass-algorithms))))
|
(setq seqno (read-from-minibuffer
|
||||||
|
"Sequence no. (1): " nil nil t nil "1")))
|
||||||
(let ((length (or length dispass-default-length)))
|
(let ((length (or length dispass-default-length)))
|
||||||
(dispass-start-process
|
(dispass-start-process
|
||||||
label nil length algo
|
label nil length algo seqno
|
||||||
(when (member label (dispass-get-labels)) '("-s")))))
|
(when (member label (dispass-get-labels)) '("-s")))))
|
||||||
|
|
||||||
;; Labels management
|
;; Labels management
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun dispass-add-label (label length algo)
|
(defun dispass-add-label (label length algo &optional seqno)
|
||||||
"Add LABEL with length LENGTH and algorithm ALGO to DisPass."
|
"Add LABEL with length LENGTH and algorithm ALGO to DisPass."
|
||||||
(interactive
|
(interactive
|
||||||
(list (read-from-minibuffer "Label: ")
|
(list (read-from-minibuffer "Label: ")
|
||||||
|
@ -211,10 +218,11 @@ an eye out for LABEL."
|
||||||
(number-to-string dispass-default-length))
|
(number-to-string dispass-default-length))
|
||||||
(completing-read
|
(completing-read
|
||||||
"Algorithm (dispass1): "
|
"Algorithm (dispass1): "
|
||||||
dispass-algorithms nil nil nil nil "dispass1")))
|
dispass-algorithms nil nil nil nil "dispass1")
|
||||||
|
(read-from-minibuffer "Sequnce no. (1): " nil nil t nil "1")))
|
||||||
(shell-command
|
(shell-command
|
||||||
(format "%s --add %s:%d:%s"
|
(format "%s --add %s:%d:%s:%s"
|
||||||
dispass-labels-executable label length algo)))
|
dispass-labels-executable label length algo seqno)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun dispass-remove-label (label)
|
(defun dispass-remove-label (label)
|
||||||
|
|
Loading…
Reference in a new issue