author | kergoth <kergoth> | 2003-04-22 21:18:03 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-04-22 21:18:03 (UTC) |
commit | bb8965d31b06ec122a0916d8c5bc4c4b68873a14 (patch) (unidiff) | |
tree | 63a70f536648757440ac38fd003ab10901d439a0 /core/apps/embeddedkonsole/main.cpp | |
parent | e3ef0f8587b10bf242d8077609988e06a37bcae5 (diff) | |
download | opie-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 (limited to 'core/apps/embeddedkonsole/main.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/apps/embeddedkonsole/main.cpp | 20 |
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 | |||
@@ -31,2 +31,5 @@ | |||
31 | 31 | ||
32 | #include <pwd.h> | ||
33 | #include <sys/types.h> | ||
34 | |||
32 | 35 | ||
@@ -50,8 +53,17 @@ int main(int argc, char* argv[]) | |||
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 | ||