Diffstat (limited to 'noncore/apps/opie-console/MyPty.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/MyPty.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp index 534f79a..b0f0275 100644 --- a/noncore/apps/opie-console/MyPty.cpp +++ b/noncore/apps/opie-console/MyPty.cpp | |||
@@ -142,14 +142,8 @@ void MyPty::error() | |||
142 | } | 142 | } |
143 | 143 | ||
144 | void MyPty::start() { | 144 | void MyPty::start() { |
145 | char* cmd = "/bin/sh"; | ||
146 | |||
147 | if ( QFile::exists( "/bin/bash" ) ) { | ||
148 | cmd = "/bin/bash"; | ||
149 | } | ||
150 | |||
151 | QStrList lis; | 145 | QStrList lis; |
152 | int r =run(cmd, lis, 0, 0); | 146 | int r =run(m_cmd.latin1(), lis, 0, 0); |
153 | r = r; | 147 | r = r; |
154 | } | 148 | } |
155 | /*! | 149 | /*! |
@@ -182,7 +176,10 @@ int MyPty::run(const char* cmd, QStrList &, const char*, int) | |||
182 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); | 176 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); |
183 | setenv("TERM",m_term,1); | 177 | setenv("TERM",m_term,1); |
184 | setenv("COLORTERM","0",1); | 178 | setenv("COLORTERM","0",1); |
185 | 179 | EnvironmentMap::Iterator it; | |
180 | for (it = m_env.begin(); it != m_env.end(); it++) { | ||
181 | setenv(it.key().latin1(), it.data().latin1(), 1); | ||
182 | } | ||
186 | if (getuid() == 0) { | 183 | if (getuid() == 0) { |
187 | char msg[] = "WARNING: You are running this shell as root!\n"; | 184 | char msg[] = "WARNING: You are running this shell as root!\n"; |
188 | write(ttyfd, msg, sizeof(msg)); | 185 | write(ttyfd, msg, sizeof(msg)); |
@@ -263,6 +260,7 @@ MyPty::MyPty(const Profile& prof) : m_cpid(0) | |||
263 | m_fd = openPty(); | 260 | m_fd = openPty(); |
264 | ProcCtl* ctl = ProcCtl::self(); | 261 | ProcCtl* ctl = ProcCtl::self(); |
265 | Q_UNUSED(ctl); | 262 | Q_UNUSED(ctl); |
263 | reload(prof); | ||
266 | } | 264 | } |
267 | 265 | ||
268 | /*! | 266 | /*! |
@@ -291,8 +289,17 @@ void MyPty::close() { | |||
291 | donePty(); | 289 | donePty(); |
292 | m_fd = openPty(); | 290 | m_fd = openPty(); |
293 | } | 291 | } |
294 | void MyPty::reload( const Profile& ) { | 292 | void MyPty::reload( const Profile& prof) { |
295 | 293 | m_env.clear(); | |
294 | m_cmd = prof.readEntry("Command", "/bin/bash"); | ||
295 | int envcount = prof.readNumEntry("EnvVars", 0); | ||
296 | for (int i=0; i<envcount; i++) { | ||
297 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); | ||
298 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); | ||
299 | if (!(name.isEmpty() || value.isEmpty())) { | ||
300 | m_env.insert(name, value); | ||
301 | } | ||
302 | } | ||
296 | } | 303 | } |
297 | /*! sends len bytes through the line */ | 304 | /*! sends len bytes through the line */ |
298 | void MyPty::send(const QByteArray& ar) | 305 | void MyPty::send(const QByteArray& ar) |