summaryrefslogtreecommitdiff
blob: 5bf3f475f94ba0a93491a5c7f0a190ecdbd40aa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
Index: instance.cpp
===================================================================
RCS file: /home/kde/kdewebdev/kommander/executor/instance.cpp,v
retrieving revision 1.49
diff -u -3 -d -p -r1.49 instance.cpp
--- kommander/executor/instance.cpp	29 Dec 2004 09:58:46 -0000	1.49
+++ kommander/executor/instance.cpp	13 Apr 2005 19:18:57 -0000
@@ -131,6 +131,35 @@ bool Instance::build(QFile *a_file)
 
 bool Instance::run(QFile *a_file)
 {
+  // Check whether extension is *.kmdr
+  if (!m_uiFileName.fileName().endsWith(".kmdr")) {
+    KMessageBox::error(0, i18n("<qt>This file does not have a <b>.kmdr</b> extension. As a security precaution "
+           "Kommander will only run Kommander scripts with a clear identity.</qt>"),
+           i18n("Wrong Extension"));
+    return false;
+  }
+  
+  // Check whether file is not in some temporary directory.
+  QStringList tmpDirs = KGlobal::dirs()->resourceDirs("tmp");
+  tmpDirs += KGlobal::dirs()->resourceDirs("cache");
+  tmpDirs.append("/tmp/");
+  tmpDirs.append("/var/tmp/");
+  
+  bool inTemp = false;
+  for (QStringList::ConstIterator I = tmpDirs.begin(); I != tmpDirs.end(); ++I)
+    if (m_uiFileName.directory(false).startsWith(*I))
+      inTemp = true;
+        
+  if (inTemp)
+  {
+     if (KMessageBox::warningYesNo(0, i18n("<qt>This dialog is running from your <i>/tmp</i> directory. "
+         " This may mean that it was run from a KMail attachment or from a webpage. "
+         "<p>Any script contained in this dialog will have write access to all of your home directory; "
+         "<b>running such dialogs may be dangerous: </b>"
+         "<p>are you sure you want to continue?</qt>")) == KMessageBox::No)
+       return false;
+  }
+  
   /* add runtime arguments */
   if (m_cmdArguments) {
     QString args;
@@ -143,18 +172,7 @@ bool Instance::run(QFile *a_file)
     KommanderWidget::setGlobal("ARGS", args);
   }
   KommanderWidget::setGlobal("ARGCOUNT", QString("%1").arg(m_cmdArguments));
-    
-  if (m_uiFileName.directory().startsWith(locateLocal("tmp", "") + "/") ||
-      m_uiFileName.directory().startsWith("/tmp/"))
-  {
-     if (KMessageBox::warningYesNo(0, i18n("<qt>This dialog is running from your <i>/tmp</i> directory. "
-         " This may mean that it was run from a KMail attachment or from a webpage. "
-         "<p>Any script contained in this dialog will have write access to all of your home directory; "
-         "<b>running such dialogs may be dangerous: </b>"
-         "<p>are you sure you want to continue?</qt>")) == KMessageBox::No)
-       return false;
-  }
-  
+     
   if (!m_uiFileName.isEmpty()) 
   {
     KommanderWidget::setGlobal("_KDDIR", m_uiFileName.directory());