summaryrefslogtreecommitdiffstats
path: root/lib/Plugins/CCpp.cpp
diff options
context:
space:
mode:
authordnovotny <danny@rawhide.localdomain>2009-09-16 10:42:40 -0400
committerdnovotny <danny@rawhide.localdomain>2009-09-16 10:42:40 -0400
commitf5ebde6f7a629dd74f023a185b0398305ecad604 (patch)
treea2f57bb0fab91468b8eee5b1aa27ee5a12693e06 /lib/Plugins/CCpp.cpp
parent42a96a87f17b45c6cba999cb965ae6ef9f7c5735 (diff)
downloadabrt-f5ebde6f7a629dd74f023a185b0398305ecad604.tar.gz
abrt-f5ebde6f7a629dd74f023a185b0398305ecad604.tar.xz
abrt-f5ebde6f7a629dd74f023a185b0398305ecad604.zip
added timeout to Polkit, added authorization check for debuginfo-install
Diffstat (limited to 'lib/Plugins/CCpp.cpp')
-rw-r--r--lib/Plugins/CCpp.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index 2f8d355..65851cb 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -24,6 +24,8 @@
#include "ABRTException.h"
#include "DebugDump.h"
#include "CommLayerInner.h"
+#include "Polkit.h"
+#include <sys/wait.h>
#include <fstream>
#include <sstream>
#include <set>
@@ -467,12 +469,46 @@ std::string CAnalyzerCCpp::GetGlobalUUID(const std::string& pDebugDumpDir)
return CreateHash(package + executable + independentBacktrace);
}
+static bool DebuginfoCheckPolkit(int uid)
+{
+ PolkitResult result;
+ int child_pid;
+
+ child_pid = fork();
+
+ if (child_pid == 0)
+ {
+ //child
+ setuid(uid);
+ result = polkit_check_authorization(getpid(),
+ "org.fedoraproject.abrt.change-daemon-settings");
+ if (result == PolkitYes)
+ {
+ exit(0); //authentication OK
+ }
+ exit(1);
+ } else
+ {
+ //parent
+ int status;
+
+ waitpid(child_pid, &status, 0);
+ if (WEXITSTATUS(status) == 0)
+ {
+ return true; //authentication OK
+ }
+ return false;
+ }
+
+}
+
void CAnalyzerCCpp::CreateReport(const std::string& pDebugDumpDir)
{
update_client(_("Starting report creation..."));
std::string package;
std::string backtrace;
+ std::string UID;
CDebugDump dd;
dd.Open(pDebugDumpDir);
@@ -481,10 +517,12 @@ void CAnalyzerCCpp::CreateReport(const std::string& pDebugDumpDir)
return;
}
dd.LoadText(FILENAME_PACKAGE, package);
+ dd.LoadText(FILENAME_UID, UID);
dd.Close();
map_plugin_settings_t settings = GetSettings();
- if (settings["InstallDebuginfo"] == "yes")
+ if (settings["InstallDebuginfo"] == "yes" &&
+ DebuginfoCheckPolkit(atoi(UID.c_str())) )
{
InstallDebugInfos(package);
}