summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMavridis Philippe <[email protected]>2021-03-04 14:46:45 +0200
committerMavridis Philippe <[email protected]>2021-03-04 14:50:53 +0200
commit4ffce7bb907da506241abd687dcd8a641f403f55 (patch)
tree85312d21dc020be3e60bbcbec6b325d7a070764a /src
parent13cb4a5e7dc1c22d25c51da52156a558be0b7d05 (diff)
downloadklamav-4ffce7bb907da506241abd687dcd8a641f403f55.tar.gz
klamav-4ffce7bb907da506241abd687dcd8a641f403f55.zip
Scheduler scipt: store path to ICEauthority file in script.
This hopefully resolves issue #21. Signed-off-by: Mavridis Philippe <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/schedule.cpp56
-rw-r--r--src/schedule.h8
2 files changed, 61 insertions, 3 deletions
diff --git a/src/schedule.cpp b/src/schedule.cpp
index 75e18b9..c0250ed 100644
--- a/src/schedule.cpp
+++ b/src/schedule.cpp
@@ -21,6 +21,8 @@
#include <kstdguiitem.h>
#include <sys/stat.h>
+/* Finding out ICEauthority path */
+#include <kprocio.h>
Schedule::Schedule( TQWidget* parent, TQStringList filepattern, const char* name, bool modal, WFlags fl )
: TQDialog( parent, name, modal, fl )
@@ -33,17 +35,19 @@ Schedule::Schedule( TQWidget* parent, TQStringList filepattern, const char* name
// for each user
// CTCronIterator i = const_cast<CTHost&>(cth).cron.begin();
-// CTCron* ctcron((CTCron*)*i);
+// CTCron* ctcron((CTCron*)*i);
+ /* Figure out where the ICEauthority file is located */
+ getICEauth();
_filepattern = filepattern;
//bool isRTL = TQApplication::reverseLayout();
TQVBoxLayout *vbox = new TQVBoxLayout(this, KDialog::marginHint(),
KDialog::spacingHint(), "vbox");
-
+
TQGroupBox *group = new TQGroupBox("Schedule Scan of Selected Folders", this);
vbox->addWidget(group);
-
+
TQGridLayout *layout = new TQGridLayout( group, 6, 6, KDialog::spacingHint(),
@@ -371,6 +375,8 @@ TQString Schedule::createScanScript()
ts << " done" << "\n";
ts << "fi" << "\n";
ts << "export DCOPSERVER=`cat ${HOME}/.DCOPserver_${HOSTNAME}_${DISPLAY} | grep local`" << "\n";
+ /* This path is always the same for the current user */
+ ts << TQString("export ICEAUTHORITY=%1 # issue 21").arg(iceauth) << "\n";
ts << "# Execution starts here" << "\n";
ts << "if [ \"$1\" = \"\" ]; then" << "\n";
ts << " exit 1" << "\n";
@@ -468,6 +474,50 @@ TQString Schedule::createStartupScript()
}
+void Schedule::getICEauth()
+{
+ /* Code taken from freshklam.cpp */
+ TQString command=TQString("iceauth -v exit");
+
+ iceproc = new KProcIO();
+ iceproc->setUseShell(TRUE);
+ iceproc->setUsePty(KProcIO::Stdout,TRUE);
+
+ *iceproc<<command;
+
+ connect( iceproc, SIGNAL(readReady(KProcIO *)),
+ SLOT(slotICEoutput(KProcIO *)) );
+ connect( iceproc, SIGNAL(processExited(TDEProcess *)),
+ SLOT(slotICEexited()) );
+
+ iceproc->start(KProcIO::NotifyOnExit);
+ iceproc->closeWhenDone();
+}
+
+
+void Schedule::slotICEexited()
+{
+ delete iceproc;
+}
+
+void Schedule::slotICEoutput(KProcIO *)
+{
+ TQString lineout = "";
+ int pos;
+
+ if ((pos = (iceproc->readln(lineout))) != -1) {
+ if ((pos = (lineout.find("Using authority file"))) != -1){
+ lineout = lineout.stripWhiteSpace();
+ int StartPoint = (lineout.find("Using authority file") + 20);
+ iceauth = lineout.mid(StartPoint).stripWhiteSpace();
+ // kdDebug() << "iceauth file: " << iceauth << endl;
+ }
+ }
+
+ iceproc->ackRead();
+ lineout = "";
+}
+
HMSTimeWidget::HMSTimeWidget(TQWidget *parent, const char *name) :
diff --git a/src/schedule.h b/src/schedule.h
index d3725fd..486019a 100644
--- a/src/schedule.h
+++ b/src/schedule.h
@@ -43,6 +43,7 @@ class KURLRequester;
class CollectionSetup;
class TQToolButton;
class TQHBoxLayout;
+class KProcIO;
class HMSTimeWidget : public KIntSpinBox
{
@@ -123,11 +124,17 @@ private slots:
void slotDelete();
void slotOK();
void slotCancel();
+
+ void slotICEoutput(KProcIO *);
+ void slotICEexited();
private:
void setupAccel();
void setupActions();
TQString createScanScript();
TQString createStartupScript();
+
+ TQString iceauth;
+ void getICEauth();
private:
signals:
@@ -163,6 +170,7 @@ private:
CTHost* cthost;
CTTask* cttask;
CTCron* ctcron;
+ KProcIO *iceproc;
};