Revision 2bac6019 vl.c
b/vl.c | ||
---|---|---|
6714 | 6714 |
|
6715 | 6715 |
/* password input */ |
6716 | 6716 |
|
6717 |
int qemu_key_check(BlockDriverState *bs, const char *name) |
|
6718 |
{ |
|
6719 |
char password[256]; |
|
6720 |
int i; |
|
6721 |
|
|
6722 |
if (!bdrv_is_encrypted(bs)) |
|
6723 |
return 0; |
|
6724 |
|
|
6725 |
term_printf("%s is encrypted.\n", name); |
|
6726 |
for(i = 0; i < 3; i++) { |
|
6727 |
monitor_readline("Password: ", 1, password, sizeof(password)); |
|
6728 |
if (bdrv_set_key(bs, password) == 0) |
|
6729 |
return 0; |
|
6730 |
term_printf("invalid password\n"); |
|
6731 |
} |
|
6732 |
return -EPERM; |
|
6733 |
} |
|
6734 |
|
|
6717 | 6735 |
static BlockDriverState *get_bdrv(int index) |
6718 | 6736 |
{ |
6719 | 6737 |
BlockDriverState *bs; |
... | ... | |
6731 | 6749 |
static void read_passwords(void) |
6732 | 6750 |
{ |
6733 | 6751 |
BlockDriverState *bs; |
6734 |
int i, j; |
|
6735 |
char password[256]; |
|
6752 |
int i; |
|
6736 | 6753 |
|
6737 | 6754 |
for(i = 0; i < 6; i++) { |
6738 | 6755 |
bs = get_bdrv(i); |
6739 |
if (bs && bdrv_is_encrypted(bs)) { |
|
6740 |
term_printf("%s is encrypted.\n", bdrv_get_device_name(bs)); |
|
6741 |
for(j = 0; j < 3; j++) { |
|
6742 |
monitor_readline("Password: ", |
|
6743 |
1, password, sizeof(password)); |
|
6744 |
if (bdrv_set_key(bs, password) == 0) |
|
6745 |
break; |
|
6746 |
term_printf("invalid password\n"); |
|
6747 |
} |
|
6748 |
} |
|
6756 |
if (bs) |
|
6757 |
qemu_key_check(bs, bdrv_get_device_name(bs)); |
|
6749 | 6758 |
} |
6750 | 6759 |
} |
6751 | 6760 |
|
... | ... | |
7622 | 7631 |
} |
7623 | 7632 |
} |
7624 | 7633 |
|
7625 |
/* Open the virtual parallel flash bloc devices */ |
|
7634 |
/* Open the virtual parallel flash block devices */
|
|
7626 | 7635 |
for(i = 0; i < MAX_PFLASH; i++) { |
7627 | 7636 |
if (pflash_filename[i]) { |
7628 | 7637 |
if (!pflash_table[i]) { |
... | ... | |
7648 | 7657 |
snapshot ? BDRV_O_SNAPSHOT : 0) < 0) { |
7649 | 7658 |
fprintf(stderr, "qemu: could not open SD card image %s\n", |
7650 | 7659 |
sd_filename); |
7651 |
} |
|
7660 |
} else |
|
7661 |
qemu_key_check(bs, sd_filename); |
|
7652 | 7662 |
} |
7653 | 7663 |
|
7654 | 7664 |
register_savevm("timer", 0, 2, timer_save, timer_load, NULL); |
Also available in: Unified diff