unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Nicolas Petton <petton.nicolas@gmail.com>
To: 15520@debbugs.gnu.org
Subject: bug#15520: 24.3; secrets.el secrets-create-item has wrong dbus arguments (fix included)
Date: Wed, 02 Oct 2013 19:20:06 +0200	[thread overview]
Message-ID: <1380734406.9521.13.camel@lingonberry> (raw)


In secrets.el, secrets-create-item has the wrong label property for the
created item, and the secret struct is not built correctly.

Here's a new version that fixes the issue.


(defun secrets-create-item (collection item password &rest attributes)
  "Create a new item in COLLECTION with label ITEM and password
PASSWORD.
ATTRIBUTES are key-value pairs set for the created item.  The
keys are keyword symbols, starting with a colon.  Example:

  \(secrets-create-item \"Tramp collection\" \"item\" \"geheim\"
   :method \"sudo\" :user \"joe\" :host \"remote-host\"\)

The object path of the created item is returned."
  (unless (member item (secrets-list-items collection))
    (let ((collection-path (secrets-unlock-collection collection))
	  result props)
      (unless (secrets-empty-path collection-path)
	;; Create attributes list.
	(while (consp (cdr attributes))
	  (unless (keywordp (car attributes))
	    (error 'wrong-type-argument (car attributes)))
	  (setq props (add-to-list
		       'props
		       (list :dict-entry
			     (substring (symbol-name (car attributes)) 1)
			     (cadr attributes))
		       'append)
		attributes (cddr attributes)))
	;; Create the item.
	(setq result
	      (dbus-call-method
	       :session secrets-service collection-path
	       secrets-interface-collection "CreateItem"
	       ;; Properties.
	       (append
		`(:array
		  (:dict-entry "org.freedesktop.Secret.Item.Label" (:variant ,item)))
		(when props
		  `((:dict-entry
		     "org.freedesktop.Secret.Item.Attributes" (:variant ,(append
'(:array) props))))))
	       ;; Secret.
	       `(:struct :object-path ,secrets-session-path
			 ,(dbus-string-to-byte-array "")
			 ,(dbus-string-to-byte-array password)
			 "text/plain")
	       ;; Do not replace. Replace does not seem to work.
	       nil))
	(secrets-prompt (cadr result))
	;; Return the object path.
	(car result)))))






             reply	other threads:[~2013-10-02 17:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-02 17:20 Nicolas Petton [this message]
2013-10-04 10:26 ` bug#15520: 24.3; secrets.el secrets-create-item has wrong dbus arguments (fix included) Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1380734406.9521.13.camel@lingonberry \
    --to=petton.nicolas@gmail.com \
    --cc=15520@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).