From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r111747: * doc-view.el (doc-view-odf->pdf-converter-soffice): Use separate Date: Wed, 13 Feb 2013 08:07:51 +0100 Message-ID: <8738x04rp4.fsf@thinkpad.tsdh.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1360739306 2204 80.91.229.3 (13 Feb 2013 07:08:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 13 Feb 2013 07:08:26 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org To: Andreas Schwab Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 13 08:08:46 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U5WST-0002BE-EG for ged-emacs-devel@m.gmane.org; Wed, 13 Feb 2013 08:08:45 +0100 Original-Received: from localhost ([::1]:52842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5WS9-0007XN-Vs for ged-emacs-devel@m.gmane.org; Wed, 13 Feb 2013 02:08:25 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:48544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5WRm-0007UA-Ce for emacs-devel@gnu.org; Wed, 13 Feb 2013 02:08:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U5WRe-00041p-FF for emacs-devel@gnu.org; Wed, 13 Feb 2013 02:08:02 -0500 Original-Received: from deliver.uni-koblenz.de ([141.26.64.15]:39959) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5WRe-00041Q-7E for emacs-devel@gnu.org; Wed, 13 Feb 2013 02:07:54 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by deliver.uni-koblenz.de (Postfix) with ESMTP id AF2841A8436; Wed, 13 Feb 2013 08:07:53 +0100 (CET) X-Virus-Scanned: amavisd-new at uni-koblenz.de Original-Received: from deliver.uni-koblenz.de ([127.0.0.1]) by localhost (deliver.uni-koblenz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nI6TTgaa3urf; Wed, 13 Feb 2013 08:07:53 +0100 (CET) X-CHKRCPT: Envelopesender noch tsdh@gnu.org Original-Received: from thinkpad.tsdh.de (tsdh.uni-koblenz.de [141.26.67.142]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTPSA id 483601A8430; Wed, 13 Feb 2013 08:07:53 +0100 (CET) Mail-Followup-To: Andreas Schwab , Stefan Monnier , emacs-devel@gnu.org In-Reply-To: (Andreas Schwab's message of "Wed, 13 Feb 2013 00:43:05 +0100") User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 141.26.64.15 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:156999 Archived-At: Andreas Schwab writes: Hi! >>> + ;; A workaround is to start soffice with a >>> + ;; separate UserInstallation directory. >>> + (concat "-env:UserInstallation=file://" >>> + (expand-file-name (format "libreoffice-docview%d" (user-uid)) >>> + temporary-file-directory)) >> >> I'm pretty sure there's some kind of race condition here that lets an >> attacker on the same machine make you write files you didn't intend. >> Also what if you have two doc-view buffers showing different ODF documents? >> Will one soffice process cause the other to return immediately as well? Yes, right. Shortly after the change you cited, I've handled the latter problem. I tested that it works by marking several MS Office/ODF files in dired and opening them all at once using F (from dired-x). It works flawlessly. --8<---------------cut here---------------start------------->8--- (defun doc-view-odf->pdf-converter-soffice (odf callback) "Convert ODF to PDF asynchronously and call CALLBACK when finished. The converted PDF is put into the current cache directory, and it is named like ODF with the extension turned to pdf." ;; FIXME: soffice doesn't work when there's another running ;; LibreOffice instance, in which case it returns success without ;; actually doing anything. See LibreOffice bug ;; https://bugs.freedesktop.org/show_bug.cgi?id=37531. A workaround ;; is to start soffice with a separate UserInstallation directory. (let ((tmp-user-install-dir (make-temp-file "libreoffice-docview" t))) (doc-view-start-process "odf->pdf" doc-view-odf->pdf-converter-program (list (concat "-env:UserInstallation=file://" tmp-user-install-dir) "--headless" "--convert-to" "pdf" "--outdir" (doc-view-current-cache-dir) odf) (lambda () (delete-directory tmp-user-install-dir t) (funcall callback))))) --8<---------------cut here---------------end--------------->8--- > It should be put in a directory like server.el and doc-view.el do. > server-ensure-safe-dir and doc-view-make-safe-dir should probably be > factored out into a generic function. Is there still a problem with this? LibreOffice doesn't write any sensitive data into that temporary directory, and as you can see, it's immediately deleted after the ODF->PDF conversion. Bye, Tassilo