summaryrefslogtreecommitdiff
path: root/core/apps/embeddedkonsole/konsole.cpp
Side-by-side diff
Diffstat (limited to 'core/apps/embeddedkonsole/konsole.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp74
1 files changed, 57 insertions, 17 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index c324c35..ec438c3 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -48,2 +48,5 @@
+#include <unistd.h>
+#include <pwd.h>
+#include <sys/types.h>
#include <sys/wait.h>
@@ -173,2 +176,38 @@ 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();
+ }
+
+ qWarning("SHELL now is %s", *shell );
+
+ if( putenv((char*)"COLORTERM=") !=0)
+ qDebug("putenv failed"); // to trigger mc's color detection
+}
@@ -177,12 +216,13 @@ Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
{
- QStrList args;
- init("/bin/sh",args);
-}
+ QStrList tmp; const char* shell;
-Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
- : QMainWindow(0, name)
-{
- init(_pgm,_args);
+ setCaption( tr("Terminal") );
+
+ konsoleInit( &shell);
+ qWarning("Using shell %s", shell);
+ init(shell,tmp);
}
+
+
void Konsole::initCommandList()
@@ -301,3 +341,3 @@ void Konsole::init(const char* _pgm, QStrList & _args)
#endif
-
+
configMenu->insertItem( tr("Font"), fontList );
@@ -370,3 +410,3 @@ void Konsole::init(const char* _pgm, QStrList & _args)
// scrollMenu->insertItem(tr( "Horizontal" ));
-
+
configMenu->insertItem(tr( "ScrollBar" ),scrollMenu);
@@ -382,3 +422,3 @@ void Konsole::init(const char* _pgm, QStrList & _args)
-
+
//scrollMenuSelected(-29);
@@ -420,3 +460,3 @@ void Konsole::show()
QMainWindow::show();
-
+
}
@@ -543,3 +583,3 @@ void Konsole::setColLin(int columns, int lines)
qDebug("konsole::setColLin:: Columns %d", columns);
-
+
if ((columns==0) || (lines==0))
@@ -765,3 +805,3 @@ void Konsole::colorMenuSelected(int iD)
}
-#ifdef QT_QWS_OPIE
+#ifdef QT_QWS_OPIE
if(iD==-19) {
@@ -892,3 +932,3 @@ i=-24;j=-25;k=-26;
} else if(index == j) {
-
+
te->setScrollbarLocation(1);
@@ -900,3 +940,3 @@ i=-24;j=-25;k=-26;
}
-
+
// case -29: {
@@ -1049,3 +1089,3 @@ i=-28;
#endif
-
+
Config cfg("Konsole");
@@ -1060,3 +1100,3 @@ i=-28;
configMenu->setItemChecked( i,FALSE);
- }
+ }
}