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 1ijluP-00071g-3B for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Dec 2019 15:15:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ijluN-0006I9-SD for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Dec 2019 15:15:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ijluN-0006I2-FH for pgsql-hackers@lists.postgresql.org; Tue, 24 Dec 2019 15:15:39 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ijluK-0005J5-4K for pgsql-hackers@lists.postgresql.org; Tue, 24 Dec 2019 15:15:38 +0000 Received: by mail-pl1-x644.google.com with SMTP id b22so8559939pls.12 for ; Tue, 24 Dec 2019 07:15:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:user-agent; bh=ojGApWfAu5Q7N58vlWtM4J96wHUNYFRn/adlostyp/s=; b=Tl287AsqGhAkeCP+MLVU/0VSpmASZvNyUX/UslJVX/e23dHK8YKZq4Td3SvHopuiJP VeH9mz8Unqw9p5g+6xJFWTMIhW+CK7MHDheTAg2Q/OU5qTdSwHeNwSvHxbINZJ7jfRdI VsYB2Y0vjID9OmnuNIxkoF05WuJvXfQ9CaN0TTgoGLViU8BWvBNIRiIc8+6C2LWlgpo2 W7rNyggxrQ6KofN9J8IdViIPp3fE2BEfhyknEvxTpXYhCpdy1Vw5s7v4dILDkK0m1/gk crD7wEJ0xd5eUJQPwf9VzP6LZpEhZ3Thx6lW1jjAR3ONCJiCcP5xgVmRJLPkD8uG7Fhe HPQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=ojGApWfAu5Q7N58vlWtM4J96wHUNYFRn/adlostyp/s=; b=tWc8RkBBImi0ZfccJElndW6HPRBfnuL3DwdAf9+pcoAv871o9aB+JmA0S56UYHQhFm Q1aRyXU9cdDWJKhMyAzxttOfoZq3ZTAyT2Qp9VHNx/Rl+VqfoPzxohOOQ3YjmufizWDF fQfC/sK9gifFk6TI4N15ukL8fJNrFaz/CXv6yJP3oDUoIqg3OIVjZ9LzttuAMBLO2idd K+jARPQXzXo7BeXej40w9/7olIer6P6CBEsy1Trs/V7yOCkvmi1d/kyKaAAWarlGt+l1 XXuEIAX7iEqQQzxaIP5fKRvffE6mzh6pv2dz/j4UG26MFYH1/e8h5Iav/i9W7rGemteb 6VCQ== X-Gm-Message-State: APjAAAX+sgpXd7sroo+rH7zU84yP5dVfXIPITz8u4TbvxdrnLyNhL3BO oPwOajxfH4o5JGaz+0xtWUY3jPjoGmibgKGZzRYw4skM4Un5Gp3cAsh7wfk1tDeRgCc8h+IsnuH 6DBCeLqSFcfJUSiqj2izlOinRc8DmzyDZ+btSH2W5BDNF3WGzRBRsYn9P4lzDerB/ln1sY4X3nC ARftcG96EWnvVc8EFK X-Google-Smtp-Source: APXvYqxmAnTNIlfDeQdaK8T2rOrXLhO3OnIg5Nrax4vj0qseoUYxOvplz+fp7AJWxBtogTOh65ZeDg== X-Received: by 2002:a17:902:6b:: with SMTP id 98mr37369311pla.128.1577200532341; Tue, 24 Dec 2019 07:15:32 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id c2sm3668483pjq.27.2019.12.24.07.15.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2019 07:15:31 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 2637B300A8F; Tue, 24 Dec 2019 12:15:20 -0300 (-03) Date: Tue, 24 Dec 2019 12:15:20 -0300 From: Alvaro Herrera To: Pg Hackers Cc: Stephen Frost Subject: weird libpq GSSAPI comment Message-ID: <20191224151520.GA16435@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I found this comment in fe-connect.c: /* * If GSSAPI is enabled and we have a credential cache, try to * set it up before sending startup messages. If it's already * operating, don't try SSL and instead just build the startup * packet. */ I'm not sure I understand this correctly. Why does it say "just build the startup" packet about the SSL thing, when in reality the SSL block below is unrelated to the GSS logic? If I consider that SSL is just a typo for GSS, then the comment doesn't seem to describe the logic either, because what it does is go to CONNECTION_GSS_STARTUP state which *doesn't* "build the startup packet" in the sense of pqBuildStartupPacket2/3, but instead it just does pqPacketSend (which is what the SSL block below calls "request SSL instead of sending the startup packet"). Also, it says "... and we have a credential cache, try to set it up..." but I think it should say "if we *don't* have a credential cache". Now that I've read this code half a dozen times, I think I'm starting to vaguely understand how it works, but I would have expected the comment to explain it so that I didn't have to do that. Can we discuss a better wording for this comment? I wrote this, but I don't think it captures all the nuances in this code: /* * If GSSAPI is enabled, we need a credential cache; we may * already have it, or set it up if not. Then, if we don't * have a GSS context, request it and switch to * CONNECTION_GSS_STARTUP to wait for the response. * * Fail altogether if GSS is required but cannot be had. */ Thanks! -- Álvaro Herrera http://www.twitter.com/alvherre