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
749ef5cd
Commit
749ef5cd
authored
Jul 13, 2017
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rc: mock '-h 0' behaviour of pw usermod for easier installer access
parent
76eb058d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
9 deletions
+22
-9
rc.initial.password
src/etc/rc.initial.password
+22
-9
No files found.
src/etc/rc.initial.password
View file @
749ef5cd
...
...
@@ -31,21 +31,34 @@
require_once
(
'config.inc'
);
require_once
(
'auth.inc'
);
$password
=
isset
(
$argv
[
1
])
?
$argv
[
1
]
:
''
;
$confirm
=
isset
(
$argv
[
2
])
?
$argv
[
2
]
:
''
;
$fp
=
fopen
(
'php://stdin'
,
'r'
);
if
(
!
empty
(
$password
)
&&
$password
===
$confirm
)
{
/* the installer needs this code to change the password */
if
(
isset
(
$argv
[
1
])
&&
isset
(
$argv
[
2
])
&&
$argv
[
1
]
===
'-h'
&&
$argv
[
2
]
===
'0'
)
{
$admin_user
=
&
getUserEntryByUID
(
0
);
if
(
$admin_user
)
{
local_user_set_password
(
$admin_user
,
$password
)
;
write_config
(
'Root user reset from console'
);
if
(
!
$admin_user
)
{
echo
"user not found
\n
"
;
exit
(
1
);
}
echo
"new password for user
{
$admin_user
[
'name'
]
}
:"
;
shell_exec
(
'/bin/stty -echo'
);
$password
=
chop
(
fgets
(
$fp
));
shell_exec
(
'/bin/stty echo'
);
echo
"
\n
"
;
if
(
empty
(
$password
))
{
echo
"empty password read
\n
"
;
exit
(
1
);
}
local_user_set_password
(
$admin_user
,
$password
);
local_user_set
(
$admin_user
);
write_config
(
'Root user reset from console'
);
exit
(
0
);
}
$fp
=
fopen
(
'php://stdin'
,
'r'
);
echo
"The root user login behaviour will be restored to its defaults.
\n\n
Do you want to proceed? [y/N]: "
;
if
(
strcasecmp
(
chop
(
fgets
(
$fp
)),
'y'
)
!=
0
)
{
...
...
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