summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-04-26 16:00:30 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2011-04-26 16:00:30 +0200
commitcf17c54d66bf0fc799957ffa675d0ab2e2c8fbed (patch)
treea210079732e077636ea155d5eb419464a58d7671
parenta3482c4a87c968281c65f17175be2cf14a55dc4f (diff)
downloadabrt-cf17c54d66bf0fc799957ffa675d0ab2e2c8fbed.tar.gz
abrt-cf17c54d66bf0fc799957ffa675d0ab2e2c8fbed.tar.xz
abrt-cf17c54d66bf0fc799957ffa675d0ab2e2c8fbed.zip
abrt-action-install-debuginfo: set real uid/gid to euid/gid
Fixes EPERM when abrt-action-install-debuginfo runs under root. Tested to work both under root and non-root Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r--src/plugins/abrt-action-install-debuginfo.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/plugins/abrt-action-install-debuginfo.c b/src/plugins/abrt-action-install-debuginfo.c
index cd5cb9df..b60c4321 100644
--- a/src/plugins/abrt-action-install-debuginfo.c
+++ b/src/plugins/abrt-action-install-debuginfo.c
@@ -16,6 +16,7 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
@@ -58,6 +59,17 @@ int main(int argc, char **argv)
error_msg_and_die("bad option", arg);
}
+ /* Switch real user/group to effective ones.
+ * Otherwise yum library gets confused - gets EPERM (why??).
+ */
+ gid_t g = getegid();
+ /* do setregid only if we have to, to not upset selinux needlessly */
+ if (g != getgid())
+ setregid(g, g);
+ uid_t u = geteuid();
+ if (u != getuid())
+ setreuid(u, u);
+
/* We use full path, and execv instead of execvp in order to
* disallow user to execute his own abrt-action-install-debuginfo.py
* in his dir by setting up corresponding malicious $PATH.