Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYRiW-0006Dl-DH for pgsql-general@arkaria.postgresql.org; Wed, 05 Jun 2019 08:56:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hYRiV-0003SI-58 for pgsql-general@arkaria.postgresql.org; Wed, 05 Jun 2019 08:56:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYRiT-0003LN-U7 for pgsql-general@lists.postgresql.org; Wed, 05 Jun 2019 08:56:18 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYRiQ-0000XI-Qw for pgsql-general@lists.postgresql.org; Wed, 05 Jun 2019 08:56:16 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 39E1F2C4; Wed, 5 Jun 2019 04:56:13 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 05 Jun 2019 04:56:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=withers.org; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=mesmtp; bh=M17n3GcYyR3wSLDdTcnTdDkA601z5pN56CKz4dgHKu8=; b=WftmdNfoJ2k3 +V10+rivWF7S9eP+Q/6gKZqvIQOdTVCS8wE8T9q1alWjOwY06UgPHEj0wRdque4N UkXviJyMjfnL/c0ghk4boAFJB4jJhsr0blc49WfMCJOKOlO4II9k5x3sAvwDKoak sxkeZcTFPGJBLQKu3rT7As0bP4YrwLQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=M17n3GcYyR3wSLDdTcnTdDkA601z5pN56CKz4dgHK u8=; b=Pb22TxK0+G0jnCwNMuNlKx6ZJrl7e1pcmtP+eri1DSV1EHtNJvH0p8hcC ygi+0i5gOJpO8N3uylLgPB0mF9HNM2I6NCwnxEPKGIcFJvUkUHQQJTbXxYjtkCoL I8WE53fd6NJpMEORf6WckRH/8GBchD3h0WS2mZ9ods7sGsYQnyf7DePmxciSJ3He aItUbm0SlDlHLGx0uLkZpl5QIZdgWeFp7NQmDpcectR+CaOY1b+sU/2tFlXLBo0Q TXfDFMkg/ydp0LgOU58AgGGhtQgaLe2yNoZNoZKhdDL4BsWxL0mHFlT05zh1Di8x KDhskQMvLWTt7kVh9Jnt10X8BgxgA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudegvddguddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomhepvehhrhhi shcuhghithhhvghrshcuoegthhhrihhsseifihhthhgvrhhsrdhorhhgqeenucfkphepud ekrddufedtrddufeekrdejudenucfrrghrrghmpehmrghilhhfrhhomheptghhrhhishes fihithhhvghrshdrohhrghenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [172.16.56.31] (ec2-18-130-138-71.eu-west-2.compute.amazonaws.com [18.130.138.71]) by mail.messagingengine.com (Postfix) with ESMTPA id A48D580059; Wed, 5 Jun 2019 04:56:11 -0400 (EDT) Subject: Re: granting right to create and delete just one database To: Laurenz Albe , pgsql-general@lists.postgresql.org References: <32b82200-576e-d51a-f16c-541068896762@withers.org> <91b121d8f4f2e4a7b85e46f87cf91f634598c88d.camel@cybertec.at> From: Chris Withers Message-ID: <176edf88-10e2-6838-64c0-d9b945367ba4@withers.org> Date: Wed, 5 Jun 2019 09:56:10 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:67.0) Gecko/20100101 Thunderbird/67.0 MIME-Version: 1.0 In-Reply-To: <91b121d8f4f2e4a7b85e46f87cf91f634598c88d.camel@cybertec.at> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 05/06/2019 09:52, Laurenz Albe wrote: > Chris Withers wrote: >> Is there any way to grant rights to a user such that they can drop and >> re-create only a single database? > No; what I'd do if I needed that is to create a SECURITY DEFINER function > that is owned by a user with the CREATEDB privilege. > This function can be called by a normal user that has the EXECUTE privilege > on the function. > > Don't forget to "SET search_path" on such a function (as mentioned in the > documentation). It might also be a good idea to REVOKE EXECUTE on the > function from PUBLIC. Thanks, that's a great idea! Is this pattern documented anywhere as a complete finished thing? cheers, Chris