summaryrefslogtreecommitdiffstats
path: root/lib/Plugins
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-07-24 12:12:59 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-07-24 12:12:59 +0200
commit280334787ea74be1c5234849672c69dbfdb2f201 (patch)
tree2781aaed86df59efad57a608a86892a190efa91e /lib/Plugins
parent337fc151e4b2682de4c3b2496045e4054080b844 (diff)
downloadabrt-280334787ea74be1c5234849672c69dbfdb2f201.tar.gz
abrt-280334787ea74be1c5234849672c69dbfdb2f201.tar.xz
abrt-280334787ea74be1c5234849672c69dbfdb2f201.zip
remove GetGIDFromUID (two copies): getpwuid does the same
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Plugins')
-rw-r--r--lib/Plugins/CCpp.cpp31
-rw-r--r--lib/Plugins/CCpp.h3
2 files changed, 9 insertions, 25 deletions
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index 7d302c79..f7293265 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -361,23 +361,7 @@ void CAnalyzerCCpp::GetIndependentBuildIdPC(const std::string& pBuildIdPC, std::
}
}
-gid_t CAnalyzerCCpp::GetGIDFromUID(const std::string& pUID)
-{
- struct passwd* pw;
-
- while (( pw = getpwent()) != NULL)
- {
- if (pw->pw_uid == atoi(pUID.c_str()))
- {
- setpwent();
- return pw->pw_gid;
- }
- }
- setpwent();
- return -1;
-}
-
-void CAnalyzerCCpp::ExecVP(const char* pCommand, char* const pArgs[], const std::string& pUID, std::string& pOutput)
+void CAnalyzerCCpp::ExecVP(const char* pCommand, char* const pArgs[], uid_t uid, std::string& pOutput)
{
int pipeout[2];
char buff[1024];
@@ -385,9 +369,10 @@ void CAnalyzerCCpp::ExecVP(const char* pCommand, char* const pArgs[], const std:
pid_t child;
gid_t GID[1];
- if ((GID[0] = GetGIDFromUID(pUID)) == -1)
+ struct passwd* pw = getpwuid(uid);
+ if (!pw)
{
- throw CABRTException(EXCEP_PLUGIN, "CAnalyzerCCpp::ExecVP(): cannot get GUI for UID.");
+ throw CABRTException(EXCEP_PLUGIN, "CAnalyzerCCpp::ExecVP(): cannot get GID for UID.");
}
pipe(pipeout); /* error check? */
@@ -415,9 +400,9 @@ void CAnalyzerCCpp::ExecVP(const char* pCommand, char* const pArgs[], const std:
/* Not a good idea, we won't see any error messages */
/* close(STDERR_FILENO); */
- setgroups(1, GID);
- setregid(atoi(pUID.c_str()), atoi(pUID.c_str()));
- setreuid(atoi(pUID.c_str()), atoi(pUID.c_str()));
+ setgroups(1, &pw->pw_gid);
+ setregid(pw->pw_gid, pw->pw_gid);
+ setreuid(uid, uid);
setsid();
execvp(pCommand, pArgs);
@@ -487,7 +472,7 @@ std::string CAnalyzerCCpp::GetLocalUUID(const std::string& pDebugDumpDir)
dd.LoadText(FILENAME_UID, UID);
dd.LoadText(FILENAME_EXECUTABLE, executable);
dd.LoadText(FILENAME_PACKAGE, package);
- ExecVP(command, args, UID, buildIdPC);
+ ExecVP(command, args, atoi(UID.c_str()), buildIdPC);
dd.Close();
free(args[1]);
GetIndependentBuildIdPC(buildIdPC, independentBuildIdPC);
diff --git a/lib/Plugins/CCpp.h b/lib/Plugins/CCpp.h
index 1bdf230e..ed83b960 100644
--- a/lib/Plugins/CCpp.h
+++ b/lib/Plugins/CCpp.h
@@ -37,8 +37,7 @@ class CAnalyzerCCpp : public CAnalyzer
void GetBacktrace(const std::string& pDebugDumpDir, std::string& pBacktrace);
void GetIndependentBacktrace(const std::string& pBacktrace, std::string& pIndependentBacktrace);
void GetIndependentBuildIdPC(const std::string& pBuildIdPC, std::string& pIndependentBuildIdPC);
- gid_t GetGIDFromUID(const std::string& pUID);
- void ExecVP(const char* pCommand, char* const pArgs[], const std::string& pUID, std::string& pOutput);
+ void ExecVP(const char* pCommand, char* const pArgs[], uid_t uid, std::string& pOutput);
std::string CreateHash(const std::string& pInput);
public:
CAnalyzerCCpp();