Diffstat (limited to 'core/apps/embeddedkonsole/konsole.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 74 |
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 @@ -47,4 +47,7 @@ #include <qpalette.h> +#include <unistd.h> +#include <pwd.h> +#include <sys/types.h> #include <sys/wait.h> #include <stdio.h> @@ -172,18 +175,55 @@ 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 +} Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, 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() { @@ -300,5 +340,5 @@ void Konsole::init(const char* _pgm, QStrList & _args) colorMenu->insertItem(tr( "Custom")); #endif - + configMenu->insertItem( tr("Font"), fontList ); configMenu->insertItem(tr( "Colors") ,colorMenu); @@ -369,5 +409,5 @@ void Konsole::init(const char* _pgm, QStrList & _args) // scrollMenu->insertSeparator(4); // scrollMenu->insertItem(tr( "Horizontal" )); - + configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); @@ -381,5 +421,5 @@ void Konsole::init(const char* _pgm, QStrList & _args) configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); - + //scrollMenuSelected(-29); // cfg.setGroup("ScrollBar"); @@ -419,5 +459,5 @@ void Konsole::show() } QMainWindow::show(); - + } @@ -542,5 +582,5 @@ void Konsole::setColLin(int columns, int lines) { qDebug("konsole::setColLin:: Columns %d", columns); - + if ((columns==0) || (lines==0)) { @@ -764,5 +804,5 @@ void Konsole::colorMenuSelected(int iD) colorMenu->setItemChecked(-18,TRUE); } -#ifdef QT_QWS_OPIE +#ifdef QT_QWS_OPIE if(iD==-19) { // Custom @@ -891,5 +931,5 @@ i=-24;j=-25;k=-26; cfg.writeEntry("Position",0); } else if(index == j) { - + te->setScrollbarLocation(1); cfg.writeEntry("Position",1); @@ -899,5 +939,5 @@ i=-24;j=-25;k=-26; cfg.writeEntry("Position",2); } - + // case -29: { // bool b=cfg.readBoolEntry("HorzScroll",0); @@ -1048,5 +1088,5 @@ i=-29; i=-28; #endif - + Config cfg("Konsole"); cfg.setGroup("ScrollBar"); @@ -1059,4 +1099,4 @@ i=-28; te->setWrapAt(120); configMenu->setItemChecked( i,FALSE); - } + } } |