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 1ocnrp-0007lu-UY for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Sep 2022 13:09:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ocnrn-0005gp-Mv for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Sep 2022 13:09:47 +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 1ocnrn-0005gf-Az for pgsql-hackers@lists.postgresql.org; Mon, 26 Sep 2022 13:09:47 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ocnrk-0007vU-Mf for pgsql-hackers@lists.postgresql.org; Mon, 26 Sep 2022 13:09:46 +0000 Received: by mail-wm1-x32a.google.com with SMTP id l8so4465726wmi.2 for ; Mon, 26 Sep 2022 06:09:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=X3Gn+7BiqkeRpMxpi7ey6kMWrtoJOpoXTdhRpWhyTeg=; b=nUVre5srC2PqqSj8A4UaQ9bRg2HcivH4s2nWyHPt+okXIbTtOYpRQCwZHl/f4EOUZI 29lD33UsdybKrd3no1nWcyvlBkOC2BiYrThN9JjQDg1OlCVmw9JlJwf0Iog5/m/Ap2S6 vSr74mRkpV79kKw9uAXVLg6BYUzB1CIbFHaiVFBRLjBymAkjCnW+Tz3U0prEbihUsiFv TMr3vN0uiC/X71UjjtSB1iH7HYpRupZLw0f6dMzD6fY1QgiNnO4sxDb44s9YAJQENB0m Uem+MN2VgM5IGuRQgyQl7uCDQvTlcYSVpxkghX4TmTwoJfB/FV1WfAaF6dHaTZDMjEzg +77A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=X3Gn+7BiqkeRpMxpi7ey6kMWrtoJOpoXTdhRpWhyTeg=; b=7jnfX+zEzLjXjwKKTlTRNoy7zWemtg8fn2qqJFboOzElfhpHhUsHeFaT8k61PllgCs dXBHp1DM0X6acDCqQAduxUmYWuNPLcbljDpP7Ak8NxBbBkIf1dmFBGFg0xXpxRWxUWQF qgFDDeK/l7edG4nxvsyghC4nPj6WWq0YVLmMG79wUufaSkcNBcQZOfXnINDPFqaQ7k1L 8tKkoe/F6p/Xw8iQbeV5P8/gzH7GEGQA3k3+c5NkRvAQhw8E68Y6hGc993EqLuddjk4g Usy4pKeitqciTtECtwtV5dqlRNSULjZSHfujoWeXa7FSLOgk3BwYJg8EEhS7QXYCsPbt a0dw== X-Gm-Message-State: ACrzQf3CZne6o41epn9O2tNiqwcYa71Ygsynu4CKK2WPv3Nq/04f2ggP ClHYpv3wv9xjNn/WVZDvauQ= X-Google-Smtp-Source: AMsMyM6MCgoh3zF6LQzDr/TfmWsPreN5EAYrhvlfjnJZe/55j/qLpEmDbKxMOw68eSMdtSQkajaFvA== X-Received: by 2002:a1c:7412:0:b0:3b4:7a81:e7e4 with SMTP id p18-20020a1c7412000000b003b47a81e7e4mr14257913wmc.15.1664197782429; Mon, 26 Sep 2022 06:09:42 -0700 (PDT) Received: from [192.168.8.246] ([54.239.6.185]) by smtp.gmail.com with ESMTPSA id c9-20020adffb09000000b0022a3517d3besm14683405wrr.5.2022.09.26.06.09.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Sep 2022 06:09:41 -0700 (PDT) Message-ID: Date: Mon, 26 Sep 2022 15:09:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: SYSTEM_USER reserved word implementation Content-Language: en-US To: Jacob Champion , "Drouvot, Bertrand" , Michael Paquier Cc: Alvaro Herrera , Tom Lane , Joe Conway , PostgreSQL Hackers References: <20220627173250.46lvecpvuunc7pf5@alvherre.pgsql> <24d638c7-16f6-afb9-c25c-6a29c169210e@amazon.com> <8fe1752a-2e3d-4ee8-656c-0caf5d860b0e@amazon.com> <1da0e60c-bd85-9f2d-2039-103055338b00@amazon.com> <40b4e4d0-d034-ea19-3ec3-1557f498770f@amazon.com> <9dae37cb-abe0-a773-da74-3e2b62279d4c@amazon.com> From: "Drouvot, Bertrand" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 9/7/22 5:48 PM, Jacob Champion wrote: > On 9/7/22 07:46, Drouvot, Bertrand wrote: >> Except the Nit above, that looks all good to me. > > A few additional comments: > >> + assigned a database role. It is represented as >> + auth_method:identity or >> + NULL if the user has not been authenticated (for >> + example if has been used). >> + > > This is rendered as > > ... (for example if Section 21.4 has been used). > > which IMO isn't too helpful. Maybe a would read better than an > ? Thanks for looking at it! Good catch, V4 coming soon will make use of instead. > > Also, this function's placement in the docs (with the System Catalog > Information Functions) seems wrong to me. I think it should go up above > in the Session Information Functions, with current_user et al. Agree, will move it to the Session Information Functions in V4. > >> + /* Build system user as auth_method:authn_id */ >> + char *system_user; >> + Size authname_len = strlen(auth_method); >> + Size authn_id_len = strlen(authn_id); >> + >> + system_user = palloc0(authname_len + authn_id_len + 2); >> + strcat(system_user, auth_method); >> + strcat(system_user, ":"); >> + strcat(system_user, authn_id); > > If we're palloc'ing anyway, can this be replaced with a single psprintf()? Fair point, V4 will make use of psprintf(). > >> + /* Initialize SystemUser now that MyClientConnectionInfo is restored. */ >> + InitializeSystemUser(MyClientConnectionInfo.authn_id, >> + hba_authname(MyClientConnectionInfo.auth_method)); > > It makes me a little nervous to call hba_authname(auth_method) without > checking to see that auth_method is actually valid (which is only true > if authn_id is not NULL). Will add additional check for safety in V4. > > We could pass the bare auth_method index, or update the documentation > for auth_method to state that it's guaranteed to be zero if authn_id is > NULL (and then enforce that). > >> case SVFOP_CURRENT_USER: >> case SVFOP_USER: >> case SVFOP_SESSION_USER: >> + case SVFOP_SYSTEM_USER: >> case SVFOP_CURRENT_CATALOG: >> case SVFOP_CURRENT_SCHEMA: >> svf->type = NAMEOID; > > Should this be moved to use TEXTOID instead? Good catch, will do in V4. Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com