summaryrefslogtreecommitdiff
path: root/core
authorzecke <zecke>2004-02-29 18:39:07 (UTC)
committer zecke <zecke>2004-02-29 18:39:07 (UTC)
commit1a59dd467d210703b69d2d694f95988f2e97c27f (patch) (side-by-side diff)
tree009e2d2c137c4d0d89b4901a8d3a53ff76bd64de /core
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 (limited to 'core') (more/less context) (ignore 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 @@
// enhancements added by Phillip Kuhn
#include <stdlib.h>
+#include <sys/types.h>
+#include <pwd.h>
+#include <unistd.h>
#ifdef QT_QWS_OPIE
#include <opie2/ocolorpopupmenu.h>
@@ -220,11 +223,49 @@ static const char *commonCmds[] =
};
+static void konsoleInit(const char** shell) {
+ if(setuid(getuid()) !=0) qDebug("setuid failed");
+ if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges
+
+
+// QPEApplication::grabKeyboard(); // for CTRL and ALT
+
+ qDebug("keyboard grabbed");
+#ifdef FAKE_CTRL_AND_ALT
+ qDebug("Fake Ctrl and Alt defined");
+ QPEApplication::grabKeyboard(); // for CTRL and ALT
+#endif
+
+ *shell = getenv("SHELL");
+ qWarning("SHell initially is %s", *shell );
+
+ if (shell == NULL || *shell == '\0') {
+ struct passwd *ent = 0;
+ uid_t me = getuid();
+ *shell = "/bin/sh";
+
+ while ( (ent = getpwent()) != 0 ) {
+ if (ent->pw_uid == me) {
+ if (ent->pw_shell != "")
+ *shell = ent->pw_shell;
+ break;
+ }
+ }
+ endpwent();
+ }
+
+ if( putenv((char*)"COLORTERM=") !=0)
+ qDebug("putenv failed"); // to trigger mc's color detection
+}
+
+
Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
QMainWindow(parent, name, fl)
{
- QStrList args;
- init("/bin/bash",args);
+ QStrList tmp; const char* shell;
+
+ konsoleInit( &shell);
+ init(shell,tmp);
}
Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)