summaryrefslogtreecommitdiffstats
path: root/lib/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Plugins')
-rw-r--r--lib/Plugins/CCpp.conf4
-rw-r--r--lib/Plugins/CCpp.cpp49
-rw-r--r--lib/Plugins/Catcut.cpp16
-rw-r--r--lib/Plugins/FileTransfer.cpp11
-rw-r--r--lib/Plugins/Firefox.cpp36
-rw-r--r--lib/Plugins/Mailx.cpp5
-rw-r--r--lib/Plugins/TicketUploader.cpp8
7 files changed, 51 insertions, 78 deletions
diff --git a/lib/Plugins/CCpp.conf b/lib/Plugins/CCpp.conf
index e5ba5ad..e42b85a 100644
--- a/lib/Plugins/CCpp.conf
+++ b/lib/Plugins/CCpp.conf
@@ -7,8 +7,8 @@ MakeCompatCore = no
# Generate memory map too (IGNORED FOR NOW)
MemoryMap = no
-# How to get debug-info: install, mount
-## install - download and install debug-info packages
+# How to get debuginfo: install, mount
+## install - download and install debuginfo packages
## mount - mount fedora NFS with debug info
## (IGNORED FOR NOW)
DebugInfo = install
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index add4e50..37a2c8b 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -101,13 +101,6 @@ static int ExecVP(char **pArgs, uid_t uid, string& pOutput)
int pipeout[2];
pid_t child;
- gid_t gid = uid;
- struct passwd* pw = getpwuid(uid);
- if (pw)
- {
- gid = pw->pw_gid;
- }
-
xpipe(pipeout);
child = fork();
if (child == -1)
@@ -120,18 +113,15 @@ static int ExecVP(char **pArgs, uid_t uid, string& pOutput)
close(pipeout[0]); /* read side of the pipe */
xmove_fd(pipeout[1], STDOUT_FILENO);
/* Make sure stdin is safely open to nothing */
- close(STDIN_FILENO);
- if (open("/dev/null", O_RDONLY))
- {
- if (open("/", O_RDONLY))
- abort(); /* never happens */
- }
+ xmove_fd(xopen("/dev/null", O_RDONLY), STDIN_FILENO);
/* Not a good idea, we won't see any error messages */
/* close(STDERR_FILENO); */
+ struct passwd* pw = getpwuid(uid);
+ gid_t gid = pw ? pw->pw_gid : uid;
setgroups(1, &gid);
- setregid(gid, gid);
- setreuid(uid, uid);
+ xsetregid(gid, gid);
+ xsetreuid(uid, uid);
setsid();
/* Nuke everything which may make setlocale() switch to non-POSIX locale:
@@ -261,7 +251,7 @@ static void GetBacktrace(const char *pDebugDumpDir,
const char *pDebugInfoDirs,
string& pBacktrace)
{
- update_client(_("Getting backtrace..."));
+ update_client(_("Generating backtrace"));
string UID;
string executable;
@@ -379,7 +369,7 @@ static void InstallDebugInfos(const char *pDebugDumpDir,
const char *debuginfo_dirs,
string& build_ids)
{
- update_client(_("Searching for debug-info packages..."));
+ update_client(_("Starting debuginfo installation"));
int pipeout[2]; //TODO: can we use ExecVP?
xpipe(pipeout);
@@ -395,8 +385,7 @@ static void InstallDebugInfos(const char *pDebugDumpDir,
{
close(pipeout[0]);
xmove_fd(pipeout[1], STDOUT_FILENO);
- close(STDIN_FILENO);
- xopen("/dev/null", O_RDONLY);
+ xmove_fd(xopen("/dev/null", O_RDONLY), STDIN_FILENO);
/* Not a good idea, we won't see any error messages */
/*close(STDERR_FILENO);*/
@@ -413,8 +402,6 @@ static void InstallDebugInfos(const char *pDebugDumpDir,
close(pipeout[1]);
- update_client(_("Downloading and installing debug-info packages..."));
-
FILE *pipeout_fp = fdopen(pipeout[0], "r");
if (pipeout_fp == NULL) /* never happens */
{
@@ -564,12 +551,6 @@ string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir)
args[4] = (char*)backtrace_path.c_str();
args[5] = NULL;
- uid_t uid = atoi(uid_str.c_str());
- gid_t gid = uid;
- struct passwd* pw = getpwuid(uid);
- if (pw)
- gid = pw->pw_gid;
-
int pipeout[2];
xpipe(pipeout); /* stdout of abrt-backtrace */
pid_t child = fork();
@@ -582,12 +563,13 @@ string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir)
xmove_fd(pipeout[1], STDOUT_FILENO);
close(pipeout[0]); /* read side of the pipe */
- /* abrt-backtrace is executed under the user's
- uid and gid. */
+ /* abrt-backtrace is executed under the user's uid and gid. */
+ uid_t uid = atoi(uid_str.c_str());
+ struct passwd* pw = getpwuid(uid);
+ gid_t gid = pw ? pw->pw_gid : uid;
setgroups(1, &gid);
- setregid(gid, gid);
- setreuid(uid, uid);
- setsid();
+ xsetregid(gid, gid);
+ xsetreuid(uid, uid);
execvp(args[0], args);
VERB1 perror_msg("Can't execute '%s'", args[0]);
@@ -638,8 +620,7 @@ static bool DebuginfoCheckPolkit(int uid)
if (child_pid == 0)
{
//child
- if (setuid(uid))
- exit(1); //paranoia
+ xsetreuid(uid, uid);
PolkitResult result = polkit_check_authorization(getpid(),
"org.fedoraproject.abrt.install-debuginfos");
exit(result != PolkitYes); //exit 1 (failure) if not allowed
diff --git a/lib/Plugins/Catcut.cpp b/lib/Plugins/Catcut.cpp
index 9974faa..ebddfdd 100644
--- a/lib/Plugins/Catcut.cpp
+++ b/lib/Plugins/Catcut.cpp
@@ -50,7 +50,7 @@ send_string(const char *pURL,
return;
}
- do
+ while (1)
{
int content_length = strlen(pContent);
FILE* f = fmemopen((void*)pContent, content_length, "r");
@@ -63,9 +63,11 @@ send_string(const char *pURL,
if (!result)
return;
update_client(_("Sending failed, try it again: %s"), curl_easy_strerror((CURLcode)result));
+ if (--retryCount <= 0)
+ break;
+ /* retry the upload if not succesful, wait a bit before next try */
+ sleep(retryDelaySeconds);
}
- /*retry the upload if not succesful, wait a bit before next try*/
- while (--retryCount != 0 && (sleep(retryDelaySeconds), 1));
throw CABRTException(EXCEP_PLUGIN, "send_string: can't send string");
}
@@ -84,7 +86,7 @@ send_file(const char *pURL,
update_client(_("Sending file %s to %s"), pFilename, pURL);
- do
+ while (1)
{
FILE* f = fopen(pFilename, "r");
if (!f)
@@ -99,9 +101,11 @@ send_file(const char *pURL,
if (!result)
return;
update_client(_("Sending failed, try it again: %s"), curl_easy_strerror((CURLcode)result));
+ if (--retryCount <= 0)
+ break;
+ /* retry the upload if not succesful, wait a bit before next try */
+ sleep(retryDelaySeconds);
}
- /*retry the upload if not succesful, wait a bit before next try*/
- while (--retryCount != 0 && (sleep(retryDelaySeconds), 1));
throw CABRTException(EXCEP_PLUGIN, "send_file: can't send file");
}
diff --git a/lib/Plugins/FileTransfer.cpp b/lib/Plugins/FileTransfer.cpp
index 03ee464..c98645c 100644
--- a/lib/Plugins/FileTransfer.cpp
+++ b/lib/Plugins/FileTransfer.cpp
@@ -68,9 +68,8 @@ void CFileTransfer::SendFile(const char *pURL, const char *pFilename)
string wholeURL = concat_path_file(pURL, pFilename);
- int result;
int count = m_nRetryCount;
- do
+ while (1)
{
FILE *f;
struct stat buf;
@@ -99,12 +98,14 @@ void CFileTransfer::SendFile(const char *pURL, const char *pFilename)
curl_easy_setopt(curl, CURLOPT_READDATA, f);
curl_easy_setopt(curl, CURLOPT_INFILESIZE, buf.st_size);
/* everything is done here; result 0 means success */
- result = curl_easy_perform(curl);
+ int result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(f);
+ if (result == 0 || --count <= 0)
+ break;
+ /* retry the upload if not succesful, wait a bit before next try */
+ sleep(m_nRetryDelay);
}
- /*retry the upload if not succesful, wait a bit before next try*/
- while (result != 0 && --count >= 0 && (sleep(m_nRetryDelay), 1));
}
/*
diff --git a/lib/Plugins/Firefox.cpp b/lib/Plugins/Firefox.cpp
index 6f2c60d..bcc5948 100644
--- a/lib/Plugins/Firefox.cpp
+++ b/lib/Plugins/Firefox.cpp
@@ -97,12 +97,6 @@ static pid_t ExecVP(char** pArgs, uid_t uid, std::string& pOutput)
int pipeout[2];
pid_t child;
- struct passwd* pw = getpwuid(uid);
- if (!pw)
- {
- throw CABRTException(EXCEP_PLUGIN, "%s: can't get GID for UID", __func__);
- }
-
xpipe(pipeout);
child = fork();
if (child == -1)
@@ -115,17 +109,15 @@ static pid_t ExecVP(char** pArgs, uid_t uid, std::string& pOutput)
close(pipeout[0]); /* read side of the pipe */
xmove_fd(pipeout[1], STDOUT_FILENO);
/* Make sure stdin is safely open to nothing */
- close(STDIN_FILENO);
- if (open("/dev/null", O_RDONLY))
- if (open("/", O_RDONLY))
- abort(); /* never happens */
+ xmove_fd(xopen("/dev/null", O_RDONLY), STDIN_FILENO);
/* Not a good idea, we won't see any error messages */
/* close(STDERR_FILENO); */
- setgroups(1, &pw->pw_gid);
- setregid(pw->pw_gid, pw->pw_gid);
- setreuid(uid, uid);
- setsid();
+ struct passwd* pw = getpwuid(uid);
+ gid_t gid = pw ? pw->pw_gid : uid;
+ setgroups(1, &gid);
+ xsetregid(gid, gid);
+ xsetreuid(uid, uid);
/* Nuke everything which may make setlocale() switch to non-POSIX locale:
* we need to avoid having gdb output in some obscure language.
@@ -251,7 +243,7 @@ static int rate_backtrace(const char *backtrace)
static void GetBacktrace(const char *pDebugDumpDir, std::string& pBacktrace)
{
- update_client(_("Getting backtrace..."));
+ update_client(_("Generating backtrace"));
std::string UID;
std::string executable;
@@ -549,7 +541,7 @@ static void InstallDebugInfos(const char *pDebugDumpDir, std::string& build_ids)
dd.LoadText(FILENAME_PACKAGE, package);
}
- update_client(_("Searching for debug-info packages..."));
+ update_client(_("Starting debuginfo installation"));
int pipein[2], pipeout[2];
xpipe(pipein);
@@ -611,8 +603,6 @@ Another application is holding the yum lock, cannot continue
safe_write(pipein[1], "y\n", sizeof("y\n")-1);
close(pipein[1]);
- update_client(_("Downloading and installing debug-info packages..."));
-
FILE *pipeout_fp = fdopen(pipeout[0], "r");
if (pipeout_fp == NULL) /* never happens */
{
@@ -676,7 +666,7 @@ Another application is holding the yum lock, cannot continue
*/
static void InstallDebugInfos(const char *pDebugDumpDir, std::string& build_ids)
{
- update_client(_("Searching for debug-info packages..."));
+ update_client(_("Starting debuginfo installation"));
int pipeout[2]; //TODO: can we use ExecVP?
xpipe(pipeout);
@@ -692,8 +682,7 @@ static void InstallDebugInfos(const char *pDebugDumpDir, std::string& build_ids)
{
close(pipeout[0]);
xmove_fd(pipeout[1], STDOUT_FILENO);
- close(STDIN_FILENO);
- xopen("/dev/null", O_RDONLY);
+ xmove_fd(xopen("/dev/null", O_RDONLY), STDIN_FILENO);
/* Not a good idea, we won't see any error messages */
/*close(STDERR_FILENO);*/
@@ -710,8 +699,6 @@ static void InstallDebugInfos(const char *pDebugDumpDir, std::string& build_ids)
close(pipeout[1]);
- update_client(_("Downloading and installing debug-info packages..."));
-
FILE *pipeout_fp = fdopen(pipeout[0], "r");
if (pipeout_fp == NULL) /* never happens */
{
@@ -860,8 +847,7 @@ static bool DebuginfoCheckPolkit(int uid)
if (child_pid == 0)
{
//child
- if (setuid(uid))
- exit(1); //paranoia
+ xsetreuid(uid, uid);
PolkitResult result = polkit_check_authorization(getpid(),
"org.fedoraproject.abrt.install-debuginfos");
exit(result != PolkitYes); //exit 1 (failure) if not allowed
diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp
index 26b6ec4..b06edeb 100644
--- a/lib/Plugins/Mailx.cpp
+++ b/lib/Plugins/Mailx.cpp
@@ -57,9 +57,8 @@ static void exec_and_feed_input(uid_t uid, const char* pText, char **pArgs)
struct passwd* pw = getpwuid(uid);
gid_t gid = pw ? pw->pw_gid : uid;
setgroups(1, &gid);
- setregid(gid, gid);
- setreuid(uid, uid);
- setsid(); /* why? I propose removing this */
+ xsetregid(gid, gid);
+ xsetreuid(uid, uid);
execvp(pArgs[0], pArgs);
exit(1); /* exec failed */
diff --git a/lib/Plugins/TicketUploader.cpp b/lib/Plugins/TicketUploader.cpp
index aa6d412..06b6cde 100644
--- a/lib/Plugins/TicketUploader.cpp
+++ b/lib/Plugins/TicketUploader.cpp
@@ -112,7 +112,7 @@ void CTicketUploader::SendFile(const char *pURL, const char *pFilename)
string wholeURL = concat_path_file(pURL, base);
int count = m_nRetryCount;
int result;
- do
+ while (1)
{
FILE* f = fopen(pFilename, "r");
if (!f)
@@ -144,9 +144,11 @@ void CTicketUploader::SendFile(const char *pURL, const char *pFilename)
{
update_client(_("Sending failed, trying again. %s"), curl_easy_strerror((CURLcode)result));
}
+ if (result == 0 || --count <= 0)
+ break;
+ /* retry the upload if not succesful, wait a bit before next try */
+ sleep(m_nRetryDelay);
}
- /*retry the upload if not succesful, wait a bit before next try*/
- while (result != 0 && --count != 0 && (sleep(m_nRetryDelay), 1));
if (count <= 0 && result != 0)
{