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.
pull/2/head
Timothy Pearson 13 years ago
parent 11a0e52fe6
commit ad1a71417d

@ -42,7 +42,7 @@
BackTrace::BackTrace(const KrashConfig *krashconf, TQObject *parent, BackTrace::BackTrace(const KrashConfig *krashconf, TQObject *parent,
const char *name) const char *name)
: TQObject(parent, name), : TQObject(parent, name),
m_krashconf(krashconf), m_temp(0) m_krashconf(krashconf), m_temp(NULL), m_temp_cmd(NULL)
{ {
m_proc = new KProcess; m_proc = new KProcess;
} }
@ -64,6 +64,7 @@ BackTrace::~BackTrace()
} }
delete m_temp; delete m_temp;
delete m_temp_cmd;
} }
void BackTrace::start() void BackTrace::start()
@ -92,14 +93,25 @@ void BackTrace::start()
::write(handle, "\n", 1); ::write(handle, "\n", 1);
::fsync(handle); ::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 // start the debugger
m_proc = new KProcess; m_proc = new KProcess;
m_proc->setUseShell(true); m_proc->setUseShell(true);
TQString str = m_krashconf->debuggerBatch(); *m_proc << "tdesu -t --comment \"" << i18n("Administrative access is required to generate a backtrace") << "\" -c \"" << m_temp_cmd->name() << "\"";
m_krashconf->expandString(str, true, m_temp->name());
*m_proc << str;
connect(m_proc, TQT_SIGNAL(receivedStdout(KProcess*, char*, int)), connect(m_proc, TQT_SIGNAL(receivedStdout(KProcess*, char*, int)),
TQT_SLOT(slotReadInput(KProcess*, char*, int))); TQT_SLOT(slotReadInput(KProcess*, char*, int)));
@ -112,9 +124,16 @@ void BackTrace::start()
void BackTrace::slotReadInput(KProcess *, char* buf, int buflen) void BackTrace::slotReadInput(KProcess *, char* buf, int buflen)
{ {
TQString newstr = TQString::fromLocal8Bit(buf, buflen); TQString newstr = TQString::fromLocal8Bit(buf, buflen);
m_strBt.append(newstr); newstr.replace("\n\n", "\n");
if (m_strBt.isEmpty()) {
emit append(newstr); if (newstr == "\n") {
newstr = "";
}
}
if (!newstr.startsWith(": ")) {
m_strBt.append(newstr);
emit append(newstr);
}
} }
void BackTrace::slotProcessExited(KProcess *proc) void BackTrace::slotProcessExited(KProcess *proc)

@ -61,6 +61,7 @@ private:
KProcess *m_proc; KProcess *m_proc;
const KrashConfig *m_krashconf; const KrashConfig *m_krashconf;
KTempFile *m_temp; KTempFile *m_temp;
KTempFile *m_temp_cmd;
TQString m_strBt; TQString m_strBt;
}; };
#endif #endif

Loading…
Cancel
Save