[PC-BSD Commits] r8206 - pcbsd/stable/SysInstaller

svn at pcbsd.org svn at pcbsd.org
Tue Dec 14 08:11:56 PST 2010


Author: kris
Date: 2010-12-14 08:11:55 -0800 (Tue, 14 Dec 2010)
New Revision: 8206

Modified:
   pcbsd/stable/SysInstaller/sys-diskwidget.cpp
   pcbsd/stable/SysInstaller/sysinstaller.h
   pcbsd/stable/SysInstaller/sysinstaller.ui
Log:

MFC enhancement to use GELI encryption via single checkbox for auto-partitioning of UFS+S/ZFS



Modified: pcbsd/stable/SysInstaller/sys-diskwidget.cpp
===================================================================
--- pcbsd/stable/SysInstaller/sys-diskwidget.cpp	2010-12-14 16:10:45 UTC (rev 8205)
+++ pcbsd/stable/SysInstaller/sys-diskwidget.cpp	2010-12-14 16:11:55 UTC (rev 8206)
@@ -21,6 +21,53 @@
   treeWidgetCustomPartition->setColumnHidden(0, true);
 }
 
+void SysInstaller::warnEncryption()
+{
+  QMessageBox::warning(this, tr("PC-BSD Installer"),
+    tr("Encryption is enabled! In addition to using passphrase, key files are randomly generated and will be stored in /boot/keys/ on the system. After installing and rebooting, you should immediately make a backup copy of these keys, or else data loss could occur should they be lost or corrupted."),
+    QMessageBox::Ok);
+
+}
+void SysInstaller::slotEnableDiskAutoEnc()
+{
+  if ( ! checkBoxEncUserData->isChecked() )
+    return; 
+
+  bool ok;
+  QString pass, confirm;
+
+  int ret = QMessageBox::question(this, tr("Disk Encryption"),
+              tr("Do you want to use a passphrase to access the encrypted volume?"),
+              QMessageBox::Yes | QMessageBox::No,
+              QMessageBox::Yes); 
+
+  if ( ret == QMessageBox::No ) {
+    autoEncPass="";
+    return;
+  }
+
+  // Get the passphrase
+  pass = QInputDialog::getText(this, tr("Enter Passphrase"),
+           tr("Enter the Passphrase for this encrypted disk"), QLineEdit::Password,
+           QString(), &ok);
+
+  // Confirm the passphrase
+  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 ( pass != confirm ) {
+    QMessageBox::critical(this, tr("Passphrase mismatch"), tr("The entered passphrases do not match!")); 
+    checkBoxEncUserData->setChecked(false);
+    return;
+  }
+
+  // Save the passphrase
+  warnEncryption();
+  autoEncPass=pass;
+}
+
 // Returns the disks MBR/GPT format scheme if known
 QString SysInstaller::getDiskScheme(QString disk)
 {
@@ -261,11 +308,8 @@
 
     }
 
-    if (haveEncryption) {
-      QMessageBox::warning(this, tr("PC-BSD Installer"),
-         tr("Encryption is enabled! Keys are randomly generated and will be stored in /boot/keys/. You should immediately make a backup copy of these keys, or else data loss could occur should they be corrupted."),
-         QMessageBox::Ok);
-    }
+    if (haveEncryption)
+      warnEncryption();
 
     // Check if we have mounts for usr / var, and if not, add their requirements to /
     if (!haveVar)
@@ -352,7 +396,7 @@
 {
   QString targetType, tmp;
   int targetLoc, totalSize = 0, mntsize;
-  QString targetDisk, targetSlice;
+  QString targetDisk, targetSlice, tmpPass, fsType;
   bool ok;
   ok = false;
 
@@ -397,13 +441,12 @@
 
      if ( radioFileSysSU->isChecked() )
      {
-       QString fsType;
 
        fsType="UFS+S";
 
        fileSystem << targetDisk << targetSlice << "/" << fsType << tmp.setNum(mntsize) << "" << "";
        totalSize = totalSize - mntsize;
-       qDebug() << "Auto-Gen FS:" <<  fileSystem;
+       //qDebug() << "Auto-Gen FS:" <<  fileSystem;
        sysFinalDiskLayout << fileSystem;
        fileSystem.clear();
       
@@ -414,7 +457,7 @@
           mntsize = 512;
        fileSystem << targetDisk << targetSlice << "SWAP" << "SWAP" << tmp.setNum(mntsize) << "" << "";
        totalSize = totalSize - mntsize;
-       qDebug() << "Auto-Gen FS:" <<  fileSystem;
+       //qDebug() << "Auto-Gen FS:" <<  fileSystem;
        sysFinalDiskLayout << fileSystem;
        fileSystem.clear();
 
@@ -423,14 +466,19 @@
        mntsize = 1024;
        fileSystem << targetDisk << targetSlice << "/var" << fsType << tmp.setNum(mntsize) << "" << "";
        totalSize = totalSize - mntsize;
-       qDebug() << "Auto-Gen FS:" <<  fileSystem;
+       //qDebug() << "Auto-Gen FS:" <<  fileSystem;
        sysFinalDiskLayout << fileSystem;
        fileSystem.clear();
 
+       // See if using encryption for this partition
+       if ( checkBoxEncUserData->isChecked() ) {
+         fsType+= ".eli";
+         tmpPass=autoEncPass;
+       }
 
        // Now use the rest of the disk / slice for /usr
-       fileSystem << targetDisk << targetSlice << "/usr" << fsType << tmp.setNum(totalSize) << "" << "";
-       qDebug() << "Auto-Gen FS:" <<  fileSystem;
+       fileSystem << targetDisk << targetSlice << "/usr" << fsType << tmp.setNum(totalSize) << "" << tmpPass;
+       //qDebug() << "Auto-Gen FS:" <<  fileSystem;
        sysFinalDiskLayout << fileSystem;
        fileSystem.clear();
 
@@ -446,16 +494,26 @@
        // Setup a UFS boot partition
        totalSize = totalSize - 500;
        fileSystem << targetDisk << targetSlice << "/boot" << "UFS" << tmp.setNum(500) << "" << "";
+       sysFinalDiskLayout << fileSystem;
+       fileSystem.clear();
 
+       // See if using encryption for this partition
+       if ( checkBoxEncUserData->isChecked() ) {
+         fsType= "ZFS.eli";
+         tmpPass=autoEncPass;
+       } else {
+         fsType= "ZFS";
+       }
+
        // Add the main zfs pool with standard partitions
-       fileSystem << targetDisk << targetSlice << "/,/var,/usr" << "ZFS" << tmp.setNum(totalSize) << "" << "";
-       qDebug() << "Auto-Gen FS:" <<  fileSystem;
+       fileSystem << targetDisk << targetSlice << "/,/var,/usr" << fsType << tmp.setNum(totalSize) << "" << tmpPass;
+       //qDebug() << "Auto-Gen FS:" <<  fileSystem;
        sysFinalDiskLayout << fileSystem;
        fileSystem.clear();
 
        // Add the previously calculated swap size
        fileSystem << targetDisk << targetSlice << "SWAP" << "SWAP" << tmp.setNum(swapsize) << "" << "";
-       qDebug() << "Auto-Gen FS:" <<  fileSystem;
+       //qDebug() << "Auto-Gen FS:" <<  fileSystem;
        sysFinalDiskLayout << fileSystem;
        fileSystem.clear();
      }

Modified: pcbsd/stable/SysInstaller/sysinstaller.h
===================================================================
--- pcbsd/stable/SysInstaller/sysinstaller.h	2010-12-14 16:10:45 UTC (rev 8205)
+++ pcbsd/stable/SysInstaller/sysinstaller.h	2010-12-14 16:11:55 UTC (rev 8206)
@@ -100,6 +100,7 @@
     void slotAddMBRPartition();
     void slotDeleteMBRPartition();
     void slotLoadDiskInfo();
+    void slotEnableDiskAutoEnc();
 
     // User Management Slots
     void slotPasswordTextChanged();
@@ -162,6 +163,10 @@
     dialogFileSystem *dfs;
     dialogSelectNetServer *dsn;
 
+    // Encryption bits
+    QString autoEncPass;
+    void warnEncryption();
+
     QList<Step> steps;
     QList<Label *> labels;  // just to handle the "Labels" list
     QList<QStringList> sysDisks; // Our lists which contains disk info

Modified: pcbsd/stable/SysInstaller/sysinstaller.ui
===================================================================
--- pcbsd/stable/SysInstaller/sysinstaller.ui	2010-12-14 16:10:45 UTC (rev 8205)
+++ pcbsd/stable/SysInstaller/sysinstaller.ui	2010-12-14 16:11:55 UTC (rev 8206)
@@ -8088,6 +8088,16 @@
                           <item row="8" column="0" colspan="3">
                            <layout class="QHBoxLayout" name="horizontalLayout_10">
                             <item>
+                             <widget class="QCheckBox" name="checkBoxEncUserData">
+                              <property name="toolTip">
+                               <string>Encrypt the /usr partition or ZFS zpool.</string>
+                              </property>
+                              <property name="text">
+                               <string>Encrypt user data</string>
+                              </property>
+                             </widget>
+                            </item>
+                            <item>
                              <spacer name="horizontalSpacer_40">
                               <property name="orientation">
                                <enum>Qt::Horizontal</enum>



More information about the Commits mailing list