Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UIfjo-0004x2-Ai for pgsql-sql@arkaria.postgresql.org; Thu, 21 Mar 2013 13:41:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UIfjn-0001hL-Hg for pgsql-sql@arkaria.postgresql.org; Thu, 21 Mar 2013 13:40:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UIfjl-0001hD-Kc for pgsql-sql@postgresql.org; Thu, 21 Mar 2013 13:40:57 +0000 Received: from mail-pb0-f47.google.com ([209.85.160.47]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UIfjZ-0003kN-BR for pgsql-sql@postgresql.org; Thu, 21 Mar 2013 13:40:56 +0000 Received: by mail-pb0-f47.google.com with SMTP id rp2so2249779pbb.34 for ; Thu, 21 Mar 2013 06:40:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=5VNoSFWoMuDDumeNK13R+qN5BHjD52Z7SBG2V5QCcPk=; b=jhwYXWlMlGEHysaEmvby/XnEUAcH51g/QjUzt9espsLNLYWomcVAcCPUHBTEPUnY3t c5iWzDGs2pDvlULUvqXrsUr+QwZK6CLxLVNuYQyn0Ci/ld8HxrTVq30ydOgnjfdVgfTG /PpbFTxxloW+6rfFsMyDzMC9E80v3mTiNg4yU0t6ZdcJ8emfQwmhheSzzFXT9k6/uxm2 mYaXZWjsL2wobj7o+AMx8ctDWGUe5vVmrV6NoqX493ZKVNlCHatZLcoHZoylbhoUQ5UA mTJIeIrGOQojI0fffEhc3v2zgm7rFaiEAcNV/xBW852LYNJ3hZqxtw44tsctKlDCG+vc 18jQ== X-Received: by 10.66.231.103 with SMTP id tf7mr14879755pac.97.1363873243766; Thu, 21 Mar 2013 06:40:43 -0700 (PDT) Received: from [192.168.1.2] (97-113-5-86.tukw.qwest.net. [97.113.5.86]) by mx.google.com with ESMTPS id ve7sm6589874pab.11.2013.03.21.06.40.42 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 21 Mar 2013 06:40:43 -0700 (PDT) Message-ID: <514B0DD9.7050204@gmail.com> Date: Thu, 21 Mar 2013 06:40:41 -0700 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: Jose Antonio Quintana/UPC CC: pgsql-sql@postgresql.org Subject: Re: Reading from file without superuser privilege References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org On 03/21/2013 04:43 AM, Jose Antonio Quintana/UPC wrote: > I need to read from a file in order to update a table. > > The manual says that it is necessary to have the superuser privilege to > read from a file. > > Is it possible to read files without this privilege? What sort of file, any file or one you want to do a COPY or \copy from? For any file you would need to use one of the untrusted languages, plpythonu for example. They need to be installed by a superuser. It is possible to create a function in an untrusted language as the superuser and then confer the superuser privileges to other users for that function by using SECURITY DEFINER, see here: http://www.postgresql.org/docs/9.2/interactive/sql-createfunction.html For COPY : "The file must be accessible to the server and the name must be specified from the viewpoint of the server. " http://www.postgresql.org/docs/9.2/interactive/sql-copy.html For \copy: "This is an operation that runs an SQL COPY command, but instead of the server reading or writing the specified file, psql reads or writes the file and routes the data between the server and the local file system. This means that file accessibility and privileges are those of the local user, not the server, and no SQL superuser privileges are required." http://www.postgresql.org/docs/9.2/interactive/app-psql.html > > Thanks. > > > _______________________________________________ > José Antonio Quintana Romero > Unitat de Projectes > Vicegerència de Desenvolupament Organitzatiu i Personal > Edifici Vèrtex. Planta 3 > Pl. Eusebi Güell, 6 > 08034 - Barcelona -- Adrian Klaver adrian.klaver@gmail.com -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql