summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-04-16 15:00:54 +0200
committerVolker Lendecke <vl@samba.org>2010-04-17 12:01:18 +0200
commit6f998b4b9a46f48b98b947f79bf9c83ec7a0b9fd (patch)
tree88357f8f692fee019276bdc33e5b081b7cba4c01
parentb0b077f27c8f87dedf8fc7898c54e2c2575c1be6 (diff)
downloadsamba-6f998b4b9a46f48b98b947f79bf9c83ec7a0b9fd.tar.gz
samba-6f998b4b9a46f48b98b947f79bf9c83ec7a0b9fd.tar.bz2
samba-6f998b4b9a46f48b98b947f79bf9c83ec7a0b9fd.zip
s3: Slightly simplify the logic of check_password_complexity()
The whole routine was just one if-branch. Do an early return instead.
-rw-r--r--source3/smbd/chgpasswd.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c
index 2cc2206337..dc58cc27ad 100644
--- a/source3/smbd/chgpasswd.c
+++ b/source3/smbd/chgpasswd.c
@@ -1115,30 +1115,34 @@ NTSTATUS check_password_complexity(const char *username,
enum samPwdChangeReason *samr_reject_reason)
{
TALLOC_CTX *tosctx = talloc_tos();
+ int check_ret;
+ char *cmd;
/* Use external script to check password complexity */
- if (lp_check_password_script() && *(lp_check_password_script())) {
- int check_ret;
- char *cmd;
+ if ((lp_check_password_script() == NULL)
+ || (*(lp_check_password_script()) == '\0')) {
+ return NT_STATUS_OK;
+ }
- cmd = talloc_string_sub(tosctx, lp_check_password_script(), "%u", username);
- if (!cmd) {
- return NT_STATUS_PASSWORD_RESTRICTION;
- }
+ cmd = talloc_string_sub(tosctx, lp_check_password_script(), "%u",
+ username);
+ if (!cmd) {
+ return NT_STATUS_PASSWORD_RESTRICTION;
+ }
- check_ret = smbrunsecret(cmd, password);
- DEBUG(5,("check_password_complexity: check password script (%s) returned [%d]\n",
- cmd, check_ret));
- TALLOC_FREE(cmd);
+ check_ret = smbrunsecret(cmd, password);
+ DEBUG(5,("check_password_complexity: check password script (%s) "
+ "returned [%d]\n", cmd, check_ret));
+ TALLOC_FREE(cmd);
- if (check_ret != 0) {
- DEBUG(1,("check_password_complexity: "
- "check password script said new password is not good enough!\n"));
- if (samr_reject_reason) {
- *samr_reject_reason = SAM_PWD_CHANGE_NOT_COMPLEX;
- }
- return NT_STATUS_PASSWORD_RESTRICTION;
+ if (check_ret != 0) {
+ DEBUG(1,("check_password_complexity: "
+ "check password script said new password is not good "
+ "enough!\n"));
+ if (samr_reject_reason) {
+ *samr_reject_reason = SAM_PWD_CHANGE_NOT_COMPLEX;
}
+ return NT_STATUS_PASSWORD_RESTRICTION;
}
return NT_STATUS_OK;