From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ben Key Newsgroups: gmane.emacs.devel Subject: Re: Modifying Emacs to use the Mac OS X Keychain Services Date: Tue, 14 Jun 2011 21:15:18 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1308104167 8773 80.91.229.12 (15 Jun 2011 02:16:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 15 Jun 2011 02:16:07 +0000 (UTC) Cc: Ted Zlatanov , Emacs Development To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 15 04:16:01 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QWfeA-0006G6-AG for ged-emacs-devel@m.gmane.org; Wed, 15 Jun 2011 04:15:58 +0200 Original-Received: from localhost ([::1]:56074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWfe9-0007n9-Bo for ged-emacs-devel@m.gmane.org; Tue, 14 Jun 2011 22:15:57 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:46593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWfdt-0007n4-7h for Emacs-devel@gnu.org; Tue, 14 Jun 2011 22:15:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QWfds-00006d-8N for Emacs-devel@gnu.org; Tue, 14 Jun 2011 22:15:41 -0400 Original-Received: from mail-bw0-f41.google.com ([209.85.214.41]:49588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWfds-00006Z-0v for Emacs-devel@gnu.org; Tue, 14 Jun 2011 22:15:40 -0400 Original-Received: by bwz17 with SMTP id 17so134200bwz.0 for ; Tue, 14 Jun 2011 19:15:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=JYqH/iOJbdqo5N+2jAom9EWh7Mm5C20Wq9yYID3/5yU=; b=SKeZBiVw2vmGviBEi8pzc8gz5kJ8dPxX5dc4wMeKgriSZig4FwtVKlnI70SXo06lhX uJfZNaNbJpbqEqKyhvtPqGAKO2S+DFgQlyAZrmYt3CFc4q6+br6SJnBpF7ZucJOJuZ1j +STye+5bSlhfkCnqaBv0bPPzZtlMt7+cj6AoI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=gYRoFKl94dOP15DD8PAKkzUZX71oS3f4woh8NPoUT5dhjxjRbOZ1vdIZBl/M7hkTI5 dNY9ohxIltVOob/CcUFZOexdqZnGtGq5iSPuyaxrYE+t3QwpbFDWFTvxjp0v1X7+5Py3 QWWkYIvL6RXTB/52SlaNB/UvZBZsMdxcX/NXw= Original-Received: by 10.204.171.65 with SMTP id g1mr5722963bkz.45.1308104138307; Tue, 14 Jun 2011 19:15:38 -0700 (PDT) Original-Received: by 10.204.59.212 with HTTP; Tue, 14 Jun 2011 19:15:18 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.214.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:140475 Archived-At: Stefan Monnier wrote: > No, a simple type cast won't do. =A0If the Lisp_Object is fully under you= r > control (so you always know you're the one who built it and never need > to check what kind of Lisp_Object it is), you can use > a Lisp_Misc_Save_value. =A0"grep -i save_value src/*.[ch]" should get > you started. > The Lisp_Object is not always under my control. The idea is to provide three functions to open a Mac OS X keychain file. The functions are ns-keychain-open to open a keychain file, ns-keychain-create to create a keychain file, and ns-keychain-create-or-open to open a keychain file if it exists or create it if it does not exist. All three of these functions, which will be callable from Lisp, need to return a SecKeychainRef object. The SecKeychainRef object is just a pointer to a structure, allocated by the operating system. Additional functions such as ns-keychain-add-generic-password and ns-keychain-get-generic-password will expect to be called with the keychain parameter set to the value returned by an earlier call to ns-keychain-open, ns-keychain-create, or ns-keychain-create-or-open. Once the calling package is finished with the keychain object it will be expected to call ns-keychain-close to release the keychain reference. Since the SecKeychainRef object will need to pass the boundary between internal Emacs code and Lisp code it cannot be considered to be always under my control. As a result I am not certain that a Lisp_Misc_Save_value is appropriate for my purpose. I am not certain that pseudovectors are appropriate either. It seems that we use pseudovectors to represent structures that are allocated by Emacs but the SecKeychainRef object is allocated by the OS. The problem is that I am not certain how to return a SecKeychainRef object from ns-keychain-open, ns-keychain-create, and ns-keychain-create-or-open so that they are callable from Lisp. Any suggestions are welcome.