void keyDialog::encfsMount() { auto m = utility::mountPath( utility::mountPathPostFix( m_ui->lineEditMountPoint->text() ) ) ; bool ro = m_ui->checkBoxOpenReadOnly->isChecked() ; if( zuluMountTask::encfsMount( m_path,m,m_key,ro ).await() ){ /* * TODO: Not suspending for a while causes a process that open the mount point * to exit prematurely with "QProcess: Destroyed while process is still running." warning. * look into why this happens. * */ this->hide() ; utility::Task::suspend( 2 ) ; m_success( m ) ; this->HideUI() ; }else{ DialogMsg msg( this ) ; msg.ShowUIOK( tr( "ERROR" ),tr( "Failed to unlock an encfs volume.\nWrong password or not an encfs volume" ) ) ; if( m_ui->cbKeyType->currentIndex() == keyDialog::Key ){ m_ui->lineEditKey->clear() ; } m_ui->lineEditKey->setFocus() ; return this->enableAll() ; } }
void tcrypt::pbSend() { auto l = tablewidget::tableColumnEntries( m_ui->tableWidget ) ; if( l.isEmpty() ){ DialogMsg msg( this ) ; msg.ShowUIOK( tr( "ERROR" ),tr( "At least one keyfile is required" ) ) ; }else{ /* * we call hide() because the GUI doesnt seem to hide when called later on in HideUI() */ this->hide() ; m_success( m_ui->lineEdit->text(),l ) ; this->HideUI() ; } }
void keyDialog::openVolume() { int keyType = m_ui->cbKeyType->currentIndex() ; if( m_volumeIsEncFs ){ if( keyType == keyDialog::Key ){ m_key = m_ui->lineEditKey->text() ; }else if( keyType == keyDialog::keyfile ){ QFile f( m_ui->lineEditKey->text() ) ; f.open( QIODevice::ReadOnly ) ; m_key = f.readAll() ; }else if( keyType == keyDialog::plugin ){ /* * m_key is already set */ } return this->encfsMount() ; } if( m_ui->lineEditKey->text().isEmpty() ){ if( keyType == keyDialog::Key ){ ; }else if( keyType == keyDialog::plugin ){ DialogMsg msg( this ) ; msg.ShowUIOK( tr( "ERROR" ),tr( "Plug in name field is empty" ) ) ; m_ui->lineEditKey->setFocus() ; return this->enableAll() ; }else if( keyType == keyDialog::keyfile ){ DialogMsg msg( this ) ; msg.ShowUIOK( tr( "ERROR" ),tr( "Keyfile field is empty" ) ) ; m_ui->lineEditKey->setFocus() ; return this->enableAll() ; } } QString test_name = m_ui->lineEditMountPoint->text() ; if( test_name.contains( "/" ) ){ DialogMsg msg( this ) ; msg.ShowUIOK( tr( "ERROR" ),tr( "\"/\" character is not allowed in the mount name field" ) ) ; m_ui->lineEditKey->setFocus() ; return this->enableAll() ; } QString m ; if( keyType == keyDialog::Key ){ QString addr = utility::keyPath() ; m = QString( "-f %1" ).arg( addr ) ; QString key = m_ui->lineEditKey->text() ; utility::keySend( addr,key ) ; }else if( keyType == keyDialog::keyfile ){ QString e = m_ui->lineEditKey->text().replace( "\"","\"\"\"" ) ; m = "-f \"" + utility::resolvePath( e ) + "\"" ; }else if( keyType == keyDialog::plugin ){ if( m_key.isEmpty() ){ m = "-G " + m_ui->lineEditKey->text().replace( "\"","\"\"\"" ) ; }else{ QString addr = utility::keyPath() ; m = QString( "-f %1" ).arg( addr ) ; utility::keySend( addr,m_key ) ; } }else if( keyType == keyDialog::tcryptKeys ){ QString addr = utility::keyPath() ; m = QString( "-f %1 " ).arg( addr ) ; utility::keySend( addr,m_key ) ; }else{ qDebug() << "ERROR: Uncaught condition" ; } QString volume = m_path ; volume.replace( "\"","\"\"\"" ) ; QString exe = zuluMountPath ; if( m_ui->checkBoxShareMountPoint->isChecked() ){ exe += " -M -m -d \"" + volume + "\"" ; }else{ exe += " -m -d \"" + volume + "\"" ; } if( m_ui->checkBoxOpenReadOnly->isChecked() ){ exe += " -e ro" ; }else{ exe += " e rw" ; } QString mountPoint = m_ui->lineEditMountPoint->text() ; mountPoint.replace( "\"","\"\"\"" ) ; exe += " -z \"" + mountPoint + "\"" ; if( !m_options.isEmpty() ){ exe += " -Y " + m_options ; } if( !m_deviceOffSet.isEmpty() ){ exe += " -o " + m_deviceOffSet ; } if( !m_keyFiles.isEmpty() ){ for( const auto& it : m_keyFiles ){ QString e = it ; e.replace( "\"","\"\"\"" ) ; exe += " -F \"" + e + "\"" ; } } if( m_veraCryptVolume ){ if( m_veraCryptPIMValue > 0 ){ exe += " -t veracrypt." + QString::number( m_veraCryptPIMValue ) + " " + m ; }else{ exe += " -t veracrypt " + m ; } }else{ exe += " " + m ; } m_veraCryptWarning.show( m_veraCryptVolume ) ; m_working = true ; auto s = utility::Task::run( utility::appendUserUID( exe ) ).await() ; m_working = false ; m_veraCryptWarning.stopTimer() ; if( s.success() ){ if( utility::mapperPathExists( m_path ) ) { /* * The volume is reported as opened and it actually is */ m_success( utility::mountPath( mountPoint ) ) ; }else{ /* * The volume is reported as opened but it isnt,possible reason is a backe end crash */ DialogMsg msg( this ) ; msg.ShowUIOK( tr( "ERROR" ),tr( "An error has occured and the volume could not be opened" ) ) ; m_cancel() ; } this->HideUI() ; }else{ m_veraCryptWarning.hide() ; if( s.exitCode() == 12 && m_ui->cbKeyType->currentIndex() == keyDialog::plugin ){ /* * A user cancelled the plugin */ this->enableAll() ; }else{ QString z = s.output() ; z.replace( tr( "ERROR: " ),"" ) ; DialogMsg msg( this ) ; msg.ShowUIOK( tr( "ERROR" ),z ) ; if( m_ui->cbKeyType->currentIndex() == keyDialog::Key ){ m_ui->lineEditKey->clear() ; } this->enableAll() ; m_ui->lineEditKey->setFocus() ; } } }