[gnome-disk-utility/gnome-3-24] Fix wrong behavior of filesystem creation dialog
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/gnome-3-24] Fix wrong behavior of filesystem creation dialog
- Date: Fri, 5 May 2017 14:37:39 +0000 (UTC)
commit 855d79e15909334d57906bbfd306c9ebf55e0336
Author: Kai Lüke <kailueke riseup net>
Date: Mon Apr 3 20:47:54 2017 +0200
Fix wrong behavior of filesystem creation dialog
As soon as a passphrase was entered the resulting filesystem was always
encrypted even if the selection was already changed to a non-luks option.
This is mainly due to the fact that luks+ext4 results in ext4 as fstype
and the decision to encrypt is just based on the passphrase length.
A new encryption property is therefore introduced to distinguish between
the cases instead of always clearing the passphrase entry in the dialog
as soon as the selection is changed. It should be better to handle and
pave the way for a split from the entangled LUKS+ext4 option.
https://bugzilla.gnome.org/show_bug.cgi?id=732566
src/disks/gducreatefilesystemwidget.c | 26 ++++++++++++++++++++++++++
src/disks/gducreatefilesystemwidget.h | 1 +
src/disks/gducreatepartitiondialog.c | 4 +++-
src/disks/gduformatvolumedialog.c | 4 +++-
4 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/src/disks/gducreatefilesystemwidget.c b/src/disks/gducreatefilesystemwidget.c
index 107268a..3793587 100644
--- a/src/disks/gducreatefilesystemwidget.c
+++ b/src/disks/gducreatefilesystemwidget.c
@@ -49,6 +49,7 @@ struct _GduCreateFilesystemWidget
gchar *fstype;
gchar *name;
gchar *passphrase;
+ gboolean encrypt;
gboolean has_info;
};
@@ -66,6 +67,7 @@ enum
PROP_FSTYPE,
PROP_NAME,
PROP_PASSPHRASE,
+ PROP_ENCRYPT,
PROP_HAS_INFO
};
@@ -128,6 +130,10 @@ gdu_create_filesystem_widget_get_property (GObject *object,
g_value_set_string (value, widget->passphrase);
break;
+ case PROP_ENCRYPT:
+ g_value_set_boolean (value, widget->encrypt);
+ break;
+
case PROP_HAS_INFO:
g_value_set_boolean (value, widget->has_info);
break;
@@ -175,6 +181,7 @@ update (GduCreateFilesystemWidget *widget)
gboolean show_filesystem_widgets = FALSE;
gboolean show_passphrase_widgets = FALSE;
gboolean has_info = FALSE;
+ gboolean encrypt = FALSE;
const gchar *fstype = NULL;
const gchar *name = NULL;
const gchar *passphrase = NULL;
@@ -202,6 +209,7 @@ update (GduCreateFilesystemWidget *widget)
else if (g_strcmp0 (id, "luks+ext4") == 0)
{
fstype = "ext4";
+ encrypt = TRUE;
/* Encrypted, compatible with Linux (LUKS + ext4) */
show_passphrase_widgets = TRUE;
if (strlen (gtk_entry_get_text (GTK_ENTRY (widget->passphrase_entry))) > 0)
@@ -304,6 +312,11 @@ update (GduCreateFilesystemWidget *widget)
widget->has_info = has_info;
g_object_notify (G_OBJECT (widget), "has-info");
}
+ if (widget->encrypt != encrypt)
+ {
+ widget->encrypt = encrypt;
+ g_object_notify (G_OBJECT (widget), "encrypt");
+ }
g_object_thaw_notify (G_OBJECT (widget));
}
@@ -606,6 +619,12 @@ gdu_create_filesystem_widget_class_init (GduCreateFilesystemWidgetClass *klass)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_ENCRYPT,
+ g_param_spec_boolean ("encrypt", NULL, NULL,
+ FALSE,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
g_object_class_install_property (gobject_class, PROP_HAS_INFO,
g_param_spec_boolean ("has-info", NULL, NULL,
FALSE,
@@ -659,6 +678,13 @@ gdu_create_filesystem_widget_get_fstype (GduCreateFilesystemWidget *widget)
return widget->fstype;
}
+gboolean
+gdu_create_filesystem_widget_get_encrypt (GduCreateFilesystemWidget *widget)
+{
+ g_return_val_if_fail (GDU_IS_CREATE_FILESYSTEM_WIDGET (widget), FALSE);
+ return widget->encrypt;
+}
+
const gchar *
gdu_create_filesystem_widget_get_passphrase (GduCreateFilesystemWidget *widget)
{
diff --git a/src/disks/gducreatefilesystemwidget.h b/src/disks/gducreatefilesystemwidget.h
index 875f2d1..dcd2019 100644
--- a/src/disks/gducreatefilesystemwidget.h
+++ b/src/disks/gducreatefilesystemwidget.h
@@ -27,6 +27,7 @@ const gchar *gdu_create_filesystem_widget_get_name (GduCreateFilesystemWid
const gchar *gdu_create_filesystem_widget_get_erase (GduCreateFilesystemWidget *widget);
const gchar *gdu_create_filesystem_widget_get_fstype (GduCreateFilesystemWidget *widget);
const gchar *gdu_create_filesystem_widget_get_passphrase (GduCreateFilesystemWidget *widget);
+gboolean gdu_create_filesystem_widget_get_encrypt (GduCreateFilesystemWidget *widget);
gboolean gdu_create_filesystem_widget_get_has_info (GduCreateFilesystemWidget *widget);
GtkWidget *gdu_create_filesystem_widget_get_name_entry (GduCreateFilesystemWidget *widget);
diff --git a/src/disks/gducreatepartitiondialog.c b/src/disks/gducreatepartitiondialog.c
index ad2d474..92a6e4d 100644
--- a/src/disks/gducreatepartitiondialog.c
+++ b/src/disks/gducreatepartitiondialog.c
@@ -355,6 +355,7 @@ create_partition_cb (GObject *source_object,
const gchar *fstype;
const gchar *name;
const gchar *passphrase;
+ gboolean encrypt;
error = NULL;
if (!udisks_partition_table_call_create_partition_finish (UDISKS_PARTITION_TABLE (source_object),
@@ -386,6 +387,7 @@ create_partition_cb (GObject *source_object,
fstype = gdu_create_filesystem_widget_get_fstype (GDU_CREATE_FILESYSTEM_WIDGET
(data->create_filesystem_widget));
name = gdu_create_filesystem_widget_get_name (GDU_CREATE_FILESYSTEM_WIDGET
(data->create_filesystem_widget));
passphrase = gdu_create_filesystem_widget_get_passphrase (GDU_CREATE_FILESYSTEM_WIDGET
(data->create_filesystem_widget));
+ encrypt = gdu_create_filesystem_widget_get_encrypt (GDU_CREATE_FILESYSTEM_WIDGET
(data->create_filesystem_widget));
/* Not meaningful to create a filesystem if requested to create an extended partition */
if (g_strcmp0 (fstype, "dos_extended") == 0)
@@ -402,7 +404,7 @@ create_partition_cb (GObject *source_object,
/* TODO: need a better way to determine if this should be TRUE */
g_variant_builder_add (&options_builder, "{sv}", "take-ownership", g_variant_new_boolean (TRUE));
}
- if (passphrase != NULL && strlen (passphrase) > 0)
+ if (encrypt && passphrase != NULL && strlen (passphrase) > 0)
g_variant_builder_add (&options_builder, "{sv}", "encrypt.passphrase", g_variant_new_string
(passphrase));
if (erase != NULL)
diff --git a/src/disks/gduformatvolumedialog.c b/src/disks/gduformatvolumedialog.c
index 2e0ca79..e851519 100644
--- a/src/disks/gduformatvolumedialog.c
+++ b/src/disks/gduformatvolumedialog.c
@@ -106,6 +106,7 @@ ensure_unused_cb (UDisksClient *client,
const gchar *fstype;
const gchar *name;
const gchar *passphrase;
+ gboolean encrypt;
if (!gdu_utils_ensure_unused_finish (client, res, NULL))
{
@@ -117,6 +118,7 @@ ensure_unused_cb (UDisksClient *client,
fstype = gdu_create_filesystem_widget_get_fstype (GDU_CREATE_FILESYSTEM_WIDGET
(data->create_filesystem_widget));
name = gdu_create_filesystem_widget_get_name (GDU_CREATE_FILESYSTEM_WIDGET
(data->create_filesystem_widget));
passphrase = gdu_create_filesystem_widget_get_passphrase (GDU_CREATE_FILESYSTEM_WIDGET
(data->create_filesystem_widget));
+ encrypt = gdu_create_filesystem_widget_get_encrypt (GDU_CREATE_FILESYSTEM_WIDGET
(data->create_filesystem_widget));
g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT);
if (name != NULL && strlen (name) > 0)
@@ -126,7 +128,7 @@ ensure_unused_cb (UDisksClient *client,
/* TODO: need a better way to determine if this should be TRUE */
g_variant_builder_add (&options_builder, "{sv}", "take-ownership", g_variant_new_boolean (TRUE));
}
- if (passphrase != NULL && strlen (passphrase) > 0)
+ if (encrypt && passphrase != NULL && strlen (passphrase) > 0)
g_variant_builder_add (&options_builder, "{sv}", "encrypt.passphrase", g_variant_new_string
(passphrase));
if (erase_type != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]