Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pcqSM-0005sP-8n for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Mar 2023 16:27:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pcqSL-0005l1-4F for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Mar 2023 16:27:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pcqSK-0005ks-PS for pgsql-hackers@lists.postgresql.org; Thu, 16 Mar 2023 16:27:56 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pcqSH-0001Yu-Q4 for pgsql-hackers@postgresql.org; Thu, 16 Mar 2023 16:27:56 +0000 Received: by mail-pl1-x633.google.com with SMTP id a2so2344995plm.4 for ; Thu, 16 Mar 2023 09:27:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678984072; h=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=EkrIaCtzB4szOh0Vrr56YXVd6cicOHHkiEcB/y9tncc=; b=WV8zWl8GGRHbOTI7b/X7u6V5qj17yRL9HyaeyNrfOjWp6kxseAPsxAmfG7oU1AnEdG IuVki/X0XZobtb8bXiOwDgd5d4XYoTe4//RP2R+N8W6XxQK8VWvaS5rS8FwzOi7zMxv/ lGMjhaJ4NpwbMrRU8W87xjXNAH4gPT7b3VHER5hnak3GuFkAw+x/3zCWagOc4KhdNHNY AznKSz22BQhhqZlQp+IWJxTqP8O+t6tIeVEv4F8L9paearYFgXgNTSIqb1T8oCQl+uGo Xpca0M05r1BHuwV0/3NrbRRdXC18uJJYa+r4aTW2ogUrX5PDsdYB4rUBg/IqJF3CrSnK JPXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678984072; h=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=EkrIaCtzB4szOh0Vrr56YXVd6cicOHHkiEcB/y9tncc=; b=eJ/Xtu0jkUoJvZjVUXppeuzeHKmMET+ODcS7u+PwJiluioBU12RH6jpp3F9ojdV7/o vqb4s5z8+ICQ7GA/MgyOaSV9mi+ItrwEGokdCT5JAq1vrI2x8hSIRvXDlVggkZlZPLST rduH0DQKqhzL3yUObcUk2ZE1g3Y4wEUGpGDJqvUeMzttNCluIc0/53sdHt81WcRB4kQk xelXZsvuoe8X325ng+nYa2OnxWImdn1xLOSZSBj3uVQXZlK4AyAmUluohE5/WNqFkx1K fMkPsnEkSRJvJ99QPZgTi52wLHNP1zSBI2TxE/XD857K4zIlF+s2CFicLhQ3rX/h14DV FG2Q== X-Gm-Message-State: AO0yUKW33SRraSne9RVREHqWDJgpYSrvvbOPMT2PAkwWlr4X0IXQRmQH uKyg4sH2F2m9GPDtwoyqzvY= X-Google-Smtp-Source: AK7set/59ry8NJXRPzAjALG5P8JAFDY8rJUpoOVSJG4QETlVhz9ilPMQDc0Ol2liDvlJC00a1ZOOmw== X-Received: by 2002:a17:902:f907:b0:19c:d5c7:e3df with SMTP id kw7-20020a170902f90700b0019cd5c7e3dfmr3480691plb.8.1678984071931; Thu, 16 Mar 2023 09:27:51 -0700 (PDT) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id kf6-20020a17090305c600b001a05122b562sm5770661plb.286.2023.03.16.09.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 09:27:50 -0700 (PDT) Date: Thu, 16 Mar 2023 09:27:49 -0700 From: Nathan Bossart To: Peter Eisentraut Cc: Alvaro Herrera , Tom Lane , Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: improving user.c error messages Message-ID: <20230316162749.GA792895@nathanxps13> References: <20230207201009.GA450353@nathanxps13> <20230220190210.GA3481922@nathanxps13> <20230220225852.GA3940888@nathanxps13> <20230309175846.GA3626988@nathanxps13> <20230310000313.GA3992372@nathanxps13> <20230316154858.GA791987@nathanxps13> <73ab0059-a652-e44a-73c6-36f350782078@enterprisedb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <73ab0059-a652-e44a-73c6-36f350782078@enterprisedb.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Mar 16, 2023 at 04:59:53PM +0100, Peter Eisentraut wrote: > On 16.03.23 16:48, Nathan Bossart wrote: >> > I think the following change in DropRole() is incorrect: >> > >> > if (!is_admin_of_role(GetUserId(), roleid)) >> > ereport(ERROR, >> > (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), >> > - errmsg("must have admin option on role \"%s\"", >> > - role))); >> > + errmsg("permission denied to drop role"), >> > + errdetail("Only roles with the %s attribute and the %s >> > option on role \"%s\" may drop this role.", >> > + "CREATEROLE", "ADMIN", >> > NameStr(roleform->rolname)))); >> > >> > The message does not reflect what check is actually performed. (Perhaps >> > this was confused with a similar but not exactly the same check in >> > RenameRole().) >> Hm. Is your point that we should only mention the admin option here? I >> mentioned both createrole and admin option in this message (and the >> createrole check above this point) in an attempt to avoid giving partial >> information. > > AFAICT, the mention of CREATEROLE is incorrect, because the code doesn't > actually check for the CREATEROLE attribute. There is a createrole check at the top of DropRole(): /* * DROP ROLE */ void DropRole(DropRoleStmt *stmt) { Relation pg_authid_rel, pg_auth_members_rel; ListCell *item; List *role_addresses = NIL; if (!have_createrole_privilege()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("permission denied to drop role"))); Granted, no one will see the admin option error unless they at least have createrole, so we could leave it out, but my intent was to list the full set of privileges required to drop the role to avoid ambiguity. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com