emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 0e4cc6a8bfb: Extend secrets.el by lock/unlock item


From: Michael Albinus
Subject: master 0e4cc6a8bfb: Extend secrets.el by lock/unlock item
Date: Mon, 8 May 2023 07:33:54 -0400 (EDT)

branch: master
commit 0e4cc6a8bfb8e1dfcfc13d4bf150fa712664ebbb
Author: Philipp Uhl <git@ph-uhl.com>
Commit: Michael Albinus <michael.albinus@gmx.de>

    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)
---
 lisp/net/secrets.el | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

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."
                    item (secrets-get-item-property item-path "Label"))
                 (throw 'item-found item-path)))))))
 
+(defun secrets-lock-item (collection item)
+  "Lock collection item labeled ITEM in COLLECTION.
+If successful, return the object path of the item.  Does not lock
+the collection."
+  (let ((item-path (secrets-item-path collection item)))
+    (unless (secrets-empty-path item-path)
+      (secrets-prompt
+       (cadr
+        (dbus-call-method
+         :session secrets-service secrets-path secrets-interface-service
+         "Lock" `(:array :object-path ,item-path)))))
+    item-path))
+
+(defun secrets-unlock-item (collection item)
+  "Unlock item labeled ITEM from collection labeled COLLECTION.
+If successful, return the object path of the item."
+  (let ((item-path (secrets-item-path collection item)))
+    (unless (secrets-empty-path item-path)
+      (secrets-prompt
+       (cadr
+        (dbus-call-method
+         :session secrets-service secrets-path secrets-interface-service
+         "Unlock" `(:array :object-path ,item-path)))))
+    item-path))
+
 (defun secrets-get-secret (collection item)
   "Return the secret of item labeled ITEM in COLLECTION.
 If there are several items labeled ITEM, it is undefined which
 one is returned.  If there is no such item, return nil.
 
 ITEM can also be an object path, which is used if contained in COLLECTION."
-  (let ((item-path (secrets-item-path collection item)))
+  (let ((item-path (secrets-unlock-item collection item)))
     (unless (secrets-empty-path item-path)
       (dbus-byte-array-to-string
        (nth 2



reply via email to

[Prev in Thread] Current Thread [Next in Thread]