From 93546d981cc14722e6ab1c00c1fd66908bbe8ba5 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 12 Jun 2012 01:58:10 -0500 Subject: Only request root access in drkonqui if yama ptrace setting requires it This resolves Bug 1005 (cherry picked from commit 30461576d34ece5d06626f217a034dbfaa353c4d) --- drkonqi/backtrace.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drkonqi/backtrace.cpp b/drkonqi/backtrace.cpp index 36a0fc8ff..7fa052e76 100644 --- a/drkonqi/backtrace.cpp +++ b/drkonqi/backtrace.cpp @@ -107,11 +107,31 @@ void BackTrace::start() ::fsync(handle); m_temp_cmd->close(); + // determine if yama has been used to prevent ptrace as normal user + bool need_root_access = false; + TQFile yamactl("/proc/sys/kernel/yama/ptrace_scope"); + if (yamactl.exists()) { + if (yamactl.open(IO_ReadOnly)) { + TQTextStream stream(&yamactl); + TQString line; + line = stream.readLine(); + if (line.toInt() != 0) { + need_root_access = true; + } + yamactl.close(); + } + } + // start the debugger m_proc = new KProcess; m_proc->setUseShell(true); - *m_proc << "kdesu -t --comment \"" << i18n("Administrative access is required to generate a backtrace") << "\" -c \"" << m_temp_cmd->name() << "\""; + if (need_root_access == false) { + *m_proc << m_temp_cmd->name(); + } + else { + *m_proc << "kdesu -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))); -- cgit v1.2.1