aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Uhl2023-05-08 13:33:42 +0200
committerMichael Albinus2023-05-08 13:33:42 +0200
commit0e4cc6a8bfb8e1dfcfc13d4bf150fa712664ebbb (patch)
tree08c48b9bb0ceb86ef8818c4558c8727fd41cd97a
parent3adc1e7f37901235bda83ea65a90644b7b0a8dbf (diff)
downloademacs-0e4cc6a8bfb8e1dfcfc13d4bf150fa712664ebbb.tar.gz
emacs-0e4cc6a8bfb8e1dfcfc13d4bf150fa712664ebbb.zip
Extend secrets.el by lock/unlock item
* lisp/net/secrets.el (secrets-lock-item, secrets-unlock-item): New defuns. (secrets-get-secret): Use `secrets-unlock-item'. (Bug#62952)
-rw-r--r--lisp/net/secrets.el27
1 files changed, 26 insertions, 1 deletions
diff --git a/lisp/net/secrets.el b/lisp/net/secrets.el
index f4e68d7b817..08ab942fddb 100644
--- a/lisp/net/secrets.el
+++ b/lisp/net/secrets.el
@@ -687,13 +687,38 @@ ITEM can also be an object path, which is returned if contained in COLLECTION."
687 item (secrets-get-item-property item-path "Label")) 687 item (secrets-get-item-property item-path "Label"))
688 (throw 'item-found item-path))))))) 688 (throw 'item-found item-path)))))))
689 689
690(defun secrets-lock-item (collection item)
691 "Lock collection item labeled ITEM in COLLECTION.
692If successful, return the object path of the item. Does not lock
693the collection."
694 (let ((item-path (secrets-item-path collection item)))
695 (unless (secrets-empty-path item-path)
696 (secrets-prompt
697 (cadr
698 (dbus-call-method
699 :session secrets-service secrets-path secrets-interface-service
700 "Lock" `(:array :object-path ,item-path)))))
701 item-path))
702
703(defun secrets-unlock-item (collection item)
704 "Unlock item labeled ITEM from collection labeled COLLECTION.
705If successful, return the object path of the item."
706 (let ((item-path (secrets-item-path collection item)))
707 (unless (secrets-empty-path item-path)
708 (secrets-prompt
709 (cadr
710 (dbus-call-method
711 :session secrets-service secrets-path secrets-interface-service
712 "Unlock" `(:array :object-path ,item-path)))))
713 item-path))
714
690(defun secrets-get-secret (collection item) 715(defun secrets-get-secret (collection item)
691 "Return the secret of item labeled ITEM in COLLECTION. 716 "Return the secret of item labeled ITEM in COLLECTION.
692If there are several items labeled ITEM, it is undefined which 717If there are several items labeled ITEM, it is undefined which
693one is returned. If there is no such item, return nil. 718one is returned. If there is no such item, return nil.
694 719
695ITEM can also be an object path, which is used if contained in COLLECTION." 720ITEM can also be an object path, which is used if contained in COLLECTION."
696 (let ((item-path (secrets-item-path collection item))) 721 (let ((item-path (secrets-unlock-item collection item)))
697 (unless (secrets-empty-path item-path) 722 (unless (secrets-empty-path item-path)
698 (dbus-byte-array-to-string 723 (dbus-byte-array-to-string
699 (nth 2 724 (nth 2