mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-02-10 05:08:13 -05:00
Add isopwd wimpwd efipwd imgpwd vhdpwd vtoypwd option in password plugin (#898)
This commit is contained in:
parent
d07aa6ce07
commit
672632a0c2
@ -134,7 +134,7 @@ static const char *g_menu_class[] =
|
|||||||
"vtoyiso", "vtoywim", "vtoyefi", "vtoyimg", "vtoyvhd", "vtoyvtoy"
|
"vtoyiso", "vtoywim", "vtoyefi", "vtoyimg", "vtoyvhd", "vtoyvtoy"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *g_menu_prefix[] =
|
const char *g_menu_prefix[img_type_max] =
|
||||||
{
|
{
|
||||||
"iso", "wim", "efi", "img", "vhd", "vtoy"
|
"iso", "wim", "efi", "img", "vhd", "vtoy"
|
||||||
};
|
};
|
||||||
|
@ -194,12 +194,14 @@ typedef struct ventoy_iso9660_vd
|
|||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
#define img_type_iso 0
|
#define img_type_start 0
|
||||||
#define img_type_wim 1
|
#define img_type_iso 0
|
||||||
#define img_type_efi 2
|
#define img_type_wim 1
|
||||||
#define img_type_img 3
|
#define img_type_efi 2
|
||||||
#define img_type_vhd 4
|
#define img_type_img 3
|
||||||
#define img_type_vtoy 5
|
#define img_type_vhd 4
|
||||||
|
#define img_type_vtoy 5
|
||||||
|
#define img_type_max 6
|
||||||
|
|
||||||
typedef struct img_info
|
typedef struct img_info
|
||||||
{
|
{
|
||||||
@ -282,6 +284,7 @@ extern ventoy_img_chunk_list g_img_chunk_list;
|
|||||||
extern ventoy_img_chunk_list g_wimiso_chunk_list;
|
extern ventoy_img_chunk_list g_wimiso_chunk_list;
|
||||||
extern char *g_wimiso_path;
|
extern char *g_wimiso_path;
|
||||||
extern char g_arch_mode_suffix[64];
|
extern char g_arch_mode_suffix[64];
|
||||||
|
extern const char *g_menu_prefix[img_type_max];
|
||||||
|
|
||||||
extern int g_ventoy_debug;
|
extern int g_ventoy_debug;
|
||||||
void ventoy_debug(const char *fmt, ...);
|
void ventoy_debug(const char *fmt, ...);
|
||||||
|
@ -43,6 +43,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
|||||||
char g_arch_mode_suffix[64];
|
char g_arch_mode_suffix[64];
|
||||||
static char g_iso_disk_name[128];
|
static char g_iso_disk_name[128];
|
||||||
static vtoy_password g_boot_pwd;
|
static vtoy_password g_boot_pwd;
|
||||||
|
static vtoy_password g_file_type_pwd[img_type_max];
|
||||||
static install_template *g_install_template_head = NULL;
|
static install_template *g_install_template_head = NULL;
|
||||||
static dud *g_dud_head = NULL;
|
static dud *g_dud_head = NULL;
|
||||||
static menu_password *g_pwd_head = NULL;
|
static menu_password *g_pwd_head = NULL;
|
||||||
@ -809,8 +810,26 @@ static int ventoy_plugin_parse_pwdstr(char *pwdstr, vtoy_password *pwd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ventoy_plugin_get_pwd_type(const char *pwd)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char pwdtype[64];
|
||||||
|
|
||||||
|
for (i = 0; pwd && i < (int)ARRAY_SIZE(g_menu_prefix); i++)
|
||||||
|
{
|
||||||
|
grub_snprintf(pwdtype, sizeof(pwdtype), "%spwd", g_menu_prefix[i]);
|
||||||
|
if (grub_strcmp(pwdtype, pwd) == 0)
|
||||||
|
{
|
||||||
|
return img_type_start + i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk)
|
static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk)
|
||||||
{
|
{
|
||||||
|
int type = -1;
|
||||||
const char *iso = NULL;
|
const char *iso = NULL;
|
||||||
const char *pwd = NULL;
|
const char *pwd = NULL;
|
||||||
VTOY_JSON *pNode = NULL;
|
VTOY_JSON *pNode = NULL;
|
||||||
@ -844,6 +863,10 @@ static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk)
|
|||||||
{
|
{
|
||||||
ventoy_plugin_parse_pwdstr(pNode->unData.pcStrVal, &g_boot_pwd);
|
ventoy_plugin_parse_pwdstr(pNode->unData.pcStrVal, &g_boot_pwd);
|
||||||
}
|
}
|
||||||
|
else if ((type = ventoy_plugin_get_pwd_type(pNode->pcName)) >= 0)
|
||||||
|
{
|
||||||
|
ventoy_plugin_parse_pwdstr(pNode->unData.pcStrVal, g_file_type_pwd + type);
|
||||||
|
}
|
||||||
else if (pNode->pcName && grub_strcmp("menupwd", pNode->pcName) == 0)
|
else if (pNode->pcName && grub_strcmp("menupwd", pNode->pcName) == 0)
|
||||||
{
|
{
|
||||||
for (pCNode = pNode->pstChild; pCNode; pCNode = pCNode->pstNext)
|
for (pCNode = pNode->pstChild; pCNode; pCNode = pCNode->pstNext)
|
||||||
@ -888,6 +911,7 @@ static int ventoy_plugin_pwd_entry(VTOY_JSON *json, const char *isodisk)
|
|||||||
|
|
||||||
static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
|
static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
|
||||||
{
|
{
|
||||||
|
int type = -1;
|
||||||
char *pos = NULL;
|
char *pos = NULL;
|
||||||
const char *iso = NULL;
|
const char *iso = NULL;
|
||||||
const char *pwd = NULL;
|
const char *pwd = NULL;
|
||||||
@ -913,6 +937,17 @@ static int ventoy_plugin_pwd_check(VTOY_JSON *json, const char *isodisk)
|
|||||||
grub_printf("Invalid bootpwd.\n");
|
grub_printf("Invalid bootpwd.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ((type = ventoy_plugin_get_pwd_type(pNode->pcName)) >= 0)
|
||||||
|
{
|
||||||
|
if (0 == ventoy_plugin_parse_pwdstr(pNode->unData.pcStrVal, NULL))
|
||||||
|
{
|
||||||
|
grub_printf("%s:<%s>\n", pNode->pcName, pNode->unData.pcStrVal);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
grub_printf("Invalid pwd <%s>\n", pNode->unData.pcStrVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (pNode->pcName && grub_strcmp("menupwd", pNode->pcName) == 0)
|
else if (pNode->pcName && grub_strcmp("menupwd", pNode->pcName) == 0)
|
||||||
{
|
{
|
||||||
grub_printf("\n");
|
grub_printf("\n");
|
||||||
@ -2475,20 +2510,45 @@ int ventoy_plugin_load_dud(dud *node, const char *isopart)
|
|||||||
|
|
||||||
static const vtoy_password * ventoy_plugin_get_password(const char *isopath)
|
static const vtoy_password * ventoy_plugin_get_password(const char *isopath)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
int len;
|
int len;
|
||||||
|
const char *pos = NULL;
|
||||||
menu_password *node = NULL;
|
menu_password *node = NULL;
|
||||||
|
|
||||||
if ((!g_pwd_head) || (!isopath))
|
if (!isopath)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = (int)grub_strlen(isopath);
|
if (g_pwd_head)
|
||||||
for (node = g_pwd_head; node; node = node->next)
|
|
||||||
{
|
{
|
||||||
if (node->pathlen == len && ventoy_strncmp(node->isopath, isopath, len) == 0)
|
len = (int)grub_strlen(isopath);
|
||||||
|
for (node = g_pwd_head; node; node = node->next)
|
||||||
{
|
{
|
||||||
return &(node->password);
|
if (node->pathlen == len && ventoy_strncmp(node->isopath, isopath, len) == 0)
|
||||||
|
{
|
||||||
|
return &(node->password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (*isopath)
|
||||||
|
{
|
||||||
|
if (*isopath == '.')
|
||||||
|
{
|
||||||
|
pos = isopath;
|
||||||
|
}
|
||||||
|
isopath++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos)
|
||||||
|
{
|
||||||
|
for (i = 0; i < (int)ARRAY_SIZE(g_menu_prefix); i++)
|
||||||
|
{
|
||||||
|
if (g_file_type_pwd[i].type && 0 == grub_strcasecmp(pos + 1, g_menu_prefix[i]))
|
||||||
|
{
|
||||||
|
return g_file_type_pwd + i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user