Monday, January 22, 2018

Re: popen from cgi program

> Heh. I was poking around with ktrace last night, though you have a much more elegant way of using it.
> I have run my program in the chroot from the command line like you suggest - it works fine there.
> In the cgi program, it blows up after a bunch of mprotect and kbind calls. I do see a .core file mentioned but i cannot find it, so the cgi part must be swallowing it.
> I made a simple little c++ program that does the popen like i am and it works fine there. It must be something in the cgi environment - permissions, perhaps? Or are there some other environmental limitations?

I think i tracked it down. I have the 'what', just not the 'why'. My program that i am calling in the popen() call looks for a local config file. It builds the path to it with a call to std::getenv("HOME"). This getenv() call is what is causing the segfault. Why would this be a problem, and what checks can i put around it to avoid calling it in a cgi environment?

No comments:

Post a Comment