Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sucs-site
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Imran Hussain
sucs-site
Commits
b0561c03
Commit
b0561c03
authored
16 years ago
by
Justin Mitchell
Browse files
Options
Downloads
Patches
Plain Diff
Use cracklib for password checking and feedback the reason to the user
parent
e798fbfe
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
components/options.php
+7
-1
7 additions, 1 deletion
components/options.php
lib/validation.php
+34
-0
34 additions, 0 deletions
lib/validation.php
with
41 additions
and
1 deletion
components/options.php
+
7
−
1
View file @
b0561c03
...
...
@@ -26,11 +26,17 @@ function changePassword ($oldpass, $newpass1, $newpass2) {
trigger_error
(
"New passwords do not match"
,
E_USER_WARNING
);
return
FALSE
;
}
/*
if (!strongPassword($newpass1)) {
trigger_error("New password is too weak.", E_USER_WARNING);
return FALSE;
}
*/
$reason
=
weakPassword
(
$newpass1
);
if
(
$reason
!==
FALSE
)
{
trigger_error
(
"New password is weak:
$reason
"
,
E_USER_WARNING
);
return
FALSE
;
}
if
(
!
(
$ldap
=
@
ldap_connect
(
"ldap://localhost"
)))
{
trigger_error
(
"LDAP connect failed"
,
E_USER_ERROR
);
...
...
This diff is collapsed.
Click to expand it.
lib/validation.php
+
34
−
0
View file @
b0561c03
...
...
@@ -30,6 +30,7 @@ function validEmail ($email)
// test whether a password is considered Strong Enough
// ideally we'd want to use cracklib or something here, but no RPM for the php bindings :-(
// dont use this, use weakPassword instead it uses cracklib
function
strongPassword
(
$pass
)
{
// you call this a password? my cat could bruteforce this.
...
...
@@ -61,4 +62,37 @@ function strongPassword ($pass) {
}
}
# Use cracklib to check for weak passwords.
# returns FALSE if the password is good i.e. not weak
# otherwise returns a string saying why its weak
function
weakPassword
(
$password
)
{
// Try fedora then debian known paths
if
(
file_exists
(
"/usr/sbin/cracklib-check"
))
$cracklib
=
"/usr/sbin/cracklib-check"
;
else
if
(
file_exists
(
"/usr/sbin/crack_testlib"
))
$cracklib
=
"/usr/sbin/crack_testlib"
;
else
return
"Cannot find cracklib"
;
$proc
=
proc_open
(
$cracklib
,
array
(
0
=>
array
(
"pipe"
,
"r"
),
1
=>
array
(
"pipe"
,
"w"
)),
$pipes
,
'/tmp/'
,
NULL
);
if
(
!
is_resource
(
$proc
))
{
return
"Cannot find cracklib"
;
}
fwrite
(
$pipes
[
0
],
$password
);
fclose
(
$pipes
[
0
]);
$last
=
""
;
do
{
$last
=
fgets
(
$pipes
[
1
]);
if
(
$last
!==
FALSE
)
$answer
=
trim
(
$last
);
}
while
(
$last
!==
FALSE
);
fclose
(
$pipes
[
1
]);
proc_close
(
$proc
);
$answer
=
substr
(
strrchr
(
$answer
,
":"
),
2
);
if
(
strtolower
(
$answer
)
==
"ok"
)
return
FALSE
;
if
(
$answer
==
""
)
return
(
"Empty password"
);
return
$answer
;
}
?>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment