Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dadigang
Ventoy
Commits
9852252a
Commit
9852252a
authored
Oct 07, 2022
by
longpanda
Browse files
Merge branch 'master' of
https://github.com/ventoy/Ventoy
parents
0585d83a
ebe0b7d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
3 deletions
+56
-3
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
+56
-3
No files found.
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
View file @
9852252a
...
...
@@ -2183,6 +2183,59 @@ int ventoy_fill_data(grub_uint32_t buflen, char *buffer)
return
len
;
}
static
int
ventoy_password_get
(
char
buf
[],
unsigned
buf_size
)
{
unsigned
i
,
cur_len
=
0
;
int
key
;
struct
grub_term_coordinate
*
pos
=
grub_term_save_pos
();
while
(
1
)
{
key
=
grub_getkey
();
if
(
key
==
'\n'
||
key
==
'\r'
)
break
;
if
(
key
==
GRUB_TERM_ESC
)
{
cur_len
=
0
;
break
;
}
if
(
key
==
'\b'
)
{
if
(
cur_len
)
{
grub_term_restore_pos
(
pos
);
for
(
i
=
0
;
i
<
cur_len
;
i
++
)
grub_xputs
(
" "
);
grub_term_restore_pos
(
pos
);
cur_len
--
;
for
(
i
=
0
;
i
<
cur_len
;
i
++
)
grub_xputs
(
"*"
);
grub_refresh
();
}
continue
;
}
if
(
!
grub_isprint
(
key
))
continue
;
if
(
cur_len
+
2
<
buf_size
)
buf
[
cur_len
++
]
=
key
;
grub_xputs
(
"*"
);
grub_refresh
();
}
grub_memset
(
buf
+
cur_len
,
0
,
buf_size
-
cur_len
);
grub_xputs
(
"
\n
"
);
grub_refresh
();
grub_free
(
pos
);
return
(
key
!=
GRUB_TERM_ESC
);
}
int
ventoy_check_password
(
const
vtoy_password
*
pwd
,
int
retry
)
{
int
offset
;
...
...
@@ -2198,7 +2251,7 @@ int ventoy_check_password(const vtoy_password *pwd, int retry)
if
(
pwd
->
type
==
VTOY_PASSWORD_TXT
)
{
grub
_password_get
(
input
,
128
);
ventoy
_password_get
(
input
,
128
);
if
(
grub_strcmp
(
pwd
->
text
,
input
)
==
0
)
{
return
0
;
...
...
@@ -2206,7 +2259,7 @@ int ventoy_check_password(const vtoy_password *pwd, int retry)
}
else
if
(
pwd
->
type
==
VTOY_PASSWORD_MD5
)
{
grub
_password_get
(
input
,
128
);
ventoy
_password_get
(
input
,
128
);
grub_crypto_hash
(
GRUB_MD_MD5
,
md5
,
input
,
grub_strlen
(
input
));
if
(
grub_memcmp
(
pwd
->
md5
,
md5
,
16
)
==
0
)
{
...
...
@@ -2216,7 +2269,7 @@ int ventoy_check_password(const vtoy_password *pwd, int retry)
else
if
(
pwd
->
type
==
VTOY_PASSWORD_SALT_MD5
)
{
offset
=
(
int
)
grub_snprintf
(
input
,
128
,
"%s"
,
pwd
->
salt
);
grub
_password_get
(
input
+
offset
,
128
);
ventoy
_password_get
(
input
+
offset
,
128
);
grub_crypto_hash
(
GRUB_MD_MD5
,
md5
,
input
,
grub_strlen
(
input
));
if
(
grub_memcmp
(
pwd
->
md5
,
md5
,
16
)
==
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