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.96) (envelope-from ) id 1vo15n-00Ejff-2Z for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Feb 2026 15:16:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vo15m-00HMrR-2L for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Feb 2026 15:16:26 +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.96) (envelope-from ) id 1vo15m-00HMrJ-1O for pgsql-hackers@lists.postgresql.org; Thu, 05 Feb 2026 15:16:26 +0000 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vo15k-00000000hKo-0brg for pgsql-hackers@postgresql.org; Thu, 05 Feb 2026 15:16:25 +0000 Received: by mail-oi1-x232.google.com with SMTP id 5614622812f47-45c89d754dfso365343b6e.1 for ; Thu, 05 Feb 2026 07:16:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770304583; x=1770909383; darn=postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=x3apgdOPfzm+KamVfGNlTNBj9nR0hHJ3On8PJVpZ9P0=; b=JBSHbQJqZoE5NcTQgdyBXyGK3j9oN18dA33A8vjIsbcIyhRw0ef0M961ToNyQ3hFwl bVJytqBN/UD6VwdMdxeHNyAFaBlFkIoU9Rq1/e9r2mUTIw0BImSs2rQlTteZEALMArfW w3FQoUD1tIHqNMJtl1tdr+25A5wkehuFFNf6uBHZlSLR/TFnbcjKPuVsc/QRg9WYMyNd sXB76OA/5ZhnhMA4M9uDAk0pFbFPSMjcCyzAqwnV+xOZC3MBNhQxqJ1oEtYjJck5soFQ ZgpM1fz57h9e5DcHw4Jnm5HGC8hC3GYHGVJzViSAPZ53iypaNKOfk0SxghEhcIQp9+kR JFPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770304583; x=1770909383; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=x3apgdOPfzm+KamVfGNlTNBj9nR0hHJ3On8PJVpZ9P0=; b=RQyLqenjdrVMftVX3fs5w76AJqGwDVy3EU9aagZ4i652z8zSQAzF9lFwUByxBZwgYc 2uy+z2iXy/Wy3uQk+AGP7QC6HAi07vH2HD10ig5n6rZcaBEnSrH9xHYDRnCEzgkRu1N2 JwWMpwuYSADJo4Ah2houXCcPJW69jQUP82LrLykpojd7a9/1XaY5wmSCAvZbz7JgcP+W IO7uqVQWFUi+Q89nN9ABinlVuRnt04iHx50Qk+DMEt+G849LL43sjmd82Ofasq1iTXBz DSCRaCtWlVJ5cPA+EswoUjFwPz4ckVy6jSEV8vNCamMOOhLamW/aizCwjuV9dG4yFvM+ LuxQ== X-Forwarded-Encrypted: i=1; AJvYcCXcLF1k5L0wrh5JNewztimXA8pD6xDM59gJ71GH21xMR1AUmJbFfFzo6JmSqyxV+q9rsESx3YJtTUID+7r6@postgresql.org X-Gm-Message-State: AOJu0YzwuRJvykRPOU31C63WwqEMT+xJF9aXOCqJctxNbpmOvRdT5c/E +zQdMC4zTINExnm6b/9OBJDYZYXkkh8nTixbJPlPWScHJL31EiKFzDQM X-Gm-Gg: AZuq6aKmfWvQv5dUWLsMVLBzgrX+PlttyPpFsAH/ZFQ+pCvc4VXdpBsOD9bN20JU97V VFIZ3t6ZETnDyEho9/uh3RwOzOcnO+gyId+mnkmzWQgTdyulZlQoAvsriMu3PmAIibJRBv/ICR9 NHRLDxT7nxi1Rt+Q69/yseM/ky8HHzgh13fOivHXQOh1OfH4fAEXfFqm9foUo9+64fojlnXBhGg sY3HGehk65aBSlGdhRScEyV81uz7lU94fF1NalI8JyNUpMXxWWjjHNr43Y0A/Rn87PNRWKgDkpw Wp6G0vCUetDnhTi1JqR+wwUDX5aZ9Jvh8lYrAFtkPeMCJi0YSaSy0j6VILsM9gWWcj+mM6g63mG JvkQrSDwvC2AevQabltBTLoGDsGtCCYkoJQBTArBwGYb/cE1F4ekZLjT8jZwlEm9MDE+bey/3Zp SZFiISaN9DtMGqpBtzn6ag1WJw8dfNWaNwcuq9wwSDHVFVGEafGnWIEK/cBCyEPU5jXbm0Oh16u EGV X-Received: by 2002:a05:6808:309b:b0:455:db31:a680 with SMTP id 5614622812f47-462d5adacccmr2934851b6e.63.1770304583345; Thu, 05 Feb 2026 07:16:23 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-40a630bc6easm3097921fac.4.2026.02.05.07.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Feb 2026 07:16:22 -0800 (PST) Date: Thu, 5 Feb 2026 09:16:20 -0600 From: Nathan Bossart To: Chao Li Cc: Euler Taveira , Peter Eisentraut , Gilles Darold , Zsolt Parragi , japin , Yuefei Shi , songjinzhou , pgsql-hackers , Andrew Dunstan , Tom Lane , liu xiaohui , Steven Niu Subject: Re: Pasword expiration warning Message-ID: References: <1f4d0b80-3fea-4f4d-8d33-a652ea23e90b@eisentraut.org> <5798afb7-b10c-436f-987e-14fb625df7d0@app.fastmail.com> <6E83A384-89B0-4141-887F-E54C02B2CACE@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6E83A384-89B0-4141-887F-E54C02B2CACE@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Feb 05, 2026 at 09:06:27AM +0800, Chao Li wrote: > Thanks for the patch. I think this is a very helpful addition. I’ve > reviewed v16 and it looks solid overall. I only have a few small > comments. Thanks for reviewing. > * The value `604800` is used in two places: here in the GUC definition > and in `crypt.c` to initialize `password_expiration_warning_threshold`. > It might be cleaner to define a shared constant (e.g., a macro in > `crypt.h`) and reuse it in both places. Eh, there are lots of examples of setting the default value in both the GUC definition and the variable declaration. TBH I've always found excessive macro use to hinder readability more than it helps anything. Sure, if we need to change the default, we'll have to update both places, but we already have to update the docs and tests and sample file, anyway. > * Using `INT_MAX` as the upper bound feels a bit meaningless. Would it > make sense to cap this at a more reasonable value (say 30, 60, or 180 > days)? That could help catch accidental misconfiguration — for example, > typing `70d` instead of `7d`. On the contrary, it's quite meaningful. It means that there's no technical restriction for arbitrarily large values and that users are free to set it to whatever value makes sense for them. > In postgresql.conf.sample, should we also mention that setting this to 0 > disables the warning? I don't think it's necessary. IMHO it's reasonably obvious that setting the value to 0 means there's effectively 0 time between enabling the warnings and the password expiring. > Switching to TopMemoryContext here makes sense to ensure the warnings > survive until the end of InitPostgres(). However, this still relies on > callers to allocate msg and detail in a sufficiently long-lived context, > which isn’t guaranteed. StoreConnectionWarning() has the following comment: * NB: Caller should ensure the strings are allocated in a long-lived context * like TopMemoryContext. > Should this be `expire_time <= 0` instead? As written, when `expire_time > == 0` the user would get a warning like “password will expire in less > than 1 minute”, which feels slightly odd. Currently, we consider the password as expired when vuntil < GetCurrentTimestamp() ... which matches the documented behavior: The VALID UNTIL clause sets a date and time after which the role's password is no longer valid. I see no need to change it. -- nathan