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 1oVxIK-00019q-PY for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Sep 2022 15:48:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oVxII-0002bg-Vh for pgsql-hackers@arkaria.postgresql.org; Wed, 07 Sep 2022 15:48:50 +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 1oVxII-0002bX-K5 for pgsql-hackers@lists.postgresql.org; Wed, 07 Sep 2022 15:48:50 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oVxIE-0001sx-CL for pgsql-hackers@lists.postgresql.org; Wed, 07 Sep 2022 15:48:50 +0000 Received: by mail-pf1-x42b.google.com with SMTP id d82so1416448pfd.10 for ; Wed, 07 Sep 2022 08:48:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=timescale.com; s=google; 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=ZsQZ5Ha2usGtmZeEi/TSXedToL+q7Jgfr7dxOnajDLo=; b=Sg0L+ySPD4obubcjyw1qUGyPSzB6/isLp3VyQ+IiP1W8ihUy90fN7tMVFap0Z6gkl7 7gq7lE63wD6Ri7YW089iDZw6A18mqEXYNToFHjDaS1w10XC7uy9UrhUr+Q7rZYqbdfzd Y3pRUzjCpWhj6y9mQUykW9FL5L+JUsksxW8BGpmdtVjxaPmnawsuAVOhrsTeEeAo+x/a T3AIK9xPFoOH0Da9MTwOACO+oOB85C4J4jvp/sssCVwXWxKCJ6/AVsbUgG+ywXkmdXWQ 1Cf+sAtXBBXVIxj7IDk+HtzjF48kZrJ+fPAv4w/vEq/3vSvLNG9/8No1WLG7hH8g/IQS pl+Q== 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=ZsQZ5Ha2usGtmZeEi/TSXedToL+q7Jgfr7dxOnajDLo=; b=Cbi7IYouiDkB02mPpegPcNyoIPioJ/2hZhtjzkHCg8tCQETr6IHGfW0N7CRN5LFV+4 fnrzn/0TlBLORfPbqlFpGSOFmym+rigHmtFrgNxEEIfUM84F8lxlvZldqhxxLWI8yVkX TXFU+22exPEno7aHR0Sl3c5TFCoor+Xz+vSsp6ItIpwfHE847Edc1Tz2Td7QU2LvAKLP Z4fmoE7t6C5TiouHKM48Vr0r4Y5vP7QQxJPTcnxT2FYo+LLawl4CP3ZfJB4j7inAZxZC jBaJ17KPgN9bhs6A72KmWNICgw9/jA+OC53qodbji4kB5PVJjhEBglzLKjV+IQ0lGOZ9 8iXw== X-Gm-Message-State: ACgBeo1Tu8XohflwI82wF6Hvq3Rg/x1lLl3VjnFVob9rZTqG3SLSMH22 Haoe5K1zI1LN1P26Ivem8xhxqg== X-Google-Smtp-Source: AA6agR7QAKJIiwu19WdIf7Np4CB7c8mf9xIw5idSQN6675OFPugut4Ls90QDbo5sHcxc8M1J9qcdRQ== X-Received: by 2002:a62:82c9:0:b0:53e:92e7:74a4 with SMTP id w192-20020a6282c9000000b0053e92e774a4mr1767675pfd.55.1662565724206; Wed, 07 Sep 2022 08:48:44 -0700 (PDT) Received: from [192.168.1.21] ([50.39.205.221]) by smtp.gmail.com with ESMTPSA id u10-20020a62d44a000000b0053653c6b9f9sm12769647pfl.204.2022.09.07.08.48.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Sep 2022 08:48:43 -0700 (PDT) Message-ID: Date: Wed, 7 Sep 2022 08:48:43 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: SYSTEM_USER reserved word implementation Content-Language: en-US To: "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: Jacob Champion In-Reply-To: <9dae37cb-abe0-a773-da74-3e2b62279d4c@amazon.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 ? 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. > + /* 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()? > + /* 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). 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? Thanks, --Jacob