diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-01-25 17:25:21 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-01-25 17:25:21 -0600 |
commit | ad1a71417d6aa07048a126a000c375bf1f0dc5c5 (patch) | |
tree | 7d9d3e2ce48d6f7f3efa53b95a50165b7e1a41a0 /drkonqi/backtrace.cpp | |
parent | 11a0e52fe6cf8f98f19b6364b8b5111665d3bcff (diff) | |
download | tdebase-ad1a71417d6aa07048a126a000c375bf1f0dc5c5.tar.gz tdebase-ad1a71417d6aa07048a126a000c375bf1f0dc5c5.zip |
Make drkonqui use tdesu when generating backtraces
This allows most Linux installations to gather backtraces with drkonqui
If a custom multiuser system does not allow sudo access for a user or users, backtraces
will not be available for those users. However, this change is due to Linux distributions
attempting to lock down a security hole, so drkonqui was broken for non-root users before
this commit anyway. Multiuser system administrators should collect and submit the backtraces anyway.
Diffstat (limited to 'drkonqi/backtrace.cpp')
-rw-r--r-- | drkonqi/backtrace.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/drkonqi/backtrace.cpp b/drkonqi/backtrace.cpp index e82ed614e..e6a4de578 100644 --- a/drkonqi/backtrace.cpp +++ b/drkonqi/backtrace.cpp @@ -42,7 +42,7 @@ BackTrace::BackTrace(const KrashConfig *krashconf, TQObject *parent, const char *name) : TQObject(parent, name), - m_krashconf(krashconf), m_temp(0) + m_krashconf(krashconf), m_temp(NULL), m_temp_cmd(NULL) { m_proc = new KProcess; } @@ -64,6 +64,7 @@ BackTrace::~BackTrace() } delete m_temp; + delete m_temp_cmd; } void BackTrace::start() @@ -92,14 +93,25 @@ void BackTrace::start() ::write(handle, "\n", 1); ::fsync(handle); + // build the debugger command + TQString str = m_krashconf->debuggerBatch(); + m_krashconf->expandString(str, true, m_temp->name()); + + // write the debugger command + m_temp_cmd = new KTempFile(TQString::null, TQString::null, 0700); + m_temp_cmd->setAutoDelete(TRUE); + handle = m_temp_cmd->handle(); + const char* dbgcommand = str.latin1(); + ::write(handle, dbgcommand, strlen(dbgcommand)); // the command to execute the debugger + ::write(handle, "\n", 1); + ::fsync(handle); + m_temp_cmd->close(); + // start the debugger m_proc = new KProcess; m_proc->setUseShell(true); - TQString str = m_krashconf->debuggerBatch(); - m_krashconf->expandString(str, true, m_temp->name()); - - *m_proc << str; + *m_proc << "tdesu -t --comment \"" << i18n("Administrative access is required to generate a backtrace") << "\" -c \"" << m_temp_cmd->name() << "\""; connect(m_proc, TQT_SIGNAL(receivedStdout(KProcess*, char*, int)), TQT_SLOT(slotReadInput(KProcess*, char*, int))); @@ -112,9 +124,16 @@ void BackTrace::start() void BackTrace::slotReadInput(KProcess *, char* buf, int buflen) { TQString newstr = TQString::fromLocal8Bit(buf, buflen); - m_strBt.append(newstr); - - emit append(newstr); + newstr.replace("\n\n", "\n"); + if (m_strBt.isEmpty()) { + if (newstr == "\n") { + newstr = ""; + } + } + if (!newstr.startsWith(": ")) { + m_strBt.append(newstr); + emit append(newstr); + } } void BackTrace::slotProcessExited(KProcess *proc) |