summaryrefslogtreecommitdiffstats
path: root/ubuntu/maverick/applications/kiosktool/debian/patches/kubuntu_03_sudo_support.diff
blob: 1ee90050149d5d234f7ce00cb09760b3216de53f (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
--- kiosktool/kiosktool/kioskrun.h	2005-04-25 10:46:33.000000000 +0100
+++ kiosktool/kiosktool/kioskrun.h	2007-07-18 17:47:04.000000000 +0100
@@ -37,6 +37,18 @@
 
 class KioskGui;
 
+class NETACCESS {
+ public:
+  static bool exists(const KURL &url, bool source, TQWidget *window);
+  static bool mkdir(const KURL &url, TQWidget *window, int permissions=-1);
+  static TQString lastErrorString();
+  static int lastError();
+  static bool file_copy (const KURL &src, const KURL &dest, int permissions=-1, bool overwrite=false, bool resume=false, TQWidget *window=0L);
+  static bool del(const KURL &url, TQWidget *window);
+  static bool file_move(const KURL &src, const KURL &target, int permissions=-1, bool overwrite=false, bool resume=false, TQWidget *window=0L);
+  static bool copy(const KURL &src, const KURL &target, TQWidget *window);
+};
+
 class KioskRun : public TQObject
 {
   friend class KioskGui;
--- kiosktool/kiosktool/kioskrun.cpp	2005-04-25 10:46:33.000000000 +0100
+++ kiosktool/kiosktool/kioskrun.cpp	2007-07-20 16:56:07.000000000 +0100
@@ -28,6 +28,7 @@
 
 #include <tqdir.h>
 #include <tqfile.h>
+#include <tqprocess.h>
 
 #include <tdeapplication.h>
 #include <tdecmdlineargs.h>
@@ -45,10 +46,124 @@
 #include "kiosksync.h"
 
 #include <tdeio/netaccess.h>
-#define NETACCESS	TDEIO::NetAccess
+// Kiosktool wants to use fish://root@localhost/... which won't work on Kubuntu because we don't run ssh by default, we don't allow ssh to do root logins and root doesn't even have a password, so implement the functions here for local copies using tdesu instead
+// #define NETACCESS	TDEIO::NetAccess
 
 #undef DEBUG_ENTRIES
 
+bool NETACCESS::exists(const KURL &url, bool source, TQWidget *window)
+{
+  if (url.protocol() == "fish" && url.host() == "localhost") {
+    bool exists = TQFile::exists(url.path());
+    return exists;
+  } else {
+    bool result = TDEIO::NetAccess::exists(url, source, window);
+    return result;
+  }
+}
+
+bool NETACCESS::mkdir(const KURL &url, TQWidget *window, int permissions)
+{
+  if (url.protocol() == "fish" && url.host() == "localhost") {
+    TQProcess proc;
+    proc.addArgument("tdesudo");
+    proc.addArgument("mkdir " + url.path());
+    TQByteArray buffer;
+    proc.launch(buffer);
+    while (!proc.normalExit()) {
+      TDEApplication::kapp->processEvents();
+    }
+    bool exists = TQFile::exists(url.path());
+    return exists;
+  } else {
+    bool result = TDEIO::NetAccess::mkdir(url, window, permissions);
+    return result;
+  }
+}
+
+TQString NETACCESS::lastErrorString()
+{
+  return "Error in Kiosktool Kubuntu modifications";
+}
+
+int NETACCESS::lastError()
+{
+  return 0;
+}
+
+bool NETACCESS::file_copy(const KURL &src, const KURL &dest, int permissions, bool overwrite, bool resume, TQWidget *window)
+{
+  if (dest.protocol() == "fish" && dest.host() == "localhost") {
+    TQProcess proc;
+    proc.addArgument("tdesudo");
+    proc.addArgument("cp " + src.path() + " " + dest.path());
+    TQByteArray buffer;
+    proc.launch(buffer);
+    while (!proc.normalExit()) {
+      TDEApplication::kapp->processEvents();
+    }
+
+    TQProcess proc2;
+    proc2.addArgument("tdesudo");
+    proc2.addArgument("chmod 0644 " + dest.path());
+    proc2.launch(buffer);
+    while (!proc2.normalExit()) {
+      TDEApplication::kapp->processEvents();
+    }
+
+    bool exists = TQFile::exists(dest.path());
+    return exists;
+  } else {
+    bool result = TDEIO::NetAccess::file_copy(src, dest, permissions, overwrite, resume, window);
+    return result;
+  }
+}
+
+bool NETACCESS::del(const KURL &url, TQWidget *window)
+{
+  if (url.protocol() == "fish" && url.host() == "localhost") {
+    TQProcess proc;
+    proc.addArgument("tdesudo");
+    proc.addArgument("rm " + url.path());
+    TQByteArray buffer;
+    proc.launch(buffer);
+    while (!proc.normalExit()) {
+      TDEApplication::kapp->processEvents();
+    }
+    bool exists = !TQFile::exists(url.path());
+    return exists;
+  } else {
+    bool result = TDEIO::NetAccess::del(url, window);
+    return result;
+  }
+}
+
+bool NETACCESS::file_move(const KURL &src, const KURL &target, int permissions, bool overwrite, bool resume, TQWidget *window)
+{
+  if (target.protocol() == "fish" && target.host() == "localhost") {
+    TQProcess proc;
+    proc.addArgument("tdesudo");
+    proc.addArgument("mv " + src.path() + " " + target.path());
+    TQByteArray buffer;
+    proc.launch(buffer);
+    while (!proc.normalExit()) {
+      TDEApplication::kapp->processEvents();
+    }
+
+    bool exists = TQFile::exists(target.path());
+    return exists;
+  } else {
+    bool result = TDEIO::NetAccess::file_move(src, target, permissions, overwrite, resume, window);
+    return result;
+  }
+}
+
+//only used for local files
+bool NETACCESS::copy(const KURL &src, const KURL &target, TQWidget *window)
+{
+  return TDEIO::NetAccess::copy(src, target, window);
+}
+
 KioskRun *KioskRun::s_self = 0;
 
 KioskRun::KioskRun( TQObject* parent, const char* name)