apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Javier Castillo II <casti...@tower1.castlecorporation.com>
Subject apr_proc_detach and chdir
Date Fri, 18 Jan 2013 19:37:00 GMT
Looking into the code for apr_proc_detach(int daemonize), it appears 
that chdir("/") is being run unconditionally.

Was there a specific reason that "/" is chosen?

I guess it's not much of a big deal, because you can chdir into the 
directory it should be in after you detach, however, why is this forced 
into the function to begin with?

It would appear to be an enhancement to leave it up to the developer 
using the function to chdir into the desired directory before or after 
apr_proc_detach() and not force them to chroot before the function call 
or require them to chdir afterwards.

It's only 3 lines of code, and should have a minimal impact on users of 
the function.

For software that parses configurations, then chroots into the required 
path, this would be alright, assuming you start the process with 
permission to chroot, and don't intend to reach out to other paths.

Otherwise, you are left to chdir back to the previous cwd.

At the moment, I am fine with using getcwd and chdir to get back to 
where I started, however it does seem counter-intuitive.

So, I am guessing that this is the expected practice when calling this 
function, correct? Any insight would be great and any other methods to 
use with this function to get around it would be appreciated.




Mime
View raw message