From 9ac5bafa5435e26467ba4240144a53c50daf4c2d Mon Sep 17 00:00:00 2001 From: eaglegai Date: Wed, 10 Apr 2024 18:54:33 +0800 Subject: [PATCH] add "min password length" check for pdbedit when adding users --- source3/utils/pdbedit.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index ede4671..497aa04 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -760,6 +760,7 @@ static int new_user(const char *username, const char *fullname, struct dom_sid u_sid; int flags; int ret = -1; + uint32_t value; tosctx = talloc_tos(); if (!tosctx) { @@ -790,6 +791,16 @@ static int new_user(const char *username, const char *fullname, goto done; } + if(!account_policy_get(PDB_POLICY_MIN_PASSWORD_LEN, &value)) { + fprintf (stderr, "Failed to get min password length!\n"); + goto done; + } + + if(value > strlen(pwd1)) { + fprintf (stderr, "Password is too short!\n"); + goto done; + } + flags = LOCAL_ADD_USER | LOCAL_SET_PASSWORD; status = local_password_change(username, flags, pwd1, &err, &msg); -- 2.33.0