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 1rb0YF-00CakP-QP for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Feb 2024 15:54:59 +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 1rb0YB-002hZm-FM for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Feb 2024 15:54:55 +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 1rb0YB-002hZe-5j for pgsql-hackers@lists.postgresql.org; Fri, 16 Feb 2024 15:54:55 +0000 Received: from mail-io1-xd36.google.com ([2607:f8b0:4864:20::d36]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rb0Y8-0074Sw-LK for pgsql-hackers@postgresql.org; Fri, 16 Feb 2024 15:54:53 +0000 Received: by mail-io1-xd36.google.com with SMTP id ca18e2360f4ac-7c488a5afcaso90084239f.2 for ; Fri, 16 Feb 2024 07:54:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708098892; x=1708703692; darn=postgresql.org; 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=XVtqZoIrrR3eVEpmSTP9HuCk2D1GaYvS9A68mxPuvxw=; b=Mw5YcUURBdBkEVpEhDm5ZKR74FnD9vqxAkVrOaSMEmKWrZzuBBzOVFxa20VfzCO1e1 N+1MswSGW8wfh3O0EHcLvmKMi9S7yo0YgZz9iYtSOpLj93D9n5rr4c10XPeX/vOZnmEv JfN9L79YN3rI+fO0j1yPJx/AaFfZSLrxvf8+PYvch4eosshQpFTQRFwotgZ1FZTkHwtk RE4bkpMLyMIsiBqYz/n+rDE41YsufPsTJeYxIHdawElPSptaZVPuxOpIrqib4KK3qUTy +iaRuuS5Z4LpW+ozMARASnuZJ6lyu8VS+0eFjn5z9YKgs5iHaFlVUFfWa0nUJV92Nhk/ 8IDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708098892; x=1708703692; 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=XVtqZoIrrR3eVEpmSTP9HuCk2D1GaYvS9A68mxPuvxw=; b=NZtcjX8Evx6l6nOUcLUZcxnPs/81VFPKRQq31AMqZno3HQSp/HjAfSFCL4B0ohggHp UgKedTHWkbJsr7NsN3id183yzv4sLHzdYutdQs/Yw4rGsVn/G+UDOEIMlC7bH2lE8OuK 72o0vS6Z1To1VcfLk7ZwH2ixpZu4tEArYT+4kKcqJOvLSIhkgpO2FqL/H6qFGYdxe6/L QAnayLxRG02bbMVtRiimZjdB/d9DI7Gn4uUb2/sbeRwwJtcxpWIK7tPvVFtu7DCw8iv5 I5WM+SZ6/8hrLxirvJjzPoBPMAB/FrCSlo5aU4r3lCH3UxMbumNnesTnleURkaOIDnjz WlTQ== X-Forwarded-Encrypted: i=1; AJvYcCX8bscCGC7AXADwzgweSJYQyeFGmdw6HJUQ9EzhzWWWMNa25QMMGYFsCGW4q+a9JAvSc3YRh62LV3sVtnubtQxhGLHZIXncjtY9etcm X-Gm-Message-State: AOJu0YzesCjNxa+t5GF+/UfeII6rDCufO81IpEzjVihagBIJEW19dePa uzzYEpHbQtszFAJxk+pKcXNqfOkgmnUhKjrIeFKf2hNF8A09ZZ+D X-Google-Smtp-Source: AGHT+IF4cl1BShs82m5GJf/E6AzaRFvHs+RJ4l6fDfTLmWrsC796KSo264vwdetLWf6Mb1lCWA5ddA== X-Received: by 2002:a5d:9c06:0:b0:7c6:67e4:b151 with SMTP id 6-20020a5d9c06000000b007c667e4b151mr2795165ioe.9.1708098891693; Fri, 16 Feb 2024 07:54:51 -0800 (PST) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id g27-20020a02cd1b000000b0047140ce03casm37910jaq.22.2024.02.16.07.54.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 07:54:51 -0800 (PST) Date: Fri, 16 Feb 2024 09:54:49 -0600 From: Nathan Bossart To: Jim Jones Cc: Maiquel Grassi , Pavel Luzanov , Erik Wienhold , "pgsql-hackers@postgresql.org" Subject: Re: Psql meta-command conninfo+ Message-ID: <20240216155449.GA1236054@nathanxps13> References: <49edac91-d47f-4cac-ae12-d51cabbd87c9@postgrespro.ru> <49635a5b-3d32-4f05-8ce4-c55c70181888@uni-muenster.de> <8a93f6c0-795f-4260-a5fd-07ccbddbc88f@uni-muenster.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8a93f6c0-795f-4260-a5fd-07ccbddbc88f@uni-muenster.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thanks for your work on this. I haven't been keeping up with the discussion, but I took a quick look at the latest patch. + + "Database", "Authenticated User", "System User" (only for PostgreSQL 16 or higher), + "Current User", "Session User", "Backend PID", "Server Address", "Server Port", + "Client Address", "Client Port", "Socket Directory", and "Host" columns are listed + by default when \conninfo+ is invoked. The columns "Encryption", + "Protocol", "Cipher", and "Compression" are added to this output when TLS (SSL) + authentication is used. The same applies to GSS authentication is used, where the + "GSSAPI" column is also added to the \conninfo+ output. I might be alone on this, but I think this command should output the same columns regardless of the version, whether it's using SSL, etc. and just put NULL in any that do not apply. IMHO that would simplify the code and help prevent confusion. Plus, I'm not aware of any existing meta-commands that provide certain columns conditionally. + if (PQsslInUse(pset.db)) + { + protocol = PQsslAttribute(pset.db, "protocol"); + cipher = PQsslAttribute(pset.db, "cipher"); + compression = PQsslAttribute(pset.db, "compression"); + appendPQExpBuffer(&buf, + " ,'SSL' AS \"Encryption\",\n" + " '%s' AS \"Protocol\",\n" + " '%s' AS \"Cipher\",\n" + " '%s' AS \"Compression\"\n", + protocol ? protocol : _("unknown"), + cipher ? cipher : _("unknown"), + (compression && strcmp(compression, "off") != 0) ? _("on") : _("off")); + } Could we pull some of this information from pg_stat_ssl instead of from libpq? The reason I suggest this is because I think it would be nice if the query that \conninfo+ uses could be copy/pasted as needed and not rely on hard-coded values chosen by the client. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com