summaryrefslogtreecommitdiff
path: root/core/apps/embeddedkonsole
Unidiff
Diffstat (limited to 'core/apps/embeddedkonsole') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/main.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/core/apps/embeddedkonsole/main.cpp b/core/apps/embeddedkonsole/main.cpp
index 167b009..91199eb 100644
--- a/core/apps/embeddedkonsole/main.cpp
+++ b/core/apps/embeddedkonsole/main.cpp
@@ -26,12 +26,15 @@
26#include <qfile.h> 26#include <qfile.h>
27 27
28#include <unistd.h> 28#include <unistd.h>
29#include <stdio.h> 29#include <stdio.h>
30#include <stdlib.h> 30#include <stdlib.h>
31 31
32#include <pwd.h>
33#include <sys/types.h>
34
32 35
33/* --| main |------------------------------------------------------ */ 36/* --| main |------------------------------------------------------ */
34int main(int argc, char* argv[]) 37int main(int argc, char* argv[])
35{ 38{
36 if(setuid(getuid()) !=0) qDebug("setuid failed"); 39 if(setuid(getuid()) !=0) qDebug("setuid failed");
37 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges 40 if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges
@@ -45,18 +48,27 @@ int main(int argc, char* argv[])
45 qDebug("Fake Ctrl and Alt defined"); 48 qDebug("Fake Ctrl and Alt defined");
46 QPEApplication::grabKeyboard(); // for CTRL and ALT 49 QPEApplication::grabKeyboard(); // for CTRL and ALT
47#endif 50#endif
48 51
49 QStrList tmp; 52 QStrList tmp;
50 const char* shell = getenv("SHELL"); 53 const char* shell = getenv("SHELL");
51 if (shell == NULL || *shell == '\0') 54
55 if (shell == NULL || *shell == '\0') {
56 struct passwd *ent = 0;
57 uid_t me = getuid();
52 shell = "/bin/sh"; 58 shell = "/bin/sh";
53 59
54 // sh is completely broken on familiar. Let's try to get something better 60 while ( (ent = getpwent()) != 0 ) {
55 if ( qstrcmp( shell, "/bin/shell" ) == 0 && QFile::exists( "/bin/bash" ) ) 61 if (ent->pw_uid == me) {
56 shell = "/bin/bash"; 62 if (ent->pw_shell != "")
63 shell = ent->pw_shell;
64 break;
65 }
66 }
67 endpwent();
68 }
57 69
58 if( putenv((char*)"COLORTERM=") !=0) 70 if( putenv((char*)"COLORTERM=") !=0)
59 qDebug("putenv failed"); // to trigger mc's color detection 71 qDebug("putenv failed"); // to trigger mc's color detection
60 72
61 Konsole m( "test", shell, tmp, TRUE ); 73 Konsole m( "test", shell, tmp, TRUE );
62 m.setCaption( Konsole::tr("Terminal") ); 74 m.setCaption( Konsole::tr("Terminal") );