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 1tCzAV-00ExXj-H8 for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Nov 2024 10:39:42 +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 1tCzAS-004NV4-0j for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Nov 2024 10:39:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tCzAR-004NUw-Np for pgsql-hackers@lists.postgresql.org; Mon, 18 Nov 2024 10:39:40 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tCzAO-002YeV-Gj for pgsql-hackers@lists.postgresql.org; Mon, 18 Nov 2024 10:39:39 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-53a007743e7so3122370e87.1 for ; Mon, 18 Nov 2024 02:39:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731926376; x=1732531176; darn=lists.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=uyreMpuIiDXnofjZ8eGgRz05s7ygwesjvDKBud3AUYw=; b=U3tK5YsbDy9X5XHAOwuamMUNJu9Up6dpa2yB0coKQvQ9ClPo+juy798m4WXWSIhKho Cq9TZWkrhjA4L6TjWYwuavrnt8adAUrKAc7G7Qu/EuQwJFDwdE1UUjEKu8Pv35zxIE8v YXlPtEgNvtDF86TgGn7qb7DBXw50cEc/IHRXtmvhkd0DNfukFBtrUgU5glkqPmxsL64I AGmpPu9/oJzK1nAwcx1W+ngY4AuNzswOdELWDYbdh+qJc5Fc/LNefjMP4mrFfZN467zc 0ByocxzWbEWhlL/nEN58i0Nif9uIb43vMS1PNXSDabm8g2b5kRhh14NY/zmzNDKQ/CDx GBTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731926376; x=1732531176; h=in-reply-to:content-transfer-encoding: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=uyreMpuIiDXnofjZ8eGgRz05s7ygwesjvDKBud3AUYw=; b=v3bgf5Npd8Rue3pmjN2ACHD2UOf4vfg1YyZ3yr6YyStcRwf7pw208YCYxCsmwKC336 jIf3gL2S0OPzQWJbY6O+U2mKITVIBJUm7MoRd85wBHfq5o2cc9i3h9zvMEXA1LTStWTn vhUxGW4+Asn6ePBmcGUu764e1qlGrqnInVIGKDGsEKugV6xwSyUpwm7j6RAeahqvwUn3 c6oagY2FY76UAs7sMUZ+0bF+c0fU9Wm4CniTI7ga1fAF5nEZXvbj72B37PQ21yc9Iweg jXxTZJUrsToM6F2KXH/1Gpnn+de24VnfH6Y2nW/vA2zlN727yQoYE6yh1lgKOjzdUcY8 uu9w== X-Gm-Message-State: AOJu0YyC5WJ06zbWbQWgQOniMWQaKW1IWUP2ClX9AkcQb3CQtRHN7Rbq xzfEdlbMymdMKOYN8h/fbWBB7Tt5A1MFkWcyNenfH9EUJRkCW0kQ X-Google-Smtp-Source: AGHT+IFAeTAH2iq0OzPY7Qk1VFE3KQ/fRcsjnlCGiE11F6GJ2OQC0P8zau1wj5A5zLCPOlJtlxbY7g== X-Received: by 2002:a05:6512:3043:b0:53d:ab21:4e17 with SMTP id 2adb3069b0e04-53dab3c50eamr4578297e87.55.1731926375406; Mon, 18 Nov 2024 02:39:35 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-236-134-5.eu-west-3.compute.amazonaws.com. [15.236.134.5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432da2982fasm156950815e9.36.2024.11.18.02.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2024 02:39:34 -0800 (PST) Date: Mon, 18 Nov 2024 10:39:33 +0000 From: Bertrand Drouvot To: Emanuele Musella Cc: pgsql-hackers@lists.postgresql.org, Tomas Vondra Subject: Re: Parametrization minimum password lenght Message-ID: References: <5702ea42-3599-4062-bd15-3e3c7cc67e6e@vondra.me> <9bd48f6d-dec0-48be-8db3-c3b29be588e7@vondra.me> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Mon, Nov 18, 2024 at 10:01:41AM +0100, Emanuele Musella wrote: > Hi all, > > we have fixed the following warning from the CFbot: > > [07:14:29.637] passwordcheck.c:37:5: error: no previous extern declaration > for non-static variable 'min_password_length' > [-Werror,-Wmissing-variable-declarations] > > > In attach the fixed patch. Thanks for the patch, that looks like a useful feature! A few random comments: === 1 + * Author: Maurizio Boriani + * Author: Emanuele Musella I'm not sure we do that usually. For example, in cb3384a0cb, Fabien Coelho has not been mentioned as an author in contrib/isn/isn.c. === 2 #include "commands/user.h" #include "fmgr.h" #include "libpq/crypt.h" +#include "commands/explain.h" +#include "utils/guc.h" The "includes" should be in the order based on their ASCII value (see 7e735035f2). === 3 +/* min_password_length minimum password length */ I think "/* Minimum password length */ is "enough" for the comment. Also what about adding "/* GUC variables */" on top of it? === 4 (Nit) +static int min_password_length; What about "min_pwd_len" to make it consistent with pwd_has_letter and pwd_has_nonletter for example? === 5 prev_check_password_hook = check_password_hook; check_password_hook = check_password; + + /* Define custom GUC variables. */ + DefineCustomIntVariable("passwordcheck.min_password_length", What about moving the DefineCustomIntVariable before the hooks? (that would be consistent with auto_explain.c, auth_delay.c, autoprewarm.c and pg_stat_statements.c to name a few). === 6 + "8 is default.", I don't think that's needed (that would be visible from pg_settings.extra_desc while it already provides the information through the boot_val field). === 7 + GUC_UNIT_MS, Not the right unit, that should be GUC_UNIT_BYTE because... === 8 postgres=# SET passwordcheck.min_password_length = 4; SET postgres=# create user test with password 'ab1'; ERROR: password is too short But with multibyte in play: postgres=# create user test with password 'äb1'; CREATE ROLE. That's because "strlen(password);" returns the number of bytes. We could make it based on the characters instead by using "pg_mbstrlen()" but that would break the behavior as compared to now. So, I think we just need to make it clear that's bytes instead. === 9 I think that a call to MarkGUCPrefixReserved() is missing (see auto_explain.c for example). === 10 + + In postgresql.conf you may set the minimum password length + by setting passwordcheck.min_password_length = INT. I think that would make sense to add a "Configuration Parameters" section and follow the format done in auto-explain or pg_prewarm for example. === 11 + The default minimum password length if not setted passwordcheck.min_password_length is 8 chars. s/chars/bytes/ (as per === 8 above) Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com