diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/backend.ui | 93 | ||||
-rw-r--r-- | src/configdialog.cpp | 15 | ||||
-rw-r--r-- | src/configdialog.h | 5 | ||||
-rw-r--r-- | src/klamav.cpp | 2 | ||||
-rw-r--r-- | src/klamavconfig.kcfg | 18 | ||||
-rw-r--r-- | src/klamscan.cpp | 2 | ||||
-rw-r--r-- | src/scanviewer.cpp | 151 | ||||
-rw-r--r-- | src/scanviewer.h | 4 |
9 files changed, 231 insertions, 61 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c6c8a91..2edf96b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -40,7 +40,7 @@ tde_add_executable( ${PROJECT_NAME} AUTOMOC activityviewer.cpp collectiondb.cpp configdialog.cpp klamavconfig.kcfgc archivelimits.ui archivetypes.ui specialfiletypes.ui - firstrunwizard.ui logoptions.ui + firstrunwizard.ui logoptions.ui backend.ui k3bjobprogressosd_mod.cpp LINK diff --git a/src/backend.ui b/src/backend.ui new file mode 100644 index 0000000..bec4513 --- /dev/null +++ b/src/backend.ui @@ -0,0 +1,93 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>KlamBackend</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>KlamBackend</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>600</width> + <height>480</height> + </rect> + </property> + <property name="caption"> + <string>Scanning Backend</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQButtonGroup"> + <property name="name"> + <cstring>backendConfig</cstring> + </property> + <property name="title"> + <string>Scanning Backend</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQRadioButton" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>kcfg_ScannerClamscan</cstring> + </property> + <property name="text"> + <string>Standalone scanner</string> + </property> + <property name="checked"> + <bool>false</bool> + </property> + </widget> + <widget class="TQCheckBox" row="1" column="1"> + <property name="name"> + <cstring>kcfg_ClamdMultiscan</cstring> + </property> + <property name="text"> + <string>Force Multiscan mode</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="TQRadioButton" row="1" column="0"> + <property name="name"> + <cstring>kcfg_ScannerClamdscan</cstring> + </property> + <property name="text"> + <string>ClamAV daemon</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </grid> + </widget> + <widget class="KTextBrowser"> + <property name="name"> + <cstring>backendHelpMessage</cstring> + </property> + <property name="textFormat"> + <enum>RichText</enum> + </property> + <property name="text"> + <string>Here you can choose the backend you'd like to use with KlamAV. +<p><b>Standalone scanner</b> uses the 'clamscan' command to perform a scan. This backend is configurable via KlamAV, but takes longer to start. This backend is also the easiest to set up, as it does not require running a system-wide daemon.</p> +<p><b>ClamAV daemon</b> uses the 'clamdscan' command to perform a scan. This backend depends on a running instance of the <i>clamd</i> daemon and depends on the options of the daemon. This backend starts up faster and also makes use of the Multiscan feature.</p</string> + </property> + </widget> + </vbox> +</widget> +<slots> + <slot>slotToggleClamdcan(bool)</slot> +</slots> +<functions> + <function access="private" specifier="non virtual">init()</function> +</functions> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>ktextbrowser.h</includehint> +</includehints> +</UI> diff --git a/src/configdialog.cpp b/src/configdialog.cpp index d59d52d..94466db 100644 --- a/src/configdialog.cpp +++ b/src/configdialog.cpp @@ -14,6 +14,7 @@ email : markey@web.de ***************************************************************************/ #include "configdialog.h" +#include "backend.h" #include "archivelimits.h" #include "archivetypes.h" #include "specialfiletypes.h" @@ -30,6 +31,7 @@ email : markey@web.de #include <tqobjectlist.h> #include <tqpushbutton.h> #include <tqradiobutton.h> +#include <tqcheckbox.h> #include <tqspinbox.h> #include <tqtextcodec.h> #include <tqtooltip.h> @@ -52,6 +54,7 @@ KlamavConfigDialog::KlamavConfigDialog( TQWidget *parent, const char* name, TDEC setWFlags( WDestructiveClose ); // IMPORTANT Don't simply change the page names, they are used as identifiers in other parts of the app. + m_klambackend = new KlamBackend( 0, "Scanning Backend" ); m_archivelimits = new ArchiveLimits( 0, "Archive Limits" ); m_archivetypes = new ArchiveTypes( 0, "Archive Types" ); m_emailprotection = new Sigtool ( 0, "E-mail protection" ); @@ -60,6 +63,10 @@ KlamavConfigDialog::KlamavConfigDialog( TQWidget *parent, const char* name, TDEC m_logoptions = new LogOptions( 0, "Event Logging" ); // add pages + addPage( m_klambackend, i18n( "Backend" ), "system-run", i18n( "Configure Scanning Backend" ) ); + connect( m_klambackend->kcfg_ScannerClamdscan, SIGNAL(toggled(bool)), this, SLOT(slotToggleClamdscan(bool)) ); + slotToggleClamdscan( m_klambackend->kcfg_ScannerClamdscan->isOn() ); // initial state + addPage( m_archivelimits, i18n( "Archive Limits" ), "ark", i18n( "Configure Archive Limits" ) ); addPage( m_archivetypes, i18n( "Archive Types" ), "application-x-tarz", i18n( "Configure Archive Types" ) ); addPage( m_emailprotection, i18n( "E-mail protection" ), "email", i18n( "Set up your e-mail client to use Klammail" ) ); @@ -85,7 +92,13 @@ KlamavConfigDialog::~KlamavConfigDialog() { } - +void KlamavConfigDialog::slotToggleClamdscan(bool on) +{ + m_klambackend->kcfg_ClamdMultiscan->setEnabled(on); + m_archivelimits->setEnabled(!on); + m_archivetypes->setEnabled(!on); + m_specialfiletypes->setEnabled(!on); +} /** Show page by object name */ void KlamavConfigDialog::showPage( const TQCString& page ) diff --git a/src/configdialog.h b/src/configdialog.h index 3100f20..8bb26af 100644 --- a/src/configdialog.h +++ b/src/configdialog.h @@ -40,10 +40,13 @@ class KlamavConfigDialog : public TDEConfigDialog void showPage( const TQCString& page ); + public slots: + void slotToggleClamdscan( bool on ); private: + bool clamdscan; - + class KlamBackend *m_klambackend; class ArchiveLimits *m_archivelimits; class ArchiveTypes *m_archivetypes; class SpecialFileTypes *m_specialfiletypes; diff --git a/src/klamav.cpp b/src/klamav.cpp index bf61432..dbe311c 100644 --- a/src/klamav.cpp +++ b/src/klamav.cpp @@ -284,7 +284,7 @@ void Klamav::slotScheduleScan() { klamscan->slotSchedule(); } void Klamav::slotOptions() { - slotConfigKlamav("Archive Limits"); + slotConfigKlamav("Scanning Backend"); } void Klamav::slotToggleWelcome() { diff --git a/src/klamavconfig.kcfg b/src/klamavconfig.kcfg index 420beeb..017730f 100644 --- a/src/klamavconfig.kcfg +++ b/src/klamavconfig.kcfg @@ -3,6 +3,24 @@ <kcfg> <kcfgfile name="klamavrc"/> +<group name="KlamavBackend"> + <entry name="ScannerClamscan" type="Bool"> + <label>Standalone scanner</label> + <whatsthis>Use KlamAV without the ClamAV daemon.</whatsthis> + <default>true</default> + </entry> + <entry name="ScannerClamdscan" type="Bool"> + <label>ClamAV daemon</label> + <whatsthis>Use KlamAV with the ClamAV daemon.</whatsthis> + <default>false</default> + </entry> + <entry name="ClamdMultiscan" type="Bool"> + <label>Force Multiscan mode</label> + <whatsthis>Force clamdscan to use multiscan mode (scan multiple directories at once in separate threads). May lower scanning time.</whatsthis> + <default>true</default> + </entry> +</group> + <group name="ArchiveLimits"> <entry name="RecursionLevel" type="Int"> <label>Maximum Recursion Level</label> diff --git a/src/klamscan.cpp b/src/klamscan.cpp index 784398f..2a945e3 100644 --- a/src/klamscan.cpp +++ b/src/klamscan.cpp @@ -295,7 +295,7 @@ void Klamscan::slotAdvOptions(){ dialog->raise(); dialog->setActiveWindow();*/ - tdemain->slotConfigKlamav( "Archive Limits" ); + tdemain->slotConfigKlamav( "Scanning Backend" ); } diff --git a/src/scanviewer.cpp b/src/scanviewer.cpp index d61f4a4..0e5e702 100644 --- a/src/scanviewer.cpp +++ b/src/scanviewer.cpp @@ -39,9 +39,9 @@ ScanViewer::ScanViewer(TQWidget *parent, const char *name) : TQWidget(parent, name) { - scanInProgress = TRUE; - multiScan = FALSE; - + scanInProgress = TRUE; + multiScan = FALSE; + //TQGridLayout *layout = new TQGridLayout(this, 6, 3, 10, 4); layout = new TQGridLayout(this, 6, 3, 10, 4); layout->setColStretch(0, 10); @@ -53,9 +53,9 @@ ScanViewer::ScanViewer(TQWidget *parent, const char *name) layout->setRowStretch(2, 10); layout->addRowSpacing(4, 10); layout->setRowStretch(4, 0); - - - + + + resultview = new TQListView(this); resultview->setShowSortIndicator(true); @@ -77,24 +77,24 @@ ScanViewer::ScanViewer(TQWidget *parent, const char *name) menu = new TQPopupMenu( resultview ); - connect(resultview, SIGNAL( contextMenuRequested( TQListViewItem *, const TQPoint& , int ) ), + connect(resultview, SIGNAL( contextMenuRequested( TQListViewItem *, const TQPoint& , int ) ), this, SLOT( slotRMB( TQListViewItem *, const TQPoint &, int ) ) ); - + status_frame = new TQFrame(this); status_frame->setFrameStyle(TQFrame::Panel | TQFrame::Sunken); TQBoxLayout *status_layout = new TQHBoxLayout(status_frame, 2); - + status_label = new TQLabel("", status_frame); status_layout->addWidget(status_label, 10); - + //matches_label = new TQLabel(status_frame); //TQFontMetrics ml_fm(matches_label->fontMetrics()); //matches_label->setFixedWidth(ml_fm.width(i18n("9999 viruses/errors found"))); //matches_label->setFixedHeight(ml_fm.lineSpacing()); //status_layout->addWidget(matches_label, 0); - - + + status_layout->activate(); status_frame->adjustSize(); status_frame->setMinimumSize(status_frame->size()); @@ -103,7 +103,7 @@ ScanViewer::ScanViewer(TQWidget *parent, const char *name) status2_frame = new TQFrame(this); status2_frame->setFrameStyle(TQFrame::Panel | TQFrame::Sunken); status2_layout = new TQHBoxLayout(status2_frame, 2); - + status2_label = new TQLabel(i18n("Files scanned: 0"), status2_frame); status2_layout->addWidget(status2_label, 10); status2_label->hide(); @@ -135,7 +135,7 @@ ScanViewer::ScanViewer(TQWidget *parent, const char *name) matches2_label->setFixedWidth(ml_fm2.width(i18n("9999 viruses/problems found"))); matches2_label->setFixedHeight(ml_fm2.lineSpacing()); status2_layout->addWidget(matches2_label, 0); - + TQToolTip::add(matches2_label, i18n("cf. 'Flanderseses' - Homer Simpson. This childish joke will be removed when KlamAV is more mature.")); status2_layout->activate(); @@ -144,7 +144,7 @@ ScanViewer::ScanViewer(TQWidget *parent, const char *name) layout->addMultiCellWidget(status2_frame, 4, 4, 0, 2); - + layout->activate(); @@ -209,7 +209,7 @@ void ScanViewer::processOutput() filesscanned++; if (!(showProgress)) status2_label->setText(i18n("Files scanned: %1").arg(filesscanned)); - + //}else if ((pos = buf.section('\n',j,j).find("ERROR:")) != -1){ }else if ((pos = (item2.find("ERROR:"))) != -1){ TQString tmpVirusName = item2.mid((fnameEndPoint+1),(item2.length() - (fnameEndPoint+1))); @@ -241,7 +241,7 @@ void ScanViewer::processOutput() "- Access Denied!").arg(tmpFName)); CollectionDB::instance()->insertEvent("Error Found","Access Denied",tmpFName); //}else if ((pos = buf.section('\n',j,j).find(": Can't open")) != -1){ - + }else if ((pos = (item2.find(": Can't open"))) != -1){ //status2_label->setText(i18n("Files scanned: %1").arg(++filesscanned)); filesscanned++; @@ -280,9 +280,9 @@ void ScanViewer::processOutput() void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recursive, bool dcopscan) { - //KMessageBox::information (this, filepattern); + //KMessageBox::information (this, filepattern); TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); - + if(( args->isSet( "scanthis" ) ) || (dcopscan)) { calculateTime = FALSE; showProgress = FALSE; @@ -341,13 +341,16 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur //kdDebug() << filepattern << endl; prog->setTotalSteps(cnt); - kdDebug() << "COUNT" << cnt << endl; + kdDebug() << "COUNT" << cnt << endl; config = TDEGlobal::config(); + config->setGroup("KlamavBackend"); + clamdscan = config->readBoolEntry("ScannerClamdscan", false); + slotClear(); QuarantineList.clear(); - + errorsEncountered = FALSE; filesscanned = 0; //status2_label->setText(i18n("Scan in Progress...")); @@ -363,17 +366,17 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur db = *ita; } } - - ////kdDebug() << "here 2" << endl; + + ////kdDebug() << "here 2" << endl; TQString dbpath; TQString excludes; - TQString options; - + TQString options; // can not be used for clamdscan + if (!(db.isEmpty())) dbpath = TQString(" -d %1 ").arg(db); config->setGroup("Klamscan"); - + if (config->readEntry("ExcludeQuarantine") == "Yes"){ config->setGroup("Kuarantine"); TQStringList lastQuarLocations = config->readListEntry("KuarantineLocations"); @@ -384,7 +387,7 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur excludes += TQString(" --exclude=%1 ").arg(quarloc); } - + //if ((recursive_box->isChecked() && !(multiScan)) || (multi_recursive && multiScan)) if (recursive) options += " -r "; @@ -397,7 +400,7 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur // if (KlamavConfig::mBsToExtract() > 0) // options += "--max-space=" + TQString("%1").arg(KlamavConfig::mBsToExtract()) + " "; -// +// // if (KlamavConfig::compressionRatio() > 0) // options += "--max-ratio=" + TQString("%1").arg(KlamavConfig::compressionRatio()) + " "; @@ -410,7 +413,7 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur if (KlamavConfig::maxScanSize() > 0) options += "--max-scansize=" + TQString("%1").arg(KlamavConfig::maxScanSize()) + "M "; - + //config->setGroup("Klamscan"); // if (KlamavConfig::virusLimitsExceeded()) // options += "--block-max "; @@ -423,7 +426,7 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur if (!(KlamavConfig::scanHTML())) options += "--no-html "; - + if (!(KlamavConfig::scanPE())) options += "--no-pe "; @@ -449,7 +452,7 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur else options+=" "; } - + if (KlamavConfig::scanArj()){ options += "--arj"; if ((KlamavConfig::arjUsing()) != "") @@ -465,7 +468,7 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur else options+=" "; } - + if (KlamavConfig::scanLzh()){ options += "--lha"; if ((KlamavConfig::lzhUsing()) != "") @@ -506,21 +509,59 @@ void ScanViewer::slotScan(const TQStringList & filepattern, int mode, bool recur options+=" "; } - kdDebug() << "clamscan -v " - << excludes << " " - << dbpath << " " - << options << " " - << "'" + m_filepattern.join("' '") + "'" << endl; + if(clamdscan) { + // make sure that clamd is running + FILE* clamdpid; + if( clamdpid = fopen("/run/clamav/clamd.pid","r") ) + fclose(clamdpid); // it's ok + else { + int choice = KMessageBox::warningYesNoCancel( + this, + i18n("The ClamAV daemon does not seem to be running on this system. Do you really want to continue with this scan or would you like to launch a standalone scan instead?'"), + i18n("Clamd not running"), + i18n("Continue this scan"), + i18n("Launch standalone scan"), + i18n("Do not ask me again") + ); + + switch(choice) { + case 2: // cancel + return; + break; + case 4: // launch standalone scan + clamdscan = false; + break; + } + } + } childproc = new KProcIO(); childproc->setUseShell(TRUE); childproc->setUsePty (KProcIO::Stdout,TRUE); - *childproc << "clamscan -v "; - *childproc << excludes << " "; - *childproc << dbpath << " "; - *childproc << options << " "; - + if(clamdscan) { + config->setGroup("KlamavBackend"); + TQString multiscanOption = config->readBoolEntry("ClamdMultiscan", true) ? " -m " : ""; + + kdDebug() << "clamdscan -v " + << multiscanOption + << "'" + m_filepattern.join("' '") + "'" << endl; + + *childproc << "clamdscan -v "; + *childproc << multiscanOption; + } else { + kdDebug() << "clamscan -v " + << excludes << " " + << dbpath << " " + << options << " " + << "'" + m_filepattern.join("' '") + "'" << endl; + + *childproc << "clamscan -v "; + *childproc << excludes << " "; + *childproc << dbpath << " "; + *childproc << options << " "; + } + *childproc << "'" + m_filepattern.join("' '") + "'"; @@ -601,7 +642,7 @@ void ScanViewer::childExited() int status = childproc->exitStatus(); int result; - + status2_label->setText( i18n("Scan Complete") ); CollectionDB::instance()->insertEvent("Manual Scan",TQString("Scan Complete"),m_filepattern.join(" ")); @@ -743,7 +784,7 @@ void ScanViewer::Quarantine(){ KMessageBox::information (this,i18n("<p>There was a problem quarantining <b>%1</b>. Check your diskspace, the permissions on your quarantine location and whether a file with the same name already exists in the quarantine. </p>").arg(fname)); } - + } } if (allQuarantined) @@ -752,7 +793,7 @@ void ScanViewer::Quarantine(){ tdemain->_tray->setPixmap(KSystemTray::loadIcon("klamav_scan_found")); config->writeEntry(TQString("Items %1").arg(quarloc), lastQuarItems); config->sync(); - + //tdemain->kuarantine->refresh(); @@ -807,7 +848,7 @@ void ScanViewer::slotQuarantineSelected() TQPtrList<TQListViewItem> list; TQListViewItemIterator it( resultview, TQListViewItemIterator::Selected ); - + QuarantineList = ""; while ( it.current() ) { TQListViewItem* tItem = it.current(); @@ -844,7 +885,7 @@ void ScanViewer::slotStartAgain() calculateTime = TRUE; emit scanStartingAgain(this); slotScan(m_filepattern, m_mode, m_recursive,false); - + } @@ -865,22 +906,22 @@ void ScanViewer::slotCancelScanTime() // void ScanViewer::startProgress() // { -// +// // cnt = 0; // //kdDebug() << "m_filepattern" << m_filepattern << endl; // TQDir d( m_filepattern ); // // int num = countFiles(d); // // if (countFiles(d) > 0) // // //kdDebug() << "count" << num << endl; -// +// // progress = new KProgressDialog (this, "progress", i18n( "Loading .." ), i18n( "Loading..." ), true); // progress->setAllowCancel(false); // prog = progress->progressBar(); // progress->setLabel(i18n( "Loading lots and lots and lots of virus information" )); // //int cnt = countFiles(d); // prog->setTotalSteps(countFiles(d)); -// //kdDebug() << "COUNT" << countFiles(d) << endl; -// +// //kdDebug() << "COUNT" << countFiles(d) << endl; +// // } int ScanViewer::countFiles( TQDir & root) @@ -894,15 +935,15 @@ int ScanViewer::countFiles( TQDir & root) } TQStringList entries = root.entryList( TQDir::Dirs | TQDir::Files | TQDir::Hidden); - - ////kdDebug() << "count" << counter << endl; + + ////kdDebug() << "count" << counter << endl; for (TQStringList::size_type j = 0; j < entries.size(); j++ ) { TQString entry = entries[j]; if( entry == "." || entry == "..") continue; - + TQFileInfo fi(root, entry ); entry = fi.absFilePath(); @@ -980,7 +1021,7 @@ void ScanViewer::slotOnItem( TQListViewItem * lineitem) status_label->setText( message); - + } void ScanViewer::slotOffItem( ) diff --git a/src/scanviewer.h b/src/scanviewer.h index fa85e6b..3114960 100644 --- a/src/scanviewer.h +++ b/src/scanviewer.h @@ -59,7 +59,7 @@ public: /** * Use this method to load whatever file/URL you have */ - + //void setDirName(TQString); void slotScan(const TQStringList & filepattern, int mode, bool recursive, bool dcopscan); void slotCancel(); @@ -128,6 +128,7 @@ private: void Quarantine(); void askUser(); int countFiles( TQDir & root); + TQString scanner; //void ScanViewer::startProgress(); TQLineEdit *template_edit; TQComboBox *files_combo, *pattern_combo, *check_combo; @@ -173,6 +174,7 @@ private: bool calculateTime; bool showProgress; TQFrame *status_frame; + bool clamdscan; }; #endif // _SCANVIEWER_H_ |