[PC-BSD Commits] r6448 - pcbsd/trunk/SysInstaller

svn at pcbsd.org svn at pcbsd.org
Fri Mar 26 11:52:14 PDT 2010


Author: kris
Date: 2010-03-26 11:52:13 -0700 (Fri, 26 Mar 2010)
New Revision: 6448

Modified:
   pcbsd/trunk/SysInstaller/dialogFileSystem.cpp
   pcbsd/trunk/SysInstaller/dialogFileSystem.h
   pcbsd/trunk/SysInstaller/sys-diskwidget.cpp
Log:

Added support to SysInstaller for encryption passphrases, now it'll prompt for the phrase to be used for mounting
a disk / partition



Modified: pcbsd/trunk/SysInstaller/dialogFileSystem.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/dialogFileSystem.cpp	2010-03-26 18:05:16 UTC (rev 6447)
+++ pcbsd/trunk/SysInstaller/dialogFileSystem.cpp	2010-03-26 18:52:13 UTC (rev 6448)
@@ -17,6 +17,8 @@
   editIndex = -1; 
 
   // Connnect our slots
+  connect(checkEncryption, SIGNAL(clicked()), this, SLOT(slotEncryptionChanged()));
+  connect(checkEncryptionZFS, SIGNAL(clicked()), this, SLOT(slotEncryptionChangedZFS()));
   connect(pushCancel, SIGNAL(clicked()), this, SLOT(slotPushCancel()));
   connect(pushSave, SIGNAL(clicked()), this, SLOT(slotPushSave()));
   connect(pushAddZFS, SIGNAL(clicked()), this, SLOT(slotAddZFSMount()));
@@ -27,6 +29,7 @@
   connect(horizontalSizeSliderZFS, SIGNAL(sliderMoved(int)), this, SLOT(slotSliderChangedValue(int)));
   connect(spinSize, SIGNAL(valueChanged(int)), this, SLOT(slotSpinBoxChanged(int)));
   connect(spinSizeZFS, SIGNAL(valueChanged(int)), this, SLOT(slotSpinBoxChanged(int)));
+  
 
 
   // Add the file-system types
@@ -65,6 +68,54 @@
 
 }
 
+// Function which toggles encryption enable / disable for regular UFS
+bool dialogFileSystem::getEncPhrase()
+{  
+   bool ok;
+   QString pass, confirm;
+   pass = QInputDialog::getText(this, tr("Enter Passphrase"),
+                                      tr("Enter the Passphrase for this encrypted disk"), QLineEdit::Password,
+                                      QString(), &ok);
+   if( ok && ! pass.isEmpty() )
+     confirm = QInputDialog::getText(this, tr("Enter Passphrase (Confirm)"),
+                                        tr("Confirm the Passphrase for this encrypted disk"), QLineEdit::Password,
+                                        QString(), &ok);
+
+   if ( ok && pass == confirm ) {
+     encPhrase = pass;
+     return true;
+   } else
+     return false;
+}
+
+// Function which toggles encryption enable / disable for regular UFS
+void dialogFileSystem::slotEncryptionChanged()
+{
+  if(checkEncryption->isChecked() ) {
+    getEncPhrase();   
+    checkEncryptionZFS->setChecked(TRUE);
+  } else {
+    encPhrase=""; 
+    checkEncryptionZFS->setChecked(FALSE);
+  }
+}
+
+// Function which toggles encryption enable / disable for ZFS
+void dialogFileSystem::slotEncryptionChangedZFS()
+{
+  if(checkEncryption->isChecked() ) {
+    getEncPhrase();   
+    encPhrase=""; 
+    checkEncryption->setChecked(TRUE);
+  } else {
+    encPhrase=""; 
+    checkEncryption->setChecked(FALSE);
+  }
+}
+
+
+
+
 // Function which checks that we don't have any partitions selected for this disk when using a partition
 bool dialogFileSystem::sliceNoExistingDiskPartition(QString Device)
 {
@@ -248,6 +299,7 @@
     if ( tmp.indexOf(".eli") != -1 )
     {
        checkEncryption->setChecked(true);
+       checkEncryptionZFS->setChecked(true);
        tmp.truncate(tmp.indexOf(".eli"));   
     } 
     for ( int i = 0; i <= comboDiskType->count(); i++ )
@@ -723,19 +775,24 @@
         XtraOpts = XtraOpts + " " + tmp;
         XtraOpts = XtraOpts.simplified();
       }
-  } // Enf of ZFS Setup
+    }
 
 
      Size = tmp.setNum(spinSize->value());
      fsType = comboDiskType->currentText();
-     if ( checkEncryption->isChecked() )
-        fsType = fsType + ".eli";
+     if ( checkEncryptionZFS->isChecked() )
+       fsType = fsType + ".eli";
+     else
+       encPhrase="";
+  // End of ZFS Setup
   } else {
      Size = tmp.setNum(spinSize->value());
      Mount = lineEditMount->text();
      fsType = comboDiskType->currentText();
      if ( checkEncryption->isChecked() )
         fsType = fsType + ".eli";
+     else
+       encPhrase="";
   }
 
   
@@ -750,9 +807,10 @@
     sysFinalDiskLayout[editIndex][3] = fsType;
     sysFinalDiskLayout[editIndex][4] = Size;
     sysFinalDiskLayout[editIndex][5] = XtraOpts;
+    sysFinalDiskLayout[editIndex][5] = encPhrase;
   } else {
     // Add a new Device
-    fileSystem << Disk << Slice << Mount << fsType << Size << XtraOpts;
+    fileSystem << Disk << Slice << Mount << fsType << Size << XtraOpts << encPhrase;
     sysFinalDiskLayout << fileSystem;
   }
 

Modified: pcbsd/trunk/SysInstaller/dialogFileSystem.h
===================================================================
--- pcbsd/trunk/SysInstaller/dialogFileSystem.h	2010-03-26 18:05:16 UTC (rev 6447)
+++ pcbsd/trunk/SysInstaller/dialogFileSystem.h	2010-03-26 18:52:13 UTC (rev 6448)
@@ -4,6 +4,7 @@
 #include <QtGui/QWidget>
 #include <QMessageBox>
 #include <QFile>
+#include <QInputDialog>
 
 
 #include "ui_dialogFileSystem.h"
@@ -36,6 +37,9 @@
     void slotAddZFSMount();
     void slotRemoveZFSMount();
     void slotSaveNewZFSMount(QString newMount);
+    void slotEncryptionChanged();
+    void slotEncryptionChangedZFS();
+    bool getEncPhrase();
 
 private:
     dialogZFSMount *dialogZFS;
@@ -52,6 +56,7 @@
     int calculateFreeSpace(int diskIndex);
     QList<QStringList> sysDisks; // Our lists which contains disk info
     QList<QStringList> sysFinalDiskLayout; // Our lists which contains the final disk layout
+    QString encPhrase;
 
 signals:
     void updated(QList<QStringList> newDiskLayout);

Modified: pcbsd/trunk/SysInstaller/sys-diskwidget.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/sys-diskwidget.cpp	2010-03-26 18:05:16 UTC (rev 6447)
+++ pcbsd/trunk/SysInstaller/sys-diskwidget.cpp	2010-03-26 18:52:13 UTC (rev 6448)
@@ -480,6 +480,10 @@
                    + copyList.at(i).at(3) + " " + copyList.at(i).at(4) \
                    + " " + copyList.at(i).at(2) + XtraTmp;
 
+          // Check if we have an encryption passphrase to use
+          if ( ! copyList.at(i).at(6).isEmpty() )
+	    tmpList << "encpass=" + copyList.at(i).at(6);
+
           // Write the user summary
           summaryList << "";
           summaryList << tr("Partition:") + " " + workingDisk + "(" + workingSlice + "):";



More information about the Commits mailing list