Report this LUKS passphrase request reason as resize (#59)

So far when prompting for the LUKS passphrase the dialog always looks
like this:

    +------------------------------------------------+
    |           LUKS Passphrase /dev/sdb1            |
    +------------------------------------------------+
    | Enter LUKS passphrase to open /dev/sdb1        |
    | Passphrase:    [                             ] |
    |                                                |
    |                                                |
    |                          [ Cancel ] [ Unlock ] |
    +------------------------------------------------+

Specifically the first line of the dialog says the reason to provide the
passphrase is to open the encryption mapping.  Now the passphrase may
also be requested when resizing the encryption mapping, as part of a
resize of check operation, show the appropriate reason in the password
dialog.

Closes #59 - Resize of LUKS2 encrypted file system fails with "Nothing
             to read on input"
This commit is contained in:
Mike Fleetwood 2021-04-02 11:33:37 +01:00 committed by Curtis Gedak
parent 80624bfd40
commit 5752682c12
3 changed files with 14 additions and 8 deletions

View File

@ -30,7 +30,7 @@ namespace GParted
class DialogPasswordEntry : public Gtk::Dialog
{
public:
DialogPasswordEntry( const Partition & partition );
DialogPasswordEntry(const Partition& partition, const Glib::ustring& reason);
~DialogPasswordEntry();
const char * get_password();
void set_error_message( const Glib::ustring & message );

View File

@ -27,7 +27,7 @@
namespace GParted
{
DialogPasswordEntry::DialogPasswordEntry( const Partition & partition )
DialogPasswordEntry::DialogPasswordEntry(const Partition& partition, const Glib::ustring& reason)
{
this->set_resizable( false );
this->set_size_request( 400, -1 );
@ -41,10 +41,8 @@ DialogPasswordEntry::DialogPasswordEntry( const Partition & partition )
vbox->set_spacing( 5 );
get_vbox()->pack_start( *vbox, Gtk::PACK_SHRINK );
// Line 1: "Enter LUKS passphrase to open /dev/sda1"
vbox->pack_start( *Utils::mk_label(
Glib::ustring::compose( _("Enter LUKS passphrase to open %1"), partition.get_path() ) ),
Gtk::PACK_SHRINK );
// Line 1: Reason message, e.g. "Enter LUKS passphrase to open /dev/sda1"
vbox->pack_start(*Utils::mk_label(reason), Gtk::PACK_SHRINK);
// Line 2: "Passphrase: [ ]"
// (Horizontal box holding prompt and entry box)

View File

@ -2137,7 +2137,10 @@ bool Win_GParted::ask_for_password_for_encrypted_resize_as_required(const Partit
// correct and don't re-prompt when it will be correct 99.9% of the time.
return true;
DialogPasswordEntry dialog(partition);
DialogPasswordEntry dialog(partition,
/* TO TRANSLATORS: looks like Enter LUKS passphrase to resize /dev/sda1 */
Glib::ustring::compose(_("Enter LUKS passphrase to resize %1"),
partition.get_path()));
dialog.set_transient_for(*this);
bool success = false;
do
@ -2781,7 +2784,12 @@ void Win_GParted::toggle_crypt_busy_state()
break;
// Open password dialog and attempt to unlock LUKS mapping.
DialogPasswordEntry dialog( *selected_partition_ptr );
DialogPasswordEntry dialog(*selected_partition_ptr,
/* TO TRANSLATORS: looks like
* Enter LUKS passphrase to open /dev/sda1
*/
Glib::ustring::compose(_("Enter LUKS passphrase to open %1"),
selected_partition_ptr->get_path()));
dialog.set_transient_for( *this );
do
{