summaryrefslogtreecommitdiff
authorzecke <zecke>2004-02-29 18:39:07 (UTC)
committer zecke <zecke>2004-02-29 18:39:07 (UTC)
commit1a59dd467d210703b69d2d694f95988f2e97c27f (patch) (unidiff)
tree009e2d2c137c4d0d89b4901a8d3a53ff76bd64de
parentf8e1f2c5201f7e86abaa7365040d919e2afcd2ae (diff)
downloadopie-1a59dd467d210703b69d2d694f95988f2e97c27f.zip
opie-1a59dd467d210703b69d2d694f95988f2e97c27f.tar.gz
opie-1a59dd467d210703b69d2d694f95988f2e97c27f.tar.bz2
from the branch to find the best shell or fallback to /bin/sh
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp45
1 files changed, 43 insertions, 2 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index eafc12e..084c39d 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -23,6 +23,9 @@
23// enhancements added by Phillip Kuhn 23// enhancements added by Phillip Kuhn
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26#include <sys/types.h>
27#include <pwd.h>
28#include <unistd.h>
26 29
27#ifdef QT_QWS_OPIE 30#ifdef QT_QWS_OPIE
28#include <opie2/ocolorpopupmenu.h> 31#include <opie2/ocolorpopupmenu.h>
@@ -220,11 +223,49 @@ static const char *commonCmds[] =
220 }; 223 };
221 224
222 225
226static void konsoleInit(const char** shell) {
227 if(setuid(getuid()) !=0) qDebug("setuid failed");
228 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges
229
230
231// QPEApplication::grabKeyboard(); // for CTRL and ALT
232
233 qDebug("keyboard grabbed");
234#ifdef FAKE_CTRL_AND_ALT
235 qDebug("Fake Ctrl and Alt defined");
236 QPEApplication::grabKeyboard(); // for CTRL and ALT
237#endif
238
239 *shell = getenv("SHELL");
240 qWarning("SHell initially is %s", *shell );
241
242 if (shell == NULL || *shell == '\0') {
243 struct passwd *ent = 0;
244 uid_t me = getuid();
245 *shell = "/bin/sh";
246
247 while ( (ent = getpwent()) != 0 ) {
248 if (ent->pw_uid == me) {
249 if (ent->pw_shell != "")
250 *shell = ent->pw_shell;
251 break;
252 }
253 }
254 endpwent();
255 }
256
257 if( putenv((char*)"COLORTERM=") !=0)
258 qDebug("putenv failed"); // to trigger mc's color detection
259}
260
261
223Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 262Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
224 QMainWindow(parent, name, fl) 263 QMainWindow(parent, name, fl)
225{ 264{
226 QStrList args; 265 QStrList tmp; const char* shell;
227 init("/bin/bash",args); 266
267 konsoleInit( &shell);
268 init(shell,tmp);
228} 269}
229 270
230Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 271Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)