From 35d57011e912d92ef564870c02b895ca9e7e556d Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Sat, 3 Dec 2016 09:58:40 +0000 Subject: [PATCH] Add bug checks into format operation methods (#774818) Ensure pre-condition of never being passed a Partition object containing an open LUKS encryption mapping is met for format operation related methods. Bug 774818 - Implement LUKS read-write actions NOT requiring a passphrase --- src/GParted_Core.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index ff84391e..78fc1907 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -2036,6 +2036,14 @@ bool GParted_Core::create_partition( Partition & new_partition, OperationDetail bool GParted_Core::create_filesystem( const Partition & partition, OperationDetail & operationdetail ) { + if ( partition.filesystem == FS_LUKS && partition.busy ) + { + operationdetail.add_child( OperationDetail( + GPARTED_BUG + ": " + _("partition contains open LUKS encryption for a create file system only step"), + STATUS_ERROR, FONT_ITALIC ) ); + return false; + } + /*TO TRANSLATORS: looks like create new ext3 file system */ operationdetail .add_child( OperationDetail( String::ucompose( _("create new %1 file system"), @@ -2067,6 +2075,14 @@ bool GParted_Core::create_filesystem( const Partition & partition, OperationDeta bool GParted_Core::format( const Partition & partition, OperationDetail & operationdetail ) { + if ( partition.filesystem == FS_LUKS && partition.busy ) + { + operationdetail.add_child( OperationDetail( + GPARTED_BUG + ": " + _("partition contains open LUKS encryption for a format file system only step"), + STATUS_ERROR, FONT_ITALIC ) ); + return false; + } + if ( partition .filesystem == FS_CLEARED ) return erase_filesystem_signatures( partition, operationdetail ) ; else @@ -2122,6 +2138,14 @@ bool GParted_Core::delete_partition( const Partition & partition, OperationDetai bool GParted_Core::remove_filesystem( const Partition & partition, OperationDetail & operationdetail ) { + if ( partition.filesystem == FS_LUKS && partition.busy ) + { + operationdetail.add_child( OperationDetail( + GPARTED_BUG + ": " + _("partition contains open LUKS encryption for a delete file system only step"), + STATUS_ERROR, FONT_ITALIC ) ); + return false; + } + bool success = true ; FileSystem* p_filesystem = NULL ; @@ -3570,6 +3594,14 @@ bool GParted_Core::filesystem_resize_disallowed( const Partition & partition ) bool GParted_Core::erase_filesystem_signatures( const Partition & partition, OperationDetail & operationdetail ) { + if ( partition.filesystem == FS_LUKS && partition.busy ) + { + operationdetail.add_child( OperationDetail( + GPARTED_BUG + ": " + _("partition contains open LUKS encryption for an erase file system signatures only step"), + STATUS_ERROR, FONT_ITALIC ) ); + return false; + } + bool overall_success = false ; operationdetail .add_child( OperationDetail( String::ucompose( _("clear old file system signatures in %1"),