summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-04-22 21:18:03 (UTC)
committer kergoth <kergoth>2003-04-22 21:18:03 (UTC)
commitbb8965d31b06ec122a0916d8c5bc4c4b68873a14 (patch) (unidiff)
tree63a70f536648757440ac38fd003ab10901d439a0
parente3ef0f8587b10bf242d8077609988e06a37bcae5 (diff)
downloadopie-bb8965d31b06ec122a0916d8c5bc4c4b68873a14.zip
opie-bb8965d31b06ec122a0916d8c5bc4c4b68873a14.tar.gz
opie-bb8965d31b06ec122a0916d8c5bc4c4b68873a14.tar.bz2
Alter embeddedkonsole to obey SHELL env var if set, otherwise use the user's default shell, falling back to /bin/sh.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/main.cpp22
1 files changed, 17 insertions, 5 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
@@ -1,67 +1,79 @@
1/* ---------------------------------------------------------------------- */ 1/* ---------------------------------------------------------------------- */
2/* */ 2/* */
3/* [main.C] Konsole */ 3/* [main.C] Konsole */
4/* */ 4/* */
5/* ---------------------------------------------------------------------- */ 5/* ---------------------------------------------------------------------- */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole, an X terminal. */ 9/* This file is part of Konsole, an X terminal. */
10/* */ 10/* */
11/* The material contained in here more or less directly orginates from */ 11/* The material contained in here more or less directly orginates from */
12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
13/* */ 13/* */
14/* ---------------------------------------------------------------------- */ 14/* ---------------------------------------------------------------------- */
15/* */ 15/* */
16/* Ported Konsole to Qt/Embedded */ 16/* Ported Konsole to Qt/Embedded */
17/* */ 17/* */
18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
19/* */ 19/* */
20/* -------------------------------------------------------------------------- */ 20/* -------------------------------------------------------------------------- */
21 21
22#include "konsole.h" 22#include "konsole.h"
23 23
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25 25
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
38 41
39 QPEApplication a( argc, argv ); 42 QPEApplication a( argc, argv );
40 43
41// QPEApplication::grabKeyboard(); // for CTRL and ALT 44// QPEApplication::grabKeyboard(); // for CTRL and ALT
42 45
43 qDebug("keyboard grabbed"); 46 qDebug("keyboard grabbed");
44#ifdef FAKE_CTRL_AND_ALT 47#ifdef FAKE_CTRL_AND_ALT
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";
59
60 while ( (ent = getpwent()) != 0 ) {
61 if (ent->pw_uid == me) {
62 if (ent->pw_shell != "")
63 shell = ent->pw_shell;
64 break;
65 }
66 }
67 endpwent();
68 }
53 69
54 // sh is completely broken on familiar. Let's try to get something better
55 if ( qstrcmp( shell, "/bin/shell" ) == 0 && QFile::exists( "/bin/bash" ) )
56 shell = "/bin/bash";
57
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") );
63 a.showMainWidget( &m ); 75 a.showMainWidget( &m );
64 76
65 return a.exec(); 77 return a.exec();
66} 78}
67 79