Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 9C078B5D803 for ; Fri, 24 Jun 2011 15:29:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 17657-06 for ; Fri, 24 Jun 2011 18:28:55 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from spinlock.commandprompt.com (host-215.commandprompt.net [207.173.203.215]) by mail.postgresql.org (Postfix) with ESMTP id 06D84B5DBF1 for ; Fri, 24 Jun 2011 15:28:54 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by spinlock.commandprompt.com (Postfix) with ESMTP id 26B83348046; Fri, 24 Jun 2011 11:28:54 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at commandprompt.com Received: from spinlock.commandprompt.com ([127.0.0.1]) by localhost (spinlock.commandprompt.com.commandprompt.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5TiD4VZ78Qiy; Fri, 24 Jun 2011 11:28:52 -0700 (PDT) Received: from perhan.alvh.no-ip.org (unknown [190.95.30.33]) by spinlock.commandprompt.com (Postfix) with ESMTPSA id 24079348044; Fri, 24 Jun 2011 11:28:52 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 6238A862B7; Fri, 24 Jun 2011 14:28:46 -0400 (CLT) Content-Type: text/plain; charset=UTF-8 Cc: pgsql-bugs Subject: Re: BUG #6076: Unexpected "Security Definer / invoker" interaction From: Alvaro Herrera To: Dave Fennell In-reply-to: <201106241448.p5OEmekP044181@wwwmaster.postgresql.org> References: <201106241448.p5OEmekP044181@wwwmaster.postgresql.org> Date: Fri, 24 Jun 2011 14:28:46 -0400 Message-Id: <1308939809-sup-2803@alvh.no-ip.org> User-Agent: Sup/git Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/202 X-Sequence-Number: 30581 Excerpts from Dave Fennell's message of vie jun 24 10:48:40 -0400 2011: > Not sure if this is a bug or possibly just undocumented (or unclearly > documented) behaviour but the interaction of functions defined as "security > definer" and functions defined as "security invoker" is not what I would > expect. > > I would expect that if a function defined as "security definer" calls a > function defined as "security invoker" the "invoker" role used would be the > "definer" of the first function? However it appears that the *actual* > invoker (current user) is used. I think your problem is that you need an explicit SET ROLE to sub1 before calling sub1.func2(). Alternatively you could set up global so that it "inherits" (which would automatically give it the privileges that both sub1 and sub2 have). There doesn't seem to be a bug here. -- Álvaro Herrera The PostgreSQL Company - Command Prompt, Inc. PostgreSQL Replication, Consulting, Custom Development, 24x7 support