Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rsv8h-00AO8u-0E for pgsql-hackers@arkaria.postgresql.org; Sat, 06 Apr 2024 01:46:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rsv8f-00743p-9U for pgsql-hackers@arkaria.postgresql.org; Sat, 06 Apr 2024 01:46:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rsv8e-00743g-Nb for pgsql-hackers@lists.postgresql.org; Sat, 06 Apr 2024 01:46:36 +0000 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rsv8X-000qv3-Fl for pgsql-hackers@lists.postgresql.org; Sat, 06 Apr 2024 01:46:35 +0000 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-617e6c873f3so1785317b3.2 for ; Fri, 05 Apr 2024 18:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1712367988; x=1712972788; darn=lists.postgresql.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=xFTVSsGJydH1bI1jlzkYIndZWPUWtULI0HnZwHQL4Vw=; b=Pq/qT4GY0Y0P3LqXlJhVGiISr7lw8GTBfNN02YEgAZLOhwZrgAS+nTCI1xT6YkVYpq VfDwaAbP6ekLEvilTleutu3Bm7QN7bi20aVSBROmjqy3M84XnTfjQHWc8xwXbaWr5fXa /KO0XK9IDBj8W+ukrnTcpi8uEbexIrC/erXq4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712367988; x=1712972788; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xFTVSsGJydH1bI1jlzkYIndZWPUWtULI0HnZwHQL4Vw=; b=ZQLN5z/qtdBWqMtfzafDtXFB86t798o1sf+Y+KpNJLtSWKABJ9hswbg1fVwcd5hnfp igx6ckz5M1M8fuj47Gpeg5NB4kHt8DLrSJLcQ2frmUmh6TIDAJU+573g5RsO04inZRK6 vPU6C4/HkysUkjIrWMJ7wcmVoYk0Fm28fvddDllrdB7XnhgzjyjRAHXAcP/u8l0GRHqP NlMlZFCjnWz0ocaANaYTS2CxwuRgQdI1qQPmtmeyivR5DqsLx4PkgMy1em23UOkliNhj LRToIKVgoo8g1WSYrgaliRhxuBI9+w9yWo2qTN6Dkr6mIhKVytimWhPF8Z9NWHtmzhlm QQpw== X-Gm-Message-State: AOJu0YzRqW/2e3vH7Zu7tIYNANFVYuo2JExQr7O7nKfvfnD9/J1cPT9f xRjswEeKlo76Jsqe5wPNSxYJZe/iVOGhk/CSoMgh70M4RWyIkdhnnzSU5yp6WA== X-Google-Smtp-Source: AGHT+IF+p8rl7QGiaMew16QRYa5AvMmmbvfKphYpi6urv2oYc4JJ9P+lL0UV+PwD/zls7Gw+CHBtQA== X-Received: by 2002:a81:83ce:0:b0:617:cbc7:26fe with SMTP id t197-20020a8183ce000000b00617cbc726femr2909547ywf.16.1712367988488; Fri, 05 Apr 2024 18:46:28 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id hz3-20020a05690c668300b00609f4a354d2sm629376ywb.71.2024.04.05.18.46.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Apr 2024 18:46:28 -0700 (PDT) Date: Fri, 5 Apr 2024 18:46:25 -0700 From: Noah Misch To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org, Daniel Gustafsson , Stephen Frost Subject: Re: DROP OWNED BY fails to clean out pg_init_privs grants Message-ID: <20240406014625.52.nmisch@google.com> References: <1745535.1712358659@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1745535.1712358659@sss.pgh.pa.us> User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Apr 05, 2024 at 07:10:59PM -0400, Tom Lane wrote: > I wondered why buildfarm member copperhead has started to fail > xversion-upgrade-HEAD-HEAD tests. I soon reproduced the problem here: > > pg_restore: creating ACL "regress_pg_dump_schema.TYPE "test_type"" > pg_restore: while PROCESSING TOC: > pg_restore: from TOC entry 4355; 0 0 ACL TYPE "test_type" buildfarm > pg_restore: error: could not execute query: ERROR: role "74603" does not exist > Command was: SELECT pg_catalog.binary_upgrade_set_record_init_privs(true); > GRANT ALL ON TYPE "regress_pg_dump_schema"."test_type" TO "74603"; > SELECT pg_catalog.binary_upgrade_set_record_init_privs(false); > REVOKE ALL ON TYPE "regress_pg_dump_schema"."test_type" FROM "74603"; > > (So now I'm wondering why *only* copperhead has shown this so far. > Are our other cross-version-upgrade testing animals AWOL?) > > I believe this is a longstanding problem that was exposed by accident > by commit 936e3fa37. If you run "make installcheck" in HEAD's > src/test/modules/test_pg_dump, and then poke around in the leftover > contrib_regression database, you can find dangling grants in > pg_init_privs: > > contrib_regression=# table pg_init_privs; > objoid | classoid | objsubid | privtype | initprivs > > --------+----------+----------+----------+-------------------------------------- > --------------------------- > ... > es} > 43134 | 1259 | 0 | e | {postgres=rwU/postgres,43125=U/postgr > es} > 43128 | 1259 | 0 | e | {postgres=arwdDxtm/postgres,43125=r/p > ostgres} > ... > > The fact that the DROP ROLE added by 936e3fa37 succeeded indicates > that these role references weren't captured in pg_shdepend. > I imagine that we also lack code that would allow DROP OWNED BY to > follow up on such entries if they existed, but I've not checked that > for sure. In any case, there's probably a nontrivial amount of code > to be written to make this work. > > Given the lack of field complaints, I suspect that extension scripts > simply don't grant privileges to random roles that aren't the > extension's owner. So I wonder a little bit if this is even worth > fixing, as opposed to blocking off somehow. But probably we should > first try to fix it. This sounds closely-related to the following thread: https://www.postgresql.org/message-id/flat/1573808483712.96817%40Optiver.com