diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Plugins/CCpp.cpp | 50 | ||||
-rw-r--r-- | lib/Utils/Polkit.cpp | 25 |
2 files changed, 73 insertions, 2 deletions
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index cc9eaf4a..76858eb8 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> @@ -512,10 +514,49 @@ 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...")); +<<<<<<< HEAD + std::string package; + std::string backtrace; + std::string UID; +======= +>>>>>>> 5349d07f9cae8a2b9686916c1e5bd01a0fe14a29 CDebugDump dd; dd.Open(pDebugDumpDir); bool bt_exists = dd.Exist(FILENAME_BACKTRACE); @@ -524,9 +565,16 @@ void CAnalyzerCCpp::CreateReport(const std::string& pDebugDumpDir) { return; /* already done */ } +<<<<<<< HEAD + dd.LoadText(FILENAME_PACKAGE, package); + dd.LoadText(FILENAME_UID, UID); + dd.Close(); +======= +>>>>>>> 5349d07f9cae8a2b9686916c1e5bd01a0fe14a29 map_plugin_settings_t settings = GetSettings(); - if (settings["InstallDebuginfo"] == "yes") + if (settings["InstallDebuginfo"] == "yes" && + DebuginfoCheckPolkit(atoi(UID.c_str())) ) { InstallDebugInfos(pDebugDumpDir); } diff --git a/lib/Utils/Polkit.cpp b/lib/Utils/Polkit.cpp index 6d6cf0dd..f0dc4c79 100644 --- a/lib/Utils/Polkit.cpp +++ b/lib/Utils/Polkit.cpp @@ -25,21 +25,44 @@ #include <unistd.h> #include "Polkit.h" +#include "abrtlib.h" +<<<<<<< HEAD +/*number of seconds: timeout for the authorization*/ +#define POLKIT_TIMEOUT 20 + +static gboolean do_cancel(GCancellable* cancellable) +{ + log("Timer has expired; cancelling authorization check\n"); + g_cancellable_cancel(cancellable); + return FALSE; +} + +======= +>>>>>>> 5349d07f9cae8a2b9686916c1e5bd01a0fe14a29 static PolkitResult do_check(PolkitSubject *subject, const char *action_id) { PolkitAuthority *authority; PolkitAuthorizationResult *result; GError *error = NULL; + GCancellable * cancellable; authority = polkit_authority_get(); +<<<<<<< HEAD + cancellable = g_cancellable_new(); + + g_timeout_add (POLKIT_TIMEOUT * 1000, + (GSourceFunc) do_cancel, + cancellable); +======= +>>>>>>> 5349d07f9cae8a2b9686916c1e5bd01a0fe14a29 result = polkit_authority_check_authorization_sync(authority, subject, action_id, NULL, POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, - NULL, + cancellable, &error); if (error) |