From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: doc-view cache file permissions Date: Tue, 30 Oct 2007 17:56:49 -0400 Message-ID: References: <7gk5p448xq.fsf@fencepost.gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1193782009 22489 80.91.229.12 (30 Oct 2007 22:06:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2007 22:06:49 +0000 (UTC) Cc: Tassilo Horn , emacs-devel@gnu.org To: Glenn Morris Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 30 23:06:51 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1ImzEV-0000wW-Li for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2007 23:06:47 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ImzEM-0008CO-7c for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2007 18:06:38 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ImzEI-0008AM-Lx for emacs-devel@gnu.org; Tue, 30 Oct 2007 18:06:34 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ImzEF-00085l-0h for emacs-devel@gnu.org; Tue, 30 Oct 2007 18:06:34 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ImzEE-00085d-SY for emacs-devel@gnu.org; Tue, 30 Oct 2007 18:06:30 -0400 Original-Received: from x-132-204-242-121.xtpr.umontreal.ca ([132.204.242.121] helo=ceviche.home) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Imz4y-0006uJ-UN; Tue, 30 Oct 2007 17:56:57 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 4C18CB4ABE; Tue, 30 Oct 2007 17:56:48 -0400 (EDT) In-Reply-To: <7gk5p448xq.fsf@fencepost.gnu.org> (Glenn Morris's message of "Tue, 30 Oct 2007 16:57:37 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:82168 Archived-At: >> + ;; Try and make sure doc-view-cache-directory exists and is safe. >> + (condition-case nil >> + (make-directory doc-view-cache-directory) >> + (file-already-exists >> + (cond >> + ((file-symlink-p doc-view-cache-directory) >> + (error "Danger: doc-view-cache-directory points to a symbolic link")) >> + ((not (file-directory-p doc-view-cache-directory)) >> + (error "doc-view-cache-directory is not a directory")) >> + ((not (file-writable-p doc-view-cache-directory)) >> + (error "Cannot write to doc-view-cache-directory")) >> + ((not (= (user-uid) (nth 2 (file-attributes doc-view-cache-directory)))) >> + (error "Danger: doc-view-cache-directory does not belong to us"))))) > Is that worthy of being the basis of a more generally available > `make-secure-directory' function? Could be. Although I might want to call it "make directory-secure" since the point is to be able to use a "known" directory which may already exist. Note that the code I just installed is simpler (and safer). Also I'm not 100% that the code is actually safe. I'm pretty sure it's safer. Otherwise, if you really want a brand new directory, you can use make-temp-file. Stefan