PostgreSQLのソースコードの修正は、3つ以上の文字を-passwordcheck強化します

ネットワークパスワードレベルを変更する必要があり、データベースのテスト、ソース・プラグインに二次修飾、一部passwordcheckに

1.使用

  • 別のディレクトリの下にpasswordcheck.c ../postgresql-11.4/contrib/passwordcheck
  • コンパイルとインストールのmake && make installを
  • PostgreSQLのプロファイル内の変更(postgresql.confの)
  • shared_preload_libraries = 'passwordcheck'
  • passwordcheck.level = '真'

2.エフェクト

パスワードは十分な長さである場合には、時間の規則に準拠していない、あなたは、新しいユーザーを作成することはできません。

ソースコードを変更3.

https://github.com/Luckyness/passwordcheck

1.参照pg_cron源は、設定ファイル内のパラメータを増加させます

/* 引入扩展 */
#include "utils/guc.h"
……
……
/*
* 配置文件内passwordcheck.level='true' 为需要特殊字符
* passwordcheck.level='false' 为只需要英文和数字
*/
static  bool passwordcheck_level =  false;
……
……
void
_PG_init(void)
{
    /* 定义密码级别参数 */
    DefineCustomBoolVariable(
        "passwordcheck.level",
        gettext_noop("passwordcheck_level true: Password must contain leter, number, special characters;false : Password must contain leter, special characters"),
        NULL,
        &passwordcheck_level,
        false,
        PGC_POSTMASTER,
        GUC_SUPERUSER_ONLY,
        NULL, NULL, NULL);

    /* activate password checks when the module is loaded */
    check_password_hook = check_password;
}

デジタルソースをチェック2. [変更の設定

        if(passwordcheck_level)
        {
            /* check if the password contains both letters and number and specialchar */
            pwd_has_number =  false;
            pwd_has_special =  false;
            pwd_has_letter =  false;
            for (i =  0; i < pwdlen; i++)
            {
                if (isalpha((unsigned  char) password[i]))
                    pwd_has_letter =  true;
                else  if (isdigit((unsigned  char) password[i]))
                    pwd_has_number =  true;
                else
                    pwd_has_special =  true;
            }
            if (!pwd_has_number ||  !pwd_has_letter ||  !pwd_has_special)
                ereport(ERROR,
                        (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                        errmsg("password must contain both letters and number and specialchar")));
        }
        else
        {
            /* check if the password contains both letters and non-letters */
            pwd_has_letter =  false;
            pwd_has_number =  false;
            for (i =  0; i < pwdlen; i++)
            {
                if (isalpha((unsigned  char) password[i]))
                    pwd_has_letter =  true;
                else
                    pwd_has_number =  true;
            }
            if (!pwd_has_letter ||  !pwd_has_number)
                ereport(ERROR,
                        (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                        errmsg("password must contain both letters and nonletters")));
        }

おすすめ

転載: www.cnblogs.com/Luckyness/p/11996834.html