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
f7b3bd17
Commit
f7b3bd17
authored
May 15, 2021
by
longpanda
Browse files
Add parent option in password plugin
parent
672632a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
4 deletions
+50
-4
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
+4
-0
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c
+46
-4
No files found.
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
View file @
f7b3bd17
...
...
@@ -906,8 +906,12 @@ typedef struct vtoy_password
grub_uint8_t
md5
[
16
];
}
vtoy_password
;
#define vtoy_menu_pwd_file 0
#define vtoy_menu_pwd_parent 1
typedef
struct
menu_password
{
int
type
;
int
pathlen
;
char
isopath
[
256
];
...
...
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c
View file @
f7b3bd17
...
...
@@ -876,13 +876,21 @@ static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk)
continue
;
}
type
=
vtoy_menu_pwd_file
;
iso
=
vtoy_json_get_string_ex
(
pCNode
->
pstChild
,
"file"
);
if
(
!
iso
)
{
type
=
vtoy_menu_pwd_parent
;
iso
=
vtoy_json_get_string_ex
(
pCNode
->
pstChild
,
"parent"
);
}
pwd
=
vtoy_json_get_string_ex
(
pCNode
->
pstChild
,
"pwd"
);
if
(
iso
&&
pwd
&&
iso
[
0
]
==
'/'
)
{
node
=
grub_zalloc
(
sizeof
(
menu_password
));
if
(
node
)
{
node
->
type
=
type
;
node
->
pathlen
=
grub_snprintf
(
node
->
isopath
,
sizeof
(
node
->
isopath
),
"%s"
,
iso
);
if
(
ventoy_plugin_parse_pwdstr
((
char
*
)
pwd
,
&
(
node
->
password
)))
...
...
@@ -959,8 +967,7 @@ static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
continue
;
}
iso
=
vtoy_json_get_string_ex
(
pCNode
->
pstChild
,
"file"
);
if
(
iso
)
if
((
iso
=
vtoy_json_get_string_ex
(
pCNode
->
pstChild
,
"file"
))
!=
NULL
)
{
pos
=
grub_strchr
(
iso
,
'*'
);
if
(
pos
||
0
==
ventoy_plugin_check_path
(
isodisk
,
iso
))
...
...
@@ -982,6 +989,26 @@ static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
grub_printf
(
"<%s%s> not found
\n
"
,
isodisk
,
iso
);
}
}
else
if
((
iso
=
vtoy_json_get_string_ex
(
pCNode
->
pstChild
,
"parent"
))
!=
NULL
)
{
if
(
ventoy_is_dir_exist
(
"%s%s"
,
isodisk
,
iso
))
{
pwd
=
vtoy_json_get_string_ex
(
pCNode
->
pstChild
,
"pwd"
);
if
(
0
==
ventoy_plugin_parse_pwdstr
((
char
*
)
pwd
,
NULL
))
{
grub_printf
(
"dir:<%s> [%s]
\n
"
,
iso
,
(
pos
?
"*"
:
"OK"
));
grub_printf
(
"pwd:<%s>
\n\n
"
,
pwd
);
}
else
{
grub_printf
(
"Invalid password for <%s>
\n
"
,
iso
);
}
}
else
{
grub_printf
(
"<%s%s> not found
\n
"
,
isodisk
,
iso
);
}
}
else
{
grub_printf
(
"No file item found in json.
\n
"
);
...
...
@@ -2525,9 +2552,24 @@ static const vtoy_password * ventoy_plugin_get_password(const char *isopath)
len
=
(
int
)
grub_strlen
(
isopath
);
for
(
node
=
g_pwd_head
;
node
;
node
=
node
->
next
)
{
if
(
node
->
pathlen
==
len
&&
ventoy_strncmp
(
node
->
isopath
,
isopath
,
len
)
==
0
)
if
(
node
->
type
==
vtoy_menu_pwd_file
)
{
if
(
node
->
pathlen
==
len
&&
ventoy_strncmp
(
node
->
isopath
,
isopath
,
len
)
==
0
)
{
return
&
(
node
->
password
);
}
}
}
for
(
node
=
g_pwd_head
;
node
;
node
=
node
->
next
)
{
if
(
node
->
type
==
vtoy_menu_pwd_parent
)
{
return
&
(
node
->
password
);
if
(
node
->
pathlen
<
len
&&
(
isopath
[
node
->
pathlen
]
==
'/'
)
&&
ventoy_strncmp
(
node
->
isopath
,
isopath
,
node
->
pathlen
)
==
0
)
{
return
&
(
node
->
password
);
}
}
}
}
...
...
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