Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
bd2d28c6
Commit
bd2d28c6
authored
Nov 28, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auth: tweak previous, hide implementation details; closes #1282
parent
2a025de4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
17 deletions
+11
-17
auth.inc
src/etc/inc/auth.inc
+10
-8
util.inc
src/etc/inc/util.inc
+0
-8
system_usermanager_passwordmg.php
src/www/system_usermanager_passwordmg.php
+1
-1
No files found.
src/etc/inc/auth.inc
View file @
bd2d28c6
...
...
@@ -488,14 +488,16 @@ function local_user_del($user)
function
local_user_set_password
(
&
$user
,
$password
)
{
$user
[
'password'
]
=
generate_password_hash
(
$password
,
10
);
// Converts ascii to unicode.
$astr
=
(
string
)
$password
;
$ustr
=
''
;
for
(
$i
=
0
;
$i
<
strlen
(
$astr
);
$i
++
)
{
$a
=
ord
(
$astr
{
$i
})
<<
8
;
$ustr
.=
sprintf
(
"%X"
,
$a
);
$cost
=
10
;
$hash
=
password_hash
(
$password
,
PASSWORD_BCRYPT
,
[
'cost'
=>
$cost
]);
if
(
$hash
!==
false
)
{
/*
* $2y$ returned is supported in FreeBSD 11.0 and up,
* but we started with FreeBSD 10.3 so need to fix:
*/
$hash
[
2
]
=
'b'
;
$user
[
'password'
]
=
$hash
;
}
}
...
...
src/etc/inc/util.inc
View file @
bd2d28c6
...
...
@@ -1575,11 +1575,3 @@ function is_install_media()
return
true
;
}
function
generate_password_hash
(
$password
,
$cost
=
10
)
{
$hash
=
password_hash
(
$password
,
PASSWORD_BCRYPT
,
[
"cost"
=>
$cost
]);
// at the moment of writing FreeBSD can't recognise $2y$... as bcrypt, $2b$ is needed
$hash
[
2
]
=
'b'
;
return
$hash
;
}
src/www/system_usermanager_passwordmg.php
View file @
bd2d28c6
...
...
@@ -58,7 +58,7 @@ if (isset($_POST['save'])) {
if
(
count
(
$input_errors
)
==
0
)
{
// all values are okay --> saving changes
$config
[
'system'
][
'user'
][
$userindex
[
$username
]][
'password'
]
=
generate_password_hash
(
$_POST
[
'passwordfld1'
],
10
);
local_user_set_password
(
$config
[
'system'
][
'user'
][
$userindex
[
$username
]],
$_POST
[
'passwordfld1'
]
);
local_user_set
(
$config
[
'system'
][
'user'
][
$userindex
[
$username
]]);
write_config
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment