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 1vnnq2-00BvUE-1m for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Feb 2026 01:07:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vnnq0-00EQyX-2Q for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Feb 2026 01:07:16 +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 1vnnq0-00EQyG-0e for pgsql-hackers@lists.postgresql.org; Thu, 05 Feb 2026 01:07:16 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vnnpx-00000000bef-2u4M for pgsql-hackers@postgresql.org; Thu, 05 Feb 2026 01:07:15 +0000 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-c62239decbeso110836a12.2 for ; Wed, 04 Feb 2026 17:07:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770253633; x=1770858433; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=4ZEa9faMwPeXkjlih5UByqLFnEVWQvkeKrQwdgj7VYE=; b=jXRD0zNXtwVwhTGAAcRoHPHUM1Utvea5if8t4dXmAnJpfoHP45H0Njm4SfLuz4aQDB c6WSAwywRxALVRlnB1mhM10E3iqVPWKhWbPqk3W4fYQdNlXUO4/931bZO3ZH6mLctWWo DoskHfOD5mG8itWWZqGghqkFeTBwv0D7VUBaKrCI7vfAkIXrCkDS7ZGdJzaCtl5+6Yi6 njxQaJ8KhEhllj8sxI7rA8DxSrOfDW34E+Aa08oCLheUhLvMyGqgI3tS6n/LDI+THwJD TRLyCKPiVQ5NvKg6s4HZjqxbd03EQO+ivNW1/tROvQtsta/C4kpt0TY6BwVOqnGzSsjo MZAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770253633; x=1770858433; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=4ZEa9faMwPeXkjlih5UByqLFnEVWQvkeKrQwdgj7VYE=; b=RsNYrDU4OOw22apm2fkndFviFiqCiorvTAurtDjf6H/wpCF77CU8qeuP2UAsBoBsk7 ybKbCr+zXNLUxxVyw/JldtwZRf3rPdxI9OcD3AtDtbTU6K+86RrCiSkEfQAEJpCRsvYb uP7/wNFmPGPekz6Wph7IYVs640/yu9T4faNowB3PWYbXryCa9ko7i3D68GLndoq+8EsA Oxj75iQRiWtyrZqC1spNghIPhX2CxA6p1/ocSulVA9svz8JY2qhs1qkiIoZPomva84Bg kHcLMqZ2ULkp+4gU8lJOsElg6b9dIhDvwjDPw/xE5R/bG05MIjrbMuRLxwOEGnQYKUlu YMqQ== X-Forwarded-Encrypted: i=1; AJvYcCV/Bau0FhuK/9gDpf8bl7nTue89CEwZunZ27BMw2Vb/F2TF5xaJW4dOnZAZtS67Ka10rCWiv9xIRVXWBH0Q@postgresql.org X-Gm-Message-State: AOJu0Yzlb6Ia4RGWryj3l3a5rAwH7f3iuaW/STeiOTES7uklxZZLpgV3 ArZPoVfkxWKta87FYaNWEGOBPoygu2elxxKFwG/by2pQ/sEBEnVFyFaW X-Gm-Gg: AZuq6aLRZ2eRgz0mTKtjKa704ZH06mIWn8oM8ahRPo8Wf+8IwQ5xCds9KmVDv01Mq7B 0NudPBO5wr8qOSrgJu08tI8nAwcPCUvUyKV0AzreplFE7WkhV4PHCHH5mcV3UBygEx/+DUfTwvZ nkpFMh9aRFwpgJVe85a5IF22hg2CbrFyDIJXR7vijSxcKqOkG9LSFQ9lEf+m0JKLJL+SDJWjmhT gCMJB1kt7kw4+c8eQZrv9lUNYHDeMRnyZVfrymY5Mfdbpfz/rOZaKHU2dxFEj7INmmLum/4msPv SAQvKLNZ3mOat0O4dvnNr2aC/YU3shy0bLHk1ubaBLuCm9blazRRpM7EiKC3x8s4d0taKbFADoY 920KG9UUHwJWlqlKwHzp69A4+OfcW/sKzNKFIrzW/Sw6ESbkiLYUwUO6yUzP7DzIeyaRR/TB/+V Sp+Ok2h/zJMx9hJd/NaHk= X-Received: by 2002:a17:902:f684:b0:2a0:acca:f3f0 with SMTP id d9443c01a7336-2a93400c9damr56950985ad.49.1770253632730; Wed, 04 Feb 2026 17:07:12 -0800 (PST) Received: from smtpclient.apple ([45.32.121.103]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a933851341sm36039315ad.4.2026.02.04.17.07.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Feb 2026 17:07:11 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.300.41.1.7\)) Subject: Re: Pasword expiration warning From: Chao Li In-Reply-To: Date: Thu, 5 Feb 2026 09:06:27 +0800 Cc: Euler Taveira , Peter Eisentraut , Gilles Darold , Zsolt Parragi , japin , Yuefei Shi , songjinzhou , pgsql-hackers , Andrew Dunstan , Tom Lane , liu xiaohui , Steven Niu Content-Transfer-Encoding: quoted-printable Message-Id: <6E83A384-89B0-4141-887F-E54C02B2CACE@gmail.com> References: <197512e0-8116-4776-a600-822d29ee68a6@darold.net> <1f4d0b80-3fea-4f4d-8d33-a652ea23e90b@eisentraut.org> <5798afb7-b10c-436f-987e-14fb625df7d0@app.fastmail.com> To: Nathan Bossart X-Mailer: Apple Mail (2.3864.300.41.1.7) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Feb 5, 2026, at 06:15, Nathan Bossart = wrote: >=20 > On Wed, Feb 04, 2026 at 06:12:07PM -0300, Euler Taveira wrote: >> That's correct. You should use ngettext(). Using the plural form = means better >> translation. Looking at some messages in the catalog, the developers = tend to >> ignore the fact that the sentence has a plural form too. Sometimes it = is hard >> to write a message if multiple parts of the message have plural form. = I >> completely understand your resistance. >=20 > Please pardon the brain fade; I'd forgotten about ngettext() and = missed > your previous message. Here is an updated patch. >=20 > --=20 > nathan > Hi Nathan, Thanks for the patch. I think this is a very helpful addition. I=E2=80=99v= e reviewed v16 and it looks solid overall. I only have a few small = comments. 1 ``` +{ name =3D> 'password_expiration_warning_threshold', type =3D> 'int', = context =3D> 'PGC_SIGHUP', group =3D> 'CONN_AUTH_AUTH', + short_desc =3D> 'Time before password expiration warnings.', + long_desc =3D> '0 means not to emit these warnings.', + flags =3D> 'GUC_UNIT_S', + variable =3D> 'password_expiration_warning_threshold', + boot_val =3D> '604800', + min =3D> '0', + max =3D> 'INT_MAX', +}, ```=20 * 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. * 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 =E2=80=94 for = example, typing `70d` instead of `7d`. 2 ``` +#password_expiration_warning_threshold =3D 7d # time before expiration = warnings ``` In postgresql.conf.sample, should we also mention that setting this to 0 = disables the warning? 3 ``` +void +StoreConnectionWarning(char *msg, char *detail) +{ + MemoryContext oldcontext; + + Assert(msg); + + if (ConnectionWarningsEmitted) + elog(ERROR, "StoreConnectionWarning() called after = EmitConnectionWarnings()"); + + oldcontext =3D MemoryContextSwitchTo(TopMemoryContext); + + MyProcPort->warning_msgs =3D lappend(MyProcPort->warning_msgs, = msg); + MyProcPort->warning_details =3D = lappend(MyProcPort->warning_details, detail); + + MemoryContextSwitchTo(oldcontext); +} ``` 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=E2=80=99t guaranteed. I wonder if it would be better for this function to pstrdup() both msg = and detail internally, so that ownership and lifetime are fully = contained here. If so, the arguments could also be declared as `const = char *`. With that change, the explicit TopMemoryContext switch in = get_role_password() could likely be avoided. 4 ``` + /* + * If we're past rolvaliduntil, the connection attempt = should fail, so + * update logdetail and return NULL. + */ + if (expire_time < 0) + { + *logdetail =3D psprintf(_("User \"%s\" has an = expired password."), + role); + return NULL; + } ``` Should this be `expire_time <=3D 0` instead? As written, when = `expire_time =3D=3D 0` the user would get a warning like =E2=80=9Cpassword= will expire in less than 1 minute=E2=80=9D, which feels slightly odd. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/