From 3ef02938760ba8d571de227173d53cb2bbc3cdbe Mon Sep 17 00:00:00 2001 From: Curtis Gedak Date: Wed, 18 Feb 2009 16:19:49 +0000 Subject: [PATCH] Added detection of LUKS encrypted partitions svn path=/trunk/; revision=1071 --- ChangeLog | 13 ++++++++++++- include/Utils.h | 5 +++-- src/DialogFeatures.cc | 10 ++++++---- src/Dialog_Partition_New.cc | 8 +++++--- src/GParted_Core.cc | 34 ++++++++++++++++++++++++++++++---- src/Utils.cc | 4 +++- src/Win_GParted.cc | 8 +++++--- 7 files changed, 64 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 57de2e94..2d804b7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-02-18 Curtis Gedak + + * include/Utils.h, + src/Dialog_Partition_New.cc, + src/DialogFeatures.cc, + src/GParted_Core.cc, + src/Utils.cc, + src/Win_GParted.cc: Added detection of LUKS encrypted partitions. + - Closes GParted bug #490740 + 2009-02-16 Curtis Gedak * src/Dialog_Base_Partition.cc, @@ -20,7 +30,8 @@ 2009-02-11 Curtis Gedak * gparted.in: Fixed typo of "freedeskdesktop" in hal-lock name. - - Thanks to Jonas Pedersen for finding this mistake. + - Thanks to Alain Kalker for discovering this mistake. + - Thanks to Jonas Pedersen for reporting this mistake upstream. - Closes GParted bug #571347 2009-02-09 Curtis Gedak diff --git a/include/Utils.h b/include/Utils.h index 949430df..2f97cdba 100644 --- a/include/Utils.h +++ b/include/Utils.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort +/* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Bart Hakvoort * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -68,7 +68,8 @@ enum FILESYSTEM FS_USED = 18, FS_UNUSED = 19, - FS_LVM2 = 20 + FS_LVM2 = 20, + FS_LUKS = 21 } ; enum SIZE_UNIT diff --git a/src/DialogFeatures.cc b/src/DialogFeatures.cc index 4741eac1..07c1159b 100644 --- a/src/DialogFeatures.cc +++ b/src/DialogFeatures.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort +/* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Bart Hakvoort * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -104,9 +104,11 @@ void DialogFeatures::load_filesystems( const std::vector & FILESYSTEMS ) //fill the features chart with valid file systems for ( unsigned short t = 0; t < FILESYSTEMS .size() ; t++ ) { - //Skip lvm2 and unknown because these are not file systems - if( FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2 || - FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN ) + //Skip luks, lvm2, and unknown because these are not file systems + if ( FILESYSTEMS[ t ] .filesystem == GParted::FS_LUKS || + FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2 || + FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN + ) continue ; show_filesystem( FILESYSTEMS[ t ] ) ; } diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc index 97d2592a..1a2fa6ad 100644 --- a/src/Dialog_Partition_New.cc +++ b/src/Dialog_Partition_New.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort +/* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Bart Hakvoort * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,7 +49,9 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, for ( unsigned int t = this ->FILESYSTEMS .size( ) ; t > 0 ; t-- ) { if ( this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN || - this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2 ) + this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2 || + this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_LUKS + ) this ->FILESYSTEMS .erase( this->FILESYSTEMS .begin() + t ) ; } @@ -287,7 +289,7 @@ void Dialog_Partition_New::Build_Filesystems_Menu( bool only_unformatted ) //fill the file system menu with the file systems (except for extended) for ( unsigned int t = 0 ; t < FILESYSTEMS .size( ) ; t++ ) { - //skip extended (lvm2 and unknown removed in Set_Data()) + //skip extended (luks, lvm2, and unknown removed in Set_Data()) if( FILESYSTEMS[ t ] .filesystem == GParted::FS_EXTENDED ) continue ; menu_filesystem .items() .push_back( diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 3d1e92db..3f57128b 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -131,6 +131,11 @@ void GParted_Core::find_supported_filesystems() fs ->filesystem = GParted::FS_LVM2 ; FILESYSTEMS .push_back( * fs ) ; + //luks encryption-- not a file system + fs = new( FS ) ; + fs ->filesystem = GParted::FS_LUKS ; + FILESYSTEMS .push_back( * fs ) ; + //unknown file system (default when no match is found) fs = new( FS ) ; fs ->filesystem = GParted::FS_UNKNOWN ; @@ -783,7 +788,7 @@ GParted::FILESYSTEM GParted_Core::get_filesystem() //other file systems libparted couldn't detect (i've send patches for these file systems to the parted guys) - // - no patches sent to parted for lvm2 + // - no patches sent to parted for lvm2, or luks char buf[512] ; ped_device_open( lp_device ); @@ -815,6 +820,22 @@ GParted::FILESYSTEM GParted_Core::get_filesystem() return GParted::FS_LVM2 ; } + //LUKS encryption + char magic[16] ; + + ped_device_open( lp_device ); + ped_geometry_read( & lp_partition ->geom, buf, 0, 1 ) ; + strncpy(magic, buf+0, 6) ; magic[6] = '\0' ; //set and terminate string + ped_device_close( lp_device ); + + if ( Glib::ustring( magic ) == "LUKS\xBA\xBE" ) + { + temp = _( "Linux Unified Key Setup encryption is not yet supported." ) ; + temp += "\n" ; + partition_temp .messages .push_back( temp ) ; + return GParted::FS_LUKS ; + } + //no file system found.... temp = _( "Unable to detect file system! Possible reasons are:" ) ; temp += "\n-"; @@ -902,9 +923,12 @@ void GParted_Core::set_mountpoints( std::vector & partitions ) for ( unsigned int t = 0 ; t < partitions .size() ; t++ ) { if ( ( partitions[ t ] .type == GParted::TYPE_PRIMARY || - partitions[ t ] .type == GParted::TYPE_LOGICAL ) && + partitions[ t ] .type == GParted::TYPE_LOGICAL + ) && partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP && - partitions[ t ] .filesystem != GParted::FS_LVM2 ) + partitions[ t ] .filesystem != GParted::FS_LVM2 && + partitions[ t ] .filesystem != GParted::FS_LUKS + ) { if ( partitions[ t ] .busy ) { @@ -944,8 +968,10 @@ void GParted_Core::set_used_sectors( std::vector & partitions ) for ( unsigned int t = 0 ; t < partitions .size() ; t++ ) { if ( partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP && + partitions[ t ] .filesystem != GParted::FS_LUKS && partitions[ t ] .filesystem != GParted::FS_LVM2 && - partitions[ t ] .filesystem != GParted::FS_UNKNOWN ) + partitions[ t ] .filesystem != GParted::FS_UNKNOWN + ) { if ( partitions[ t ] .type == GParted::TYPE_PRIMARY || partitions[ t ] .type == GParted::TYPE_LOGICAL ) diff --git a/src/Utils.cc b/src/Utils.cc index 95cb3fc0..e90260a3 100644 --- a/src/Utils.cc +++ b/src/Utils.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Bart Hakvoort +/* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Bart Hakvoort * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -88,6 +88,7 @@ Glib::ustring Utils::get_color( FILESYSTEM filesystem ) case FS_USED : return "#F8F8BA" ; // ~ light tan yellow case FS_UNUSED : return "#FFFFFF" ; //white case FS_LVM2 : return "#CC9966" ; // ~ medium brown + case FS_LUKS : return "#625B81" ; //purple dark default : return "#000000" ; } @@ -134,6 +135,7 @@ Glib::ustring Utils::get_filesystem_string( FILESYSTEM filesystem ) case FS_USED : return _("used") ; case FS_UNUSED : return _("unused") ; case FS_LVM2 : return "lvm2" ; + case FS_LUKS : return "crypt-luks" ; default : return "" ; } diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index 5470064b..0d06aa3b 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -385,9 +385,11 @@ Gtk::Menu * Win_GParted::create_format_menu() for ( unsigned int t =0; t < gparted_core .get_filesystems() .size() ; t++ ) { - //Skip lvm2 and unknown because these are not file systems - if( gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LVM2 || - gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_UNKNOWN ) + //Skip luks, lvm2, and unknown because these are not file systems + if ( gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LUKS || + gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_LVM2 || + gparted_core .get_filesystems()[ t ] .filesystem == GParted::FS_UNKNOWN + ) continue ; hbox = manage( new Gtk::HBox() );