summaryrefslogtreecommitdiffstats
path: root/lib/Plugins/Mailx.cpp
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2010-01-18 13:19:54 +0100
committerKarel Klic <kklic@redhat.com>2010-01-18 13:19:54 +0100
commit4267cbcc29781ddcac00e259dfe05f3a26fbc2ec (patch)
tree213e47138967f1e7af4ee9ff9a3f2ed861cb5815 /lib/Plugins/Mailx.cpp
parentb2d1bd9e4f387c5a014d3002d741f25421c37aac (diff)
parentb41833ed61f7b579d2a46b26d261616c21a6ae32 (diff)
downloadabrt-4267cbcc29781ddcac00e259dfe05f3a26fbc2ec.tar.gz
abrt-4267cbcc29781ddcac00e259dfe05f3a26fbc2ec.tar.xz
abrt-4267cbcc29781ddcac00e259dfe05f3a26fbc2ec.zip
Merge branch 'master' of git://git.fedorahosted.org/git/abrt
Diffstat (limited to 'lib/Plugins/Mailx.cpp')
-rw-r--r--lib/Plugins/Mailx.cpp33
1 files changed, 8 insertions, 25 deletions
diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp
index 70eddb8..df33e84 100644
--- a/lib/Plugins/Mailx.cpp
+++ b/lib/Plugins/Mailx.cpp
@@ -39,33 +39,16 @@ CMailx::CMailx() :
static void exec_and_feed_input(uid_t uid, const char* pText, char **pArgs)
{
int pipein[2];
- pid_t child;
- xpipe(pipein);
- child = fork();
- if (child == -1)
- {
- close(pipein[0]);
- close(pipein[1]);
- throw CABRTException(EXCEP_PLUGIN, "Can't fork");
- }
- if (child == 0)
- {
- close(pipein[1]);
- xmove_fd(pipein[0], STDIN_FILENO);
-
- struct passwd* pw = getpwuid(uid);
- gid_t gid = pw ? pw->pw_gid : uid;
- setgroups(1, &gid);
- xsetregid(gid, gid);
- xsetreuid(uid, uid);
-
- execvp(pArgs[0], pArgs);
- exit(1); /* exec failed */
- }
+ pid_t child = fork_execv_on_steroids(
+ EXECFLG_INPUT | EXECFLG_QUIET | EXECFLG_SETGUID,
+ pArgs,
+ pipein,
+ /*unsetenv_vec:*/ NULL,
+ /*dir:*/ NULL,
+ uid);
- close(pipein[0]);
- safe_write(pipein[1], pText, strlen(pText));
+ full_write(pipein[1], pText, strlen(pText));
close(pipein[1]);
waitpid(child, NULL, 0); /* wait for command completion */