On 28.11.2016 09:47, xmineral(a)seznam.cz wrote:
Hello,
im using elfutils in ABRT program specifically when generating core_backtrace. According
to this
https://github.com/abrt/abrt/issues/890 post, it is not a good idea using elfutils
under root. So I have tried moving as much elfutils function calls to non-root process as
possible. That means the parent process is forked and in child process there are opened
necessary files:
https://github.com/xsulca00/abrt/blob/iss%23890/src/hooks/abrt-hook-ccpp....
https://github.com/xsulca00/satyr/blob/iss%23890/lib/core_unwind_elfutils...
and then UID and GID of child is changed and then I can call elfutils:
https://github.com/xsulca00/abrt/blob/iss%23890/src/hooks/abrt-hook-ccpp....
https://github.com/xsulca00/satyr/blob/iss%23890/lib/core_unwind_elfutils...
Is there any way how I can pass the opened files to elfutils functions? Especially for
"/etc/[tid]/mem" which is needed in dwfl_linux_proc_find_elf that is part of
Dwfl_Callbacks proc_cb ?
I think that this should work:
(while being root)
1. open file descriptor
2. call seteuid()
3. pass the file descriptor to the new process
I'm not saying that you need to do exactly this in case of elfutils but it
should work in the general case.
--
Petr Spacek @ Red Hat